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

Commit b096bbe

Browse files
committed
unit tests
1 parent ae5e8c6 commit b096bbe

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

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

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import com.google.gson.JsonElement;
55
import com.google.gson.JsonPrimitive;
66
import com.google.gson.reflect.TypeToken;
7+
8+
import org.junit.Assert;
79
import org.junit.Test;
810

911
import java.lang.reflect.Type;
@@ -198,6 +200,38 @@ public void testLDUserCustomMarshalWithBuiltInAttributesRedactsCorrectAttrs() {
198200
Type type = new TypeToken<Map<String, JsonElement>>(){}.getType();
199201
Map<String, JsonElement> privateJson = config.gson.fromJson(config.gson.toJson(user), type);
200202
assertNull(privateJson.get("email"));
201-
203+
}
204+
205+
@Test
206+
public void getValueGetsBuiltInAttribute() {
207+
LDUser user = new LDUser.Builder("key")
208+
.name("Jane")
209+
.build();
210+
assertEquals(new JsonPrimitive("Jane"), user.getValueForEvaluation("name"));
211+
}
212+
213+
@Test
214+
public void getValueGetsCustomAttribute() {
215+
LDUser user = new LDUser.Builder("key")
216+
.custom("height", 5)
217+
.build();
218+
assertEquals(new JsonPrimitive(5), user.getValueForEvaluation("height"));
219+
}
220+
221+
@Test
222+
public void getValueGetsBuiltInAttributeEvenIfCustomAttrHasSameName() {
223+
LDUser user = new LDUser.Builder("key")
224+
.name("Jane")
225+
.custom("name", "Joan")
226+
.build();
227+
assertEquals(new JsonPrimitive("Jane"), user.getValueForEvaluation("name"));
228+
}
229+
230+
@Test
231+
public void getValueReturnsNullIfNotFound() {
232+
LDUser user = new LDUser.Builder("key")
233+
.name("Jane")
234+
.build();
235+
assertNull(user.getValueForEvaluation("height"));
202236
}
203237
}

0 commit comments

Comments
 (0)