Skip to content

Commit

Permalink
Merge pull request #55 from navikt/put-uten-body
Browse files Browse the repository at this point in the history
Skal kunne kalle put-endepunkt uten body
  • Loading branch information
eirarset authored Apr 15, 2024
2 parents ef5242a + 0a83d75 commit 512a490
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ abstract class AbstractRestClient(val restTemplate: RestTemplate) {
uriVariables: Map<String, *> = emptyMap<String, String>(),
): T? = executeNullable(uri, HttpMethod.POST, HttpEntity(payload, httpHeaders), uriVariables)

inline fun <reified T : Any> putForEntityNullable(
uri: String,
payload: Any,
httpHeaders: HttpHeaders? = null,
uriVariables: Map<String, *> = emptyMap<String, String>(),
): T? = executeNullable(uri, HttpMethod.PUT, HttpEntity(payload, httpHeaders), uriVariables)

inline fun <reified T : Any> putForEntity(
uri: String,
payload: Any,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ internal class AbstractRestClientTest {
fun postUtenResponseBody(): String? {
return postForEntityNullable<String>(uri.toString(), emptyMap<String, String>())
}
fun putUtenResponseBody(): String? {
return putForEntityNullable<String>(uri.toString(), emptyMap<String, String>())
}
}

companion object {
Expand Down Expand Up @@ -117,6 +120,16 @@ internal class AbstractRestClientTest {
assertThat(client.postUtenResponseBody()).isNull()
}

@Test
fun `skal kunne kalle på put-endepunkt og forvente svar uten body`() {
wireMockServer.stubFor(
WireMock.put(anyUrl())
.willReturn(created()),
)

assertThat(client.putUtenResponseBody()).isNull()
}

@Test
fun `query param request skal feile hvis query params ikke mer med`() {
wireMockServer.stubFor(
Expand Down

0 comments on commit 512a490

Please sign in to comment.