Skip to content

Commit

Permalink
CIRCSTORE-502 add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-barannyk committed Apr 19, 2024
1 parent c252c83 commit 084a899
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions src/test/java/org/folio/rest/api/RequestsApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ public void canCreateARequest(String requestLevel) throws InterruptedException,
.withProxy("Stuart", "Rebecca", "6059539205")
.withStatus(OPEN_NOT_YET_FILLED)
.withPosition(1)
.primary()
.withPickupServicePointId(pickupServicePointId)
.withTags(new Tags().withTagList(asList("new", "important")))
.create(),
Expand All @@ -178,7 +177,6 @@ public void canCreateARequest(String requestLevel) throws InterruptedException,
assertThat(representation.getInteger("position"), is(1));
assertThat(representation.getString("pickupServicePointId"), is(pickupServicePointId.toString()));
assertThat(representation.containsKey("patronComments"), is(false));
assertThat(representation.getString("ecsRequestPhase"), is("Primary"));

assertThat(representation.containsKey("item"), is(true));
JsonObject item = representation.getJsonObject("item");
Expand Down Expand Up @@ -1960,6 +1958,46 @@ public void cannotCreateRequestWithoutStatus()
)));
}

@Test
public void canCreateRequestWithEcsRequestPhase() throws MalformedURLException,
ExecutionException, InterruptedException, TimeoutException {

JsonObject representation = createEntity(
new RequestRequestBuilder()
.page()
.primary()
.withId(UUID.randomUUID())
.create(),
requestStorageUrl()).getJson();
assertThat(representation.getString("ecsRequestPhase"), is("Primary"));

representation = createEntity(
new RequestRequestBuilder()
.page()
.secondary()
.withId(UUID.randomUUID())
.create(),
requestStorageUrl()).getJson();
assertThat(representation.getString("ecsRequestPhase"), is("Secondary"));
}

@Test
public void shouldReturn400IfInvalidEcsRequestPhase() throws MalformedURLException,
ExecutionException, InterruptedException, TimeoutException {

var request = new RequestRequestBuilder()
.page()
.withEcsRequestPhase("Invalid")
.withId(UUID.randomUUID())
.create();

CompletableFuture<JsonResponse> createCompleted = new CompletableFuture<>();
client.post(requestStorageUrl(), request, TENANT_ID, ResponseHandler.json(createCompleted));

assertThat(createCompleted.get(5, TimeUnit.SECONDS).getStatusCode(), is(400));
}


private RequestDto.RequestDtoBuilder holdShelfOpenRequest() {
return RequestDto.builder()
.requesterId(UUID.randomUUID().toString())
Expand Down

0 comments on commit 084a899

Please sign in to comment.