use of org.folio.rest.support.IndividualResource in project mod-circulation-storage by folio-org.
the class LoansApiTest method canSearchByLoanItemStatus.
@Test
public void canSearchByLoanItemStatus() throws Exception {
final IndividualResource agedToLostLoan = loansClient.create(new LoanRequestBuilder().agedToLost());
loansClient.create(new LoanRequestBuilder().lostAndPaid());
final List<String> agedToLostLoans = loansClient.getMany("itemStatus==Aged to lost").getRecords().stream().map(json -> json.getString("id")).collect(Collectors.toList());
assertThat(agedToLostLoans, hasSize(1));
assertThat(agedToLostLoans, hasItem(agedToLostLoan.getId()));
}
use of org.folio.rest.support.IndividualResource in project mod-circulation-storage by folio-org.
the class LoanPoliciesApiTest method createFixedDueDateSchedule.
private IndividualResource createFixedDueDateSchedule(String name, DateTime from, DateTime to, DateTime dueDate) throws Exception {
UUID fddId = UUID.randomUUID();
JsonObject fdd = FixedDueDateApiTest.createFixedDueDate(fddId.toString(), name, "desc");
JsonObject fddSchedule = FixedDueDateApiTest.createSchedule(from.toString(), to.toString(), dueDate.toString());
fdd.put(FixedDueDateApiTest.SCHEDULE_SECTION, new JsonArray().add(fddSchedule));
CompletableFuture<JsonResponse> createCompleted = new CompletableFuture<>();
client.post(FixedDueDateApiTest.dueDateURL(), fdd, StorageTestSuite.TENANT_ID, ResponseHandler.json(createCompleted));
JsonResponse response = createCompleted.get(5, TimeUnit.SECONDS);
assertThat(String.format("Failed to create due date: %s", response.getBody()), response, matchesCreated());
return new IndividualResource(response);
}
use of org.folio.rest.support.IndividualResource in project mod-circulation-storage by folio-org.
the class LoanPoliciesApiTest method cannotUseHoldAlternateRenewalLoanPeriodForFixedProfile.
@Test
public void cannotUseHoldAlternateRenewalLoanPeriodForFixedProfile() throws Exception {
DateTime from = DateTime.now().minusMonths(3);
DateTime to = DateTime.now().plusMonths(3);
DateTime dueDate = to.plusDays(15);
IndividualResource fixedDueDateSchedule = createFixedDueDateSchedule("semester_for_fixed_policy", from, to, dueDate);
LoanPolicyRequestBuilder loanPolicy = emptyPolicy().fixed(fixedDueDateSchedule.getId()).withAlternateFixedDueDateScheduleId(fixedDueDateSchedule.getId()).withHoldsRenewalLoanPeriod(new Period().withDuration(1).withIntervalId(Period.IntervalId.DAYS));
CompletableFuture<JsonResponse> createCompleted = new CompletableFuture<>();
client.post(loanPolicyStorageUrl(), loanPolicy.create(), StorageTestSuite.TENANT_ID, ResponseHandler.json(createCompleted));
JsonResponse postResponse = createCompleted.get(5, TimeUnit.SECONDS);
assertThat(postResponse.getStatusCode(), is(422));
assertThat(postResponse.getJson().getJsonArray("errors").getJsonObject(0).getString("message"), is("Alternate Renewal Loan Period for Holds is not allowed for policies with Fixed profile"));
}
use of org.folio.rest.support.IndividualResource in project mod-circulation-storage by folio-org.
the class CheckInStorageApiTest method canCreateRecordWithoutOptionalParameters.
@Test
public void canCreateRecordWithoutOptionalParameters() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
JsonObject checkInToCreate = createSampleCheckIn().withItemStatusPriorToCheckIn(null).withItemLocationId(null).withRequestQueueSize(null).create();
IndividualResource createResult = checkInClient.create(checkInToCreate);
assertThat(createResult.getJson(), is(checkInToCreate));
assertCreateEventForCheckIn(checkInToCreate);
}
use of org.folio.rest.support.IndividualResource in project mod-circulation-storage by folio-org.
the class CheckInStorageApiTest method canCreateRecordWithoutId.
@Test
public void canCreateRecordWithoutId() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
JsonObject checkInToCreate = createSampleCheckIn().withId(null).create();
IndividualResource createResult = checkInClient.create(checkInToCreate);
assertThat(createResult.getId(), notNullValue());
assertThat(createResult.getJson(), hasSameProperties(checkInToCreate));
assertCreateEventForCheckIn(checkInToCreate);
}
Aggregations