Skip to content

Commit

Permalink
MODTLR-10 Extend EcsTlrApiTest
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksandrVidinieiev committed Jan 26, 2024
1 parent 2da1600 commit d625dab
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/test/java/org/folio/api/EcsTlrApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.UUID;

import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson;
import static com.github.tomakehurst.wiremock.client.WireMock.jsonResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
Expand Down Expand Up @@ -64,18 +65,20 @@ void getByIdNotFound() throws Exception {
@Test
void titleLevelRequestIsCreatedForDifferentTenant() {
EcsTlr ecsTlr = buildEcsTlr();
String ecsTlrJson = asJsonString(ecsTlr);
wireMockServer.stubFor(WireMock.post(urlMatching(".*/circulation/requests"))
.withHeader(TENANT_HEADER, equalTo(ANOTHER_TENANT))
.willReturn(jsonResponse(asJsonString(ecsTlr), HttpStatus.SC_CREATED)));
.willReturn(jsonResponse(ecsTlrJson, HttpStatus.SC_CREATED)));
assertEquals(TENANT, getCurrentTenantId());

doPost(TLR_URL, ecsTlr)
.expectStatus().isCreated()
.expectBody().json(asJsonString(ecsTlr));
.expectBody().json(ecsTlrJson);

assertEquals(TENANT, getCurrentTenantId());
wireMockServer.verify(postRequestedFor(urlMatching(".*/circulation/requests"))
.withHeader(TENANT_HEADER, equalTo(ANOTHER_TENANT)));
.withHeader(TENANT_HEADER, equalTo(ANOTHER_TENANT))
.withRequestBody(equalToJson(ecsTlrJson)));
}

private String getCurrentTenantId() {
Expand Down

0 comments on commit d625dab

Please sign in to comment.