Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import dev.openfeature.sdk.ProviderEvent;
import dev.openfeature.sdk.Reason;
import dev.openfeature.sdk.Value;
import dev.openfeature.sdk.exceptions.GeneralError;
import dev.openfeature.sdk.exceptions.ParseError;
import dev.openfeature.sdk.exceptions.TypeMismatchError;
import java.util.Map;
Expand Down Expand Up @@ -205,7 +206,7 @@ private <T> ProviderEvaluation<T> resolve(Class<T> type, String key, EvaluationC
if (value == null) {
String message = String.format("variant %s not found in flag with key %s", resolvedVariant, key);
log.debug(message);
throw new TypeMismatchError(message);
throw new GeneralError(message);
}
if (value instanceof Integer && type == Double.class) {
// if this is an integer and we are trying to resolve a double, convert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "dev.openfeature.contrib.providers.flagd.e2e.steps")
@ConfigurationParameter(key = OBJECT_FACTORY_PROPERTY_NAME, value = "io.cucumber.picocontainer.PicoFactory")
@IncludeTags("in-process")
@ExcludeTags({"unixsocket", "targetURI"})
@ExcludeTags({"unixsocket", "targetURI", "no-default"})
@Testcontainers
@Isolated
public class RunInProcessTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.assertj.core.api.Assertions.assertThat;

import dev.openfeature.contrib.providers.flagd.e2e.State;
import dev.openfeature.sdk.ErrorCode;
import dev.openfeature.sdk.FlagEvaluationDetails;
import dev.openfeature.sdk.ImmutableMetadata;
import dev.openfeature.sdk.Value;
Expand Down Expand Up @@ -77,6 +78,15 @@ public void the_variant_should_be(String variant) {
assertThat(state.evaluation.getVariant()).isEqualTo(variant);
}

@Then("the error-code should be {string}")
public void the_error_code_should_be(String errorCode) {
if (errorCode.isEmpty()) {
assertThat(state.evaluation.getErrorCode()).isNull();
} else {
assertThat(state.evaluation.getErrorCode()).isEqualTo(ErrorCode.valueOf(errorCode));
}
}

@Then("the flag should be part of the event payload")
public void the_flag_was_modified() {
Event event = state.lastEvent.orElseThrow(AssertionError::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import dev.openfeature.sdk.ProviderEvaluation;
import dev.openfeature.sdk.Reason;
import dev.openfeature.sdk.Value;
import dev.openfeature.sdk.exceptions.GeneralError;
import dev.openfeature.sdk.exceptions.ParseError;
import dev.openfeature.sdk.exceptions.TypeMismatchError;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -279,7 +280,7 @@ public void variantMismatchFlag() throws Exception {
getInProcessResolverWith(new MockStorage(flagMap), (connectionEvent) -> {});

// when/then
assertThrows(TypeMismatchError.class, () -> {
assertThrows(GeneralError.class, () -> {
inProcessResolver.booleanEvaluation("mismatchFlag", false, new ImmutableContext());
});
}
Expand All @@ -288,14 +289,14 @@ public void variantMismatchFlag() throws Exception {
public void typeMismatchEvaluation() throws Exception {
// given
final Map<String, FeatureFlag> flagMap = new HashMap<>();
flagMap.put("stringFlag", BOOLEAN_FLAG);
flagMap.put("booleanFlag", BOOLEAN_FLAG);

InProcessResolver inProcessResolver =
getInProcessResolverWith(new MockStorage(flagMap), (connectionEvent) -> {});

// when/then
assertThrows(TypeMismatchError.class, () -> {
inProcessResolver.stringEvaluation("stringFlag", "false", new ImmutableContext());
inProcessResolver.stringEvaluation("booleanFlag", "false", new ImmutableContext());
});
}

Expand Down