diff --git a/gradle.properties b/gradle.properties index ffb9317..f3ba253 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=8.2.2 +version=8.3.0 diff --git a/src/main/java/com/configcat/ConfigCatClient.java b/src/main/java/com/configcat/ConfigCatClient.java index 99650fe..6632529 100644 --- a/src/main/java/com/configcat/ConfigCatClient.java +++ b/src/main/java/com/configcat/ConfigCatClient.java @@ -184,6 +184,11 @@ public CompletableFuture> getValueDetailsAsync(Class }); } + @Override + public Map getAllValues() { + return this.getAllValues(null); + } + @Override public Map getAllValues(User user) { try { @@ -198,6 +203,11 @@ public Map getAllValues(User user) { } } + @Override + public CompletableFuture> getAllValuesAsync() { + return this.getAllValuesAsync(null); + } + @Override public CompletableFuture> getAllValuesAsync(User user) { return this.getSettingsAsync() @@ -227,6 +237,11 @@ public CompletableFuture> getAllValuesAsync(User user) { }); } + @Override + public List> getAllValueDetails() { + return this.getAllValueDetails(null); + } + @Override public List> getAllValueDetails(User user) { try { @@ -241,6 +256,11 @@ public List> getAllValueDetails(User user) { } } + @Override + public CompletableFuture>> getAllValueDetailsAsync() { + return this.getAllValueDetailsAsync(null); + } + @Override public CompletableFuture>> getAllValueDetailsAsync(User user) { return this.getSettingsAsync() diff --git a/src/main/java/com/configcat/ConfigurationProvider.java b/src/main/java/com/configcat/ConfigurationProvider.java index 67d3eef..94b5d17 100644 --- a/src/main/java/com/configcat/ConfigurationProvider.java +++ b/src/main/java/com/configcat/ConfigurationProvider.java @@ -102,6 +102,13 @@ public interface ConfigurationProvider extends Closeable { */ CompletableFuture> getValueDetailsAsync(Class classOfT, String key, User user, T defaultValue); + /** + * Gets the values of all feature flags or settings synchronously. + * + * @return a collection of all values. + */ + Map getAllValues(); + /** * Gets the values of all feature flags or settings synchronously. * @@ -110,6 +117,13 @@ public interface ConfigurationProvider extends Closeable { */ Map getAllValues(User user); + /** + * Gets the values of all feature flags or settings asynchronously. + * + * @return a future which computes the collection of all values. + */ + CompletableFuture> getAllValuesAsync(); + /** * Gets the values of all feature flags or settings asynchronously. * @@ -118,6 +132,13 @@ public interface ConfigurationProvider extends Closeable { */ CompletableFuture> getAllValuesAsync(User user); + /** + * Gets the detailed values of all feature flags or settings synchronously. + * + * @return a collection of all the evaluation results with details + */ + List> getAllValueDetails(); + /** * Gets the detailed values of all feature flags or settings synchronously. * @@ -126,6 +147,13 @@ public interface ConfigurationProvider extends Closeable { */ List> getAllValueDetails(User user); + /** + * Gets the detailed values of all feature flags or settings asynchronously. + * + * @return a future which computes the collection of all detailed values. + */ + CompletableFuture>> getAllValueDetailsAsync(); + /** * Gets the detailed values of all feature flags or settings asynchronously. * diff --git a/src/main/java/com/configcat/Constants.java b/src/main/java/com/configcat/Constants.java index 506098b..7a44fe3 100644 --- a/src/main/java/com/configcat/Constants.java +++ b/src/main/java/com/configcat/Constants.java @@ -8,5 +8,5 @@ private Constants() { /* prevent from instantiation*/ } static final String CONFIG_JSON_NAME = "config_v5.json"; static final String SERIALIZATION_FORMAT_VERSION = "v2"; - static final String VERSION = "8.2.2"; + static final String VERSION = "8.3.0"; } \ No newline at end of file diff --git a/src/test/java/com/configcat/ConfigCatClientTest.java b/src/test/java/com/configcat/ConfigCatClientTest.java index d6baf24..74bb278 100644 --- a/src/test/java/com/configcat/ConfigCatClientTest.java +++ b/src/test/java/com/configcat/ConfigCatClientTest.java @@ -258,7 +258,29 @@ public void getAllValues() throws IOException { server.enqueue(new MockResponse().setResponseCode(200).setBody(TEST_JSON_MULTIPLE)); cl.forceRefresh(); - Map allValues = cl.getAllValues(null); + Map allValues = cl.getAllValues(); + + assertEquals(true, allValues.get("key1")); + assertEquals(false, allValues.get("key2")); + + server.shutdown(); + cl.close(); + } + + @Test + public void getAllValuesAsync() throws IOException, ExecutionException, InterruptedException { + MockWebServer server = new MockWebServer(); + server.start(); + + ConfigCatClient cl = ConfigCatClient.get(APIKEY, options -> { + options.pollingMode(PollingModes.manualPoll()); + options.baseUrl(server.url("/").toString()); + }); + + server.enqueue(new MockResponse().setResponseCode(200).setBody(TEST_JSON_MULTIPLE)); + cl.forceRefresh(); + + Map allValues = cl.getAllValuesAsync().get(); assertEquals(true, allValues.get("key1")); assertEquals(false, allValues.get("key2")); @@ -280,7 +302,44 @@ public void getAllValueDetails() throws IOException { server.enqueue(new MockResponse().setResponseCode(200).setBody(TEST_JSON_MULTIPLE)); cl.forceRefresh(); - List> allValuesDetails = cl.getAllValueDetails(null); + List> allValuesDetails = cl.getAllValueDetails(); + + //assert result list + assertEquals(2, allValuesDetails.size()); + + //assert result 1 + EvaluationDetails element = allValuesDetails.get(0); + assertEquals("key1", element.getKey()); + assertTrue((boolean) element.getValue()); + assertFalse(element.isDefaultValue()); + assertNull(element.getError()); + assertEquals("fakeId1", element.getVariationId()); + + //assert result 2 + element = allValuesDetails.get(1); + assertEquals("key2", element.getKey()); + assertFalse((boolean) element.getValue()); + assertFalse(element.isDefaultValue()); + assertNull(element.getError()); + assertEquals("fakeId2", element.getVariationId()); + server.shutdown(); + cl.close(); + } + + @Test + public void getAllValueDetailsAsync() throws IOException, ExecutionException, InterruptedException { + MockWebServer server = new MockWebServer(); + server.start(); + + ConfigCatClient cl = ConfigCatClient.get(APIKEY, options -> { + options.pollingMode(PollingModes.manualPoll()); + options.baseUrl(server.url("/").toString()); + }); + + server.enqueue(new MockResponse().setResponseCode(200).setBody(TEST_JSON_MULTIPLE)); + cl.forceRefresh(); + + List> allValuesDetails = cl.getAllValueDetailsAsync().get(); //assert result list assertEquals(2, allValuesDetails.size());