Search in sources :

Example 1 with Period

use of org.folio.rest.jaxrs.model.Period 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"));
}
Also used : LoanPolicyRequestBuilder(org.folio.rest.support.builders.LoanPolicyRequestBuilder) CompletableFuture(java.util.concurrent.CompletableFuture) org.folio.rest.support.matchers.periodJsonObjectMatcher.matchesPeriod(org.folio.rest.support.matchers.periodJsonObjectMatcher.matchesPeriod) Period(org.folio.rest.jaxrs.model.Period) IndividualResource(org.folio.rest.support.IndividualResource) DateTime(org.joda.time.DateTime) JsonResponse(org.folio.rest.support.JsonResponse) Test(org.junit.Test)

Example 2 with Period

use of org.folio.rest.jaxrs.model.Period in project mod-circulation-storage by folio-org.

the class LoanPoliciesApiTest method cannotUseRenewalsPeriodForFixedProfile.

@Test
public void cannotUseRenewalsPeriodForFixedProfile() throws Exception {
    DateTime from = DateTime.now().minusMonths(3);
    DateTime to = DateTime.now().plusMonths(3);
    DateTime dueDate = to.plusDays(15);
    IndividualResource fixedDueDateSchedule = createFixedDueDateSchedule("semester fixed policy test", from, to, dueDate);
    LoanPolicyRequestBuilder loanPolicy = emptyPolicy().fixed(fixedDueDateSchedule.getId()).withAlternateFixedDueDateScheduleId(fixedDueDateSchedule.getId()).withName("test").withRenewalPeriod(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("Period in RenewalsPolicy is not allowed for policies with Fixed profile"));
}
Also used : LoanPolicyRequestBuilder(org.folio.rest.support.builders.LoanPolicyRequestBuilder) CompletableFuture(java.util.concurrent.CompletableFuture) org.folio.rest.support.matchers.periodJsonObjectMatcher.matchesPeriod(org.folio.rest.support.matchers.periodJsonObjectMatcher.matchesPeriod) Period(org.folio.rest.jaxrs.model.Period) IndividualResource(org.folio.rest.support.IndividualResource) DateTime(org.joda.time.DateTime) JsonResponse(org.folio.rest.support.JsonResponse) Test(org.junit.Test)

Aggregations

CompletableFuture (java.util.concurrent.CompletableFuture)2 Period (org.folio.rest.jaxrs.model.Period)2 IndividualResource (org.folio.rest.support.IndividualResource)2 JsonResponse (org.folio.rest.support.JsonResponse)2 LoanPolicyRequestBuilder (org.folio.rest.support.builders.LoanPolicyRequestBuilder)2 org.folio.rest.support.matchers.periodJsonObjectMatcher.matchesPeriod (org.folio.rest.support.matchers.periodJsonObjectMatcher.matchesPeriod)2 DateTime (org.joda.time.DateTime)2 Test (org.junit.Test)2