|
|
package com.yohoufo.order.service.handler.penalty;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.jknack.handlebars.internal.Files;
|
|
|
import com.yohobuy.ufo.model.order.common.OrderAttributes;
|
|
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
|
|
import com.yohoufo.order.model.dto.BuyerPenalty;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import org.junit.Assert;
|
|
|
import org.junit.BeforeClass;
|
|
|
import org.junit.Test;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.net.URI;
|
|
|
import java.net.URL;
|
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
|
public class BuyerPenaltyRuleSelectorTest {
|
|
|
|
|
|
static BuyerPenalty buyerPenalty;
|
|
|
static String buyerPenaltyConfig = "{\"stockCaseMap\":{\"goodsInStock\":{\"stockTypeName\":\"goodsInStock\",\"triggerCaseMap\":{\"beforeSellerDeliver\":{\"name\":\"beforeSellerDeliver\",\"stagedCollection\":[{\"index\":1,\"moneyRange\":{\"min\":18},\"rate\":0.01,\"timeRange\":{\"max\":3600,\"min\":0}},{\"index\":2,\"moneyRange\":{\"min\":38},\"rate\":0.02,\"timeRange\":{\"min\":3600}}]},\"beforeDepotReceive\":{\"name\":\"beforeDepotReceive\",\"stagedCollection\":[{\"moneyRange\":{\"min\":68},\"rate\":0.03}]}}},\"advanceSale\":{\"stockTypeName\":\"advanceSale\",\"triggerCaseMap\":{\"beforeSellerDeliver\":{\"name\":\"beforeSellerDeliver\",\"stagedCollection\":[{\"index\":1,\"moneyRange\":{\"min\":0},\"rate\":0,\"timeRange\":{\"max\":86400,\"min\":0}},{\"index\":2,\"moneyRange\":{\"min\":0},\"rate\":0.08,\"timeRange\":{\"min\":86400}}]},\"beforeDepotReceive\":{\"name\":\"beforeDepotReceive\",\"stagedCollection\":[{\"moneyRange\":{\"min\":68},\"rate\":0.03}]}}}}}";
|
|
|
|
|
|
@BeforeClass
|
|
|
public static void init() {
|
|
|
public static void init() throws IOException {
|
|
|
String buyerPenaltyConfig = Files.read(BuyerPenaltyRuleSelectorTest.class.getResourceAsStream("/data/buyer_penalty.json"));
|
|
|
buyerPenalty = JSONObject.parseObject(buyerPenaltyConfig, BuyerPenalty.class);
|
|
|
}
|
|
|
|
...
|
...
|
|