use of org.folio.inventory.support.http.client.Response in project mod-inventory by folio-org.
the class ItemApiMoveExamples method canMoveToHoldingsRecordWithHoldingSchemasMismatching.
@Test
public void canMoveToHoldingsRecordWithHoldingSchemasMismatching() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException, IllegalAccessException {
UUID instanceId = UUID.randomUUID();
InstanceApiClient.createInstance(okapiClient, smallAngryPlanet(instanceId));
final UUID existedHoldingId = createHoldingForInstance(instanceId);
final UUID newHoldingId = createNonCompatibleHoldingForInstance(instanceId);
Assert.assertNotEquals(existedHoldingId, newHoldingId);
final IndividualResource createItem = itemsClient.create(new ItemRequestBuilder().forHolding(existedHoldingId).withBarcode("645398607547").withStatus(ItemStatusName.AVAILABLE.value()));
JsonObject itemsMoveRequestBody = new ItemsMoveRequestBuilder(newHoldingId, new JsonArray(Collections.singletonList(createItem.getId()))).create();
Response postMoveItemsResponse = moveItems(itemsMoveRequestBody);
assertThat(postMoveItemsResponse.getStatusCode(), is(200));
}
use of org.folio.inventory.support.http.client.Response in project mod-inventory by folio-org.
the class ItemApiMoveExamples method canMoveItemsToDifferentHoldingsRecord.
@Test
public void canMoveItemsToDifferentHoldingsRecord() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID instanceId = UUID.randomUUID();
InstanceApiClient.createInstance(okapiClient, smallAngryPlanet(instanceId));
final UUID existedHoldingId = createHoldingForInstance(instanceId);
final UUID newHoldingId = createHoldingForInstance(instanceId);
Assert.assertNotEquals(existedHoldingId, newHoldingId);
final IndividualResource createItem1 = itemsClient.create(new ItemRequestBuilder().forHolding(existedHoldingId).withBarcode("645398607547").withStatus(ItemStatusName.AVAILABLE.value()));
final IndividualResource createItem2 = itemsClient.create(new ItemRequestBuilder().forHolding(existedHoldingId).withBarcode("645398607546").withStatus(ItemStatusName.AVAILABLE.value()));
JsonObject itemsMoveRequestBody = new ItemsMoveRequestBuilder(newHoldingId, new JsonArray(Arrays.asList(createItem1.getId(), createItem2.getId()))).create();
Response postItemsMoveResponse = moveItems(itemsMoveRequestBody);
assertThat(postItemsMoveResponse.getStatusCode(), is(200));
assertThat(new JsonObject(postItemsMoveResponse.getBody()).getJsonArray("nonUpdatedIds").size(), is(0));
assertThat(postItemsMoveResponse.getContentType(), containsString(APPLICATION_JSON));
JsonObject updatedItem1 = itemsClient.getById(createItem1.getId()).getJson();
JsonObject updatedItem2 = itemsClient.getById(createItem2.getId()).getJson();
Assert.assertEquals(newHoldingId.toString(), updatedItem1.getString(HOLDINGS_RECORD_ID));
Assert.assertEquals(newHoldingId.toString(), updatedItem2.getString(HOLDINGS_RECORD_ID));
}
use of org.folio.inventory.support.http.client.Response in project mod-inventory by folio-org.
the class ItemApiMoveExamples method canMoveItemsDueToItemUpdateError.
@Test
public void canMoveItemsDueToItemUpdateError() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID instanceId = UUID.randomUUID();
InstanceApiClient.createInstance(okapiClient, smallAngryPlanet(instanceId));
final UUID existedHoldingId = createHoldingForInstance(instanceId);
final UUID newHoldingId = createHoldingForInstance(instanceId);
Assert.assertNotEquals(existedHoldingId, newHoldingId);
final IndividualResource createItem1 = itemsClient.create(new ItemRequestBuilder().forHolding(existedHoldingId).withBarcode("645398607547").withStatus(ItemStatusName.AVAILABLE.value()));
final IndividualResource createItem2 = itemsClient.create(new ItemRequestBuilder().forHolding(existedHoldingId).withBarcode("645398607546").withId(ID_FOR_FAILURE).withStatus(ItemStatusName.AVAILABLE.value()));
JsonObject itemsMoveRequestBody = new ItemsMoveRequestBuilder(newHoldingId, new JsonArray(Arrays.asList(createItem1.getId(), createItem2.getId()))).create();
Response postItemsMoveResponse = moveItems(itemsMoveRequestBody);
List nonUpdatedIdsIds = postItemsMoveResponse.getJson().getJsonArray("nonUpdatedIds").getList();
assertThat(nonUpdatedIdsIds.size(), is(1));
assertThat(nonUpdatedIdsIds.get(0), equalTo(ID_FOR_FAILURE.toString()));
assertThat(postItemsMoveResponse.getStatusCode(), is(200));
assertThat(postItemsMoveResponse.getContentType(), containsString(APPLICATION_JSON));
JsonObject updatedItem1 = itemsClient.getById(createItem1.getId()).getJson();
assertThat(newHoldingId.toString(), equalTo(updatedItem1.getString(HOLDINGS_RECORD_ID)));
JsonObject updatedItem2 = itemsClient.getById(createItem2.getId()).getJson();
assertThat(existedHoldingId.toString(), equalTo(updatedItem2.getString(HOLDINGS_RECORD_ID)));
}
use of org.folio.inventory.support.http.client.Response in project mod-inventory by folio-org.
the class IsbnUtilsApiExamples method testIsbnConvertTo10FromIsbn13WithInvalidIsbn.
@Test
public void testIsbnConvertTo10FromIsbn13WithInvalidIsbn() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
final var conversionCompleted = okapiClient.get(ApiRoot.isbnConvertTo10("isbn=97819301109911&hyphens=true"));
Response conversionResponse = conversionCompleted.toCompletableFuture().get(5, SECONDS);
checkErrorResponse(conversionResponse, String.format(INVALID_ISBN_MESSAGE, "97819301109911"));
}
use of org.folio.inventory.support.http.client.Response in project mod-inventory by folio-org.
the class IsbnUtilsApiExamples method verifyValidator.
private void verifyValidator(String isbnParam, boolean isValid) throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
final var validateGetCompleted = okapiClient.get(ApiRoot.isbnValidate(isbnParam));
Response validateGetResponse = validateGetCompleted.toCompletableFuture().get(5, SECONDS);
assertThat(validateGetResponse.getStatusCode(), is(200));
JsonObject result = validateGetResponse.getJson();
assertThat(result.getBoolean(IsbnUtilsApi.IS_VALID), is(isValid));
}
Aggregations