From f0c8213e3aec7f890eba464314606b798f6ac300 Mon Sep 17 00:00:00 2001 From: Kavindu Dodanduwa Date: Tue, 12 Dec 2023 11:29:32 -0800 Subject: [PATCH] improve test and add check for unused imports Signed-off-by: Kavindu Dodanduwa --- checkstyle.xml | 3 ++- .../openfeature/sdk/OpenFeatureAPITest.java | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/checkstyle.xml b/checkstyle.xml index f2bcb59a7..2cf598c37 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -63,7 +63,8 @@ default="checkstyle-xpath-suppressions.xml" /> - + + diff --git a/src/test/java/dev/openfeature/sdk/OpenFeatureAPITest.java b/src/test/java/dev/openfeature/sdk/OpenFeatureAPITest.java index 2ed2a2939..3b0e89566 100644 --- a/src/test/java/dev/openfeature/sdk/OpenFeatureAPITest.java +++ b/src/test/java/dev/openfeature/sdk/OpenFeatureAPITest.java @@ -46,16 +46,21 @@ void namedProviderOverwrittenTest() { @Test void providerToMultipleNames() { - FeatureProvider provider = new InMemoryProvider(Collections.EMPTY_MAP); + FeatureProvider inMemAsEventingProvider = new InMemoryProvider(Collections.EMPTY_MAP); + FeatureProvider noOpAsNonEventingProvider = new NoOpProvider(); // register same provider for multiple names & as default provider - OpenFeatureAPI.getInstance().setProviderAndWait(provider); - OpenFeatureAPI.getInstance().setProviderAndWait("clientA", provider); - OpenFeatureAPI.getInstance().setProviderAndWait("clientB", provider); - - assertEquals(provider, OpenFeatureAPI.getInstance().getProvider()); - assertEquals(provider, OpenFeatureAPI.getInstance().getProvider("clientA")); - assertEquals(provider, OpenFeatureAPI.getInstance().getProvider("clientB")); + OpenFeatureAPI.getInstance().setProviderAndWait(inMemAsEventingProvider); + OpenFeatureAPI.getInstance().setProviderAndWait("clientA", inMemAsEventingProvider); + OpenFeatureAPI.getInstance().setProviderAndWait("clientB", inMemAsEventingProvider); + OpenFeatureAPI.getInstance().setProviderAndWait("clientC", noOpAsNonEventingProvider); + OpenFeatureAPI.getInstance().setProviderAndWait("clientD", noOpAsNonEventingProvider); + + assertEquals(inMemAsEventingProvider, OpenFeatureAPI.getInstance().getProvider()); + assertEquals(inMemAsEventingProvider, OpenFeatureAPI.getInstance().getProvider("clientA")); + assertEquals(inMemAsEventingProvider, OpenFeatureAPI.getInstance().getProvider("clientB")); + assertEquals(noOpAsNonEventingProvider, OpenFeatureAPI.getInstance().getProvider("clientC")); + assertEquals(noOpAsNonEventingProvider, OpenFeatureAPI.getInstance().getProvider("clientD")); } @Test