Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ public FlagBuilder variationForAll(int variationIndex) {
public FlagBuilder valueForAll(LDValue value) {
variations.clear();
variations.add(value);
return variationForAll(0);
return variationForAll(0).offVariation(0);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,18 @@ public void flagConfigSimpleBoolean() throws Exception {
);
}

@Test
public void valueForAllSetsOffVariationToTheValue() throws Exception {
verifyFlag(
f -> f.valueForAll(LDValue.of("x")),
fb -> fb.on(true).variations("x").offVariation(0).fallthroughVariation(0)
);
verifyFlag(
f -> f.valueForAll(LDValue.of("x")).on(false),
fb -> fb.on(false).variations("x").offVariation(0).fallthroughVariation(0)
);
}

@Test
public void usingBooleanConfigMethodsForcesFlagToBeBoolean() throws Exception {
Function<ModelBuilders.FlagBuilder, ModelBuilders.FlagBuilder> expectedBooleanFlag = fb ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ public void deletesFlag() throws Exception {
}
}

@Test
public void valueForAllReturnsValueWhenTargetingIsOff() throws Exception {
td.update(td.flag("flag").valueForAll(LDValue.of("x")).on(false));

try (LDClient client = new LDClient(SDK_KEY, config)) {
assertThat(client.stringVariation("flag", LDContext.create("user"), "default"), equalTo("x"));
}
}

@Test
public void usesTargets() throws Exception {
td.update(td.flag("flag").fallthroughVariation(false).variationForUser("user1", true));
Expand Down
Loading