Search in sources :

Example 6 with JsonErrorResponse

use of org.folio.rest.support.JsonErrorResponse in project mod-inventory-storage by folio-org.

the class InstanceStorageTest method cannotProvideAdditionalPropertiesInInstanceIdentifiers.

@Test
public void cannotProvideAdditionalPropertiesInInstanceIdentifiers() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
    JsonObject requestWithAdditionalProperty = nod(UUID.randomUUID());
    requestWithAdditionalProperty.getJsonArray("identifiers").add(identifier(UUID_ISBN, "5645678432576").put("somethingAdditional", "foo"));
    CompletableFuture<JsonErrorResponse> createCompleted = new CompletableFuture<>();
    client.post(instancesStorageUrl(""), requestWithAdditionalProperty, TENANT_ID, ResponseHandler.jsonErrors(createCompleted));
    JsonErrorResponse response = createCompleted.get(5, SECONDS);
    assertThat(response.getStatusCode(), is(AdditionalHttpStatusCodes.UNPROCESSABLE_ENTITY));
    assertThat(response.getErrors(), hasSoleMessageContaining("Unrecognized field"));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) JsonErrorResponse(org.folio.rest.support.JsonErrorResponse) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Example 7 with JsonErrorResponse

use of org.folio.rest.support.JsonErrorResponse in project mod-inventory-storage by folio-org.

the class InstanceStorageTest method cannotProvideAdditionalPropertiesInInstance.

@Test
public void cannotProvideAdditionalPropertiesInInstance() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
    JsonObject requestWithAdditionalProperty = nod(UUID.randomUUID());
    requestWithAdditionalProperty.put("somethingAdditional", "foo");
    CompletableFuture<JsonErrorResponse> createCompleted = new CompletableFuture<>();
    client.post(instancesStorageUrl(""), requestWithAdditionalProperty, TENANT_ID, ResponseHandler.jsonErrors(createCompleted));
    JsonErrorResponse response = createCompleted.get(5, SECONDS);
    assertThat(response.getStatusCode(), is(AdditionalHttpStatusCodes.UNPROCESSABLE_ENTITY));
    assertThat(response.getErrors(), hasSoleMessageContaining("Unrecognized field"));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) JsonErrorResponse(org.folio.rest.support.JsonErrorResponse) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Aggregations

JsonObject (io.vertx.core.json.JsonObject)7 CompletableFuture (java.util.concurrent.CompletableFuture)7 JsonErrorResponse (org.folio.rest.support.JsonErrorResponse)7 Test (org.junit.Test)7 UUID (java.util.UUID)5