Authored by chenchao

add unit test

... ... @@ -14,6 +14,7 @@ import com.yohobuy.ufo.model.order.bo.SellerTypeNode;
import com.yohoufo.order.utils.SellerHelper;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.slf4j.Logger;
import java.math.BigDecimal;
... ... @@ -23,6 +24,7 @@ import java.util.function.Function;
/**
* Created by chao.chen on 2019/1/15.
*/
@ToString
public class SellerWrapper {
@Getter
StoredSeller storedSeller;
... ...
package com.yohoufo.order.service;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.github.jknack.handlebars.internal.Files;
import com.yohobuy.ufo.model.order.bo.SellerBo;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohoufo.dal.order.model.StoredSeller;
import com.yohoufo.order.BaseWebTest;
import com.yohoufo.order.model.dto.BuyerPenalty;
import com.yohoufo.order.service.handler.penalty.BuyerPenaltyRuleSelectorTest;
import com.yohoufo.order.service.impl.SellerService;
import com.yohoufo.order.service.impl.SellerWrapper;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.IOException;
import java.util.List;
/**
* Created by chao.chen on 2019/1/9.
*/
... ... @@ -16,6 +28,8 @@ public class SellerServiceTest extends BaseWebTest {
@Autowired
private SellerService sellerService;
@Test
public void testGetEntrySellerType(){
EntrySellerType none = sellerService.getEntrySellerType(44);
... ... @@ -40,4 +54,9 @@ public class SellerServiceTest extends BaseWebTest {
SellerBo sellerBo = sellerService.getSellerWithAuth(uid);
System.out.println(sellerBo);
}
}
... ...
package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.github.jknack.handlebars.internal.Files;
import com.yohoufo.dal.order.model.StoredSeller;
import com.yohoufo.order.service.handler.penalty.BuyerPenaltyRuleSelectorTest;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
import java.util.function.Function;
public class SellerWrapperTest {
private Logger logger = LoggerFactory.getLogger(getClass());
public static List<StoredSeller> initStoredSellerList() throws IOException {
String buyerPenaltyConfig = Files.read(BuyerPenaltyRuleSelectorTest.class.getResourceAsStream("/data/Seller.json"));
return JSONObject.parseObject(buyerPenaltyConfig, new TypeReference<List<StoredSeller>>(){});
}
@Test
public void testSellerPolicy(){
try {
List<StoredSeller> storedSellers = initStoredSellerList();
for(StoredSeller storedSeller : storedSellers){
SellerWrapper sellerWrapper = new SellerWrapper(storedSeller.getUid(),logger)
.storedSellerDataSource((uid) -> storedSeller )
.addSpecialSuperFunc((uid)->false)
.buildSellerWrapper().attachAssetPolicy();
logger.info("sellerWrapper {}", sellerWrapper);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
... ...
[
{"uid":1, "entryType": 0},
{"uid":11, "entryType": 1},
{"uid":12, "entryType": 2},
{"uid":13, "entryType": 3},
{"uid":14, "entryType": 4}
]
\ No newline at end of file
... ...