use of org.folio.HttpStatus.HTTP_CREATED in project mod-inventory-storage by folio-org.
the class HoldingsStorageTest method canPostSynchronousBatchWithExistingIdWithUpsertTrue.
@Test
public void canPostSynchronousBatchWithExistingIdWithUpsertTrue() {
final String existingHrId = UUID.randomUUID().toString();
final JsonArray holdingsArray1 = threeHoldings();
final JsonArray holdingsArray2 = threeHoldings();
holdingsArray1.getJsonObject(1).put("id", existingHrId);
holdingsArray2.getJsonObject(1).put("id", existingHrId);
final Response firstResponse = postSynchronousBatch("?upsert=true", holdingsArray1);
final JsonObject existingHrBeforeUpdate = getById(existingHrId).getJson();
final Response secondResponse = postSynchronousBatch("?upsert=true", holdingsArray2);
assertThat(firstResponse, statusCodeIs(HTTP_CREATED));
assertThat(secondResponse, statusCodeIs(HTTP_CREATED));
Stream.concat(holdingsArray1.stream(), holdingsArray2.stream()).map(json -> ((JsonObject) json).getString("id")).filter(id -> !id.equals(existingHrId)).map(this::getById).map(Response::getJson).forEach(DomainEventAssertions::assertCreateEventForHolding);
await().untilAsserted(() -> {
var newHr = getById(existingHrId).getJson();
final String id = newHr.getString("id");
final String instanceId = newHr.getString("instanceId");
assertThat(getHoldingsEvents(instanceId, id).size(), greaterThan(0));
assertUpdateEvent(getLastHoldingEvent(instanceId, id), existingHrBeforeUpdate, newHr);
});
}
use of org.folio.HttpStatus.HTTP_CREATED in project mod-inventory-storage by folio-org.
the class ItemStorageTest method canPostSynchronousBatchWithGeneratedHRID.
@Test
public void canPostSynchronousBatchWithGeneratedHRID() {
log.info("Starting canPostSynchronousBatchWithGeneratedHRID");
setItemSequence(1);
final JsonArray itemsArray = threeItems();
assertThat(postSynchronousBatch(itemsArray), statusCodeIs(HTTP_CREATED));
for (Object item : itemsArray) {
assertExists((JsonObject) item);
}
itemsArray.stream().map(o -> (JsonObject) o).forEach(item -> {
final Response response = getById(item.getString("id"));
assertExists(response, item);
assertHRIDRange(response, "it00000000001", "it00000000003");
});
log.info("Finished canPostSynchronousBatchWithGeneratedHRID");
}
use of org.folio.HttpStatus.HTTP_CREATED in project mod-inventory-storage by folio-org.
the class HoldingsStorageTest method canPostSynchronousBatchWithGeneratedHRID.
@Test
public void canPostSynchronousBatchWithGeneratedHRID() {
log.info("Starting canPostSynchronousBatchWithGeneratedHRID");
setHoldingsSequence(1);
final JsonArray holdingsArray = threeHoldings();
assertThat(postSynchronousBatch(holdingsArray), statusCodeIs(HTTP_CREATED));
holdingsArray.stream().map(o -> (JsonObject) o).forEach(holdings -> {
final Response response = getById(holdings.getString("id"));
assertExists(response, holdings);
assertHRIDRange(response, "ho00000000001", "ho00000000003");
JsonObject body = response.getJson();
assertEquals(body.getString("effectiveLocationId"), body.getString("permanentLocationId"));
});
log.info("Finished canPostSynchronousBatchWithGeneratedHRID");
}
Aggregations