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
9 changes: 4 additions & 5 deletions common/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
com.github.oowekyala.ooxml:nice-xml-messages:3.1=pmd
com.github.rholder:guava-retrying:2.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.github.spotbugs:spotbugs-annotations:4.10.2=annotationProcessor,testAnnotationProcessor
com.github.spotbugs:spotbugs-annotations:4.10.3=compileClasspath,spotbugs,testCompileClasspath
com.github.spotbugs:spotbugs:4.10.3=spotbugs
com.github.spotbugs:spotbugs-annotations:4.10.4=compileClasspath,spotbugs,testCompileClasspath
com.github.spotbugs:spotbugs:4.10.4=spotbugs
com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs
com.google.code.findbugs:jsr305:3.0.2=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,spotbugs,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.code.gson:gson:2.13.2=pmd
Expand Down Expand Up @@ -74,8 +74,7 @@ org.junit.platform:junit-platform-engine:1.14.1=testCompileClasspath,testRuntime
org.junit.platform:junit-platform-launcher:1.14.1=testRuntimeClasspath
org.junit:junit-bom:5.14.1=testCompileClasspath,testRuntimeClasspath
org.junit:junit-bom:6.1.0=annotationProcessor,testAnnotationProcessor
org.junit:junit-bom:6.1.2=spotbugs
org.mockito:mockito-core:5.23.0=testCompileClasspath,testRuntimeClasspath
org.mockito:mockito-core:5.24.0=testCompileClasspath,testRuntimeClasspath
org.objenesis:objenesis:3.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath
org.ow2.asm:asm-analysis:9.10.1=spotbugs
Expand All @@ -88,7 +87,7 @@ org.ow2.asm:asm:9.10.1=spotbugs
org.ow2.asm:asm:9.9=jacocoAnt
org.ow2.asm:asm:9.9.1=pmd
org.pcollections:pcollections:4.0.2=pmd
org.projectlombok:lombok:1.18.44=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath
org.projectlombok:lombok:1.18.48=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath
org.reflections:reflections:0.10.2=checkstyle
org.slf4j:jul-to-slf4j:1.7.36=pmd
org.slf4j:slf4j-api:1.7.30=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ class ObjectArrayTest extends Specification {
subject.getAsBoolean(0) == result

where:
name || value || result
"one String" || "1" || true
"zero String" || "0" || false
"one Int" || 1 || true
"zero Int" || 0 || false
"one Double" || 1.0 || true
"String true" || "true" || true
"Boolean true" || true || true
"Boolean false" || false || false
name || value || result
"one String" || "1" || true
"zero String" || "0" || false
"one Int" || 1 || true
"zero Int" || 0 || false
"one Double" || 1.0 || true
"String true" || "true" || true
"Boolean true" || true || true
"Boolean false" || false || false
}

@Unroll("getAsBoolean with default #name")
Expand All @@ -224,16 +224,16 @@ class ObjectArrayTest extends Specification {
subject.getAsBoolean(0, defaultValue) == result

where:
name || value || defaultValue || result
"one String" || "1" || false || true
"zero String" || "0" || true || false
"one Int" || 1 || false || true
"zero Int" || 0 || true || false
"one Double" || 1.0 || false || true
"String true" || "true" || false || true
"Boolean true" || true || false || true
"Nothing true" || null || true || true
"Nothing false" || null || false || false
name || value || defaultValue || result
"one String" || "1" || false || true
"zero String" || "0" || true || false
"one Int" || 1 || false || true
"zero Int" || 0 || true || false
"one Double" || 1.0 || false || true
"String true" || "true" || false || true
"Boolean true" || true || false || true
"Nothing true" || null || true || true
"Nothing false" || null || false || false
}

def "getAsString"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ class ObjectMapTest extends Specification {
subject.getAsBoolean("value") == result

where:
name || value || result
"one String" || "1" || true
"zero String" || "0" || false
"one Int" || 1 || true
"zero Int" || 0 || false
"one Double" || 1.0 || true
"String true" || "true" || true
"Boolean true" || true || true
"Boolean false" || false || false
name || value || result
"one String" || "1" || true
"zero String" || "0" || false
"one Int" || 1 || true
"zero Int" || 0 || false
"one Double" || 1.0 || true
"String true" || "true" || true
"Boolean true" || true || true
"Boolean false" || false || false
}

