|
1 | 1 | package com.launchdarkly.client;
|
2 | 2 |
|
3 | 3 | import com.google.gson.JsonArray;
|
| 4 | +import com.google.gson.JsonElement; |
4 | 5 | import com.google.gson.JsonPrimitive;
|
5 | 6 | import org.easymock.EasyMockSupport;
|
6 | 7 | import org.junit.Before;
|
7 | 8 | import org.junit.Test;
|
8 | 9 |
|
9 | 10 | import java.io.IOException;
|
| 11 | +import java.util.Map; |
10 | 12 | import java.util.concurrent.ExecutionException;
|
11 | 13 | import java.util.concurrent.Future;
|
12 | 14 | import java.util.concurrent.TimeUnit;
|
13 | 15 | import java.util.concurrent.TimeoutException;
|
14 | 16 |
|
15 | 17 | import static org.easymock.EasyMock.anyObject;
|
16 | 18 | import static org.easymock.EasyMock.expect;
|
17 |
| -import static org.junit.Assert.assertEquals; |
18 |
| -import static org.junit.Assert.assertFalse; |
19 |
| -import static org.junit.Assert.assertTrue; |
| 19 | +import static org.junit.Assert.*; |
20 | 20 |
|
21 | 21 | public class LDClientTest extends EasyMockSupport {
|
22 | 22 | private FeatureRequestor requestor;
|
@@ -71,6 +71,23 @@ public void testTestFeatureStoreSetFeatureTrue() throws IOException, Interrupted
|
71 | 71 | verifyAll();
|
72 | 72 | }
|
73 | 73 |
|
| 74 | + @Test |
| 75 | + public void testTestOfflineModeAllFlags() throws IOException, InterruptedException, ExecutionException, TimeoutException { |
| 76 | + TestFeatureStore testFeatureStore = new TestFeatureStore(); |
| 77 | + LDConfig config = new LDConfig.Builder() |
| 78 | + .startWaitMillis(10L) |
| 79 | + .offline(true) |
| 80 | + .featureStore(testFeatureStore) |
| 81 | + .build(); |
| 82 | + |
| 83 | + client = new LDClient("", config);//createMockClient(config); |
| 84 | + testFeatureStore.setFeatureTrue("key"); |
| 85 | + Map<String, JsonElement> allFlags = client.allFlags(new LDUser("user")); |
| 86 | + assertNotNull("Expected non-nil response from allFlags() when offline mode is set to true", allFlags); |
| 87 | + assertEquals("Didn't get expected flag count from allFlags() in offline mode", 1, allFlags.size()); |
| 88 | + assertTrue("Test flag should be true, but was not.", allFlags.get("key").getAsBoolean()); |
| 89 | + } |
| 90 | + |
74 | 91 | @Test
|
75 | 92 | public void testTestFeatureStoreSetFalse() throws IOException, InterruptedException, ExecutionException, TimeoutException {
|
76 | 93 | TestFeatureStore testFeatureStore = new TestFeatureStore();
|
|
0 commit comments