Skip to content

Commit

Permalink
add deprecated default getName to be backward compatible as much as p…
Browse files Browse the repository at this point in the history
…ossible

Signed-off-by: Kavindu Dodanduwa <[email protected]>
  • Loading branch information
Kavindu-Dodan committed May 31, 2024
1 parent 2d2c5cf commit 12f7f4d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/dev/openfeature/sdk/ClientMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@
*/
public interface ClientMetadata {
String getDomain();

@Deprecated
// this is here for compatibility with getName() exposed from {@link Metadata}
default String getName() {
return getDomain();
}
}
3 changes: 3 additions & 0 deletions src/test/java/dev/openfeature/sdk/FlagEvaluationSpecTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,14 @@ public void initialize(EvaluationContext evaluationContext) throws Exception {
@Specification(number="1.2.2", text="The client interface MUST define a metadata member or accessor, containing an immutable domain field or accessor of type string, which corresponds to the domain value supplied during client creation. In previous drafts, this property was called name. For backwards compatibility, implementations should consider name an alias to domain.")
@Test void clientMetadata() {
Client c = _client();
assertNull(c.getMetadata().getName());
assertNull(c.getMetadata().getDomain());

String domainName = "test domain";
FeatureProviderTestUtils.setFeatureProvider(new AlwaysBrokenProvider());
Client c2 = api.getClient(domainName);

assertEquals(domainName, c2.getMetadata().getName());
assertEquals(domainName, c2.getMetadata().getDomain());
}

Expand Down

0 comments on commit 12f7f4d

Please sign in to comment.