Search in sources :

Example 1 with RequestItemSummary

use of org.folio.rest.support.builders.RequestItemSummary in project mod-circulation-storage by folio-org.

the class RequestsApiTest method canFindRequestsWithIsbnIdentifier.

@Test
public void canFindRequestsWithIsbnIdentifier() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
    final UUID nodRequestId = UUID.randomUUID();
    final UUID smallAngryPlanetRequestId = UUID.randomUUID();
    final UUID issnIdentifierId = UUID.randomUUID();
    final UUID isbnIdentifierId = UUID.randomUUID();
    final UUID bnbIdentifierId = UUID.randomUUID();
    final String isbn = "978-92-8011-566-10";
    final RequestItemSummary nod = new RequestItemSummary("Nod", "565578437802").addIdentifier(issnIdentifierId, "978-92-8011-566-9").addIdentifier(bnbIdentifierId, "2193988").addIdentifier(isbnIdentifierId, isbn);
    final RequestItemSummary smallAngryPlanet = new RequestItemSummary("SAP", "565578437803").addIdentifier(isbnIdentifierId, isbn).addIdentifier(bnbIdentifierId, "2193989");
    final RequestItemSummary temeraire = new RequestItemSummary("Temeraire", "565578437804");
    createEntity(new RequestRequestBuilder().withId(nodRequestId).recall().toHoldShelf().withItem(nod).create(), requestStorageUrl());
    createEntity(new RequestRequestBuilder().withId(smallAngryPlanetRequestId).recall().toHoldShelf().withItem(smallAngryPlanet).create(), requestStorageUrl());
    createEntity(new RequestRequestBuilder().withId(UUID.randomUUID()).recall().toHoldShelf().withItem(temeraire).create(), requestStorageUrl());
    List<JsonObject> isbnRequests = findRequestsByQuery("instance.identifiers = %s and instance.identifiers = %s", isbnIdentifierId, isbn);
    assertThat(isbnRequests.size(), is(2));
    assertThat(isbnRequests.get(0).getString("id"), is(nodRequestId.toString()));
    assertThat(isbnRequests.get(1).getString("id"), is(smallAngryPlanetRequestId.toString()));
}
Also used : RequestRequestBuilder(org.folio.rest.support.builders.RequestRequestBuilder) RequestItemSummary(org.folio.rest.support.builders.RequestItemSummary) JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID) Test(org.junit.Test)

Example 2 with RequestItemSummary

use of org.folio.rest.support.builders.RequestItemSummary in project mod-circulation-storage by folio-org.

the class RequestsApiTest method canCreateARequest.

