Search in sources :

Example 11 with PrecedingSucceedingTitle

use of org.folio.rest.api.entities.PrecedingSucceedingTitle in project mod-inventory-storage by folio-org.

the class PrecedingSucceedingTitleTest method cannotCreatePrecedingSucceedingTitleWithNonExistingSucceedingInstance.

@Test
public void cannotCreatePrecedingSucceedingTitleWithNonExistingSucceedingInstance() {
    String nonExistingInstanceId = "14b65645-2e49-4a85-8dc1-43d444710570";
    IndividualResource instance1Response = createInstance("Title One");
    JsonArray identifiers = new JsonArray();
    identifiers.add(identifier(UUID_ISBN, "9781473619777"));
    PrecedingSucceedingTitle precedingSucceedingTitle = new PrecedingSucceedingTitle(instance1Response.getId().toString(), nonExistingInstanceId, TITLE, HRID, identifiers);
    Response response = precedingSucceedingTitleClient.attemptToCreate(precedingSucceedingTitle.getJson());
    assertThat(response.getStatusCode(), is(HttpResponseStatus.UNPROCESSABLE_ENTITY.code()));
    assertErrors(response, "Cannot set preceding_succeeding_title.succeedinginstanceid = " + "14b65645-2e49-4a85-8dc1-43d444710570 because it does not exist in instance.id.");
}
Also used : JsonArray(io.vertx.core.json.JsonArray) 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 12 with PrecedingSucceedingTitle

use of org.folio.rest.api.entities.PrecedingSucceedingTitle in project mod-inventory-storage by folio-org.

the class PrecedingSucceedingTitleTest method failedUpdatePrecedingSucceedingTitleCollectionWhenTitleNotContainsInstanceId.

@Test
public void failedUpdatePrecedingSucceedingTitleCollectionWhenTitleNotContainsInstanceId() throws Exception {
    String instanceId = UUID.randomUUID().toString();
    PrecedingSucceedingTitle precedingSucceedingTitle = new PrecedingSucceedingTitle(null, null, null, null, null);
    var titles = new PrecedingSucceedingTitles(List.of(precedingSucceedingTitle));
    CompletableFuture<Response> putCompleted = new CompletableFuture<>();
    client.put(precedingSucceedingTitleUrl("/instances/" + instanceId), titles.getJson(), TENANT_ID, ResponseHandler.any(putCompleted));
    Response response = putCompleted.get(10, SECONDS);
    assertThat(response.getStatusCode(), is(422));
    assertThat(response.getBody(), containsString("The precedingInstanceId or succeedingInstanceId should contain instanceId"));
}
Also used : Response(org.folio.rest.support.Response) CompletableFuture(java.util.concurrent.CompletableFuture) PrecedingSucceedingTitles(org.folio.rest.api.entities.PrecedingSucceedingTitles) PrecedingSucceedingTitle(org.folio.rest.api.entities.PrecedingSucceedingTitle) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 13 with PrecedingSucceedingTitle

use of org.folio.rest.api.entities.PrecedingSucceedingTitle 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 14 with PrecedingSucceedingTitle

use of org.folio.rest.api.entities.PrecedingSucceedingTitle 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)

Aggregations

PrecedingSucceedingTitle (org.folio.rest.api.entities.PrecedingSucceedingTitle)14 Test (org.junit.Test)14 IndividualResource (org.folio.rest.support.IndividualResource)11 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)11 JsonArray (io.vertx.core.json.JsonArray)10 Response (org.folio.rest.support.Response)8 CompletableFuture (java.util.concurrent.CompletableFuture)3 PrecedingSucceedingTitles (org.folio.rest.api.entities.PrecedingSucceedingTitles)3 JsonObject (io.vertx.core.json.JsonObject)1