Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Implement equals for the ImmutableMetadata object #512

Merged
merged 2 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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("error XXX")
.flagMetadata(ImmutableMetadata.builder().addString("metadata","1").build())
.build();

FlagEvaluationDetails fed2 = FlagEvaluationDetails.builder()
.reason(Reason.ERROR.toString())
.value(false)
.errorCode(ErrorCode.GENERAL)
.errorMessage("error XXX")
.flagMetadata(ImmutableMetadata.builder().addString("metadata","1").build())
.build();

assertEquals(fed1,fed2);
}
}
Loading