Skip to content

Commit

Permalink
fix client spec tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sighphyre committed Nov 27, 2024
1 parent 4ba1c45 commit d83d62d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/main/java/io/getunleash/DefaultUnleash.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public boolean isEnabled(
private @Nullable io.getunleash.variant.Payload adapt(@Nullable Payload payload) {
return Optional.ofNullable(payload)
.map(p -> new io.getunleash.variant.Payload(p.getType(), p.getValue()))
.orElse(null);
.orElse(new io.getunleash.variant.Payload("string", null));
}

@Override
Expand All @@ -262,9 +262,7 @@ public Variant getVariant(String toggleName, UnleashContext context, Variant def
Context adaptedContext = adapt(enhancedContext);

Variant variant =
adapt(
this.unleashEngine.getVariant(toggleName, adaptedContext),
defaultValue);
adapt(this.unleashEngine.getVariant(toggleName, adaptedContext), defaultValue);

Boolean enabled = this.unleashEngine.isEnabled(toggleName, adaptedContext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ private List<DynamicTest> createVariantTests(String fileName)
private Unleash setupUnleash(TestDefinition testDefinition) throws URISyntaxException {
mockUnleashAPI(testDefinition);

// Required because the client is available before it may have had the chance to talk with
// Required because the client is available before it may have had the chance to
// talk with
// the API
String backupFile = writeUnleashBackup(testDefinition);

Expand Down Expand Up @@ -194,7 +195,8 @@ private String writeUnleashBackup(TestDefinition definition) {
+ definition.getName()
+ ".json";

// TODO: we can probably drop this after introduction of `synchronousFetchOnInitialisation`.
// TODO: we can probably drop this after introduction of
// `synchronousFetchOnInitialisation`.
try (FileWriter writer = new FileWriter(backupFile)) {
writer.write(definition.getState().toString());
} catch (IOException e) {
Expand Down

0 comments on commit d83d62d

Please sign in to comment.