2727import static org .junit .Assert .assertEquals ;
2828
2929public class EvaluatorTest {
30- private static final String _matchingKey = "test" ;
31- private static final String _bucketingKey = "test" ;
32- private static final String _splitName = "split_name_test" ;
33- private static final Long _changeNumber = 123123L ;
34- private static final String _defaultTreatmentValue = "defaultTreatment" ;
35- private static final String _testLabelValue = "test label" ;
36- private static final String _trafficTypeValue = "tt" ;
37- private static final String _treatmentValue = "treatment_test" ;
30+ private static final String MatchingKey = "test" ;
31+ private static final String BucketingKey = "test" ;
32+ private static final String SplitName = "split_name_test" ;
33+ private static final Long ChangeNumber = 123123L ;
34+ private static final String DefaultTreatmentValue = "defaultTreatment" ;
35+ private static final String TestLabelValue = "test label" ;
36+ private static final String TrafficTypeValue = "tt" ;
37+ private static final String TreatmentValue = "treatment_test" ;
3838
3939 private SplitFetcher _splitFetcher ;
4040 private Evaluator _evaluator ;
@@ -59,99 +59,99 @@ public void before() {
5959
6060 @ Test
6161 public void evaluateWhenSplitNameDoesNotExistReturnControl () throws ChangeNumberExceptionWrapper {
62- Mockito .when (_splitFetcher .fetch (_splitName )).thenReturn (null );
62+ Mockito .when (_splitFetcher .fetch (SplitName )).thenReturn (null );
6363
64- TreatmentLabelAndChangeNumber result = _evaluator .evaluateFeature (_matchingKey , _bucketingKey , _splitName , null , _splitClient );
64+ TreatmentLabelAndChangeNumber result = _evaluator .evaluateFeature (MatchingKey , BucketingKey , SplitName , null , _splitClient );
6565
6666 assertEquals ("control" , result .treatment );
6767 assertEquals ("definition not found" , result .label );
6868 }
6969
7070 @ Test
7171 public void evaluateWhenSplitIsKilledReturnDefaultTreatment () throws ChangeNumberExceptionWrapper {
72- ParsedSplit split = ParsedSplit .createParsedSplitForTests (_splitName , 0 , true , _defaultTreatmentValue , _conditions , _trafficTypeValue , _changeNumber , 2 );
73- Mockito .when (_splitFetcher .fetch (_splitName )).thenReturn (split );
72+ ParsedSplit split = ParsedSplit .createParsedSplitForTests (SplitName , 0 , true , DefaultTreatmentValue , _conditions , TrafficTypeValue , ChangeNumber , 2 );
73+ Mockito .when (_splitFetcher .fetch (SplitName )).thenReturn (split );
7474
75- TreatmentLabelAndChangeNumber result = _evaluator .evaluateFeature (_matchingKey , _bucketingKey , _splitName , null , _splitClient );
75+ TreatmentLabelAndChangeNumber result = _evaluator .evaluateFeature (MatchingKey , BucketingKey , SplitName , null , _splitClient );
7676
77- assertEquals (_defaultTreatmentValue , result .treatment );
77+ assertEquals (DefaultTreatmentValue , result .treatment );
7878 assertEquals ("killed" , result .label );
79- assertEquals (_changeNumber , result .changeNumber );
79+ assertEquals (ChangeNumber , result .changeNumber );
8080 }
8181
8282 @ Test
8383 public void evaluateWithoutConditionsReturnDefaultTreatment () throws ChangeNumberExceptionWrapper {
84- ParsedSplit split = ParsedSplit .createParsedSplitForTests (_splitName , 0 , false , _defaultTreatmentValue , _conditions , _trafficTypeValue , _changeNumber , 2 );
85- Mockito .when (_splitFetcher .fetch (_splitName )).thenReturn (split );
84+ ParsedSplit split = ParsedSplit .createParsedSplitForTests (SplitName , 0 , false , DefaultTreatmentValue , _conditions , TrafficTypeValue , ChangeNumber , 2 );
85+ Mockito .when (_splitFetcher .fetch (SplitName )).thenReturn (split );
8686
87- TreatmentLabelAndChangeNumber result = _evaluator .evaluateFeature (_matchingKey , _bucketingKey , _splitName , null , _splitClient );
87+ TreatmentLabelAndChangeNumber result = _evaluator .evaluateFeature (MatchingKey , BucketingKey , SplitName , null , _splitClient );
8888
89- assertEquals (_defaultTreatmentValue , result .treatment );
89+ assertEquals (DefaultTreatmentValue , result .treatment );
9090 assertEquals ("default rule" , result .label );
91- assertEquals (_changeNumber , result .changeNumber );
91+ assertEquals (ChangeNumber , result .changeNumber );
9292 }
9393
9494 @ Test
9595 public void evaluateWithRollOutConditionBucketIsBiggerTrafficAllocationReturnDefaultTreatment () throws ChangeNumberExceptionWrapper {
9696 Partition partition = new Partition ();
97- partition .treatment = _treatmentValue ;
97+ partition .treatment = TreatmentValue ;
9898 partition .size = 100 ;
9999 _partitions .add (partition );
100- ParsedCondition condition = new ParsedCondition (ConditionType .ROLLOUT , _matcher ,_partitions , _testLabelValue );
100+ ParsedCondition condition = new ParsedCondition (ConditionType .ROLLOUT , _matcher ,_partitions , TestLabelValue );
101101 _conditions .add (condition );
102102
103- ParsedSplit split = new ParsedSplit (_splitName , 0 , false , _defaultTreatmentValue , _conditions , _trafficTypeValue , _changeNumber , 10 , 12 , 2 , _configurations );
103+ ParsedSplit split = new ParsedSplit (SplitName , 0 , false , DefaultTreatmentValue , _conditions , TrafficTypeValue , ChangeNumber , 10 , 12 , 2 , _configurations );
104104
105- Mockito .when (_splitFetcher .fetch (_splitName )).thenReturn (split );
106- Mockito .when (condition .matcher ().match (_matchingKey , _bucketingKey , null , _splitClient )).thenReturn (true );
105+ Mockito .when (_splitFetcher .fetch (SplitName )).thenReturn (split );
106+ Mockito .when (condition .matcher ().match (MatchingKey , BucketingKey , null , _splitClient )).thenReturn (true );
107107
108- TreatmentLabelAndChangeNumber result = _evaluator .evaluateFeature (_matchingKey , _bucketingKey , _splitName , null , _splitClient );
108+ TreatmentLabelAndChangeNumber result = _evaluator .evaluateFeature (MatchingKey , BucketingKey , SplitName , null , _splitClient );
109109
110- assertEquals (_defaultTreatmentValue , result .treatment );
110+ assertEquals (DefaultTreatmentValue , result .treatment );
111111 assertEquals ("not in split" , result .label );
112- assertEquals (_changeNumber , result .changeNumber );
112+ assertEquals (ChangeNumber , result .changeNumber );
113113 }
114114
115115 @ Test
116116 public void evaluateWithRollOutConditionTrafficAllocationIsBiggerBucketReturnTreatment () throws ChangeNumberExceptionWrapper {
117117 Partition partition = new Partition ();
118- partition .treatment = _treatmentValue ;
118+ partition .treatment = TreatmentValue ;
119119 partition .size = 100 ;
120120 _partitions .add (partition );
121- ParsedCondition condition = new ParsedCondition (ConditionType .ROLLOUT , _matcher , _partitions , _testLabelValue );
121+ ParsedCondition condition = new ParsedCondition (ConditionType .ROLLOUT , _matcher , _partitions , TestLabelValue );
122122 _conditions .add (condition );
123123
124- ParsedSplit split = new ParsedSplit (_splitName , 0 , false , _defaultTreatmentValue , _conditions , _trafficTypeValue , _changeNumber , 60 , 18 , 2 , _configurations );
124+ ParsedSplit split = new ParsedSplit (SplitName , 0 , false , DefaultTreatmentValue , _conditions , TrafficTypeValue , ChangeNumber , 60 , 18 , 2 , _configurations );
125125
126- Mockito .when (_splitFetcher .fetch (_splitName )).thenReturn (split );
127- Mockito .when (condition .matcher ().match (_matchingKey , _bucketingKey , null , _splitClient )).thenReturn (true );
126+ Mockito .when (_splitFetcher .fetch (SplitName )).thenReturn (split );
127+ Mockito .when (condition .matcher ().match (MatchingKey , BucketingKey , null , _splitClient )).thenReturn (true );
128128
129- TreatmentLabelAndChangeNumber result = _evaluator .evaluateFeature (_matchingKey , _bucketingKey , _splitName , null , _splitClient );
129+ TreatmentLabelAndChangeNumber result = _evaluator .evaluateFeature (MatchingKey , BucketingKey , SplitName , null , _splitClient );
130130
131- assertEquals (_treatmentValue , result .treatment );
132- assertEquals (_testLabelValue , result .label );
133- assertEquals (_changeNumber , result .changeNumber );
131+ assertEquals (TreatmentValue , result .treatment );
132+ assertEquals (TestLabelValue , result .label );
133+ assertEquals (ChangeNumber , result .changeNumber );
134134 }
135135
136136 @ Test
137137 public void evaluateWithWhitelistConditionReturnTreatment () throws ChangeNumberExceptionWrapper {
138138 Partition partition = new Partition ();
139- partition .treatment = _treatmentValue ;
139+ partition .treatment = TreatmentValue ;
140140 partition .size = 100 ;
141141 _partitions .add (partition );
142142 ParsedCondition condition = new ParsedCondition (ConditionType .WHITELIST , _matcher , _partitions , "test whitelist label" );
143143 _conditions .add (condition );
144144
145- ParsedSplit split = new ParsedSplit (_splitName , 0 , false , _defaultTreatmentValue , _conditions , _trafficTypeValue , _changeNumber , 60 , 18 , 2 , _configurations );
145+ ParsedSplit split = new ParsedSplit (SplitName , 0 , false , DefaultTreatmentValue , _conditions , TrafficTypeValue , ChangeNumber , 60 , 18 , 2 , _configurations );
146146
147- Mockito .when (_splitFetcher .fetch (_splitName )).thenReturn (split );
148- Mockito .when (condition .matcher ().match (_matchingKey , _bucketingKey , null , _splitClient )).thenReturn (true );
147+ Mockito .when (_splitFetcher .fetch (SplitName )).thenReturn (split );
148+ Mockito .when (condition .matcher ().match (MatchingKey , BucketingKey , null , _splitClient )).thenReturn (true );
149149
150- TreatmentLabelAndChangeNumber result = _evaluator .evaluateFeature (_matchingKey , _bucketingKey , _splitName , null , _splitClient );
150+ TreatmentLabelAndChangeNumber result = _evaluator .evaluateFeature (MatchingKey , BucketingKey , SplitName , null , _splitClient );
151151
152- assertEquals (_treatmentValue , result .treatment );
152+ assertEquals (TreatmentValue , result .treatment );
153153 assertEquals ("test whitelist label" , result .label );
154- assertEquals (_changeNumber , result .changeNumber );
154+ assertEquals (ChangeNumber , result .changeNumber );
155155 }
156156
157157 private SplitClientImpl getSplitClient (SplitFetcher splitFetcher , SDKReadinessGates gates , Evaluator evaluator ) {
0 commit comments