Search in sources :

Example 66 with IndividualResource

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

the class ItemEffectiveCallNumberComponentsTest method canCalculateEffectiveCallNumberPropertyOnCreate.

@Test
@Parameters(source = ItemEffectiveCallNumberComponentsTestData.class, method = "createPropertiesParams")
@TestCaseName("[{index}]: {params}")
public void canCalculateEffectiveCallNumberPropertyOnCreate(CallNumberComponentPropertyNames callNumberProperties, String holdingsPropertyValue, String itemPropertyValue) {
    final String effectiveValue = StringUtils.firstNonBlank(itemPropertyValue, holdingsPropertyValue);
    IndividualResource holdings = createHoldingsWithPropertySetAndInstance(callNumberProperties.holdingsPropertyName, holdingsPropertyValue);
    IndividualResource createdItem = itemsClient.create(nodWithNoBarcode(holdings.getId()).put(callNumberProperties.itemPropertyName, itemPropertyValue));
    assertThat(createdItem.getJson().getString(callNumberProperties.itemPropertyName), is(itemPropertyValue));
    Response getResponse = itemsClient.getById(createdItem.getId());
    assertThat(getResponse.getStatusCode(), is(HttpURLConnection.HTTP_OK));
    JsonObject effectiveCallNumberComponents = getResponse.getJson().getJsonObject("effectiveCallNumberComponents");
    assertNotNull(effectiveCallNumberComponents);
    assertThat(effectiveCallNumberComponents.getString(callNumberProperties.effectivePropertyName), is(effectiveValue));
}
Also used : Response(org.folio.rest.support.Response) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(org.folio.rest.support.IndividualResource) Parameters(junitparams.Parameters) Test(org.junit.Test) TestCaseName(junitparams.naming.TestCaseName)

Example 67 with IndividualResource

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

the class ItemEffectiveCallNumberComponentsTest method createHoldingsWithPropertySetAndInstance.

private IndividualResource createHoldingsWithPropertySetAndInstance(String propertyName, String propertyValue) {
    IndividualResource instance = instancesClient.create(instance(UUID.randomUUID()));
    IndividualResource holdings = holdingsClient.create(new HoldingRequestBuilder().withId(UUID.randomUUID()).forInstance(instance.getId()).withPermanentLocation(mainLibraryLocationId).create().put(propertyName, propertyValue));
    assertThat(holdings.getJson().getString(propertyName), is(propertyValue));
    return holdings;
}
Also used : HoldingRequestBuilder(org.folio.rest.support.builders.HoldingRequestBuilder) IndividualResource(org.folio.rest.support.IndividualResource)

Example 68 with IndividualResource

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

the class HoldingsSourceTest method canNotRemoveSpecialHoldingsSources.

@Test
public void canNotRemoveSpecialHoldingsSources() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
    IndividualResource holdingsSource = holdingsSourceClient.create(new JsonObject().put("name", "source with folio source").put("source", "folio"));
    UUID folioHoldingsSourceId = holdingsSource.getId();
    Response folioDeleteResponse = holdingsSourceClient.attemptToDelete(folioHoldingsSourceId);
    // it should not have been deleted:
    assertThat(folioDeleteResponse.getStatusCode(), is(HttpURLConnection.HTTP_BAD_REQUEST));
}
Also used : Response(org.folio.rest.support.Response) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(org.folio.rest.support.IndividualResource) UUID(java.util.UUID) Test(org.junit.Test)

Example 69 with IndividualResource

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

the class HoldingsSourceTest method canReplaceAHoldingsSource.

@Test
public void canReplaceAHoldingsSource() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
    IndividualResource sourceResponse = holdingsSourceClient.create(new JsonObject().put("name", "replaceable source"));
    JsonObject source = sourceResponse.getJson();
    assertThat(source.getString("id"), is(notNullValue()));
    assertThat(source.getString("name"), is("replaceable source"));
    sourceResponse = holdingsSourceClient.create(new JsonObject().put("name", "replacement source"));
    source = sourceResponse.getJson();
    assertThat(source.getString("id"), is(notNullValue()));
    assertThat(source.getString("name"), is("replacement source"));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Example 70 with IndividualResource

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

the class InstanceDiscoverySuppressMigrationScriptTest method verifySuppressed.

private void verifySuppressed(List<IndividualResource> instances) throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
    for (IndividualResource instance : instances) {
        Instance instanceInStorage = instancesClient.getById(instance.getId()).getJson().mapTo(Instance.class);
        assertThat(instanceInStorage.getDiscoverySuppress(), is(true));
    }
}
Also used : Instance(org.folio.rest.jaxrs.model.Instance) IndividualResource(org.folio.rest.support.IndividualResource)

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