Skip to content

Commit

Permalink
Better handling of client name for order tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anotheroneofthese committed Aug 28, 2024
1 parent e8698fd commit 7bd090e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/test/kotlin/no/nb/mlt/wls/order/service/OrderServiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.springframework.web.server.ServerErrorException
import org.springframework.web.server.ServerWebInputException
import reactor.core.publisher.Mono

// FIXME - Handle client used in test more gracefully
@Suppress("ReactiveStreamsUnusedPublisher")
@TestInstance(PER_CLASS)
@ExtendWith(MockKExtension::class)
class OrderServiceTest {
Expand Down Expand Up @@ -65,7 +65,7 @@ class OrderServiceTest {
fun `save when order exists throws`() {
runTest {
every { db.findByHostNameAndHostOrderId(top.hostName, top.hostOrderId) } returns Mono.just(top.toOrder())
assertThat(cut.createOrder("axiell", top).statusCode.is4xxClientError)
assertThat(cut.createOrder(testClientName, top).statusCode.is4xxClientError)
}
}

Expand All @@ -86,7 +86,7 @@ class OrderServiceTest {

assertThatExceptionOfType(ServerErrorException::class.java).isThrownBy {
runBlocking {
cut.createOrder("axiell", top)
cut.createOrder(testClientName, top)
}
}
}
Expand All @@ -98,7 +98,7 @@ class OrderServiceTest {

assertThatExceptionOfType(ServerErrorException::class.java).isThrownBy {
runBlocking {
cut.createOrder("axiell", top)
cut.createOrder(testClientName, top)
}
}
}
Expand All @@ -111,7 +111,7 @@ class OrderServiceTest {
coEvery { synq.createOrder(any()) } returns ResponseEntity(HttpStatus.CREATED)
every { db.save(any()) } returns Mono.just(top.toOrder())

assertThat(cut.createOrder("axiell", top).statusCode.is2xxSuccessful)
assertThat(cut.createOrder(testClientName, top).statusCode.is2xxSuccessful)
}
}

Expand Down Expand Up @@ -141,11 +141,13 @@ class OrderServiceTest {
callbackUrl = "callbackUrl"
)

private val testClientName = HostName.AXIELL.name

private fun <T : Throwable> assertExceptionThrownWithMessage(
payload: ApiOrderPayload,
message: String,
exception: Class<T>
) = assertThatExceptionOfType(exception).isThrownBy {
runBlocking { cut.createOrder("axiell", payload) }
runBlocking { cut.createOrder(testClientName, payload) }
}.withMessageContaining(message)
}

0 comments on commit 7bd090e

Please sign in to comment.