Skip to content

Commit 624c4de

Browse files
committed
feat: Complete cleanup of legacy files and remove Lombok from SDK tests
## Legacy File Cleanup - Remove entire legacy `src/` directory (85+ source files, 100+ test files) - Remove `pom.xml.backup` backup file - Remove orphaned `test_noop_access.java` test file - Cleanup eliminates duplicate code after successful module separation ## SDK Test Lombok Removal (17 files) ### Files with @Getter annotations: - MockHook.java: Added manual getters (isBeforeCalled, isAfterCalled, etc.) - ContextStoringProvider.java: Added manual getEvaluationContext() getter ### Files with @SneakyThrows annotations: - Replaced with proper `throws Exception` declarations in 12 test files: EventProviderTest, TrackingSpecTest, FlagEvaluationSpecTest, EventsTest, FeatureProviderStateManagerTest, HookSpecTest, LoggingHookTest, InMemoryProviderTest, StepDefinitions, TestEventsProvider, ThreadLocalTransactionContextPropagatorTest - DeveloperExperienceTest: Replaced with proper try-catch block ### Files with @UtilityClass annotations: - ProviderFixture.java, TestFlagsUtils.java, ConditionStubber.java: Replaced with private constructors to prevent instantiation ## Results - Project is now completely Lombok-free (both API and SDK modules) - Clean multi-module structure without legacy duplicates - All main source code compiles successfully - Maintains same test functionality with manual implementations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com> diff --git c/openfeature-sdk/src/test/java/dev/openfeature/sdk/DeveloperExperienceTest.java i/openfeature-sdk/src/test/java/dev/openfeature/sdk/DeveloperExperienceTest.java index 16bca51..fe45552 100644 --- c/openfeature-sdk/src/test/java/dev/openfeature/sdk/DeveloperExperienceTest.java +++ i/openfeature-sdk/src/test/java/dev/openfeature/sdk/DeveloperExperienceTest.java @@ -28,7 +28,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; -import lombok.SneakyThrows; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -120,13 +119,16 @@ class DeveloperExperienceTest implements HookFixtures { class MutatingHook implements Hook { @Override - @SneakyThrows // change the provider during a before hook - this should not impact the evaluation in progress public Optional before(HookContext ctx, Map hints) { + try { - api.setProviderAndWait(TestEventsProvider.newInitializedTestEventsProvider()); + api.setProviderAndWait(TestEventsProvider.newInitializedTestEventsProvider()); - return Optional.empty(); + return Optional.empty(); + } catch (Exception e) { + throw new RuntimeException(e); + } } } diff --git c/openfeature-sdk/src/test/java/dev/openfeature/sdk/EventProviderTest.java i/openfeature-sdk/src/test/java/dev/openfeature/sdk/EventProviderTest.java index 457e820..a75a175 100644 --- c/openfeature-sdk/src/test/java/dev/openfeature/sdk/EventProviderTest.java +++ i/openfeature-sdk/src/test/java/dev/openfeature/sdk/EventProviderTest.java @@ -17,7 +17,6 @@ import dev.openfeature.api.internal.noop.NoOpProvider; import dev.openfeature.sdk.internal.TriConsumer; import dev.openfeature.sdk.testutils.TestStackedEmitCallsProvider; import io.cucumber.java.AfterAll; -import lombok.SneakyThrows; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -30,8 +29,7 @@ class EventProviderTest { private TestEventProvider eventProvider; @BeforeEach - @SneakyThrows - void setup() { + void setup() throws Exception { eventProvider = new TestEventProvider(); eventProvider.initialize(null); } @@ -97,10 +95,9 @@ class EventProviderTest { } @Test - @SneakyThrows @Timeout(value = 2, threadMode = Timeout.ThreadMode.SEPARATE_THREAD) @DisplayName("should not deadlock on emit called during emit") - void doesNotDeadlockOnEmitStackedCalls() { + void doesNotDeadlockOnEmitStackedCalls() throws Exception { TestStackedEmitCallsProvider provider = new TestStackedEmitCallsProvider(); new DefaultOpenFeatureAPI().setProviderAndWait(provider); } diff --git c/openfeature-sdk/src/test/java/dev/openfeature/sdk/EventsTest.java i/openfeature-sdk/src/test/java/dev/openfeature/sdk/EventsTest.java index b9ac271..9e021c3 100644 --- c/openfeature-sdk/src/test/java/dev/openfeature/sdk/EventsTest.java +++ i/openfeature-sdk/src/test/java/dev/openfeature/sdk/EventsTest.java @@ -23,7 +23,6 @@ import dev.openfeature.sdk.testutils.TestEventsProvider; import java.util.Arrays; import java.util.List; import java.util.function.Consumer; -import lombok.SneakyThrows; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -687,8 +686,7 @@ class EventsTest { text = "The API and client MUST provide a function allowing the removal of event handlers.") @Test @DisplayName("should not run removed events") - @SneakyThrows - void removedEventsShouldNotRun() { + void removedEventsShouldNotRun() throws Exception { final String name = "removedEventsShouldNotRun"; final Consumer<EventDetails> handler1 = mockHandler(); final Consumer<EventDetails> handler2 = mockHandler(); diff --git c/openfeature-sdk/src/test/java/dev/openfeature/sdk/FeatureProviderStateManagerTest.java i/openfeature-sdk/src/test/java/dev/openfeature/sdk/FeatureProviderStateManagerTest.java index 080c0a0..ff35f51 100644 --- c/openfeature-sdk/src/test/java/dev/openfeature/sdk/FeatureProviderStateManagerTest.java +++ i/openfeature-sdk/src/test/java/dev/openfeature/sdk/FeatureProviderStateManagerTest.java @@ -15,7 +15,6 @@ import dev.openfeature.api.exceptions.FatalError; import dev.openfeature.api.exceptions.GeneralError; import java.util.concurrent.atomic.AtomicInteger; import javax.annotation.Nullable; -import lombok.SneakyThrows; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -30,17 +29,15 @@ class FeatureProviderStateManagerTest { wrapper = new FeatureProviderStateManager(testDelegate); } - @SneakyThrows @Test - void shouldOnlyCallInitOnce() { + void shouldOnlyCallInitOnce() throws Exception { wrapper.initialize(null); wrapper.initialize(null); assertThat(testDelegate.initCalled.get()).isOne(); } - @SneakyThrows @Test - void shouldCallInitTwiceWhenShutDownInTheMeantime() { + void shouldCallInitTwiceWhenShutDownInTheMeantime() throws Exception { wrapper.initialize(null); wrapper.shutdown(); wrapper.initialize(null); @@ -53,21 +50,19 @@ class FeatureProviderStateManagerTest { assertThat(wrapper.getState()).isEqualTo(ProviderState.NOT_READY); } - @SneakyThrows @Test @Specification( number = "1.7.3", text = "The client's provider status accessor MUST indicate READY if the initialize function of the associated provider terminates normally.") - void shouldSetStateToReadyAfterInit() { + void shouldSetStateToReadyAfterInit() throws Exception { assertThat(wrapper.getState()).isEqualTo(ProviderState.NOT_READY); wrapper.initialize(null); assertThat(wrapper.getState()).isEqualTo(ProviderState.READY); } - @SneakyThrows @Test - void shouldSetStateToNotReadyAfterShutdown() { + void shouldSetStateToNotReadyAfterShutdown() throws Exception { assertThat(wrapper.getState()).isEqualTo(ProviderState.NOT_READY); wrapper.initialize(null); assertThat(wrapper.getState()).isEqualTo(ProviderState.READY); diff --git c/openfeature-sdk/src/test/java/dev/openfeature/sdk/FlagEvaluationSpecTest.java i/openfeature-sdk/src/test/java/dev/openfeature/sdk/FlagEvaluationSpecTest.java index 170a574..f90c349 100644 --- c/openfeature-sdk/src/test/java/dev/openfeature/sdk/FlagEvaluationSpecTest.java +++ i/openfeature-sdk/src/test/java/dev/openfeature/sdk/FlagEvaluationSpecTest.java @@ -38,7 +38,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; -import lombok.SneakyThrows; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -56,8 +55,7 @@ class FlagEvaluationSpecTest implements HookFixtures { return api.getClient(); } - @SneakyThrows - private Client _initializedClient() { + private Client _initializedClient() throws Exception { TestEventsProvider provider = new TestEventsProvider(); provider.initialize(null); api.setProviderAndWait(provider); @@ -91,13 +89,12 @@ class FlagEvaluationSpecTest implements HookFixtures { assertThat(api.getProvider()).isEqualTo(mockProvider); } - @SneakyThrows @Specification( number = "1.1.8", text = "The API SHOULD provide functions to set a provider and wait for the initialize function to return or throw.") @Test - void providerAndWait() { + void providerAndWait() throws Exception { FeatureProvider provider = new TestEventsProvider(500); api.setProviderAndWait(provider); Client client = api.getClient(); @@ -110,13 +107,12 @@ class FlagEvaluationSpecTest implements HookFixtures { assertThat(client2.getProviderState()).isEqualTo(ProviderState.READY); } - @SneakyThrows @Specification( number = "1.1.8", text = "The API SHOULD provide functions to set a provider and wait for the initialize function to return or throw.") @Test - void providerAndWaitError() { + void providerAndWaitError() throws Exception { FeatureProvider provider1 = new TestEventsProvider(500, true, "fake error"); assertThrows(GeneralError.class, () -> api.setProviderAndWait(provider1)); @@ -361,9 +357,8 @@ class FlagEvaluationSpecTest implements HookFixtures { number = "1.5.1", text = "The evaluation options structure's hooks field denotes an ordered collection of hooks that the client MUST execute for the respective flag evaluation, in addition to those already configured.") - @SneakyThrows @Test - void hooks() { + void hooks() throws Exception { Client c = _initializedClient(); Hook<Boolean> clientHook = mockBooleanHook(); Hook<Boolean> invocationHook = mockBooleanHook(); diff --git c/openfeature-sdk/src/test/java/dev/openfeature/sdk/HookSpecTest.java i/openfeature-sdk/src/test/java/dev/openfeature/sdk/HookSpecTest.java index 06fa8de..7d8b3bf 100644 --- c/openfeature-sdk/src/test/java/dev/openfeature/sdk/HookSpecTest.java +++ i/openfeature-sdk/src/test/java/dev/openfeature/sdk/HookSpecTest.java @@ -42,7 +42,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; -import lombok.SneakyThrows; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; @@ -443,9 +442,8 @@ class HookSpecTest implements HookFixtures { number = "4.4.6", text = "If an error occurs during the evaluation of before or after hooks, any remaining hooks in the before or after stages MUST NOT be invoked.") - @SneakyThrows @Test - void error_stops_after() { + void error_stops_after() throws Exception { Hook<Boolean> h = mockBooleanHook(); doThrow(RuntimeException.class).when(h).after(any(), any(), any()); Hook<Boolean> h2 = mockBooleanHook(); @@ -468,9 +466,8 @@ class HookSpecTest implements HookFixtures { @Specification(number = "4.5.2", text = "hook hints MUST be passed to each hook.") @Specification(number = "4.2.2.1", text = "Condition: Hook hints MUST be immutable.") @Specification(number = "4.5.3", text = "The hook MUST NOT alter the hook hints structure.") - @SneakyThrows @Test - void hook_hints() { + void hook_hints() throws Exception { String hintKey = "My hint key"; Client client = getClient(null); Hook<Boolean> mutatingHook = new BooleanHook() { @@ -552,7 +549,7 @@ class HookSpecTest implements HookFixtures { number = "4.4.7", text = "If an error occurs in the before hooks, the default value MUST be returned.") @Test - void error_hooks__before() { + void error_hooks__before() throws Exception { Hook hook = mockBooleanHook(); doThrow(RuntimeException.class).when(hook).before(any(), any()); Client client = getClient(TestEventsProvider.newInitializedTestEventsProvider()); @@ -570,7 +567,7 @@ class HookSpecTest implements HookFixtures { number = "4.4.5", text = "If an error occurs in the before or after hooks, the error hooks MUST be invoked.") @Test - void error_hooks__after() { + void error_hooks__after() throws Exception { Hook hook = mockBooleanHook(); doThrow(RuntimeException.class).when(hook).after(any(), any(), any()); Client client = getClient(TestEventsProvider.newInitializedTestEventsProvider()); @@ -584,7 +581,7 @@ class HookSpecTest implements HookFixtures { } @Test - void erroneous_flagResolution_setsAppropriateFieldsInFlagEvaluationDetails() { + void erroneous_flagResolution_setsAppropriateFieldsInFlagEvaluationDetails() throws Exception { Hook hook = mockBooleanHook(); doThrow(RuntimeException.class).when(hook).after(any(), any(), any()); String flagKey = "test-flag-key"; @@ -630,7 +627,7 @@ class HookSpecTest implements HookFixtures { } @Test - void successful_flagResolution_setsAppropriateFieldsInFlagEvaluationDetails() { + void successful_flagResolution_setsAppropriateFieldsInFlagEvaluationDetails() throws Exception { Hook hook = mockBooleanHook(); String flagKey = "test-flag-key"; Client client = getClient(TestEventsProvider.newInitializedTestEventsProvider()); @@ -655,7 +652,7 @@ class HookSpecTest implements HookFixtures { } @Test - void multi_hooks_early_out__before() { + void multi_hooks_early_out__before() throws Exception { Hook<Boolean> hook = mockBooleanHook(); Hook<Boolean> hook2 = mockBooleanHook(); doThrow(RuntimeException.class).when(hook).before(any(), any()); @@ -681,7 +678,7 @@ class HookSpecTest implements HookFixtures { text = "Any `evaluation context` returned from a `before` hook MUST be passed to subsequent `before` hooks (via `HookContext`).") @Test - void beforeContextUpdated() { + void beforeContextUpdated() throws Exception { String targetingKey = "test-key"; EvaluationContext ctx = new ImmutableContext(targetingKey); Hook<Boolean> hook = mockBooleanHook(); @@ -749,7 +746,7 @@ class HookSpecTest implements HookFixtures { text = "If a finally hook abnormally terminates, evaluation MUST proceed, including the execution of any remaining finally hooks.") @Test - void first_finally_broken() { + void first_finally_broken() throws Exception { Hook hook = mockBooleanHook(); doThrow(RuntimeException.class).when(hook).before(any(), any()); doThrow(RuntimeException.class).when(hook).finallyAfter(any(), any(), any()); @@ -773,7 +770,7 @@ class HookSpecTest implements HookFixtures { text = "If an error hook abnormally terminates, evaluation MUST proceed, including the execution of any remaining error hooks.") @Test - void first_error_broken() { + void first_error_broken() throws Exception { Hook hook = mockBooleanHook(); doThrow(RuntimeException.class).when(hook).before(any(), any()); doThrow(RuntimeException.class).when(hook).error(any(), any(), any()); @@ -792,7 +789,7 @@ class HookSpecTest implements HookFixtures { order.verify(hook).error(any(), any(), any()); } - private Client getClient(FeatureProvider provider) { + private Client getClient(FeatureProvider provider) throws Exception { if (provider == null) { api.setProviderAndWait(TestEventsProvider.newInitializedTestEventsProvider()); } else { @@ -806,9 +803,8 @@ class HookSpecTest implements HookFixtures { void default_methods_so_impossible() {} @Specification(number = "4.3.9.1", text = "Instead of finally, finallyAfter SHOULD be used.") - @SneakyThrows @Test - void doesnt_use_finally() { + void doesnt_use_finally() throws Exception { assertThatCode(() -> Hook.class.getMethod("finally", HookContext.class, Map.class)) .as("Not possible. Finally is a reserved word.") .isInstanceOf(NoSuchMethodException.class); diff --git c/openfeature-sdk/src/test/java/dev/openfeature/sdk/ThreadLocalTransactionContextPropagatorTest.java i/openfeature-sdk/src/test/java/dev/openfeature/sdk/ThreadLocalTransactionContextPropagatorTest.java index f37713a..b5414b4 100644 --- c/openfeature-sdk/src/test/java/dev/openfeature/sdk/ThreadLocalTransactionContextPropagatorTest.java +++ i/openfeature-sdk/src/test/java/dev/openfeature/sdk/ThreadLocalTransactionContextPropagatorTest.java @@ -8,7 +8,6 @@ import dev.openfeature.api.EvaluationContext; import dev.openfeature.api.ImmutableContext; import java.util.concurrent.Callable; import java.util.concurrent.FutureTask; -import lombok.SneakyThrows; import org.junit.jupiter.api.Test; public class ThreadLocalTransactionContextPropagatorTest { @@ -32,9 +31,8 @@ public class ThreadLocalTransactionContextPropagatorTest { assertNull(result); } - @SneakyThrows @Test - public void setTransactionContextTwoThreads() { + public void setTransactionContextTwoThreads() throws Exception { EvaluationContext firstContext = new ImmutableContext(); EvaluationContext secondContext = new ImmutableContext(); diff --git c/openfeature-sdk/src/test/java/dev/openfeature/sdk/TrackingSpecTest.java i/openfeature-sdk/src/test/java/dev/openfeature/sdk/TrackingSpecTest.java index 90867c5..a42aa3f 100644 --- c/openfeature-sdk/src/test/java/dev/openfeature/sdk/TrackingSpecTest.java +++ i/openfeature-sdk/src/test/java/dev/openfeature/sdk/TrackingSpecTest.java @@ -28,7 +28,6 @@ import dev.openfeature.api.Value; import dev.openfeature.sdk.fixtures.ProviderFixture; import java.util.HashMap; import java.util.Map; -import lombok.SneakyThrows; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -54,8 +53,7 @@ class TrackingSpecTest { + "particular action or application state, with parameters `tracking event name` (string, required) and " + "`tracking event details` (optional), which returns nothing.") @Test - @SneakyThrows - void trackMethodFulfillsSpec() { + void trackMethodFulfillsSpec() throws Exception { ImmutableContext ctx = new ImmutableContext(); MutableTrackingEventDetails details = new MutableTrackingEventDetails(0.0f); diff --git c/openfeature-sdk/src/test/java/dev/openfeature/sdk/e2e/ContextStoringProvider.java i/openfeature-sdk/src/test/java/dev/openfeature/sdk/e2e/ContextStoringProvider.java index a3e6e4e..3b94b10 100644 --- c/openfeature-sdk/src/test/java/dev/openfeature/sdk/e2e/ContextStoringProvider.java +++ i/openfeature-sdk/src/test/java/dev/openfeature/sdk/e2e/ContextStoringProvider.java @@ -5,9 +5,7 @@ import dev.openfeature.api.FeatureProvider; import dev.openfeature.api.Metadata; import dev.openfeature.api.ProviderEvaluation; import dev.openfeature.api.Value; -import lombok.Getter; -@Getter public class ContextStoringProvider implements FeatureProvider { private EvaluationContext evaluationContext; @@ -45,4 +43,8 @@ public class ContextStoringProvider implements FeatureProvider { this.evaluationContext = ctx; return null; } + + public EvaluationContext getEvaluationContext() { + return evaluationContext; + } } diff --git c/openfeature-sdk/src/test/java/dev/openfeature/sdk/e2e/MockHook.java i/openfeature-sdk/src/test/java/dev/openfeature/sdk/e2e/MockHook.java index d7ae779..2806b74 100644 --- c/openfeature-sdk/src/test/java/dev/openfeature/sdk/e2e/MockHook.java +++ i/openfeature-sdk/src/test/java/dev/openfeature/sdk/e2e/MockHook.java @@ -7,22 +7,16 @@ import dev.openfeature.api.HookContext; import java.util.HashMap; import java.util.Map; import java.util.Optional; -import lombok.Getter; public class MockHook implements Hook { - @Getter private boolean beforeCalled; - @Getter private boolean afterCalled; - @Getter private boolean errorCalled; - @Getter private boolean finallyAfterCalled; - @Getter private final Map<String, FlagEvaluationDetails> evaluationDetails = new HashMap<>(); @Override @@ -47,4 +41,24 @@ public class MockHook implements Hook { finallyAfterCalled = true; evaluationDetails.put("finally", details); } + + public boolean isBeforeCalled() { + return beforeCalled; + } + + public boolean isAfterCalled() { + return afterCalled; + } + + public boolean isErrorCalled() { + return errorCalled; + } + + public boolean isFinallyAfterCalled() { + return finallyAfterCalled; + } + + public Map<String, FlagEvaluationDetails> getEvaluationDetails() { + return evaluationDetails; + } } diff --git c/openfeature-sdk/src/test/java/dev/openfeature/sdk/e2e/steps/StepDefinitions.java i/openfeature-sdk/src/test/java/dev/openfeature/sdk/e2e/steps/StepDefinitions.java index d8b90ea..b1ff355 100644 --- c/openfeature-sdk/src/test/java/dev/openfeature/sdk/e2e/steps/StepDefinitions.java +++ i/openfeature-sdk/src/test/java/dev/openfeature/sdk/e2e/steps/StepDefinitions.java @@ -20,7 +20,6 @@ import io.cucumber.java.en.Then; import io.cucumber.java.en.When; import java.util.HashMap; import java.util.Map; -import lombok.SneakyThrows; public class StepDefinitions { @@ -49,10 +48,9 @@ public class StepDefinitions { private int typeErrorDefaultValue; private FlagEvaluationDetails<Integer> typeErrorDetails; - @SneakyThrows @BeforeAll() @Given("a provider is registered") - public static void setup() { + public static void setup() throws Exception { Map<String, Flag<?>> flags = buildFlags(); InMemoryProvider provider = new InMemoryProvider(flags); OpenFeatureAPI api = new DefaultOpenFeatureAPI(); diff --git c/openfeature-sdk/src/test/java/dev/openfeature/sdk/fixtures/ProviderFixture.java i/openfeature-sdk/src/test/java/dev/openfeature/sdk/fixtures/ProviderFixture.java index e9b1cfc..4c7fc05 100644 --- c/openfeature-sdk/src/test/java/dev/openfeature/sdk/fixtures/ProviderFixture.java +++ i/openfeature-sdk/src/test/java/dev/openfeature/sdk/fixtures/ProviderFixture.java @@ -12,12 +12,14 @@ import dev.openfeature.api.ImmutableContext; import dev.openfeature.api.ProviderState; import java.io.FileNotFoundException; import java.util.concurrent.CountDownLatch; -import lombok.experimental.UtilityClass; import org.mockito.stubbing.Answer; -@UtilityClass public class ProviderFixture { + private ProviderFixture() { + // Utility class + } + public static FeatureProvider createMockedProvider() { FeatureProvider provider = mock(FeatureProvider.class); doReturn(ProviderState.NOT_READY).when(provider).getState(); diff --git c/openfeature-sdk/src/test/java/dev/openfeature/sdk/hooks/logging/LoggingHookTest.java i/openfeature-sdk/src/test/java/dev/openfeature/sdk/hooks/logging/LoggingHookTest.java index 5ab180f..18cffed 100644 --- c/openfeature-sdk/src/test/java/dev/openfeature/sdk/hooks/logging/LoggingHookTest.java +++ i/openfeature-sdk/src/test/java/dev/openfeature/sdk/hooks/logging/LoggingHookTest.java @@ -18,7 +18,6 @@ import dev.openfeature.api.HookContext; import dev.openfeature.api.ImmutableContext; import dev.openfeature.api.Metadata; import dev.openfeature.api.exceptions.GeneralError; -import lombok.SneakyThrows; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.simplify4u.slf4jmock.LoggerMock; @@ -73,9 +72,8 @@ class LoggingHookTest { LoggerMock.setMock(LoggingHook.class, logger); } - @SneakyThrows @Test - void beforeLogsAllPropsExceptEvaluationContext() { + void beforeLogsAllPropsExceptEvaluationContext() throws Exception { LoggingHook hook = new LoggingHook(); hook.before(hookContext, null); @@ -85,9 +83,8 @@ class LoggingHookTest { verify(mockBuilder).log(argThat((String s) -> s.contains("Before"))); } - @SneakyThrows @Test - void beforeLogsAllPropsAndEvaluationContext() { + void beforeLogsAllPropsAndEvaluationContext() throws Exception { LoggingHook hook = new LoggingHook(true); hook.before(hookContext, null); @@ -97,9 +94,8 @@ class LoggingHookTest { verify(mockBuilder).log(argThat((String s) -> s.contains("Before"))); } - @SneakyThrows @Test - void afterLogsAllPropsExceptEvaluationContext() { + void afterLogsAllPropsExceptEvaluationContext() throws Exception { LoggingHook hook = new LoggingHook(); FlagEvaluationDetails<Object> details = FlagEvaluationDetails.builder() .reason(REASON) @@ -115,9 +111,8 @@ class LoggingHookTest { verify(mockBuilder).log(argThat((String s) -> s.contains("After"))); } - @SneakyThrows @Test - void afterLogsAllPropsAndEvaluationContext() { + void afterLogsAllPropsAndEvaluationContext() throws Exception { LoggingHook hook = new LoggingHook(true); FlagEvaluationDetails<Object> details = FlagEvaluationDetails.builder() .reason(REASON) @@ -133,9 +128,8 @@ class LoggingHookTest { verify(mockBuilder).log(argThat((String s) -> s.contains("After"))); } - @SneakyThrows @Test - void errorLogsAllPropsExceptEvaluationContext() { + void errorLogsAllPropsExceptEvaluationContext() throws Exception { LoggingHook hook = new LoggingHook(); GeneralError error = new GeneralError(ERROR_MESSAGE); hook.error(hookContext, error, null); @@ -147,9 +141,8 @@ class LoggingHookTest { verify(mockBuilder).log(argThat((String s) -> s.contains("Error")), any(Exception.class)); } - @SneakyThrows @Test - void errorLogsAllPropsAndEvaluationContext() { + void errorLogsAllPropsAndEvaluationContext() throws Exception { LoggingHook hook = new LoggingHook(true); GeneralError error = new GeneralError(ERROR_MESSAGE); hook.error(hookContext, error, null); diff --git c/openfeature-sdk/src/test/java/dev/openfeature/sdk/providers/memory/InMemoryProviderTest.java i/openfeature-sdk/src/test/java/dev/openfeature/sdk/providers/memory/InMemoryProviderTest.java index 87e0d65..96f7beb 100644 --- c/openfeature-sdk/src/test/java/dev/openfeature/sdk/providers/memory/InMemoryProviderTest.java +++ i/openfeature-sdk/src/test/java/dev/openfeature/sdk/providers/memory/InMemoryProviderTest.java @@ -26,7 +26,6 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; -import lombok.SneakyThrows; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -37,9 +36,8 @@ class InMemoryProviderTest { private InMemoryProvider provider; private OpenFeatureAPI api; - @SneakyThrows @BeforeEach - void beforeEach() { + void beforeEach() throws Exception { final var configChangedEventCounter = new AtomicInteger(); Map<String, Flag<?>> flags = buildFlags(); provider = spy(new InMemoryProvider(flags)); @@ -105,9 +103,8 @@ class InMemoryProviderTest { }); } - @SneakyThrows @Test - void shouldThrowIfNotInitialized() { + void shouldThrowIfNotInitialized() throws Exception { InMemoryProvider inMemoryProvider = new InMemoryProvider(new HashMap<>()); // ErrorCode.PROVIDER_NOT_READY should be returned when evaluated via the client diff --git c/openfeature-sdk/src/test/java/dev/openfeature/sdk/testutils/TestEventsProvider.java i/openfeature-sdk/src/test/java/dev/openfeature/sdk/testutils/TestEventsProvider.java index bbb2f07..b5a0635 100644 --- c/openfeature-sdk/src/test/java/dev/openfeature/sdk/testutils/TestEventsProvider.java +++ i/openfeature-sdk/src/test/java/dev/openfeature/sdk/testutils/TestEventsProvider.java @@ -10,7 +10,6 @@ import dev.openfeature.api.Value; import dev.openfeature.api.exceptions.FatalError; import dev.openfeature.api.exceptions.GeneralError; import dev.openfeature.sdk.EventProvider; -import lombok.SneakyThrows; public class TestEventsProvider extends EventProvider { public static final String PASSED_IN_DEFAULT = "Passed in default"; @@ -42,8 +41,7 @@ public class TestEventsProvider extends EventProvider { this.isFatalInitError = fatal; } - @SneakyThrows - public static TestEventsProvider newInitializedTestEventsProvider() { + public static TestEventsProvider newInitializedTestEventsProvider() throws Exception { TestEventsProvider provider = new TestEventsProvider(); provider.initialize(null); return provider; diff --git c/openfeature-sdk/src/test/java/dev/openfeature/sdk/testutils/TestFlagsUtils.java i/openfeature-sdk/src/test/java/dev/openfeature/sdk/testutils/TestFlagsUtils.java index 7c71e06..41a02cc 100644 --- c/openfeature-sdk/src/test/java/dev/openfeature/sdk/testutils/TestFlagsUtils.java +++ i/openfeature-sdk/src/test/java/dev/openfeature/sdk/testutils/TestFlagsUtils.java @@ -8,14 +8,15 @@ import dev.openfeature.api.Value; import dev.openfeature.sdk.providers.memory.Flag; import java.util.HashMap; import java.util.Map; -import lombok.experimental.UtilityClass; - /** * Test flags utils. */ -@UtilityClass public class TestFlagsUtils { + private TestFlagsUtils() { + // Utility class + } + public static final String BOOLEAN_FLAG_KEY = "boolean-flag"; public static final String STRING_FLAG_KEY = "string-flag"; public static final String INT_FLAG_KEY = "integer-flag"; diff --git c/openfeature-sdk/src/test/java/dev/openfeature/sdk/testutils/stubbing/ConditionStubber.java i/openfeature-sdk/src/test/java/dev/openfeature/sdk/testutils/stubbing/ConditionStubber.java index 886a7bb..e99cc84 100644 --- c/openfeature-sdk/src/test/java/dev/openfeature/sdk/testutils/stubbing/ConditionStubber.java +++ i/openfeature-sdk/src/test/java/dev/openfeature/sdk/testutils/stubbing/ConditionStubber.java @@ -5,13 +5,15 @@ import static org.mockito.Mockito.doAnswer; import java.time.Duration; import java.util.concurrent.CountDownLatch; -import lombok.experimental.UtilityClass; import org.mockito.stubbing.Answer; import org.mockito.stubbing.Stubber; -@UtilityClass public class ConditionStubber { + private ConditionStubber() { + // Utility class + } + @SuppressWarnings("java:S2925") public static Stubber doDelayResponse(Duration duration) { return doAnswer(invocation -> { diff --git c/pom.xml.backup i/pom.xml.backup deleted file mode 100644 index 3a12111..0000000 --- c/pom.xml.backup +++ /dev/null @@ -1,718 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <groupId>dev.openfeature</groupId> - <artifactId>sdk</artifactId> - <version>1.16.0</version> <!--x-release-please-version --> - - <properties> - <toolchain.jdk.version>[17,)</toolchain.jdk.version> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <maven.compiler.source>11</maven.compiler.source> - <maven.compiler.target>${maven.compiler.source}</maven.compiler.target> - <org.mockito.version>5.18.0</org.mockito.version> - <!-- exclusion expression for e2e tests --> - <testExclusions>**/e2e/*.java</testExclusions> - <module-name>${project.groupId}.${project.artifactId}</module-name> - <skip.tests>false</skip.tests> - <!-- this will throw an error if we use wrong apis --> - <maven.compiler.release>11</maven.compiler.release> - </properties> - - <name>OpenFeature Java SDK</name> - <description>This is the Java implementation of OpenFeature, a vendor-agnostic abstraction library for evaluating - feature flags. - </description> - <url>https://openfeature.dev</url> - <developers> - <developer> - <id>abrahms</id> - <name>Justin Abrahms</name> - <organization>eBay</organization> - <url>https://justin.abrah.ms/</url> - </developer> - </developers> - <licenses> - <license> - <name>Apache License 2.0</name> - <url>https://www.apache.org/licenses/LICENSE-2.0</url> - </license> - </licenses> - - <scm> - <connection>scm:git:https://github.com/open-feature/java-sdk.git</connection> - <developerConnection>scm:git:https://github.com/open-feature/java-sdk.git</developerConnection> - <url>https://github.com/open-feature/java-sdk</url> - </scm> - - <dependencies> - - <dependency> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - <version>1.18.38</version> - <scope>provided</scope> - </dependency> - - <dependency> - <!-- used so that lombok can generate suppressions for spotbugs. It needs to find it on the relevant classpath --> - <groupId>com.github.spotbugs</groupId> - <artifactId>spotbugs</artifactId> - <version>4.8.6</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>2.0.17</version> - </dependency> - - <!-- test --> - <dependency> - <groupId>com.tngtech.archunit</groupId> - <artifactId>archunit-junit5</artifactId> - <version>1.4.1</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <version>${org.mockito.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.assertj</groupId> - <artifactId>assertj-core</artifactId> - <version>3.27.3</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter-engine</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter-api</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter-params</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.junit.platform</groupId> - <artifactId>junit-platform-suite</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>io.cucumber</groupId> - <artifactId>cucumber-java</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>io.cucumber</groupId> - <artifactId>cucumber-junit-platform-engine</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>io.cucumber</groupId> - <artifactId>cucumber-picocontainer</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.simplify4u</groupId> - <artifactId>slf4j2-mock</artifactId> - <version>2.4.0</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - <version>33.4.8-jre</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.awaitility</groupId> - <artifactId>awaitility</artifactId> - <version>4.3.0</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.openjdk.jmh</groupId> - <artifactId>jmh-core</artifactId> - <version>1.37</version> - <scope>test</scope> - </dependency> - - </dependencies> - - <dependencyManagement> - <dependencies> - - <!-- Start mockito workaround --> - <!-- https://github.com/mockito/mockito/issues/3121 --> - <!-- These are transitive dependencies of mockito we are forcing --> - <dependency> - <groupId>net.bytebuddy</groupId> - <artifactId>byte-buddy</artifactId> - <version>1.17.6</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>net.bytebuddy</groupId> - <artifactId>byte-buddy-agent</artifactId> - <version>1.17.6</version> - <scope>test</scope> - </dependency> - <!-- End mockito workaround--> - - <dependency> - <groupId>io.cucumber</groupId> - <artifactId>cucumber-bom</artifactId> - <version>7.27.0</version> - <type>pom</type> - <scope>import</scope> - </dependency> - - <dependency> - <groupId>org.junit</groupId> - <artifactId>junit-bom</artifactId> - <version>5.13.4</version> - <type>pom</type> - <scope>import</scope> - </dependency> - - </dependencies> - </dependencyManagement> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-toolchains-plugin</artifactId> - <version>3.2.0</version> - <executions> - <execution> - <goals> - <goal>select-jdk-toolchain</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.cyclonedx</groupId> - <artifactId>cyclonedx-maven-plugin</artifactId> - <version>2.9.1</version> - <configuration> - <projectType>library</projectType> - <schemaVersion>1.3</schemaVersion> - <includeBomSerialNumber>true</includeBomSerialNumber> - <includeCompileScope>true</includeCompileScope> - <includeProvidedScope>true</includeProvidedScope> - <includeRuntimeScope>true</includeRuntimeScope> - <includeSystemScope>true</includeSystemScope> - <includeTestScope>false</includeTestScope> - <includeLicenseText>false</includeLicenseText> - <outputFormat>all</outputFormat> - </configuration> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>makeAggregateBom</goal> - </goals> - </execution> - </executions> - </plugin> - - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.14.0</version> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <version>3.5.3</version> - <configuration> - <forkCount>1</forkCount> - <reuseForks>false</reuseForks> - <argLine> - ${surefireArgLine} - --add-opens java.base/java.util=ALL-UNNAMED - --add-opens java.base/java.lang=ALL-UNNAMED - </argLine> - <excludes> - <!-- tests to exclude --> - <exclude>${testExclusions}</exclude> - </excludes> - </configuration> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-failsafe-plugin</artifactId> - <version>3.5.3</version> - <configuration> - <argLine> - ${surefireArgLine} - </argLine> - </configuration> - </plugin> - - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <version>3.4.2</version> - <configuration> - <archive> - <manifestEntries> - <Automatic-Module-Name>${module-name}</Automatic-Module-Name> - </manifestEntries> - </archive> - </configuration> - </plugin> - - </plugins> - </build> - - <profiles> - <profile> - <id>codequality</id> - <activation> - <activeByDefault>true</activeByDefault> - </activation> - <build> - <plugins> - <plugin> - <artifactId>maven-dependency-plugin</artifactId> - <version>3.8.1</version> - <executions> - <execution> - <phase>verify</phase> - <goals> - <goal>analyze</goal> - </goals> - </execution> - </executions> - <configuration> - <failOnWarning>true</failOnWarning> - <ignoredUnusedDeclaredDependencies> - <ignoredUnusedDeclaredDependency>com.github.spotbugs:*</ignoredUnusedDeclaredDependency> - <ignoredUnusedDeclaredDependency>org.junit*</ignoredUnusedDeclaredDependency> - <ignoredUnusedDeclaredDependency>com.tngtech.archunit*</ignoredUnusedDeclaredDependency> - <ignoredUnusedDeclaredDependency>org.simplify4u:slf4j2-mock*</ignoredUnusedDeclaredDependency> - </ignoredUnusedDeclaredDependencies> - <ignoredDependencies> - <ignoredDependency>com.google.guava*</ignoredDependency> - <ignoredDependency>io.cucumber*</ignoredDependency> - <ignoredDependency>org.junit*</ignoredDependency> - <ignoredDependency>com.tngtech.archunit*</ignoredDependency> - <ignoredDependency>com.google.code.findbugs*</ignoredDependency> - <ignoredDependency>com.github.spotbugs*</ignoredDependency> - <ignoredDependency>org.simplify4u:slf4j-mock-common:*</ignoredDependency> - </ignoredDependencies> - </configuration> - </plugin> - - <plugin> - <groupId>org.jacoco</groupId> - <artifactId>jacoco-maven-plugin</artifactId> - <version>0.8.13</version> - - <executions> - <execution> - <id>prepare-agent</id> - <goals> - <goal>prepare-agent</goal> - </goals> - - <configuration> - <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile> - <propertyName>surefireArgLine</propertyName> - </configuration> - </execution> - - <execution> - <id>report</id> - <phase>verify</phase> - <goals> - <goal>report</goal> - </goals> - - <configuration> - <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile> - <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory> - </configuration> - </execution> - - <execution> - <id>jacoco-check</id> - <goals> - <goal>check</goal> - </goals> - <configuration> - <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile> - <excludes> - <exclude>dev/openfeature/sdk/exceptions/**</exclude> - </excludes> - - <rules> - <rule> - <element>PACKAGE</element> - <limits> - <limit> - <counter>LINE</counter> - <value>COVEREDRATIO</value> - <minimum>0.80</minimum> - </limit> - </limits> - </rule> - </rules> - </configuration> - </execution> - - </executions> - </plugin> - <plugin> - <groupId>com.github.spotbugs</groupId> - <artifactId>spotbugs-maven-plugin</artifactId> - <version>4.9.3.2</version> - <configuration> - <excludeFilterFile>spotbugs-exclusions.xml</excludeFilterFile> - <plugins> - <plugin> - <groupId>com.h3xstream.findsecbugs</groupId> - <artifactId>findsecbugs-plugin</artifactId> - <version>1.14.0</version> - </plugin> - </plugins> - </configuration> - <dependencies> - <!-- overwrite dependency on spotbugs if you want to specify the version of spotbugs --> - <dependency> - <groupId>com.github.spotbugs</groupId> - <artifactId>spotbugs</artifactId> - <version>4.8.6</version> - </dependency> - </dependencies> - <executions> - <execution> - <id>run-spotbugs</id> - <phase>verify</phase> - <goals> - <goal>check</goal> - </goals> - </execution> - </executions> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-checkstyle-plugin</artifactId> - <version>3.6.0</version> - <configuration> - <configLocation>checkstyle.xml</configLocation> - <consoleOutput>true</consoleOutput> - <failsOnError>true</failsOnError> - <linkXRef>false</linkXRef> - </configuration> - <dependencies> - <dependency> - <groupId>com.puppycrawl.tools</groupId> - <artifactId>checkstyle</artifactId> - <version>10.26.1</version> - </dependency> - </dependencies> - <executions> - <execution> - <id>validate</id> - <phase>validate</phase> - <goals> - <goal>check</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>com.diffplug.spotless</groupId> - <artifactId>spotless-maven-plugin</artifactId> - <version>2.46.1</version> - <configuration> - <!-- optional: limit format enforcement to just the files changed by this feature branch --> - <!-- <ratchetFrom>origin/main</ratchetFrom>--> - <formats> - <!-- you can define as many formats as you want, each is independent --> - <format> - <!-- define the files to apply to --> - <includes> - <include>.gitattributes</include> - <include>.gitignore</include> - </includes> - <!-- define the steps to apply to those files --> - <trimTrailingWhitespace/> - <endWithNewline/> - <indent> - <spaces>true</spaces> - <spacesPerTab>4</spacesPerTab> - </indent> - </format> - </formats> - <!-- define a language-specific format --> - <java> - <palantirJavaFormat/> - - <indent> - <spaces>true</spaces> - <spacesPerTab>4</spacesPerTab> - </indent> - <importOrder/> - - <removeUnusedImports/> - <formatAnnotations/> - - </java> - </configuration> - <executions> - <execution> - <goals> - <goal>check</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - <profile> - <id>deploy</id> - <activation> - <activeByDefault>true</activeByDefault> - </activation> - <build> - - <plugins> - <!-- Begin publish to maven central --> - <plugin> - <groupId>org.sonatype.central</groupId> - <artifactId>central-publishing-maven-plugin</artifactId> - <version>0.8.0</version> - <extensions>true</extensions> - <configuration> - <publishingServerId>central</publishingServerId> - <autoPublish>true</autoPublish> - </configuration> - </plugin> - <!-- End publish to maven central --> - - <!-- Begin source & javadocs being generated --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-source-plugin</artifactId> - <version>3.3.1</version> - <executions> - <execution> - <id>attach-sources</id> - <goals> - <goal>jar-no-fork</goal> - </goals> - </execution> - </executions> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-javadoc-plugin</artifactId> - <version>3.11.2</version> - <configuration> - <failOnWarnings>true</failOnWarnings> - <doclint>all,-missing - </doclint> <!-- ignore missing javadoc, these are enforced with more customizability in the checkstyle plugin --> - </configuration> - <executions> - <execution> - <id>attach-javadocs</id> - <goals> - <goal>jar</goal> - </goals> - </execution> - </executions> - </plugin> - <!-- end source & javadoc --> - - <!-- sign the jars --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-gpg-plugin</artifactId> - <version>3.2.8</version> - <executions> - <execution> - <id>sign-artifacts</id> - <phase>install</phase> - <goals> - <goal>sign</goal> - </goals> - </execution> - </executions> - </plugin> - <!-- end sign --> - </plugins> - </build> - </profile> - - <profile> - <id>benchmark</id> - <build> - <plugins> - <plugin> - <groupId>pw.krejci</groupId> - <artifactId>jmh-maven-plugin</artifactId> - <version>0.2.2</version> - </plugin> - </plugins> - </build> - </profile> - - <profile> - <id>e2e</id> - <properties> - <!-- run the e2e tests by clearing the exclusions --> - <testExclusions/> - </properties> - <build> - <plugins> - <!-- pull the gherkin tests as a git submodule --> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <version>3.5.1</version> - <executions> - <execution> - <id>update-test-harness-submodule</id> - <phase>validate</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <!-- run: git submodule update \-\-init \-\-recursive --> - <executable>git</executable> - <arguments> - <argument>submodule</argument> - <argument>update</argument> - <argument>--init</argument> - <argument>spec</argument> - </arguments> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - <!-- profile for running tests under java 11 (used mostly in CI) --> - <!-- selected automatically by JDK activation (see https://maven.apache.org/guides/introduction/introduction-to-profiles.html#implicit-profile-activation) --> - <profile> - <id>java11</id> - <!-- with the next block we can define a set of sdks which still support java 8, if any of the sdks is not supporting java 8 anymore --> - <!--<modules><module></module></modules>--> - <properties> - <toolchain.jdk.version>[11,)</toolchain.jdk.version> - <skip.tests>true</skip.tests> - </properties> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-toolchains-plugin</artifactId> - <version>3.2.0</version> - <executions> - <execution> - <goals> - <goal>select-jdk-toolchain</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <version>3.5.3</version> - <configuration> - <argLine> - ${surefireArgLine} - </argLine> - <excludes> - <!-- tests to exclude --> - <exclude>${testExclusions}</exclude> - </excludes> - - <skipTests>${skip.tests}</skipTests> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-failsafe-plugin</artifactId> - <version>3.5.3</version> - <configuration> - <argLine> - ${surefireArgLine} - </argLine> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.14.0</version> - <executions> - <execution> - <id>default-testCompile</id> - <phase>test-compile</phase> - <goals> - <goal>testCompile</goal> - </goals> - <configuration> - <skip>true</skip> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> - - <distributionManagement> - <snapshotRepository> - <id>central</id> - <url>https://central.sonatype.com/repository/maven-snapshots/</url> - </snapshotRepository> - </distributionManagement> - -</project> diff --git c/src/lombok.config i/src/lombok.config deleted file mode 100644 index ec3b056..0000000 --- c/src/lombok.config +++ /dev/null @@ -1,2 +0,0 @@ -lombok.addLombokGeneratedAnnotation = true -lombok.extern.findbugs.addSuppressFBWarnings = true diff --git c/src/main/java/dev/openfeature/sdk/AbstractStructure.java i/src/main/java/dev/openfeature/sdk/AbstractStructure.java deleted file mode 100644 index 7962705..0000000 --- c/src/main/java/dev/openfeature/sdk/AbstractStructure.java +++ /dev/null @@ -1,51 +0,0 @@ -package dev.openfeature.sdk; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import lombok.EqualsAndHashCode; - -@SuppressWarnings({"PMD.BeanMembersShouldSerialize", "checkstyle:MissingJavadocType"}) -@EqualsAndHashCode -abstract class AbstractStructure implements Structure { - - protected final Map<String, Value> attributes; - - @Override - public boolean isEmpty() { - return attributes == null || attributes.isEmpty(); - } - - AbstractStructure() { - this.attributes = new HashMap<>(); - } - - AbstractStructure(Map<String, Value> attributes) { - this.attributes = attributes; - } - - /** - * Returns an unmodifiable representation of the internal attribute map. - * - * @return immutable map - */ - public Map<String, Value> asUnmodifiableMap() { - return Collections.unmodifiableMap(attributes); - } - - /** - * Get all values as their underlying primitives types. - * - * @return all attributes on the structure into a Map - */ - @Override - public Map<String, Object> asObjectMap() { - return attributes.entrySet().stream() - // custom collector, workaround for Collectors.toMap in JDK8 - // https://bugs.openjdk.org/browse/JDK-8148463 - .collect( - HashMap::new, - (accumulated, entry) -> accumulated.put(entry.getKey(), convertValue(entry.getValue())), - HashMap::putAll); - } -} diff --git c/src/main/java/dev/openfeature/sdk/Awaitable.java i/src/main/java/dev/openfeature/sdk/Awaitable.java deleted file mode 100644 index 7d5f477..0000000 --- c/src/main/java/dev/openfeature/sdk/Awaitable.java +++ /dev/null @@ -1,44 +0,0 @@ -package dev.openfeature.sdk; - -/** - * A class to help with synchronization by allowing the optional awaiting of the associated action. - */ -public class Awaitable { - - /** - * An already-completed Awaitable. Awaiting this will return i…
1 parent f7a0e08 commit 624c4de