@Test
@Parameters({ "Title", "Item" })
public void canCreateARequest(String requestLevel) throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
    UUID id = UUID.randomUUID();
    UUID itemId = UUID.randomUUID();
    UUID requesterId = UUID.randomUUID();
    UUID proxyId = UUID.randomUUID();
    UUID holdingsRecordId = UUID.randomUUID();
    UUID instanceId = UUID.randomUUID();
    UUID pickupServicePointId = UUID.randomUUID();
    DateTime requestDate = new DateTime(2017, 7, 22, 10, 22, 54, DateTimeZone.UTC);
    DateTime requestExpirationDate = new DateTime(2017, 7, 30, 0, 0, DateTimeZone.UTC);
    DateTime holdShelfExpirationDate = new DateTime(2017, 8, 31, 0, 0, DateTimeZone.UTC);
    UUID isbnIdentifierId = UUID.randomUUID();
    UUID issnIdentifierId = UUID.randomUUID();
    final RequestItemSummary nod = new RequestItemSummary("Nod", "565578437802").addIdentifier(isbnIdentifierId, "978-92-8011-566-9").addIdentifier(issnIdentifierId, "2193988");
    JsonObject representation = createEntity(new RequestRequestBuilder().recall().toHoldShelf().withId(id).withRequestDate(requestDate).withItemId(itemId).withRequesterId(requesterId).withProxyId(proxyId).withRequestExpirationDate(requestExpirationDate).withHoldShelfExpirationDate(holdShelfExpirationDate).withRequestLevel(requestLevel).withItem(nod).withHoldingsRecordId(holdingsRecordId).withInstanceId(instanceId).withRequester("Jones", "Stuart", "Anthony", "6837502674015").withProxy("Stuart", "Rebecca", "6059539205").withStatus(OPEN_NOT_YET_FILLED).withPosition(1).withPickupServicePointId(pickupServicePointId).withTags(new Tags().withTagList(asList("new", "important"))).create(), requestStorageUrl()).getJson();
    assertThat(representation.getString("id"), is(id.toString()));
    assertThat(representation.getString("requestType"), is("Recall"));
    assertThat(representation.getString("requestDate"), is(equivalentTo(requestDate)));
    assertThat(representation.getString("itemId"), is(itemId.toString()));
    assertThat(representation.getString("instanceId"), is(instanceId.toString()));
    assertThat(representation.getString("holdingsRecordId"), is(holdingsRecordId.toString()));
    assertThat(representation.getString("requesterId"), is(requesterId.toString()));
    assertThat(representation.getString("proxyUserId"), is(proxyId.toString()));
    assertThat(representation.getString("fulfilmentPreference"), is("Hold Shelf"));
    assertThat(representation.getString("requestExpirationDate"), is(equivalentTo(requestExpirationDate)));
    assertThat(representation.getString("holdShelfExpirationDate"), is(equivalentTo(holdShelfExpirationDate)));
    assertThat(representation.getString("status"), is(OPEN_NOT_YET_FILLED));
    assertThat(representation.getInteger("position"), is(1));
    assertThat(representation.getString("pickupServicePointId"), is(pickupServicePointId.toString()));
    assertThat(representation.containsKey("patronComments"), is(false));
    assertThat(representation.containsKey("item"), is(true));
    JsonObject item = representation.getJsonObject("item");
    assertThat(item.getString("barcode"), is("565578437802"));
    assertThat(representation.containsKey("instance"), is(true));
    JsonObject instance = representation.getJsonObject("instance");
    assertThat(instance.getString("title"), is("Nod"));
    JsonArray identifiers = instance.getJsonArray("identifiers");
    assertThat(identifiers.size(), is(2));
    assertThat(identifiers.getJsonObject(0).getString("identifierTypeId"), is(isbnIdentifierId.toString()));
    assertThat(identifiers.getJsonObject(0).getString("value"), is("978-92-8011-566-9"));
    assertThat(identifiers.getJsonObject(1).getString("identifierTypeId"), is(issnIdentifierId.toString()));
    assertThat(identifiers.getJsonObject(1).getString("value"), is("2193988"));
    assertThat(representation.containsKey("requester"), is(true));
    final JsonObject requesterRepresentation = representation.getJsonObject("requester");
    assertThat(requesterRepresentation.getString("lastName"), is("Jones"));
    assertThat(requesterRepresentation.getString("firstName"), is("Stuart"));
    assertThat(requesterRepresentation.getString("middleName"), is("Anthony"));
    assertThat(requesterRepresentation.getString("barcode"), is("6837502674015"));
    assertThat("has information taken from proxying user", representation.containsKey("proxy"), is(true));
    final JsonObject proxyRepresentation = representation.getJsonObject("proxy");
    assertThat("last name is taken from proxying user", proxyRepresentation.getString("lastName"), is("Stuart"));
    assertThat("first name is taken from proxying user", proxyRepresentation.getString("firstName"), is("Rebecca"));
    assertThat("middle name is not taken from proxying user", proxyRepresentation.containsKey("middleName"), is(false));
    assertThat("barcode is taken from proxying user", proxyRepresentation.getString("barcode"), is("6059539205"));
    assertThat(representation.containsKey("tags"), is(true));
    final JsonObject tagsRepresentation = representation.getJsonObject("tags");
    assertThat(tagsRepresentation.containsKey("tagList"), is(true));
    assertThat(tagsRepresentation.getJsonArray("tagList"), contains("new", "important"));
    assertCreateEventForRequest(representation);
}
Also used : JsonArray(io.vertx.core.json.JsonArray) RequestRequestBuilder(org.folio.rest.support.builders.RequestRequestBuilder) RequestItemSummary(org.folio.rest.support.builders.RequestItemSummary) JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID) DateTime(org.joda.time.DateTime) Tags(org.folio.rest.jaxrs.model.Tags) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 3 with RequestItemSummary

use of org.folio.rest.support.builders.RequestItemSummary in project mod-circulation-storage by folio-org.

the class IsbnNormalizationTest method createRequests.

private void createRequests(String... titlesToCreate) throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
    Map<String, RequestItemSummary> requests = new HashMap<String, RequestItemSummary>();
    // Interesting Times has two ISBNs: 0552167541, 978-0-552-16754-3
    requests.put("Interesting Times", new RequestItemSummary("Interesting Times", "000000004").addIdentifier(isbnIdentifierId, "978-0-552-16754-3").addIdentifier(isbnIdentifierId, "0552167541"));
    requests.put("Temeraire", new RequestItemSummary("Temeraire", "000000002").addIdentifier(isbnIdentifierId, "9780007258710"));
    requests.put("Uprooted", new RequestItemSummary("Uprooted", "565575337892").addIdentifier(isbnIdentifierId, "9781447294146"));
    for (String title : titlesToCreate) {
        JsonObject representation = createEntity(new RequestRequestBuilder().recall().toHoldShelf().withItem(requests.get(title)).create(), requestStorageUrl()).getJson();
    }
}
Also used : RequestRequestBuilder(org.folio.rest.support.builders.RequestRequestBuilder) HashMap(java.util.HashMap) RequestItemSummary(org.folio.rest.support.builders.RequestItemSummary) JsonObject(io.vertx.core.json.JsonObject)

Aggregations

JsonObject (io.vertx.core.json.JsonObject)3 RequestItemSummary (org.folio.rest.support.builders.RequestItemSummary)3 RequestRequestBuilder (org.folio.rest.support.builders.RequestRequestBuilder)3 UUID (java.util.UUID)2 Test (org.junit.Test)2 JsonArray (io.vertx.core.json.JsonArray)1 HashMap (java.util.HashMap)1 Parameters (junitparams.Parameters)1 Tags (org.folio.rest.jaxrs.model.Tags)1 DateTime (org.joda.time.DateTime)1