Search in sources :

Example 41 with IndividualResource

use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.

the class ItemStorageTest method shouldFindItemByCallNumberWhenThereIsSuffix.

@Test
public void shouldFindItemByCallNumberWhenThereIsSuffix() throws Exception {
    final UUID holdingsRecordId = createInstanceAndHolding(mainLibraryLocationId);
    final IndividualResource firstItemToMatch = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withItemLevelCallNumber("GE77 .F73 2014").available());
    final IndividualResource secondItemToMatch = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withItemLevelCallNumber("GE77 .F73 2014").withItemLevelCallNumberSuffix("Curriculum Materials Collection").available());
    itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withItemLevelCallNumber("GE77 .F73 ").withItemLevelCallNumberSuffix("2014 Curriculum Materials Collection").available());
    final List<UUID> foundItems = searchByCallNumberEyeReadable("GE77 .F73 2014");
    assertThat(foundItems.size(), is(2));
    assertThat(foundItems, hasItems(firstItemToMatch.getId(), secondItemToMatch.getId()));
}
Also used : UUID(java.util.UUID) IndividualResource(org.folio.rest.support.IndividualResource) ItemRequestBuilder(org.folio.rest.support.builders.ItemRequestBuilder) Test(org.junit.Test)

Example 42 with IndividualResource

use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.

the class PrecedingSucceedingTitleTest method canCreateConnectedPrecedingSucceedingTitle.

@Test
public void canCreateConnectedPrecedingSucceedingTitle() {
    IndividualResource instance1Resource = createInstance("Title One");
    IndividualResource instance2Resource = createInstance("Title Two");
    String instance1Id = instance1Resource.getId().toString();
    String instance2Id = instance2Resource.getId().toString();
    PrecedingSucceedingTitle precedingSucceedingTitle = new PrecedingSucceedingTitle(instance1Id, instance2Id, null, null, null);
    IndividualResource response = precedingSucceedingTitleClient.create(precedingSucceedingTitle.getJson());
    assertPrecedingSucceedingTitle(response, instance1Id, instance2Id, null, null, new JsonArray());
}
Also used : JsonArray(io.vertx.core.json.JsonArray) PrecedingSucceedingTitle(org.folio.rest.api.entities.PrecedingSucceedingTitle) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Example 43 with IndividualResource

use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.

the class PrecedingSucceedingTitleTest method canCreateUnconnectedSucceedingTitle.

@Test
public void canCreateUnconnectedSucceedingTitle() {
    IndividualResource instanceResource = createInstance("Title One");
    String instanceId = instanceResource.getId().toString();
    JsonArray identifiers = new JsonArray();
    identifiers.add(identifier(UUID_ISBN, "9781473619777"));
    PrecedingSucceedingTitle precedingSucceedingTitle = new PrecedingSucceedingTitle(instanceId, null, TITLE, HRID, identifiers);
    IndividualResource response = precedingSucceedingTitleClient.create(precedingSucceedingTitle.getJson());
    assertPrecedingSucceedingTitle(response, instanceId, null, TITLE, HRID, identifiers);
}
Also used : JsonArray(io.vertx.core.json.JsonArray) PrecedingSucceedingTitle(org.folio.rest.api.entities.PrecedingSucceedingTitle) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Example 44 with IndividualResource

use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.

the class PrecedingSucceedingTitleTest method cannotCreatePrecedingSucceedingTitleWithNonExistingPrecedingInstance.

@Test
public void cannotCreatePrecedingSucceedingTitleWithNonExistingPrecedingInstance() {
    String nonExistingInstanceId = "14b65645-2e49-4a85-8dc1-43d444710570";
    IndividualResource instanceResource = createInstance("Title One");
    PrecedingSucceedingTitle precedingSucceedingTitle = new PrecedingSucceedingTitle(nonExistingInstanceId, instanceResource.getId().toString(), null, null, null);
    Response response = precedingSucceedingTitleClient.attemptToCreate(precedingSucceedingTitle.getJson());
    assertThat(response.getStatusCode(), is(HttpResponseStatus.UNPROCESSABLE_ENTITY.code()));
    assertErrors(response, "Cannot set preceding_succeeding_title.precedinginstanceid = " + "14b65645-2e49-4a85-8dc1-43d444710570 because it does not exist in instance.id.");
}
Also used : Response(org.folio.rest.support.Response) PrecedingSucceedingTitle(org.folio.rest.api.entities.PrecedingSucceedingTitle) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Example 45 with IndividualResource

use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.

the class PrecedingSucceedingTitleTest method canDeletePrecedingSucceedingTitle.

@Test
public void canDeletePrecedingSucceedingTitle() {
    IndividualResource instanceResource = createInstance("Title One");
    JsonArray identifiers = new JsonArray();
    identifiers.add(identifier(UUID_ISBN, "9781473619777"));
    PrecedingSucceedingTitle precedingSucceedingTitle = new PrecedingSucceedingTitle(null, instanceResource.getId().toString(), TITLE, HRID, identifiers);
    IndividualResource response = precedingSucceedingTitleClient.create(precedingSucceedingTitle.getJson());
    precedingSucceedingTitleClient.delete(response.getId());
    Response getResponse = precedingSucceedingTitleClient.getById(response.getId());
    assertThat(getResponse.getStatusCode(), is(HttpURLConnection.HTTP_NOT_FOUND));
}
Also used : JsonArray(io.vertx.core.json.JsonArray) Response(org.folio.rest.support.Response) PrecedingSucceedingTitle(org.folio.rest.api.entities.PrecedingSucceedingTitle) IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Aggregations

IndividualResource (org.folio.rest.support.IndividualResource)89 Test (org.junit.Test)73 JsonObject (io.vertx.core.json.JsonObject)44 UUID (java.util.UUID)37 Response (org.folio.rest.support.Response)20 CompletableFuture (java.util.concurrent.CompletableFuture)19 JsonArray (io.vertx.core.json.JsonArray)17 JsonResponse (org.folio.rest.support.JsonResponse)17 LoanRequestBuilder (org.folio.rest.support.builders.LoanRequestBuilder)17 DateTime (org.joda.time.DateTime)12 PrecedingSucceedingTitle (org.folio.rest.api.entities.PrecedingSucceedingTitle)11 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)11 TextResponse (org.folio.rest.support.TextResponse)7 ItemRequestBuilder (org.folio.rest.support.builders.ItemRequestBuilder)7 InstancesBatchResponse (org.folio.rest.jaxrs.model.InstancesBatchResponse)6 JsonErrorResponse (org.folio.rest.support.JsonErrorResponse)6 TRUE (java.lang.Boolean.TRUE)4 HttpURLConnection (java.net.HttpURLConnection)4 MalformedURLException (java.net.MalformedURLException)4 DateFormat (java.text.DateFormat)4