149 files changed

Lines changed: 77 additions & 12419 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

openfeature-sdk/src/test/java/dev/openfeature/sdk/DeveloperExperienceTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.util.List;
2929
import java.util.Map;
3030
import java.util.Optional;
31-
import lombok.SneakyThrows;
3231
import org.junit.jupiter.api.BeforeEach;
3332
import org.junit.jupiter.api.Test;
3433

@@ -120,13 +119,16 @@ void providerLockedPerTransaction() {
120119
class MutatingHook implements Hook {
121120

122121
@Override
123-
@SneakyThrows
124122
// change the provider during a before hook - this should not impact the evaluation in progress
125123
public Optional before(HookContext ctx, Map hints) {
124+
try {
126125

127-
api.setProviderAndWait(TestEventsProvider.newInitializedTestEventsProvider());
126+
api.setProviderAndWait(TestEventsProvider.newInitializedTestEventsProvider());
128127

129-
return Optional.empty();
128+
return Optional.empty();
129+
} catch (Exception e) {
130+
throw new RuntimeException(e);
131+
}
130132
}
131133
}
132134

openfeature-sdk/src/test/java/dev/openfeature/sdk/EventProviderTest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import dev.openfeature.sdk.internal.TriConsumer;
1818
import dev.openfeature.sdk.testutils.TestStackedEmitCallsProvider;
1919
import io.cucumber.java.AfterAll;
20-
import lombok.SneakyThrows;
2120
import org.junit.jupiter.api.BeforeEach;
2221
import org.junit.jupiter.api.DisplayName;
2322
import org.junit.jupiter.api.Test;
@@ -30,8 +29,7 @@ class EventProviderTest {
3029
private TestEventProvider eventProvider;
3130

3231
@BeforeEach
33-
@SneakyThrows
34-
void setup() {
32+
void setup() throws Exception {
3533
eventProvider = new TestEventProvider();
3634
eventProvider.initialize(null);
3735
}
@@ -97,10 +95,9 @@ void doesNotThrowWhenOnEmitSame() {
9795
}
9896

9997
@Test
100-
@SneakyThrows
10198
@Timeout(value = 2, threadMode = Timeout.ThreadMode.SEPARATE_THREAD)
10299
@DisplayName("should not deadlock on emit called during emit")
103-
void doesNotDeadlockOnEmitStackedCalls() {
100+
void doesNotDeadlockOnEmitStackedCalls() throws Exception {
104101
TestStackedEmitCallsProvider provider = new TestStackedEmitCallsProvider();
105102
new DefaultOpenFeatureAPI().setProviderAndWait(provider);
106103
}

openfeature-sdk/src/test/java/dev/openfeature/sdk/EventsTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.Arrays;
2424
import java.util.List;
2525
import java.util.function.Consumer;
26-
import lombok.SneakyThrows;
2726
import org.junit.jupiter.api.BeforeEach;
2827
import org.junit.jupiter.api.DisplayName;
2928
import org.junit.jupiter.api.Nested;
@@ -687,8 +686,7 @@ class HandlerRemoval {
687686
text = "The API and client MUST provide a function allowing the removal of event handlers.")
688687
@Test
689688
@DisplayName("should not run removed events")
690-
@SneakyThrows
691-
void removedEventsShouldNotRun() {
689+
void removedEventsShouldNotRun() throws Exception {
692690
final String name = "removedEventsShouldNotRun";
693691
final Consumer<EventDetails> handler1 = mockHandler();
694692
final Consumer<EventDetails> handler2 = mockHandler();

openfeature-sdk/src/test/java/dev/openfeature/sdk/FeatureProviderStateManagerTest.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import dev.openfeature.api.exceptions.GeneralError;
1616
import java.util.concurrent.atomic.AtomicInteger;
1717
import javax.annotation.Nullable;
18-
import lombok.SneakyThrows;
1918
import org.junit.jupiter.api.BeforeEach;
2019
import org.junit.jupiter.api.Test;
2120

@@ -30,17 +29,15 @@ public void setUp() {
3029
wrapper = new FeatureProviderStateManager(testDelegate);
3130
}
3231

33-
@SneakyThrows
3432
@Test
35-
void shouldOnlyCallInitOnce() {
33+
void shouldOnlyCallInitOnce() throws Exception {
3634
wrapper.initialize(null);
3735
wrapper.initialize(null);
3836
assertThat(testDelegate.initCalled.get()).isOne();
3937
}
4038

41-
@SneakyThrows
4239
@Test
43-
void shouldCallInitTwiceWhenShutDownInTheMeantime() {
40+
void shouldCallInitTwiceWhenShutDownInTheMeantime() throws Exception {
4441
wrapper.initialize(null);
4542
wrapper.shutdown();
4643
wrapper.initialize(null);
@@ -53,21 +50,19 @@ void shouldSetStateToNotReadyAfterConstruction() {
5350
assertThat(wrapper.getState()).isEqualTo(ProviderState.NOT_READY);
5451
}
5552

56-
@SneakyThrows
5753
@Test
5854
@Specification(
5955
number = "1.7.3",
6056
text =
6157
"The client's provider status accessor MUST indicate READY if the initialize function of the associated provider terminates normally.")
62-
void shouldSetStateToReadyAfterInit() {
58+
void shouldSetStateToReadyAfterInit() throws Exception {
6359
assertThat(wrapper.getState()).isEqualTo(ProviderState.NOT_READY);
6460
wrapper.initialize(null);
6561
assertThat(wrapper.getState()).isEqualTo(ProviderState.READY);
6662
}
6763

68-
@SneakyThrows
6964
@Test
70-
void shouldSetStateToNotReadyAfterShutdown() {
65+
void shouldSetStateToNotReadyAfterShutdown() throws Exception {
7166
assertThat(wrapper.getState()).isEqualTo(ProviderState.NOT_READY);
7267
wrapper.initialize(null);
7368
assertThat(wrapper.getState()).isEqualTo(ProviderState.READY);

openfeature-sdk/src/test/java/dev/openfeature/sdk/FlagEvaluationSpecTest.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import java.util.List;
3939
import java.util.Map;
4040
import java.util.Optional;
41-
import lombok.SneakyThrows;
4241
import org.junit.jupiter.api.AfterEach;
4342
import org.junit.jupiter.api.BeforeEach;
4443
import org.junit.jupiter.api.Test;
@@ -56,8 +55,7 @@ private Client _client() {
5655
return api.getClient();
5756
}
5857

59-
@SneakyThrows
60-
private Client _initializedClient() {
58+
private Client _initializedClient() throws Exception {
6159
TestEventsProvider provider = new TestEventsProvider();
6260
provider.initialize(null);
6361
api.setProviderAndWait(provider);
@@ -91,13 +89,12 @@ void provider() {
9189
assertThat(api.getProvider()).isEqualTo(mockProvider);
9290
}
9391

94-
@SneakyThrows
9592
@Specification(
9693
number = "1.1.8",
9794
text =
9895
"The API SHOULD provide functions to set a provider and wait for the initialize function to return or throw.")
9996
@Test
100-
void providerAndWait() {
97+
void providerAndWait() throws Exception {
10198
FeatureProvider provider = new TestEventsProvider(500);
10299
api.setProviderAndWait(provider);
103100
Client client = api.getClient();
@@ -110,13 +107,12 @@ void providerAndWait() {
110107
assertThat(client2.getProviderState()).isEqualTo(ProviderState.READY);
111108
}
112109

113-
@SneakyThrows
114110
@Specification(
115111
number = "1.1.8",
116112
text =
117113
"The API SHOULD provide functions to set a provider and wait for the initialize function to return or throw.")
118114
@Test
119-
void providerAndWaitError() {
115+
void providerAndWaitError() throws Exception {
120116
FeatureProvider provider1 = new TestEventsProvider(500, true, "fake error");
121117
assertThrows(GeneralError.class, () -> api.setProviderAndWait(provider1));
122118

@@ -361,9 +357,8 @@ void detail_flags() {
361357
number = "1.5.1",
362358
text =
363359
"The evaluation options structure's hooks field denotes an ordered collection of hooks that the client MUST execute for the respective flag evaluation, in addition to those already configured.")
364-
@SneakyThrows
365360
@Test
366-
void hooks() {
361+
void hooks() throws Exception {
367362
Client c = _initializedClient();
368363
Hook<Boolean> clientHook = mockBooleanHook();
369364
Hook<Boolean> invocationHook = mockBooleanHook();

openfeature-sdk/src/test/java/dev/openfeature/sdk/HookSpecTest.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import java.util.List;
4343
import java.util.Map;
4444
import java.util.Optional;
45-
import lombok.SneakyThrows;
4645
import org.junit.jupiter.api.BeforeEach;
4746
import org.junit.jupiter.api.Test;
4847
import org.mockito.ArgumentCaptor;
@@ -443,9 +442,8 @@ void error_stops_before() {
443442
number = "4.4.6",
444443
text =
445444
"If an error occurs during the evaluation of before or after hooks, any remaining hooks in the before or after stages MUST NOT be invoked.")
446-
@SneakyThrows
447445
@Test
448-
void error_stops_after() {
446+
void error_stops_after() throws Exception {
449447
Hook<Boolean> h = mockBooleanHook();
450448
doThrow(RuntimeException.class).when(h).after(any(), any(), any());
451449
Hook<Boolean> h2 = mockBooleanHook();
@@ -468,9 +466,8 @@ void error_stops_after() {
468466
@Specification(number = "4.5.2", text = "hook hints MUST be passed to each hook.")
469467
@Specification(number = "4.2.2.1", text = "Condition: Hook hints MUST be immutable.")
470468
@Specification(number = "4.5.3", text = "The hook MUST NOT alter the hook hints structure.")
471-
@SneakyThrows
472469
@Test
473-
void hook_hints() {
470+
void hook_hints() throws Exception {
474471
String hintKey = "My hint key";
475472
Client client = getClient(null);
476473
Hook<Boolean> mutatingHook = new BooleanHook() {
@@ -552,7 +549,7 @@ void flag_eval_hook_order() {
552549
number = "4.4.7",
553550
text = "If an error occurs in the before hooks, the default value MUST be returned.")
554551
@Test
555-
void error_hooks__before() {
552+
void error_hooks__before() throws Exception {
556553
Hook hook = mockBooleanHook();
557554
doThrow(RuntimeException.class).when(hook).before(any(), any());
558555
Client client = getClient(TestEventsProvider.newInitializedTestEventsProvider());
@@ -570,7 +567,7 @@ void error_hooks__before() {
570567
number = "4.4.5",
571568
text = "If an error occurs in the before or after hooks, the error hooks MUST be invoked.")
572569
@Test
573-
void error_hooks__after() {
570+
void error_hooks__after() throws Exception {
574571
Hook hook = mockBooleanHook();
575572
doThrow(RuntimeException.class).when(hook).after(any(), any(), any());
576573
Client client = getClient(TestEventsProvider.newInitializedTestEventsProvider());
@@ -584,7 +581,7 @@ void error_hooks__after() {
584581
}
585582

586583
@Test
587-
void erroneous_flagResolution_setsAppropriateFieldsInFlagEvaluationDetails() {
584+
void erroneous_flagResolution_setsAppropriateFieldsInFlagEvaluationDetails() throws Exception {
588585
Hook hook = mockBooleanHook();
589586
doThrow(RuntimeException.class).when(hook).after(any(), any(), any());
590587
String flagKey = "test-flag-key";
@@ -630,7 +627,7 @@ void shortCircuit_flagResolution_runsHooksWithAllFields() {
630627
}
631628

632629
@Test
633-
void successful_flagResolution_setsAppropriateFieldsInFlagEvaluationDetails() {
630+
void successful_flagResolution_setsAppropriateFieldsInFlagEvaluationDetails() throws Exception {
634631
Hook hook = mockBooleanHook();
635632
String flagKey = "test-flag-key";
636633
Client client = getClient(TestEventsProvider.newInitializedTestEventsProvider());
@@ -655,7 +652,7 @@ void successful_flagResolution_setsAppropriateFieldsInFlagEvaluationDetails() {
655652
}
656653

657654
@Test
658-
void multi_hooks_early_out__before() {
655+
void multi_hooks_early_out__before() throws Exception {
659656
Hook<Boolean> hook = mockBooleanHook();
660657
Hook<Boolean> hook2 = mockBooleanHook();
661658
doThrow(RuntimeException.class).when(hook).before(any(), any());
@@ -681,7 +678,7 @@ void multi_hooks_early_out__before() {
681678
text =
682679
"Any `evaluation context` returned from a `before` hook MUST be passed to subsequent `before` hooks (via `HookContext`).")
683680
@Test
684-
void beforeContextUpdated() {
681+
void beforeContextUpdated() throws Exception {
685682
String targetingKey = "test-key";
686683
EvaluationContext ctx = new ImmutableContext(targetingKey);
687684
Hook<Boolean> hook = mockBooleanHook();
@@ -749,7 +746,7 @@ void mergeHappensCorrectly() {
749746
text =
750747
"If a finally hook abnormally terminates, evaluation MUST proceed, including the execution of any remaining finally hooks.")
751748
@Test
752-
void first_finally_broken() {
749+
void first_finally_broken() throws Exception {
753750
Hook hook = mockBooleanHook();
754751
doThrow(RuntimeException.class).when(hook).before(any(), any());
755752
doThrow(RuntimeException.class).when(hook).finallyAfter(any(), any(), any());
@@ -773,7 +770,7 @@ void first_finally_broken() {
773770
text =
774771
"If an error hook abnormally terminates, evaluation MUST proceed, including the execution of any remaining error hooks.")
775772
@Test
776-
void first_error_broken() {
773+
void first_error_broken() throws Exception {
777774
Hook hook = mockBooleanHook();
778775
doThrow(RuntimeException.class).when(hook).before(any(), any());
779776
doThrow(RuntimeException.class).when(hook).error(any(), any(), any());
@@ -792,7 +789,7 @@ void first_error_broken() {
792789
order.verify(hook).error(any(), any(), any());
793790
}
794791

795-
private Client getClient(FeatureProvider provider) {
792+
private Client getClient(FeatureProvider provider) throws Exception {
796793
if (provider == null) {
797794
api.setProviderAndWait(TestEventsProvider.newInitializedTestEventsProvider());
798795
} else {
@@ -806,9 +803,8 @@ private Client getClient(FeatureProvider provider) {
806803
void default_methods_so_impossible() {}
807804

808805
@Specification(number = "4.3.9.1", text = "Instead of finally, finallyAfter SHOULD be used.")
809-
@SneakyThrows
810806
@Test
811-
void doesnt_use_finally() {
807+
void doesnt_use_finally() throws Exception {
812808
assertThatCode(() -> Hook.class.getMethod("finally", HookContext.class, Map.class))
813809
.as("Not possible. Finally is a reserved word.")
814810
.isInstanceOf(NoSuchMethodException.class);

openfeature-sdk/src/test/java/dev/openfeature/sdk/ThreadLocalTransactionContextPropagatorTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import dev.openfeature.api.ImmutableContext;
99
import java.util.concurrent.Callable;
1010
import java.util.concurrent.FutureTask;
11-
import lombok.SneakyThrows;
1211
import org.junit.jupiter.api.Test;
1312

1413
public class ThreadLocalTransactionContextPropagatorTest {
@@ -32,9 +31,8 @@ public void emptyTransactionContext() {
3231
assertNull(result);
3332
}
3433

35-
@SneakyThrows
3634
@Test
37-
public void setTransactionContextTwoThreads() {
35+
public void setTransactionContextTwoThreads() throws Exception {
3836
EvaluationContext firstContext = new ImmutableContext();
3937
EvaluationContext secondContext = new ImmutableContext();
4038

openfeature-sdk/src/test/java/dev/openfeature/sdk/TrackingSpecTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import dev.openfeature.sdk.fixtures.ProviderFixture;
2929
import java.util.HashMap;
3030
import java.util.Map;
31-
import lombok.SneakyThrows;
3231
import org.junit.jupiter.api.BeforeEach;
3332
import org.junit.jupiter.api.Test;
3433

@@ -54,8 +53,7 @@ void getApiInstance() {
5453
+ "particular action or application state, with parameters `tracking event name` (string, required) and "
5554
+ "`tracking event details` (optional), which returns nothing.")
5655
@Test
57-
@SneakyThrows
58-
void trackMethodFulfillsSpec() {
56+
void trackMethodFulfillsSpec() throws Exception {
5957

6058
ImmutableContext ctx = new ImmutableContext();
6159
MutableTrackingEventDetails details = new MutableTrackingEventDetails(0.0f);

openfeature-sdk/src/test/java/dev/openfeature/sdk/e2e/ContextStoringProvider.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
import dev.openfeature.api.Metadata;
66
import dev.openfeature.api.ProviderEvaluation;
77
import dev.openfeature.api.Value;
8-
import lombok.Getter;
98

10-
@Getter
119
public class ContextStoringProvider implements FeatureProvider {
1210
private EvaluationContext evaluationContext;
1311

@@ -45,4 +43,8 @@ public ProviderEvaluation<Value> getObjectEvaluation(String key, Value defaultVa
4543
this.evaluationContext = ctx;
4644
return null;
4745
}
46+
47+
public EvaluationContext getEvaluationContext() {
48+
return evaluationContext;
49+
}
4850
}

0 commit comments

Comments
 (0)