use of org.folio.rest.api.entities.PrecedingSucceedingTitles 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.PrecedingSucceedingTitles 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.PrecedingSucceedingTitles 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"));
}
Aggregations