Search in sources :

Example 1 with PrecedingSucceedingTitle

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

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

the class PrecedingSucceedingTitleTest method cannotCreatePrecedingSucceedingTitleWithEmptyPrecedingAndSucceedingInstanceId.

@Test
public void cannotCreatePrecedingSucceedingTitleWithEmptyPrecedingAndSucceedingInstanceId() {
    JsonArray identifiers = new JsonArray();
    identifiers.add(identifier(UUID_ISBN, "9781473619777"));
    PrecedingSucceedingTitle precedingSucceedingTitle = new PrecedingSucceedingTitle(null, null, TITLE, HRID, identifiers);
    Response response = precedingSucceedingTitleClient.attemptToCreate(precedingSucceedingTitle.getJson());
    assertThat(response.getStatusCode(), is(HttpResponseStatus.UNPROCESSABLE_ENTITY.code()));
    assertErrors(response, "The precedingInstanceId and succeedingInstanceId can't be empty at the same time");
}
Also used : JsonArray(io.vertx.core.json.JsonArray) Response(org.folio.rest.support.Response) PrecedingSucceedingTitle(org.folio.rest.api.entities.PrecedingSucceedingTitle) Test(org.junit.Test)

Example 3 with PrecedingSucceedingTitle

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

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

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

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