Skip to content

Commit

Permalink
improve test and add check for unused imports
Browse files Browse the repository at this point in the history
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
  • Loading branch information
Kavindu-Dodan committed Dec 12, 2023
1 parent f82228f commit f0c8213
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
3 changes: 2 additions & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
default="checkstyle-xpath-suppressions.xml" />
<property name="optional" value="true"/>
</module>


<module name="UnusedImports"/>
<module name="OuterTypeFilename"/>
<module name="IllegalTokenText">
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
Expand Down
21 changes: 13 additions & 8 deletions src/test/java/dev/openfeature/sdk/OpenFeatureAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f0c8213

Please sign in to comment.