From d83d62d3183e69601a868b0f15a49128909ea84a Mon Sep 17 00:00:00 2001 From: Simon Hornby Date: Wed, 27 Nov 2024 17:26:56 +0200 Subject: [PATCH] fix client spec tests --- src/main/java/io/getunleash/DefaultUnleash.java | 6 ++---- .../io/getunleash/integration/ClientSpecificationTest.java | 6 ++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/getunleash/DefaultUnleash.java b/src/main/java/io/getunleash/DefaultUnleash.java index fafdeb97a..b3e1f87f7 100644 --- a/src/main/java/io/getunleash/DefaultUnleash.java +++ b/src/main/java/io/getunleash/DefaultUnleash.java @@ -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 @@ -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); diff --git a/src/test/java/io/getunleash/integration/ClientSpecificationTest.java b/src/test/java/io/getunleash/integration/ClientSpecificationTest.java index cfc550a77..d6cc50c21 100644 --- a/src/test/java/io/getunleash/integration/ClientSpecificationTest.java +++ b/src/test/java/io/getunleash/integration/ClientSpecificationTest.java @@ -120,7 +120,8 @@ private List 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); @@ -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) {