@@ -44,9 +44,9 @@ public class SplitClientIntegrationTest {
4444
4545 @ Test
4646 public void getTreatmentWithStreamingEnabled () throws Exception {
47- MockResponse response = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850109, \" t\" :1585948850109}, \" rbs\" :{\" d\" :[],\" s\" :-1 ,\" t\" :-1 }}" );
48- MockResponse response2 = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850110, \" t\" :1585948850110}, \" rbs\" :{\" d\" :[],\" s\" :-1 ,\" t\" :-1 }}" );
49- MockResponse response3 = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850111, \" t\" :1585948850111}, \" rbs\" :{\" d\" :[],\" s\" :-1 ,\" t\" :-1 }}" );
47+ MockResponse response = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850109, \" t\" :1585948850109}, \" rbs\" :{\" d\" :[],\" s\" :1585948850109 ,\" t\" :1585948850109 }}" );
48+ MockResponse response2 = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850110, \" t\" :1585948850110}, \" rbs\" :{\" d\" :[],\" s\" :1585948850110 ,\" t\" :1585948850110 }}" );
49+ MockResponse response3 = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850111, \" t\" :1585948850111}, \" rbs\" :{\" d\" :[],\" s\" :1585948850111 ,\" t\" :1585948850111 }}" );
5050 Queue responses = new LinkedList <>();
5151 responses .add (response );
5252 Queue responses2 = new LinkedList <>();
@@ -144,7 +144,7 @@ public void getTreatmentWithStreamingEnabled() throws Exception {
144144
145145 @ Test
146146 public void getTreatmentWithStreamingEnabledAndAuthDisabled () throws Exception {
147- MockResponse response = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850109, \" t\" :1585948850109}, \" rbs\" :{\" s\" :-1 ,\" t\" :-1 ,\" d\" :[]}}" );
147+ MockResponse response = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850109, \" t\" :1585948850109}, \" rbs\" :{\" s\" :1585948850109 ,\" t\" :1585948850109 ,\" d\" :[]}}" );
148148 Queue responses = new LinkedList <>();
149149 responses .add (response );
150150 SplitMockServer splitServer = new SplitMockServer (CustomDispatcher .builder ()
@@ -165,14 +165,19 @@ public void getTreatmentWithStreamingEnabledAndAuthDisabled() throws Exception {
165165
166166 String result = client .getTreatment ("admin" , "push_test" );
167167 Assert .assertEquals ("on_whitelist" , result );
168-
168+ Assert .assertEquals ("on" , client .getTreatment ("bilal@@split.io" , "rbs_flag" , new HashMap <String , Object >() {{
169+ put ("email" , "bilal@@split.io" );
170+ }}));
171+ Assert .
assertEquals (
"off" ,
client .
getTreatment (
"[email protected] " ,
"rbs_flag" ,
new HashMap <
String ,
Object >() {{
172+ put (
"email" ,
"[email protected] " );
173+ }}));
169174 client .destroy ();
170175 splitServer .stop ();
171176 }
172177
173178 @ Test
174179 public void getTreatmentWithStreamingDisabled () throws Exception {
175- MockResponse response = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850109, \" t\" :1585948850109}, \" rbs\" :{\" d\" :[],\" s\" :-1 ,\" t\" :-1 }}" );
180+ MockResponse response = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850109, \" t\" :1585948850109}, \" rbs\" :{\" d\" :[],\" s\" :1585948850109 ,\" t\" :1585948850109 }}" );
176181 Queue responses = new LinkedList <>();
177182 responses .add (response );
178183 SplitMockServer splitServer = new SplitMockServer (CustomDispatcher .builder ()
@@ -224,8 +229,8 @@ public void managerSplitsWithStreamingEnabled() throws Exception {
224229 manager .blockUntilReady ();
225230
226231 List <SplitView > results = manager .splits ();
227- Assert .assertEquals (4 , results .size ());
228- Assert .assertEquals (3 , results .stream ().filter (r -> !r .killed ).toArray ().length );
232+ Assert .assertEquals (5 , results .size ());
233+ Assert .assertEquals (4 , results .stream ().filter (r -> !r .killed ).toArray ().length );
229234
230235 // SPLIT_KILL should fetch.
231236 OutboundSseEvent sseEventSplitKill = new OutboundEvent
@@ -237,7 +242,7 @@ public void managerSplitsWithStreamingEnabled() throws Exception {
237242
238243 Awaitility .await ()
239244 .atMost (2L , TimeUnit .MINUTES )
240- .until (() -> 2 == manager .splits ().stream ().filter (r -> !r .killed ).toArray ().length );
245+ .until (() -> 3 == manager .splits ().stream ().filter (r -> !r .killed ).toArray ().length );
241246
242247 splitServer .stop ();
243248 sseServer .stop ();
@@ -320,9 +325,9 @@ public void splitClientOccupancyNotifications() throws Exception {
320325
321326 @ Test
322327 public void splitClientControlNotifications () throws Exception {
323- MockResponse response = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850109, \" t\" :1585948850109}, \" rbs\" :{\" d\" :[],\" s\" :-1 ,\" t\" :-1 }}" );
324- MockResponse response2 = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850110, \" t\" :1585948850110}, \" rbs\" :{\" d\" :[],\" s\" :-1 ,\" t\" :-1 }}" );
325- MockResponse response3 = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850111, \" t\" :1585948850111}, \" rbs\" :{\" d\" :[],\" s\" :-1 ,\" t\" :-1 }}" );
328+ MockResponse response = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850109, \" t\" :1585948850109}, \" rbs\" :{\" d\" :[],\" s\" :1585948850109 ,\" t\" :1585948850109 }}" );
329+ MockResponse response2 = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850110, \" t\" :1585948850110}, \" rbs\" :{\" d\" :[],\" s\" :1585948850110 ,\" t\" :1585948850110 }}" );
330+ MockResponse response3 = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850111, \" t\" :1585948850111}, \" rbs\" :{\" d\" :[],\" s\" :1585948850111 ,\" t\" :1585948850111 }}" );
326331 Queue responses = new LinkedList <>();
327332 responses .add (response );
328333 Queue responses2 = new LinkedList <>();
@@ -564,7 +569,7 @@ public void splitClientMultiFactory() throws Exception {
564569
565570 @ Test
566571 public void keepAlive () throws Exception {
567- MockResponse response = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850109, \" t\" :1585948850109}, \" rbs\" :{\" d\" :[],\" s\" :-1 ,\" t\" :-1 }}" );
572+ MockResponse response = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850109, \" t\" :1585948850109}, \" rbs\" :{\" d\" :[],\" s\" :1585948850109 ,\" t\" :1585948850109 }}" );
568573 Queue responses = new LinkedList <>();
569574 responses .add (response );
570575
@@ -602,7 +607,7 @@ public void keepAlive() throws Exception {
602607
603608 @ Test
604609 public void testConnectionClosedByRemoteHostIsProperlyHandled () throws Exception {
605- MockResponse response = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850109, \" t\" :1585948850109}, \" rbs\" :{\" d\" :[],\" s\" :-1 ,\" t\" :-1 }}" );
610+ MockResponse response = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850109, \" t\" :1585948850109}, \" rbs\" :{\" d\" :[],\" s\" :1585948850109 ,\" t\" :1585948850109 }}" );
606611 Queue responses = new LinkedList <>();
607612 responses .add (response );
608613 SplitMockServer splitServer = new SplitMockServer (CustomDispatcher .builder ()
@@ -640,7 +645,7 @@ public void testConnectionClosedByRemoteHostIsProperlyHandled() throws Exception
640645
641646 @ Test
642647 public void testConnectionClosedIsProperlyHandled () throws Exception {
643- MockResponse response = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850109, \" t\" :1585948850109}, \" rbs\" :{\" d\" :[],\" s\" :-1 ,\" t\" :-1 }}" );
648+ MockResponse response = new MockResponse ().setBody ("{\" ff\" :{\" d\" : [], \" s\" :1585948850109, \" t\" :1585948850109}, \" rbs\" :{\" d\" :[],\" s\" :1585948850109 ,\" t\" :1585948850109 }}" );
644649 Queue responses = new LinkedList <>();
645650 responses .add (response );
646651 SplitMockServer splitServer = new SplitMockServer (CustomDispatcher .builder ()
@@ -706,15 +711,21 @@ public void testPluggableMode() throws IOException, URISyntaxException {
706711 Assert .assertTrue (events .stream ().anyMatch (e -> "keyValue" .equals (e .getEventDto ().key ) && e .getEventDto ().value == 12L ));
707712 Assert .assertTrue (events .stream ().anyMatch (e -> "keyProperties" .equals (e .getEventDto ().key ) && e .getEventDto ().properties != null ));
708713
709- Assert .assertEquals (2 , splits .size ());
714+ Assert .assertEquals (3 , splits .size ());
710715 Assert .assertTrue (splits .stream ().anyMatch (sw -> "first.name" .equals (sw .name )));
711716 Assert .assertTrue (splits .stream ().anyMatch (sw -> "second.name" .equals (sw .name )));
712717 Assert .assertEquals ("on" , client .getTreatment ("key" , "first.name" ));
713718 Assert .assertEquals ("off" , client .getTreatmentWithConfig ("FakeKey" , "second.name" ).treatment ());
714719 Assert .assertEquals ("control" , client .getTreatment ("FakeKey" , "noSplit" ));
720+ Assert .assertEquals ("on" , client .getTreatment ("bilal@@split.io" , "rbs_flag" , new HashMap <String , Object >() {{
721+ put ("email" , "bilal@@split.io" );
722+ }}));
723+ Assert .
assertEquals (
"off" ,
client .
getTreatment (
"[email protected] " ,
"rbs_flag" ,
new HashMap <
String ,
Object >() {{
724+ put (
"email" ,
"[email protected] " );
725+ }}));
715726
716727 List <ImpressionConsumer > impressions = customStorageWrapper .getImps ();
717- Assert .assertEquals (2 , impressions .size ());
728+ Assert .assertEquals (4 , impressions .size ());
718729 Assert .assertTrue (impressions .stream ().anyMatch (imp -> "first.name" .equals (imp .getKeyImpression ().feature ) && "on" .equals (imp .getKeyImpression ().treatment )));
719730 Assert .assertTrue (impressions .stream ().anyMatch (imp -> "second.name" .equals (imp .getKeyImpression ().feature ) && "off" .equals (imp .getKeyImpression ().treatment )));
720731
@@ -727,7 +738,7 @@ public void testPluggableMode() throws IOException, URISyntaxException {
727738 String key3 = keys .stream ().filter (key -> key .contains ("getTreatmentWithConfig/" )).collect (Collectors .toList ()).get (0 );
728739
729740 Assert .assertEquals (Optional .of (3L ), Optional .ofNullable (latencies .get (key1 )));
730- Assert .assertEquals (Optional .of (1L ), Optional .of (latencies .get (key2 )));
741+ Assert .assertEquals (Optional .of (3L ), Optional .of (latencies .get (key2 )));
731742 Assert .assertEquals (Optional .of (1L ), Optional .of (latencies .get (key3 )));
732743
733744 Thread .sleep (500 );
0 commit comments