-
Notifications
You must be signed in to change notification settings - Fork 39
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
chore: fix jacoco coverage minimum, throw in memory provider #561
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/main/java/dev/openfeature/sdk/exceptions/ProviderNotReadyError.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package dev.openfeature.sdk.exceptions; | ||
|
||
import dev.openfeature.sdk.ErrorCode; | ||
import lombok.Getter; | ||
import lombok.experimental.StandardException; | ||
|
||
@SuppressWarnings("checkstyle:MissingJavadocType") | ||
@StandardException | ||
public class ProviderNotReadyError extends OpenFeatureError { | ||
private static final long serialVersionUID = 1L; | ||
@Getter private final ErrorCode errorCode = ErrorCode.PROVIDER_NOT_READY; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,22 @@ | |
|
||
import com.google.common.collect.ImmutableMap; | ||
import dev.openfeature.sdk.Client; | ||
import dev.openfeature.sdk.ImmutableContext; | ||
import dev.openfeature.sdk.OpenFeatureAPI; | ||
import dev.openfeature.sdk.Value; | ||
import dev.openfeature.sdk.exceptions.FlagNotFoundError; | ||
import dev.openfeature.sdk.exceptions.TypeMismatchError; | ||
import lombok.SneakyThrows; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.omg.CORBA.DynAnyPackage.TypeMismatch; | ||
|
||
import java.util.Map; | ||
|
||
import static dev.openfeature.sdk.Structure.mapToStructure; | ||
import static dev.openfeature.sdk.testutils.TestFlagsUtils.buildFlags; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.spy; | ||
|
@@ -81,4 +86,17 @@ void getObjectEvaluation() { | |
assertEquals(expectedObject, client.getObjectValue("object-flag", new Value(true))); | ||
} | ||
|
||
@Test | ||
void notFound() { | ||
assertThrows(FlagNotFoundError.class, () -> { | ||
provider.getBooleanEvaluation("not-found-flag", false, new ImmutableContext()); | ||
}); | ||
} | ||
|
||
@Test | ||
void typeMismatch() { | ||
assertThrows(TypeMismatchError.class, () -> { | ||
provider.getBooleanEvaluation("string-flag", false, new ImmutableContext()); | ||
}); | ||
} | ||
Comment on lines
+89
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These bring coverage of the new package up to 80%+ to fix the failure in main. |
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@liran2000 throwing like this ends in the same result, but it's a bit easier to trace, and also simpler to write. This is how we generally recommend it's done. There is a small performance cost in serialization of the exception, but I think it's worth it.