Skip to content

Commit

Permalink
fix: Implement equals for the ImmutableMetadata object
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Poignant <[email protected]>
  • Loading branch information
thomaspoignant committed Jul 17, 2023
1 parent bbb4008 commit 9077751
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/dev/openfeature/sdk/ImmutableMetadata.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.openfeature.sdk;

import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
Expand All @@ -10,6 +11,7 @@
* through builder and accessors.
*/
@Slf4j
@EqualsAndHashCode
public class ImmutableMetadata {
private final Map<String, Object> metadata;

Expand Down
22 changes: 22 additions & 0 deletions src/test/java/dev/openfeature/sdk/FlagEvaluationDetailsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,26 @@ public void sevenArgConstructor() {
assertEquals(errorMessage, details.getErrorMessage());
assertEquals(metadata, details.getFlagMetadata());
}

@Test
@DisplayName("should be able to compare 2 FlagEvaluationDetails")
public void compareFlagEvaluationDetails(){
FlagEvaluationDetails fed1 = FlagEvaluationDetails.builder()
.reason(Reason.ERROR.toString())
.value(false)
.errorCode(ErrorCode.GENERAL)
.errorMessage("impossible to contact GO Feature Flag relay proxy instance")
.flagMetadata(ImmutableMetadata.builder().addString("metadata","1").build())
.build();

FlagEvaluationDetails fed2 = FlagEvaluationDetails.builder()
.reason(Reason.ERROR.toString())
.value(false)
.errorCode(ErrorCode.GENERAL)
.errorMessage("impossible to contact GO Feature Flag relay proxy instance")
.flagMetadata(ImmutableMetadata.builder().addString("metadata","1").build())
.build();

assertEquals(fed1,fed2);
}
}

0 comments on commit 9077751

Please sign in to comment.