1
|
package com.yohoufo.order.service.handler.penalty;
|
1
|
package com.yohoufo.order.service.handler.penalty;
|
2
|
|
2
|
|
3
|
import com.alibaba.fastjson.JSONObject;
|
3
|
import com.alibaba.fastjson.JSONObject;
|
|
|
4
|
+import com.github.jknack.handlebars.internal.Files;
|
4
|
import com.yohobuy.ufo.model.order.common.OrderAttributes;
|
5
|
import com.yohobuy.ufo.model.order.common.OrderAttributes;
|
5
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
6
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
6
|
import com.yohoufo.order.model.dto.BuyerPenalty;
|
7
|
import com.yohoufo.order.model.dto.BuyerPenalty;
|
|
|
8
|
+import org.apache.commons.io.FileUtils;
|
7
|
import org.junit.Assert;
|
9
|
import org.junit.Assert;
|
8
|
import org.junit.BeforeClass;
|
10
|
import org.junit.BeforeClass;
|
9
|
import org.junit.Test;
|
11
|
import org.junit.Test;
|
10
|
|
12
|
|
|
|
13
|
+import java.io.File;
|
|
|
14
|
+import java.io.IOException;
|
|
|
15
|
+import java.io.InputStream;
|
11
|
import java.math.BigDecimal;
|
16
|
import java.math.BigDecimal;
|
|
|
17
|
+import java.net.URI;
|
|
|
18
|
+import java.net.URL;
|
12
|
|
19
|
|
13
|
import static org.junit.Assert.*;
|
20
|
import static org.junit.Assert.*;
|
14
|
|
21
|
|
15
|
public class BuyerPenaltyRuleSelectorTest {
|
22
|
public class BuyerPenaltyRuleSelectorTest {
|
|
|
23
|
+
|
16
|
static BuyerPenalty buyerPenalty;
|
24
|
static BuyerPenalty buyerPenalty;
|
17
|
- 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}]}}}}}";
|
|
|
18
|
|
25
|
|
19
|
@BeforeClass
|
26
|
@BeforeClass
|
20
|
- public static void init() {
|
27
|
+ public static void init() throws IOException {
|
|
|
28
|
+ String buyerPenaltyConfig = Files.read(BuyerPenaltyRuleSelectorTest.class.getResourceAsStream("/data/buyer_penalty.json"));
|
21
|
buyerPenalty = JSONObject.parseObject(buyerPenaltyConfig, BuyerPenalty.class);
|
29
|
buyerPenalty = JSONObject.parseObject(buyerPenaltyConfig, BuyerPenalty.class);
|
22
|
}
|
30
|
}
|
23
|
|
31
|
|