Skip to content

Commit fc31565

Browse files
committed
add test
1 parent fb5744b commit fc31565

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

core-api/src/test/java/com/optimizely/ab/OptimizelyUserContextTest.java

+28
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,34 @@ public void decideForKeys_ups_batching() throws Exception {
456456
assertEquals(savedProfile.userId, userId);
457457
}
458458

459+
@Test
460+
public void decideAll_ups_batching() throws Exception {
461+
UserProfileService ups = mock(UserProfileService.class);
462+
463+
optimizely = new Optimizely.Builder()
464+
.withDatafile(datafile)
465+
.withUserProfileService(ups)
466+
.build();
467+
468+
Map<String, Object> attributes = Collections.singletonMap("gender", "f");
469+
470+
OptimizelyUserContext user = optimizely.createUserContext(userId, attributes);
471+
Map<String, OptimizelyDecision> decisions = user.decideAll();
472+
473+
assertEquals(decisions.size(), 3);
474+
475+
ArgumentCaptor<Map> argumentCaptor = ArgumentCaptor.forClass(Map.class);
476+
477+
478+
verify(ups, times(1)).lookup(userId);
479+
verify(ups, times(1)).save(argumentCaptor.capture());
480+
481+
Map<String, Object> savedUps = argumentCaptor.getValue();
482+
UserProfile savedProfile = UserProfileUtils.convertMapToUserProfile(savedUps);
483+
484+
assertEquals(savedProfile.userId, userId);
485+
}
486+
459487
@Test
460488
public void decideAll_allFlags_enabledFlagsOnly() {
461489
String flagKey1 = "feature_1";

0 commit comments

Comments
 (0)