Search in sources :

Example 86 with IndividualResource

use of org.folio.rest.support.IndividualResource in project mod-circulation-storage by folio-org.

the class RequestsApiTest method createCancellationReason.

private IndividualResource createCancellationReason(String name, String description) throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
    final JsonObject body = new JsonObject();
    body.put("name", name);
    body.put("description", description);
    CompletableFuture<JsonResponse> createCompleted = new CompletableFuture<>();
    client.post(cancelReasonURL(), body, TENANT_ID, ResponseHandler.json(createCompleted));
    JsonResponse postResponse = createCompleted.get(5, TimeUnit.SECONDS);
    assertThat(String.format("Failed to create cancellation reason: %s", postResponse.getBody()), postResponse.getStatusCode(), is(HTTP_CREATED));
    return new IndividualResource(postResponse);
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(org.folio.rest.support.IndividualResource) JsonResponse(org.folio.rest.support.JsonResponse)

Example 87 with IndividualResource

use of org.folio.rest.support.IndividualResource in project mod-circulation-storage by folio-org.

the class LoansAnonymizationApiTest method shouldNotAnonymizeLoansHistoryForOtherUser.

@Test
public void shouldNotAnonymizeLoansHistoryForOtherUser() throws MalformedURLException, ExecutionException, InterruptedException, TimeoutException {
    final UUID firstUserId = UUID.randomUUID();
    final UUID secondUserId = UUID.randomUUID();
    final IndividualResource loanForOtherUser = loansClient.create(new LoanRequestBuilder().closed().withUserId(firstUserId));
    anonymizeLoansFor(secondUserId);
    hasLoanHistoryForUser(firstUserId, loanForOtherUser.getId());
}
Also used : LoanRequestBuilder(org.folio.rest.support.builders.LoanRequestBuilder) UUIDMatchers.isUUID(org.folio.rest.support.matchers.UUIDMatchers.isUUID) UUID(java.util.UUID) IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Example 88 with IndividualResource

use of org.folio.rest.support.IndividualResource in project mod-circulation-storage by folio-org.

the class AssertingRecordClient method getById.

public IndividualResource getById(UUID id) throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
    JsonResponse response = attemptGetById(id);
    assertThat("Failed to get record", response, isOk());
    return new IndividualResource(response);
}
Also used : IndividualResource(org.folio.rest.support.IndividualResource) JsonResponse(org.folio.rest.support.JsonResponse)

Example 89 with IndividualResource

use of org.folio.rest.support.IndividualResource in project mod-circulation-storage by folio-org.

the class AssertingRecordClient method create.

public IndividualResource create(JsonObject representation) throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
    JsonResponse response = attemptCreate(representation);
    assertThat("Failed to create record", response, isCreated());
    return new IndividualResource(response);
}
Also used : IndividualResource(org.folio.rest.support.IndividualResource) JsonResponse(org.folio.rest.support.JsonResponse)

Aggregations

IndividualResource (org.folio.rest.support.IndividualResource)89 Test (org.junit.Test)73 JsonObject (io.vertx.core.json.JsonObject)44 UUID (java.util.UUID)37 Response (org.folio.rest.support.Response)20 CompletableFuture (java.util.concurrent.CompletableFuture)19 JsonArray (io.vertx.core.json.JsonArray)17 JsonResponse (org.folio.rest.support.JsonResponse)17 LoanRequestBuilder (org.folio.rest.support.builders.LoanRequestBuilder)17 DateTime (org.joda.time.DateTime)12 PrecedingSucceedingTitle (org.folio.rest.api.entities.PrecedingSucceedingTitle)11 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)11 TextResponse (org.folio.rest.support.TextResponse)7 ItemRequestBuilder (org.folio.rest.support.builders.ItemRequestBuilder)7 InstancesBatchResponse (org.folio.rest.jaxrs.model.InstancesBatchResponse)6 JsonErrorResponse (org.folio.rest.support.JsonErrorResponse)6 TRUE (java.lang.Boolean.TRUE)4 HttpURLConnection (java.net.HttpURLConnection)4 MalformedURLException (java.net.MalformedURLException)4 DateFormat (java.text.DateFormat)4