use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansApiTest method canGetALoanById.
@Test
public void canGetALoanById() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
UUID id = UUID.randomUUID();
UUID itemId = UUID.randomUUID();
UUID userId = UUID.randomUUID();
UUID proxyUserId = UUID.randomUUID();
JsonObject loanRequest = new LoanRequestBuilder().withId(id).withItemId(itemId).withUserId(userId).withProxyUserId(proxyUserId).withLoanDate(new DateTime(2016, 10, 15, 8, 26, 53, DateTimeZone.UTC)).open().withAction("checkedout").withItemStatus("Checked out").create();
loansClient.create(loanRequest);
JsonObject loan = loansClient.getById(id).getJson();
assertThat("id does not match", loan.getString("id"), is(id.toString()));
assertThat("user id does not match", loan.getString("userId"), is(userId.toString()));
assertThat("proxy user id does not match", loan.getString("proxyUserId"), is(proxyUserId.toString()));
assertThat("item id does not match", loan.getString("itemId"), is(itemId.toString()));
assertThat("loan date does not match", loan.getString("loanDate"), is("2016-10-15T08:26:53.000Z"));
assertThat("item status is not checked out", loan.getString("itemStatus"), is("Checked out"));
assertThat(loan, isOpen());
}
use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansApiTest method canCreateAnAlreadyClosedLoanWithoutUserId.
@Test
public void canCreateAnAlreadyClosedLoanWithoutUserId() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
UUID id = UUID.randomUUID();
JsonObject loanRequest = new LoanRequestBuilder().withId(id).withNoUserId().closed().create();
final IndividualResource createLoanResponse = loansClient.create(loanRequest);
JsonObject loan = createLoanResponse.getJson();
assertThat(loan, isClosed());
assertThat("should not have a user ID", loan.containsKey("userId"), is(false));
assertCreateEventForLoan(loan);
}
use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansApiTest method canDeleteALoan.
@Test
public void canDeleteALoan() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID id = UUID.randomUUID();
IndividualResource loanResouce = loansClient.create(new LoanRequestBuilder().withId(id).create());
loansClient.deleteById(id);
JsonResponse getResponse = loansClient.attemptGetById(id);
assertThat(getResponse, isNotFound());
JsonObject loan = loanResouce.getJson();
assertCreateEventForLoan(loan);
assertRemoveEventForLoan(loan);
}
use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansApiTest method cannotProvideAdditionalPropertiesInLoanStatus.
@Test
public void cannotProvideAdditionalPropertiesInLoanStatus() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID id = UUID.randomUUID();
JsonObject requestWithAdditionalProperty = new LoanRequestBuilder().withId(id).create();
requestWithAdditionalProperty.getJsonObject("status").put("somethingAdditional", "foo");
JsonResponse response = loansClient.attemptCreate(requestWithAdditionalProperty);
assertThat(response, isValidationResponseWhich(hasMessageContaining("Unrecognized field")));
assertNoLoanEvent(id.toString());
}
use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansApiTest method cannotCreateALoanWithoutAction.
@Test
public void cannotCreateALoanWithoutAction() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
JsonObject loanRequest = new LoanRequestBuilder().create();
loanRequest.remove("action");
JsonResponse response = loansClient.attemptCreate(loanRequest);
assertThat(response, isValidationResponseWhich(allOf(// any server language
anyOf(hasMessage("must not be null"), hasMessage("darf nicht null sein")), hasParameter("action", "null"))));
assertNoLoanEvent(loanRequest.getString("id"));
}
Aggregations