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.");
}
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"));
}
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());
}
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);
}
Aggregations