diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..28caaaa --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +ko_fi: petruki +github: [petruki] \ No newline at end of file diff --git a/.github/workflows/master-2.yml b/.github/workflows/master-2.yml index 8e640e0..a888012 100644 --- a/.github/workflows/master-2.yml +++ b/.github/workflows/master-2.yml @@ -17,7 +17,7 @@ jobs: fetch-depth: 0 - name: Set up JDK 17 - uses: actions/setup-java@v5 + uses: actions/setup-java@v6 with: java-version: 17 distribution: 'temurin' @@ -42,7 +42,7 @@ jobs: - uses: actions/checkout@v7 - name: Setup Java - uses: actions/setup-java@v5 + uses: actions/setup-java@v6 with: distribution: 'temurin' java-version: ${{ matrix.java }} @@ -51,7 +51,7 @@ jobs: run: mvn -version - name: Cache Maven packages - uses: actions/cache@v5 + uses: actions/cache@v6 with: path: ~/.m2/repository key: ${{ runner.os }}-m2-${{ matrix.java }} diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index c4a2201..4304e16 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -17,7 +17,7 @@ jobs: fetch-depth: 0 - name: Set up JDK 17 - uses: actions/setup-java@v5 + uses: actions/setup-java@v6 with: java-version: 17 distribution: 'temurin' @@ -42,7 +42,7 @@ jobs: - uses: actions/checkout@v7 - name: Setup Java - uses: actions/setup-java@v5 + uses: actions/setup-java@v6 with: distribution: 'temurin' java-version: ${{ matrix.java }} @@ -51,7 +51,7 @@ jobs: run: mvn -version - name: Cache Maven packages - uses: actions/cache@v5 + uses: actions/cache@v6 with: path: ~/.m2/repository key: ${{ runner.os }}-m2-${{ matrix.java }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8d4d0f0..cc17d8b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/checkout@v7 - name: Setup Java - uses: actions/setup-java@v5 + uses: actions/setup-java@v6 with: distribution: 'temurin' java-version: ${{ matrix.java }} @@ -28,7 +28,7 @@ jobs: run: mvn -version - name: Cache Maven packages - uses: actions/cache@v5 + uses: actions/cache@v6 with: path: ~/.m2/repository key: ${{ runner.os }}-m2-${{ matrix.java }} @@ -45,7 +45,7 @@ jobs: steps: - uses: actions/checkout@v7 - name: Set up Apache Maven Central - uses: actions/setup-java@v5 + uses: actions/setup-java@v6 with: distribution: 'temurin' java-version: '8' diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index e2b8e55..6e55dc2 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -34,7 +34,7 @@ jobs: fetch-depth: 0 - name: Set up JDK 17 - uses: actions/setup-java@v5 + uses: actions/setup-java@v6 with: java-version: 17 distribution: 'temurin' diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 2a541a8..b28de87 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -26,7 +26,7 @@ jobs: fetch-depth: 0 - name: Setup Java - uses: actions/setup-java@v5 + uses: actions/setup-java@v6 with: distribution: 'temurin' java-version: ${{ github.event.inputs.jdk }} @@ -35,7 +35,7 @@ jobs: run: mvn -version - name: Cache Maven packages - uses: actions/cache@v5 + uses: actions/cache@v6 with: path: ~/.m2/repository key: ${{ runner.os }}-m2-${{ matrix.java }} diff --git a/.gitignore b/.gitignore index bde6020..bb9e179 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,8 @@ local.properties ## OS X ############################## .DS_Store + +############################## +## Sonar +############################## +.sonar/ \ No newline at end of file diff --git a/pom.xml b/pom.xml index e17c540..0f1e85d 100644 --- a/pom.xml +++ b/pom.xml @@ -56,28 +56,28 @@ 2.48 2.48 1.2.0 - 2.14.0 + 2.15.0 - 3.20.0 + 3.21.0 3.13.0 - 2.0.18 + 2.0.20 - 5.4.0 + 5.5.1 5.14.4 1.9.1 1.14.4 - 3.15.0 + 3.16.0 3.4.0 3.12.0 - 3.5.6 + 3.6.0 3.2.8 - 5.7.0.6970 + 5.8.0.7211 0.8.15 - 0.11.0 + 0.12.0 jacoco @@ -180,21 +180,21 @@ - + com.fasterxml.jackson.core jackson-core - 2.21.3 + 2.22.4 com.fasterxml.jackson.core jackson-databind - 2.21.3 + 2.22.4 com.fasterxml.jackson.core jackson-annotations - 2.21 + 2.22 @@ -234,6 +234,8 @@ switcherapi switcherapi_switcher-client ${project.groupId}:${project.artifactId} + ${project.build.outputDirectory} + ${project.build.testOutputDirectory} false diff --git a/src/main/java/com/switcherapi/client/model/SwitcherRequest.java b/src/main/java/com/switcherapi/client/model/SwitcherRequest.java index 4cafc8c..9f3728e 100644 --- a/src/main/java/com/switcherapi/client/model/SwitcherRequest.java +++ b/src/main/java/com/switcherapi/client/model/SwitcherRequest.java @@ -141,7 +141,7 @@ public boolean isBypassMetrics() { } private boolean canUseAsync() { - return super.delay > 0 && !this.executionsMap.isEmpty(); + return super.delay > 0L && !this.executionsMap.isEmpty(); } @Override diff --git a/src/test/java/com/switcherapi/client/SwitcherThrottle1Test.java b/src/test/java/com/switcherapi/client/SwitcherThrottle1Test.java index 16888f0..761f641 100644 --- a/src/test/java/com/switcherapi/client/SwitcherThrottle1Test.java +++ b/src/test/java/com/switcherapi/client/SwitcherThrottle1Test.java @@ -12,6 +12,7 @@ import static com.switcherapi.client.remote.Constants.DEFAULT_ENV; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; class SwitcherThrottle1Test extends MockWebServerHelper { @@ -40,11 +41,11 @@ static void tearDown() { void shouldReturnTrue_withThrottle() { // Initial remote call givenResponse(generateMockAuth(10)); //auth - givenResponse(generateCriteriaResponse("true", false)); //criteria - sync (cached) + givenResponse(generateCriteriaResponse("true", false)); //criteria - sync // Throttle period - should use cache - givenResponse(generateCriteriaResponse("false", false)); //criteria - async (background) - givenResponse(generateCriteriaResponse("false", false)); //criteria - async after 1 sec (background) + givenResponse(generateCriteriaResponse("true", false)); //criteria - async (cached) + givenResponse(generateCriteriaResponse("false", false)); //criteria - async after 1.5 sec (background) //test Switcher switcher = SwitchersBase @@ -52,7 +53,7 @@ void shouldReturnTrue_withThrottle() { .flushExecutions() .resetInputs() .checkValue("value") - .throttle(1000); + .throttle(1500); for (int i = 0; i < 50; i++) { assertTrue(switcher.isItOn()); @@ -60,6 +61,10 @@ void shouldReturnTrue_withThrottle() { assertEquals(Boolean.FALSE, CountDownHelper.waitUntil(10, false, switcher::isItOn)); + + for (int i = 0; i < 50; i++) { + assertFalse(switcher.isItOn()); + } } } diff --git a/src/test/java/com/switcherapi/client/SwitcherThrottle2Test.java b/src/test/java/com/switcherapi/client/SwitcherThrottle2Test.java index 8c3e0a9..348ec80 100644 --- a/src/test/java/com/switcherapi/client/SwitcherThrottle2Test.java +++ b/src/test/java/com/switcherapi/client/SwitcherThrottle2Test.java @@ -39,18 +39,18 @@ static void tearDown() { void shouldRetrieveNewResponse_whenStrategyInputChanged() { // Initial remote call givenResponse(generateMockAuth(10)); //auth - givenResponse(generateCriteriaResponse("true", false)); //criteria - sync (cached) - givenResponse(generateCriteriaResponse("false", false)); //criteria - async (cached) + givenResponse(generateCriteriaResponse("true", false)); //criteria - sync // Throttle period - should use cache - givenResponse(generateCriteriaResponse("false", false)); //criteria - async after 1 sec (background) + givenResponse(generateCriteriaResponse("true", false)); //criteria - async (cached) + givenResponse(generateCriteriaResponse("false", false)); //criteria - async after 1.5 sec (background) //test SwitcherBuilder switcher = SwitchersBase .getSwitcher(SwitchersBase.USECASE11) .flushExecutions() .resetInputs() - .throttle(1000); + .throttle(1500); for (int i = 0; i < 100; i++) { assertTrue(switcher.checkValue("value").isItOn());