Search in sources :

Example 16 with IndividualResource

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

the class CheckInStorageApiTest method canGetCheckInById.

@Test
public void canGetCheckInById() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
    JsonObject checkInToCreate = createSampleCheckIn().create();
    IndividualResource createResult = checkInClient.create(checkInToCreate);
    IndividualResource checkInById = checkInClient.getById(createResult.getId());
    assertThat(createResult.getJson(), is(checkInToCreate));
    assertThat(checkInById.getJson(), is(checkInToCreate));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Example 17 with IndividualResource

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

the class PatronActionSessionAPITest method canCreatePatronActionSession.

@Test
public void canCreatePatronActionSession() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
    String actionType = "Check-out";
    JsonObject request = createPatronActionSession(actionType);
    IndividualResource individualResource = assertRecordClient.create(request);
    assertThat(individualResource.getJson().getString("actionType"), is(actionType));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Example 18 with IndividualResource

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

the class LoansAnonymizationApiTest method shouldAnonymizeSingleClosedLoanForUser.

@Test
public void shouldAnonymizeSingleClosedLoanForUser() throws MalformedURLException, ExecutionException, InterruptedException, TimeoutException {
    final UUID userId = UUID.randomUUID();
    final IndividualResource loan = loansClient.create(new LoanRequestBuilder().closed().withUserId(userId));
    anonymizeLoansFor(userId);
    final IndividualResource fetchedLoan = loansClient.getById(loan.getId());
    assertThat("Should no longer have a user ID", fetchedLoan.getJson().containsKey("userId"), is(false));
    assertThat("Anonymized loans should still be present", loansClient.getAll().getTotalRecords(), is(1));
}
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 19 with IndividualResource

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

the class LoansAnonymizationApiTest method shouldAnonymizeSingleClosedLoanHistoryForUser.

@Test
public void shouldAnonymizeSingleClosedLoanHistoryForUser() throws MalformedURLException, ExecutionException, InterruptedException, TimeoutException {
    final UUID userId = UUID.randomUUID();
    final IndividualResource loan = loansClient.create(new LoanRequestBuilder().open().withUserId(userId));
    loansClient.replace(loan.getId(), LoanRequestBuilder.from(loan.getJson()).withReturnDate(DateTime.now()).closed());
    anonymizeLoansFor(userId);
    final MultipleRecords<JsonObject> historyRecords = getLoanActionHistoryForUser(userId);
    assertThat("Should be no history records for user", historyRecords.getRecords().size(), is(0));
    assertThat("Should be no history records for user", historyRecords.getTotalRecords(), is(0));
}
Also used : LoanRequestBuilder(org.folio.rest.support.builders.LoanRequestBuilder) JsonObject(io.vertx.core.json.JsonObject) UUIDMatchers.isUUID(org.folio.rest.support.matchers.UUIDMatchers.isUUID) UUID(java.util.UUID) IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Example 20 with IndividualResource

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

the class LoansAnonymizationApiTest method shouldNotAnonymizeLoansForOtherUser.

@Test
public void shouldNotAnonymizeLoansForOtherUser() throws MalformedURLException, ExecutionException, InterruptedException, TimeoutException {
    final UUID firstUserId = UUID.randomUUID();
    final UUID secondUserId = UUID.randomUUID();
    final IndividualResource otherUsersLoan = loansClient.create(new LoanRequestBuilder().closed().withUserId(firstUserId));
    anonymizeLoansFor(secondUserId);
    final IndividualResource fetchedLoan = loansClient.getById(otherUsersLoan.getId());
    assertThat(fetchedLoan.getJson().getString("userId"), isUUID(firstUserId));
    assertThat("Anonymized loans should still be present", loansClient.getAll().getTotalRecords(), is(1));
}
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)

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