Authored by wujiexiang

增加便于测试的方法

1 package com.yohoufo.order.model.bo; 1 package com.yohoufo.order.model.bo;
2 2
  3 +import com.google.common.annotations.VisibleForTesting;
3 import com.yohoufo.order.utils.BeanTool; 4 import com.yohoufo.order.utils.BeanTool;
4 import lombok.Data; 5 import lombok.Data;
5 import lombok.ToString; 6 import lombok.ToString;
@@ -22,7 +23,9 @@ public class PlatformServiceFeeDefinition { @@ -22,7 +23,9 @@ public class PlatformServiceFeeDefinition {
22 //费用规则 按照threshold从小到大排序 23 //费用规则 按照threshold从小到大排序
23 private List<FeeRule> rules = new ArrayList<>(); 24 private List<FeeRule> rules = new ArrayList<>();
24 25
25 - public void setRules(List<FeeRule> rules) { 26 +
  27 + @VisibleForTesting
  28 + public void setAndSortRules(List<FeeRule> rules) {
26 this.rules = rules; 29 this.rules = rules;
27 sortRules(Comparator.comparing(FeeRule::getThreshold).reversed()); 30 sortRules(Comparator.comparing(FeeRule::getThreshold).reversed());
28 } 31 }
@@ -156,7 +156,7 @@ public class SellerOrderQuantityStatsTest { @@ -156,7 +156,7 @@ public class SellerOrderQuantityStatsTest {
156 three.setRate(BigDecimal.valueOf(0.035)); 156 three.setRate(BigDecimal.valueOf(0.035));
157 three.setThreshold(0); 157 three.setThreshold(0);
158 158
159 - psfd.setRules(Lists.newArrayList(one, two, three)); 159 + psfd.setAndSortRules(Lists.newArrayList(one, two, three));
160 160
161 return SellerServiceFeeRuleDefinition.builder().serviceFeeDefinition(psfd).statsCode(statCode).enterType(EntrySellerType.NOT_ENTRY.getCode()).build(); 161 return SellerServiceFeeRuleDefinition.builder().serviceFeeDefinition(psfd).statsCode(statCode).enterType(EntrySellerType.NOT_ENTRY.getCode()).build();
162 } 162 }
@@ -175,7 +175,7 @@ public class SellerOrderQuantityStatsTest { @@ -175,7 +175,7 @@ public class SellerOrderQuantityStatsTest {
175 three.setRate(BigDecimal.valueOf(0.015)); 175 three.setRate(BigDecimal.valueOf(0.015));
176 three.setThreshold(20); 176 three.setThreshold(20);
177 177
178 - psfd.setRules(Lists.newArrayList(one, two, three)); 178 + psfd.setAndSortRules(Lists.newArrayList(one, two, three));
179 179
180 return SellerServiceFeeRuleDefinition.builder().serviceFeeDefinition(psfd).statsCode(statCode).enterType(EntrySellerType.COMMON.getCode()).build(); 180 return SellerServiceFeeRuleDefinition.builder().serviceFeeDefinition(psfd).statsCode(statCode).enterType(EntrySellerType.COMMON.getCode()).build();
181 } 181 }
@@ -194,7 +194,7 @@ public class SellerOrderQuantityStatsTest { @@ -194,7 +194,7 @@ public class SellerOrderQuantityStatsTest {
194 three.setRate(BigDecimal.valueOf(0.005)); 194 three.setRate(BigDecimal.valueOf(0.005));
195 three.setThreshold(0); 195 three.setThreshold(0);
196 196
197 - psfd.setRules(Lists.newArrayList(one, two, three)); 197 + psfd.setAndSortRules(Lists.newArrayList(one, two, three));
198 198
199 return SellerServiceFeeRuleDefinition.builder().serviceFeeDefinition(psfd).statsCode(statCode).enterType(EntrySellerType.COMMON.getCode()).build(); 199 return SellerServiceFeeRuleDefinition.builder().serviceFeeDefinition(psfd).statsCode(statCode).enterType(EntrySellerType.COMMON.getCode()).build();
200 } 200 }