File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
main/java/io/split/client/impressions
test/java/io/split/client/impressions Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 55
66public class ImpressionHasher {
77
8- private static final String HASHABLE_FORMAT = "%s:%s:%s:%d" ;
8+ private static final String HASHABLE_FORMAT = "%s:%s:%s:%s:% d" ;
99 private static final String UNKNOWN = "UNKNOWN" ;
1010
1111 private static String unknownIfNull (String s ) {
@@ -23,6 +23,7 @@ public static Long process(KeyImpression impression) {
2323 return MurmurHash3 .hash128x64 (String .format (HASHABLE_FORMAT ,
2424 unknownIfNull (impression .keyName ),
2525 unknownIfNull (impression .feature ),
26+ unknownIfNull (impression .treatment ),
2627 unknownIfNull (impression .label ),
2728 zeroIfNull (impression .changeNumber )).getBytes ())[0 ];
2829 }
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ public void works() {
1616 imp1 .keyName = "someKey" ;
1717 imp1 .changeNumber = 123L ;
1818 imp1 .label = "someLabel" ;
19+ imp1 .treatment = "someTreatment" ;
1920
2021 // Different feature
2122 KeyImpression imp2 = new KeyImpression ();
@@ -39,6 +40,11 @@ public void works() {
3940 imp2 .changeNumber = imp1 .changeNumber ;
4041 imp2 .label = "someOtherLabel" ;
4142 assertThat (ImpressionHasher .process (imp1 ), not (equalTo (ImpressionHasher .process (imp2 ))));
43+
44+ // different treatment
45+ imp2 .label = imp1 .label ;
46+ imp2 .treatment = "someOtherTreatment" ;
47+ assertThat (ImpressionHasher .process (imp1 ), not (equalTo (ImpressionHasher .process (imp2 ))));
4248 }
4349
4450 @ Test
@@ -59,6 +65,9 @@ public void doesNotCrash() {
5965 imp1 .label = null ;
6066 assertNotNull (ImpressionHasher .process (imp1 ));
6167
68+ imp1 .treatment = null ;
69+ assertNotNull (ImpressionHasher .process (imp1 ));
70+
6271 assertNull (ImpressionHasher .process (null ));
6372 }
6473}
You can’t perform that action at this time.
0 commit comments