Search in sources :

Example 71 with IndividualResource

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

the class InstanceDiscoverySuppressMigrationScriptTest method canSetDiscoverySuppressIfNotPresent.

@Test
public void canSetDiscoverySuppressIfNotPresent() throws Exception {
    List<IndividualResource> allInstances = createInstances(3);
    for (IndividualResource instance : allInstances) {
        assertThat(unsetJsonbProperty("instance", instance.getId(), DISCOVERY_SUPPRESS).rowCount(), is(1));
    }
    executeMultipleSqlStatements(MIGRATION_SCRIPT);
    verifyNotSuppressed(allInstances);
}
Also used : IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Example 72 with IndividualResource

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

the class InstanceStorageTest method canSearchByStaffSuppressProperty.

@Test
public void canSearchByStaffSuppressProperty() throws Exception {
    final IndividualResource suppressedInstance = createInstance(smallAngryPlanet(UUID.randomUUID()).put(STAFF_SUPPRESS, true));
    final IndividualResource notSuppressedInstance = createInstance(smallAngryPlanet(UUID.randomUUID()).put(STAFF_SUPPRESS, false));
    final IndividualResource notSuppressedInstanceDefault = createInstance(smallAngryPlanet(UUID.randomUUID()));
    final List<IndividualResource> suppressedInstances = instancesClient.getMany("%s==true", STAFF_SUPPRESS);
    final List<IndividualResource> notSuppressedInstances = instancesClient.getMany("cql.allRecords=1 not %s==true", STAFF_SUPPRESS);
    assertThat(suppressedInstances.size(), is(1));
    assertThat(suppressedInstances.get(0).getId(), is(suppressedInstance.getId()));
    assertThat(notSuppressedInstances.size(), is(2));
    assertThat(notSuppressedInstances.stream().map(IndividualResource::getId).collect(Collectors.toList()), containsInAnyOrder(notSuppressedInstance.getId(), notSuppressedInstanceDefault.getId()));
}
Also used : IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Example 73 with IndividualResource

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

the class PrecedingSucceedingTitleTest method canUpdateConnectedPrecedingSucceedingTitle.

@Test
public void canUpdateConnectedPrecedingSucceedingTitle() {
    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());
    PrecedingSucceedingTitle newPrecedingSucceedingTitle = new PrecedingSucceedingTitle(instance2Id, instance1Id, null, null, null);
    precedingSucceedingTitleClient.replace(response.getId(), newPrecedingSucceedingTitle.getJson());
    assertPrecedingSucceedingTitle(response, instance2Id, instance1Id, 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 74 with IndividualResource

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

the class PrecedingSucceedingTitleTest method canGetPrecedingSucceedingTitleByQuery.

@Test
public void canGetPrecedingSucceedingTitleByQuery() {
    IndividualResource instance1Resource = createInstance("Title One");
    IndividualResource instance2Resource = createInstance("Title Two");
    String instance1Id = instance1Resource.getId().toString();
    String instance2Id = instance2Resource.getId().toString();
    JsonArray identifiers = new JsonArray();
    identifiers.add(identifier(UUID_ISBN, "9781473619777"));
    PrecedingSucceedingTitle precedingSucceedingTitle = new PrecedingSucceedingTitle(instance1Id, instance2Id, TITLE, HRID, identifiers);
    IndividualResource response = precedingSucceedingTitleClient.create(precedingSucceedingTitle.getJson());
    List<JsonObject> badParameterResponse = precedingSucceedingTitleClient.getByQuery("?query=succeedingInstanceId=" + instance2Id);
    assertThat(badParameterResponse.size(), is(1));
    assertPrecedingSucceedingTitle(badParameterResponse.get(0), response.getId().toString(), instance1Id, instance2Id, TITLE, HRID, identifiers);
}
Also used : JsonArray(io.vertx.core.json.JsonArray) PrecedingSucceedingTitle(org.folio.rest.api.entities.PrecedingSucceedingTitle) JsonObject(io.vertx.core.json.JsonObject) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Example 75 with IndividualResource

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

the class TestBaseWithInventoryUtil method getInstanceStatusByCode.

private IndividualResource getInstanceStatusByCode(String code) {
    CompletableFuture<Response> getCompleted = new CompletableFuture<>();
    client.get(instanceStatusesUrl("?query=code=" + code), TENANT_ID, ResponseHandler.json(getCompleted));
    JsonObject instanceStatus = get(getCompleted).getJson().getJsonArray("instanceStatuses").getJsonObject(0);
    return new IndividualResource(instanceStatus);
}
Also used : Response(org.folio.rest.support.Response) CompletableFuture(java.util.concurrent.CompletableFuture) JsonObject(io.vertx.core.json.JsonObject) 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