use of org.folio.rest.api.entities.PrecedingSucceedingTitle in project mod-inventory-storage by folio-org.
the class PrecedingSucceedingTitleTest method cannotPutByInvalidPrecedingSucceedingId.
@Test
public void cannotPutByInvalidPrecedingSucceedingId() {
IndividualResource instance1Resource = createInstance("Title One");
JsonArray identifiers = new JsonArray();
identifiers.add(identifier(UUID_ISBN, "9781473619777"));
PrecedingSucceedingTitle precedingSucceedingTitle = new PrecedingSucceedingTitle(instance1Resource.getId().toString(), null, TITLE, HRID, identifiers);
Response putResponse = precedingSucceedingTitleClient.attemptToReplace("abc", precedingSucceedingTitle.getJson());
assertThat(putResponse.getStatusCode(), is(HttpResponseStatus.UNPROCESSABLE_ENTITY.code()));
assertErrors(putResponse, INVALID_UUID_ERROR_MESSAGE);
}
use of org.folio.rest.api.entities.PrecedingSucceedingTitle in project mod-inventory-storage by folio-org.
the class PrecedingSucceedingTitleTest method canCreateUnconnectedPrecedingTitle.
@Test
public void canCreateUnconnectedPrecedingTitle() {
IndividualResource instanceResource = createInstance("Title One");
String instanceId = instanceResource.getId().toString();
JsonArray identifiers = new JsonArray();
identifiers.add(identifier(UUID_ISBN, "9781473619777"));
PrecedingSucceedingTitle precedingSucceedingTitle = new PrecedingSucceedingTitle(null, instanceId, TITLE, HRID, identifiers);
IndividualResource response = precedingSucceedingTitleClient.create(precedingSucceedingTitle.getJson());
assertPrecedingSucceedingTitle(response, null, instanceId, TITLE, HRID, identifiers);
}
use of org.folio.rest.api.entities.PrecedingSucceedingTitle in project mod-inventory-storage by folio-org.
the class PrecedingSucceedingTitleTest method canUpdatePrecedingSucceedingTitleCollection.
@Test
public void canUpdatePrecedingSucceedingTitleCollection() throws Exception {
IndividualResource instance1Resource = createInstance("Title One");
String instanceId = instance1Resource.getId().toString();
PrecedingSucceedingTitle precedingSucceedingTitle1 = new PrecedingSucceedingTitle(instanceId, null, null, null, null);
precedingSucceedingTitleClient.create(precedingSucceedingTitle1.getJson());
PrecedingSucceedingTitle precedingSucceedingTitle2 = new PrecedingSucceedingTitle(instanceId, null, null, null, null);
precedingSucceedingTitleClient.create(precedingSucceedingTitle2.getJson());
precedingSucceedingTitle1.put(PRECEDING_INSTANCE_ID_KEY, null);
precedingSucceedingTitle1.put(SUCCEEDING_INSTANCE_ID_KEY, instanceId);
precedingSucceedingTitle2.put(PRECEDING_INSTANCE_ID_KEY, null);
precedingSucceedingTitle2.put(SUCCEEDING_INSTANCE_ID_KEY, instanceId);
var titles = new PrecedingSucceedingTitles(List.of(precedingSucceedingTitle1, precedingSucceedingTitle2));
CompletableFuture<Response> putCompleted = new CompletableFuture<>();
client.put(precedingSucceedingTitleUrl("/instances/" + instanceId), titles.getJson(), TENANT_ID, ResponseHandler.empty(putCompleted));
Response response = putCompleted.get(10, SECONDS);
assertThat(response.getStatusCode(), is(204));
var existedTitles = precedingSucceedingTitleClient.getByQuery(String.format("?query=succeedingInstanceId==(%s)+or+precedingInstanceId==(%s)", instanceId, instanceId));
existedTitles.forEach(entry -> {
assertThat(entry.getString("succeedingInstanceId"), equalTo(instanceId));
assertThat(entry.getString("precedingInstanceId"), nullValue());
});
precedingSucceedingTitleClient.delete(UUID.fromString(existedTitles.get(0).getString("id")));
precedingSucceedingTitleClient.delete(UUID.fromString(existedTitles.get(1).getString("id")));
}
use of org.folio.rest.api.entities.PrecedingSucceedingTitle in project mod-inventory-storage by folio-org.
the class PrecedingSucceedingTitleTest method failedUpdatePrecedingSucceedingTitleCollectionWhenInstanceIsMissing.
@Test
public void failedUpdatePrecedingSucceedingTitleCollectionWhenInstanceIsMissing() throws Exception {
String missedInstanceId = UUID.randomUUID().toString();
PrecedingSucceedingTitle precedingSucceedingTitle1 = new PrecedingSucceedingTitle(missedInstanceId, null, null, null, null);
PrecedingSucceedingTitle precedingSucceedingTitle2 = new PrecedingSucceedingTitle(null, missedInstanceId, null, null, null);
var titles = new PrecedingSucceedingTitles(List.of(precedingSucceedingTitle1, precedingSucceedingTitle2));
CompletableFuture<Response> putCompleted = new CompletableFuture<>();
client.put(precedingSucceedingTitleUrl("/instances/" + missedInstanceId), titles.getJson(), TENANT_ID, ResponseHandler.any(putCompleted));
Response response = putCompleted.get(10, SECONDS);
assertThat(response.getStatusCode(), is(404));
assertThat(response.getBody(), is("Instance not found"));
}
use of org.folio.rest.api.entities.PrecedingSucceedingTitle in project mod-inventory-storage by folio-org.
the class PrecedingSucceedingTitleTest method canUpdateUnconnectedPrecedingSucceedingTitle.
@Test
public void canUpdateUnconnectedPrecedingSucceedingTitle() {
IndividualResource instance1Resource = createInstance("Title One");
String instance1Id = instance1Resource.getId().toString();
JsonArray identifiers = new JsonArray();
identifiers.add(identifier(UUID_ISBN, "9781473619777"));
PrecedingSucceedingTitle precedingSucceedingTitle = new PrecedingSucceedingTitle(instance1Id, null, TITLE, HRID, identifiers);
IndividualResource response = precedingSucceedingTitleClient.create(precedingSucceedingTitle.getJson());
IndividualResource instance2Resource = createInstance("Title Two");
String instance2Id = instance2Resource.getId().toString();
String newTitle = "New";
String newHrid = "inst000000000133";
JsonArray newIdentifiers = new JsonArray();
newIdentifiers.add(identifier(UUID_ISBN, "1081473619777"));
PrecedingSucceedingTitle newPrecedingSucceedingTitle = new PrecedingSucceedingTitle(instance2Id, instance1Id, newTitle, newHrid, newIdentifiers);
precedingSucceedingTitleClient.replace(response.getId(), newPrecedingSucceedingTitle.getJson());
assertPrecedingSucceedingTitle(response, instance2Id, instance1Id, newTitle, newHrid, newIdentifiers);
}
Aggregations