@Unroll("getAsBoolean with default #name")
Expand All @@ -134,16 +134,16 @@ class ObjectMapTest extends Specification {
subject.getAsBoolean("value", defaultValue) == result

where:
name || value || defaultValue || result
"one String" || "1" || false || true
"zero String" || "0" || true || false
"one Int" || 1 || false || true
"zero Int" || 0 || true || false
"one Double" || 1.0 || false || true
"String true" || "true" || false || true
"Boolean true" || true || false || true
"Nothing true" || null || true || true
"Nothing false" || null || false || false
name || value || defaultValue || result
"one String" || "1" || false || true
"zero String" || "0" || true || false
"one Int" || 1 || false || true
"zero Int" || 0 || true || false
"one Double" || 1.0 || false || true
"String true" || "true" || false || true
"Boolean true" || true || false || true
"Nothing true" || null || true || true
"Nothing false" || null || false || false
}

def "getAsString"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ class RequestTest extends Specification {
subject.withResponseRetryConfiguration(ResponseRetryConfiguration.<TestResponse>builder()
.stopStrategy(ResponseRetryConfiguration.StopStrategy.COUNT)
.count(3)
.onResponse(Collections.singletonList(ResponseMatcher.builder().predicate({ t -> true }).build()))
.onResponse(Collections.singletonList(ResponseMatcher.builder().predicate({ t ->
true
}).build()))
.build())

when:
Expand All @@ -230,12 +232,16 @@ class RequestTest extends Specification {
def retry = ResponseRetryConfiguration.<TestResponse>builder()
.stopStrategy(ResponseRetryConfiguration.StopStrategy.COUNT)
.count(3)
.onResponse(Collections.singletonList(ResponseMatcher.builder().predicate({ t -> true }).build()))
.onResponse(Collections.singletonList(ResponseMatcher.builder().predicate({ t ->
true
}).build()))
.build()

filterChain = mock(RequestFilter)
subject = new TestRequest(filterChain)
def response = subject.withResponseRetryConfiguration(retry, { e -> new UpstreamSystemUnavailable("System is not ready", e) })
def response = subject.withResponseRetryConfiguration(retry, { e ->
new UpstreamSystemUnavailable("System is not ready", e)
})

when:
subject.execute().throwException()
Expand Down Expand Up @@ -312,7 +318,9 @@ class RequestTest extends Specification {
.withFeature(Feature.ACCOUNTS)
.withHeader("headerKey", "headerValue")
.withPath("/some/path")
.withQueryStringParams(new SingleValueMap<String, String>().tap {put("key", "value")})
.withQueryStringParams(new SingleValueMap<String, String>().tap {
put("key", "value")
})
.withRequestTimeout(Duration.ofMillis(100))

when: "same instance"
Expand All @@ -337,7 +345,9 @@ class RequestTest extends Specification {
.withFeature(Feature.ACCOUNTS)
.withHeader("headerKey", "headerValue")
.withPath("/some/path")
.withQueryStringParams(new SingleValueMap<String, String>().tap {put("key", "value")})
.withQueryStringParams(new SingleValueMap<String, String>().tap {
put("key", "value")
})
.withRequestTimeout(Duration.ofMillis(100))

then:
Expand All @@ -353,7 +363,9 @@ class RequestTest extends Specification {
.withFeature(Feature.TRANSFERS)
.withHeader("headerKey", "headerValue2")
.withPath("/some/other/path")
.withQueryStringParams(new SingleValueMap<String, String>().tap {put("key", "value2")})
.withQueryStringParams(new SingleValueMap<String, String>().tap {
put("key", "value2")
})
.withRequestTimeout(Duration.ofMillis(100))

then:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class ResponseRetryConfigurationTest extends Specification implements WithMocker
subject = ResponseRetryConfiguration.<TestResponse>builder()
.stopStrategy(RetryConfiguration.StopStrategy.COUNT)
.count(2)
.onResponse(Collections.singletonList(ResponseMatcher.builder().predicate( { t-> true }).build()))
.onResponse(Collections.singletonList(ResponseMatcher.builder().predicate({ t->
true
}).build()))
.build()

request.withRetryer(subject.instance())
Expand Down Expand Up @@ -86,8 +88,12 @@ class ResponseRetryConfigurationTest extends Specification implements WithMocker
subject = ResponseRetryConfiguration.<TestResponse>builder()
.stopStrategy(RetryConfiguration.StopStrategy.COUNT)
.count(2)
.onResponse(Collections.singletonList(ResponseMatcher.builder().predicate( { t-> true }).build()))
.exceptionSupplier({ e -> new UpstreamSystemMaintenance("System is not ready", e) })
.onResponse(Collections.singletonList(ResponseMatcher.builder().predicate({ t->
true
}).build()))
.exceptionSupplier({ e ->
new UpstreamSystemMaintenance("System is not ready", e)
})
.build()

request.withResponseRetryConfiguration(subject)
Expand All @@ -105,11 +111,17 @@ class ResponseRetryConfigurationTest extends Specification implements WithMocker
subject = ResponseRetryConfiguration.<TestResponse>builder()
.stopStrategy(RetryConfiguration.StopStrategy.COUNT)
.count(2)
.onResponse(Collections.singletonList(ResponseMatcher.builder().predicate( { t-> true }).build()))
.exceptionSupplier({ e -> new UpstreamSystemMaintenance("System is not ready", e) })
.onResponse(Collections.singletonList(ResponseMatcher.builder().predicate({ t->
true
}).build()))
.exceptionSupplier({ e ->
new UpstreamSystemMaintenance("System is not ready", e)
})
.build()

request.withResponseRetryConfiguration(subject, { e -> new UpstreamSystemUnavailable("System is not available") })
request.withResponseRetryConfiguration(subject, { e ->
new UpstreamSystemUnavailable("System is not available")
})

when:
request.execute().throwException()
Expand All @@ -133,13 +145,13 @@ class ResponseRetryConfigurationTest extends Specification implements WithMocker
error.message == message

where:
configuration | message
ResponseRetryConfiguration.builder().build() | "Missing required field at configuration."
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.COUNT).build() | "Missing required fields for stopStrategy COUNT: count at configuration."
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.DURATION).build() | "Missing required fields for stopStrategy DURATION: duration at configuration."
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.COUNT).count(1).pauseStrategy(RetryConfiguration.PauseStrategy.FIXED).build() | "Missing required fields for pauseStrategy FIXED: pause at configuration."
configuration | message
ResponseRetryConfiguration.builder().build() | "Missing required field at configuration."
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.COUNT).build() | "Missing required fields for stopStrategy COUNT: count at configuration."
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.DURATION).build() | "Missing required fields for stopStrategy DURATION: duration at configuration."
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.COUNT).count(1).pauseStrategy(RetryConfiguration.PauseStrategy.FIXED).build() | "Missing required fields for pauseStrategy FIXED: pause at configuration."
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.COUNT).count(1).pauseStrategy(RetryConfiguration.PauseStrategy.INCREMENTING).build() | "Missing required fields for pauseStrategy INCREMENTING: initialPause, increment at configuration."
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.COUNT).count(1).pauseStrategy(RetryConfiguration.PauseStrategy.FIBONACCI).build() | "Missing required fields for pauseStrategy FIBONACCI: multiplier, maxPause at configuration."
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.COUNT).count(1).pauseStrategy(RetryConfiguration.PauseStrategy.FIBONACCI).build() | "Missing required fields for pauseStrategy FIBONACCI: multiplier, maxPause at configuration."
}

