Authored by wujiexiang

修改junit test

... ... @@ -35,6 +35,7 @@ import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
public class SellerEnterTypeChangeEventTest extends BaseWebTest {
... ... @@ -63,31 +64,25 @@ public class SellerEnterTypeChangeEventTest extends BaseWebTest {
}
@Test
public void test_stats_event() {
public void test_stats_event() throws Exception{
BuyerOrder buyerOrder = new BuyerOrder();
buyerOrder.setUid(500031424);
buyerOrder.setOrderCode(9939757498185L);
buyerOrder.setSellerUid(500031424);
orderChangeListenerContainer.fireAsyncEvent(new BuyerOrderChangeEvent(buyerOrder, BuyerOrderChangeEvent.BizCase.APPRAISE_SUCCESS, OrderStatus.DONE));
TimeUnit.SECONDS.sleep(10);
}
@Test
public void test_enter_event() {
public void test_enter_event() throws Exception{
EventBusPublisher.publishEvent(SellerEnterTypeChangeEvent.builder().sellerUid(500031116).eventType(EnterQuitEnum.ENTER).build());
TimeUnit.SECONDS.sleep(10);
}
@Test
public void test_quit_event() {
EventBusPublisher.publishEvent(SellerEnterTypeChangeEvent.builder().sellerUid(500031424).eventType(EnterQuitEnum.QUIT).build());
}
@Test
public void platformServiceFeeDetail() {
SellerPlatformServiceFeeResp sellerPlatformServiceFeeResp = sellerService.platformServiceFeeDetail(500031424);
System.out.println(sellerPlatformServiceFeeResp);
Assert.assertNotNull(sellerPlatformServiceFeeResp);
Assert.assertEquals(sellerPlatformServiceFeeResp.getCurrentRate(), "5.0%");
public void test_quit_event() throws Exception{
EventBusPublisher.publishEvent(SellerEnterTypeChangeEvent.builder().sellerUid(500031116).eventType(EnterQuitEnum.QUIT).build());
TimeUnit.SECONDS.sleep(10);
}
@Test
... ... @@ -108,7 +103,8 @@ public class SellerEnterTypeChangeEventTest extends BaseWebTest {
Mockito.when(sellerService.getEntrySellerType(500031424)).thenReturn(EntrySellerType.SUPER_ENTRY);
BigDecimal feeRate = sellerPlatformServiceFeeSupport.getPlatformServiceFeeRate(500031424, SkupType.IN_STOCK);
Assert.assertEquals(feeRate.toPlainString(),"0.045");
Assert.assertTrue(feeRate != null);
Assert.assertEquals(feeRate.toPlainString(), "0.045");
}
@Test
... ... @@ -125,7 +121,7 @@ public class SellerEnterTypeChangeEventTest extends BaseWebTest {
Mockito.when(statsConfigurationManager.getStatsConfig(Mockito.any(SellerOrderStatsEntry.class))).thenReturn(SellerOrderStatsConfiguration.emptyConfiguration);
Mockito.when(statsConfigurationManager.getStatsProcessor(SellerOrderStatsConfiguration.emptyConfiguration.getStatsProcessorName())).thenReturn(new EmptyStatsProcessor(){
Mockito.when(statsConfigurationManager.getStatsProcessor(SellerOrderStatsConfiguration.emptyConfiguration.getStatsProcessorName())).thenReturn(new EmptyStatsProcessor() {
@Override
public SellerOrderStatsResult getResult(SellerOrderStatsEntry entry, SellerOrderStatsConfiguration configuration) {
SellerOrderStatsResult statsResult = new SellerOrderStatsResult();
... ... @@ -140,13 +136,18 @@ public class SellerEnterTypeChangeEventTest extends BaseWebTest {
Mockito.when(sellerService.getEntrySellerType(500031424)).thenReturn(EntrySellerType.SUPER_ENTRY);
BigDecimal feeRate = sellerPlatformServiceFeeSupport.getPlatformServiceFeeRate(500031424, SkupType.IN_STOCK);
Assert.assertEquals(feeRate.toPlainString(),"0.044");
Assert.assertTrue(feeRate != null);
Assert.assertEquals(feeRate.toPlainString(), "0.044");
}
@Test
public void getPlatformServiceFeeRate_withoutRules() {
Mockito.when(sellerServiceFeeRuleCacheService.getRuleDefinitions()).thenReturn(Lists.newArrayList());
Mockito.when(statsConfigurationManager.getStatsConfig(Mockito.any(SellerOrderStatsEntry.class))).thenReturn(SellerOrderStatsConfiguration.emptyConfiguration);
Mockito.when(statsConfigurationManager.getStatsProcessor(SellerOrderStatsConfiguration.emptyConfiguration.getStatsProcessorName())).thenReturn(new EmptyStatsProcessor());
Mockito.when(sellerService.getEntrySellerType(500031424)).thenReturn(EntrySellerType.SUPER_ENTRY);
BigDecimal feeRate = sellerPlatformServiceFeeSupport.getPlatformServiceFeeRate(500031424, SkupType.IN_STOCK);
Assert.assertEquals(feeRate,null);
Assert.assertTrue(feeRate == null);
}
}
... ...