Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit be75e5f

Browse files
committed
misc cleanup
1 parent 7251919 commit be75e5f

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

src/test/java/com/launchdarkly/client/FeatureFlagTest.java

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
package com.launchdarkly.client;
22

3-
import com.google.gson.JsonElement;
4-
import com.google.gson.JsonPrimitive;
5-
6-
import org.junit.Assert;
73
import org.junit.Before;
84
import org.junit.Test;
95

106
import java.util.Arrays;
117

8+
import static com.launchdarkly.client.TestUtil.booleanFlagWithClauses;
129
import static com.launchdarkly.client.TestUtil.fallthroughVariation;
1310
import static com.launchdarkly.client.TestUtil.jbool;
1411
import static com.launchdarkly.client.TestUtil.jint;
@@ -213,7 +210,7 @@ public void flagMatchesUserFromRules() throws Exception {
213210
@Test
214211
public void clauseCanMatchBuiltInAttribute() throws Exception {
215212
Clause clause = new Clause("name", Operator.in, Arrays.asList(js("Bob")), false);
216-
FeatureFlag f = TestUtil.booleanFlagWithClauses(clause);
213+
FeatureFlag f = booleanFlagWithClauses(clause);
217214
LDUser user = new LDUser.Builder("key").name("Bob").build();
218215

219216
assertEquals(jbool(true), f.evaluate(user, featureStore).getValue());
@@ -222,7 +219,7 @@ public void clauseCanMatchBuiltInAttribute() throws Exception {
222219
@Test
223220
public void clauseCanMatchCustomAttribute() throws Exception {
224221
Clause clause = new Clause("legs", Operator.in, Arrays.asList(jint(4)), false);
225-
FeatureFlag f = TestUtil.booleanFlagWithClauses(clause);
222+
FeatureFlag f = booleanFlagWithClauses(clause);
226223
LDUser user = new LDUser.Builder("key").custom("legs", 4).build();
227224

228225
assertEquals(jbool(true), f.evaluate(user, featureStore).getValue());
@@ -231,7 +228,7 @@ public void clauseCanMatchCustomAttribute() throws Exception {
231228
@Test
232229
public void clauseReturnsFalseForMissingAttribute() throws Exception {
233230
Clause clause = new Clause("legs", Operator.in, Arrays.asList(jint(4)), false);
234-
FeatureFlag f = TestUtil.booleanFlagWithClauses(clause);
231+
FeatureFlag f = booleanFlagWithClauses(clause);
235232
LDUser user = new LDUser.Builder("key").name("Bob").build();
236233

237234
assertEquals(jbool(false), f.evaluate(user, featureStore).getValue());
@@ -240,7 +237,7 @@ public void clauseReturnsFalseForMissingAttribute() throws Exception {
240237
@Test
241238
public void clauseCanBeNegated() throws Exception {
242239
Clause clause = new Clause("name", Operator.in, Arrays.asList(js("Bob")), true);
243-
FeatureFlag f = TestUtil.booleanFlagWithClauses(clause);
240+
FeatureFlag f = booleanFlagWithClauses(clause);
244241
LDUser user = new LDUser.Builder("key").name("Bob").build();
245242

246243
assertEquals(jbool(false), f.evaluate(user, featureStore).getValue());
@@ -258,7 +255,7 @@ public void testSegmentMatchClauseRetrievesSegmentFromStore() throws Exception {
258255
LDUser user = new LDUser.Builder("foo").build();
259256

260257
FeatureFlag.EvalResult result = flag.evaluate(user, featureStore);
261-
Assert.assertEquals(new JsonPrimitive(true), result.getValue());
258+
assertEquals(jbool(true), result.getValue());
262259
}
263260

264261
@Test
@@ -267,17 +264,11 @@ public void testSegmentMatchClauseFallsThroughIfSegmentNotFound() throws Excepti
267264
LDUser user = new LDUser.Builder("foo").build();
268265

269266
FeatureFlag.EvalResult result = flag.evaluate(user, featureStore);
270-
Assert.assertEquals(new JsonPrimitive(false), result.getValue());
267+
assertEquals(jbool(false), result.getValue());
271268
}
272269

273270
private FeatureFlag segmentMatchBooleanFlag(String segmentKey) {
274-
Clause clause = new Clause("", Operator.segmentMatch, Arrays.asList(new JsonPrimitive(segmentKey)), false);
275-
Rule rule = new Rule(Arrays.asList(clause), 1, null);
276-
return new FeatureFlagBuilder("key")
277-
.variations(Arrays.<JsonElement>asList(new JsonPrimitive(false), new JsonPrimitive(true)))
278-
.fallthrough(new VariationOrRollout(0, null))
279-
.on(true)
280-
.rules(Arrays.asList(rule))
281-
.build();
271+
Clause clause = new Clause("", Operator.segmentMatch, Arrays.asList(js(segmentKey)), false);
272+
return booleanFlagWithClauses(clause);
282273
}
283274
}

0 commit comments

Comments
 (0)