@Unroll
Expand All @@ -155,12 +167,12 @@ class ResponseRetryConfigurationTest extends Specification implements WithMocker
noExceptionThrown()

where:
configuration | _
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.COUNT).count(1).build() | null
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.DURATION).duration(Duration.ofSeconds(1)).build() | null
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.COUNT).count(1).pauseStrategy(RetryConfiguration.PauseStrategy.FIXED).pause(Duration.ofMillis(10)).build() | null
configuration | _
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.COUNT).count(1).build() | null
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.DURATION).duration(Duration.ofSeconds(1)).build() | null
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.COUNT).count(1).pauseStrategy(RetryConfiguration.PauseStrategy.FIXED).pause(Duration.ofMillis(10)).build() | null
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.COUNT).count(1).pauseStrategy(RetryConfiguration.PauseStrategy.INCREMENTING).initialPause(Duration.ofMillis(10)).increment(Duration.ofMillis(10)).build() | null
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.COUNT).count(1).pauseStrategy(RetryConfiguration.PauseStrategy.FIBONACCI).maxPause(Duration.ofMillis(100)).multiplier(Duration.ofSeconds(1)).build() | null
ResponseRetryConfiguration.builder().stopStrategy(RetryConfiguration.StopStrategy.COUNT).count(1).pauseStrategy(RetryConfiguration.PauseStrategy.FIBONACCI).maxPause(Duration.ofMillis(100)).multiplier(Duration.ofSeconds(1)).build() | null
}

def "call when all attempts fail"() {
Expand Down
Loading
Loading