use of org.folio.rest.support.JsonErrorResponse in project mod-inventory-storage by folio-org.
the class ItemStorageTest method cannotProvideAdditionalPropertiesInItem.
@Test
public void cannotProvideAdditionalPropertiesInItem() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID holdingsRecordId = createInstanceAndHolding(mainLibraryLocationId);
JsonObject requestWithAdditionalProperty = nod(UUID.randomUUID(), holdingsRecordId);
requestWithAdditionalProperty.put("somethingAdditional", "foo");
CompletableFuture<JsonErrorResponse> createCompleted = new CompletableFuture<>();
client.post(itemsStorageUrl(""), requestWithAdditionalProperty, StorageTestSuite.TENANT_ID, ResponseHandler.jsonErrors(createCompleted));
JsonErrorResponse response = createCompleted.get(5, TimeUnit.SECONDS);
assertThat(response.getStatusCode(), is(AdditionalHttpStatusCodes.UNPROCESSABLE_ENTITY));
assertThat(response.getErrors(), hasSoleMessageContaining("Unrecognized field"));
}
use of org.folio.rest.support.JsonErrorResponse in project mod-inventory-storage by folio-org.
the class ItemStorageTest method cannotRemoveItemStatus.
@Test
public void cannotRemoveItemStatus() throws Exception {
UUID holdingsRecordId = createInstanceAndHolding(mainLibraryLocationId);
UUID id = UUID.randomUUID();
JsonObject itemToCreate = smallAngryPlanet(id, holdingsRecordId).put("status", new JsonObject().put("name", "Available"));
createItem(itemToCreate);
JsonObject createdItem = getById(id).getJson();
assertThat(createdItem.getJsonObject("status").getString("name"), is("Available"));
JsonObject replacement = itemToCreate.copy();
replacement.remove("status");
CompletableFuture<JsonErrorResponse> updateCompleted = new CompletableFuture<>();
client.put(itemsStorageUrl("/" + id), replacement, TENANT_ID, ResponseHandler.jsonErrors(updateCompleted));
JsonErrorResponse updateResponse = updateCompleted.get(5, TimeUnit.SECONDS);
assertThat(updateResponse.getStatusCode(), is(422));
assertThat(updateResponse.getErrors().size(), is(1));
JsonObject error = updateResponse.getErrors().get(0);
assertThat(error.getString("message"), anyOf(is("may not be null"), is("must not be null")));
assertThat(error.getJsonArray("parameters").getJsonObject(0).getString("key"), is("status"));
}
use of org.folio.rest.support.JsonErrorResponse in project mod-inventory-storage by folio-org.
the class ItemStorageTest method cannotProvideAdditionalPropertiesInItemStatus.
@Test
public void cannotProvideAdditionalPropertiesInItemStatus() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID holdingsRecordId = createInstanceAndHolding(mainLibraryLocationId);
JsonObject requestWithAdditionalProperty = nod(UUID.randomUUID(), holdingsRecordId);
requestWithAdditionalProperty.put("status", new JsonObject().put("somethingAdditional", "foo"));
CompletableFuture<JsonErrorResponse> createCompleted = new CompletableFuture<>();
client.post(itemsStorageUrl(""), requestWithAdditionalProperty, StorageTestSuite.TENANT_ID, ResponseHandler.jsonErrors(createCompleted));
JsonErrorResponse response = createCompleted.get(5, TimeUnit.SECONDS);
assertThat(response.getStatusCode(), is(AdditionalHttpStatusCodes.UNPROCESSABLE_ENTITY));
assertThat(response.getErrors(), hasSoleMessageContaining("Unrecognized field"));
}
use of org.folio.rest.support.JsonErrorResponse in project mod-inventory-storage by folio-org.
the class ItemStorageTest method cannotProvideAdditionalPropertiesInItemLocation.
@Test
public void cannotProvideAdditionalPropertiesInItemLocation() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID holdingsRecordId = createInstanceAndHolding(mainLibraryLocationId);
JsonObject requestWithAdditionalProperty = nod(UUID.randomUUID(), holdingsRecordId);
requestWithAdditionalProperty.put("location", new JsonObject().put("somethingAdditional", "foo"));
CompletableFuture<JsonErrorResponse> createCompleted = new CompletableFuture<>();
client.post(itemsStorageUrl(""), requestWithAdditionalProperty, StorageTestSuite.TENANT_ID, ResponseHandler.jsonErrors(createCompleted));
JsonErrorResponse response = createCompleted.get(5, TimeUnit.SECONDS);
assertThat(response.getStatusCode(), is(AdditionalHttpStatusCodes.UNPROCESSABLE_ENTITY));
assertThat(response.getErrors(), hasSoleMessageContaining("Unrecognized field"));
}
use of org.folio.rest.support.JsonErrorResponse in project mod-inventory-storage by folio-org.
the class ItemStorageTest method cannotRemoveItemStatusName.
@Test
public void cannotRemoveItemStatusName() throws Exception {
UUID holdingsRecordId = createInstanceAndHolding(mainLibraryLocationId);
UUID id = UUID.randomUUID();
JsonObject itemToCreate = smallAngryPlanet(id, holdingsRecordId).put("status", new JsonObject().put("name", "Available"));
createItem(itemToCreate);
JsonObject createdItem = getById(id).getJson();
assertThat(createdItem.getJsonObject("status").getString("name"), is("Available"));
JsonObject replacement = itemToCreate.copy();
replacement.getJsonObject("status").remove("name");
CompletableFuture<JsonErrorResponse> updateCompleted = new CompletableFuture<>();
client.put(itemsStorageUrl("/" + id), replacement, TENANT_ID, ResponseHandler.jsonErrors(updateCompleted));
JsonErrorResponse updateResponse = updateCompleted.get(5, TimeUnit.SECONDS);
assertThat(updateResponse.getStatusCode(), is(422));
assertThat(updateResponse.getErrors().size(), is(1));
JsonObject error = updateResponse.getErrors().get(0);
assertThat(error.getString("message"), anyOf(is("may not be null"), is("must not be null")));
assertThat(error.getJsonArray("parameters").getJsonObject(0).getString("key"), is("status.name"));
}
Aggregations