use of api.support.builders.Address in project mod-circulation by folio-org.
the class RequestsAPICreationTests method canCreateARequestToBeFulfilledByDeliveryToAnAddress.
@Test
void canCreateARequestToBeFulfilledByDeliveryToAnAddress() {
final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet(ItemBuilder::available);
final IndividualResource work = addressTypesFixture.work();
final IndividualResource charlotte = usersFixture.charlotte(builder -> builder.withAddress(new Address(work.getId(), "Fake first address line", "Fake second address line", "Fake city", "Fake region", "Fake postal code", "Fake country code")));
final IndividualResource james = usersFixture.james();
checkOutFixture.checkOutByBarcode(smallAngryPlanet, james);
IndividualResource createdRequest = requestsFixture.place(new RequestBuilder().recall().forItem(smallAngryPlanet).deliverToAddress(work.getId()).by(charlotte));
JsonObject representation = createdRequest.getJson();
assertThat(representation.getString("id"), is(not(emptyString())));
assertThat(representation.getString("requestType"), is("Recall"));
assertThat(representation.getString("fulfilmentPreference"), is("Delivery"));
assertThat(representation.getString("deliveryAddressTypeId"), is(work.getId()));
assertThat("Request should have a delivery address", representation.containsKey("deliveryAddress"), is(true));
final JsonObject deliveryAddress = representation.getJsonObject("deliveryAddress");
assertThat(deliveryAddress.getString("addressTypeId"), is(work.getId()));
assertThat(deliveryAddress.getString("addressLine1"), is("Fake first address line"));
assertThat(deliveryAddress.getString("addressLine2"), is("Fake second address line"));
assertThat(deliveryAddress.getString("city"), is("Fake city"));
assertThat(deliveryAddress.getString("region"), is("Fake region"));
assertThat(deliveryAddress.getString("postalCode"), is("Fake postal code"));
assertThat(deliveryAddress.getString("countryId"), is("Fake country code"));
}
use of api.support.builders.Address in project mod-circulation by folio-org.
the class RequestsAPIRetrievalTests method canGetARequestToBeFulfilledByDeliveryToAnAddressById.
@Test
void canGetARequestToBeFulfilledByDeliveryToAnAddressById() {
final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet(ItemBuilder::available);
final IndividualResource workAddressType = addressTypesFixture.work();
final IndividualResource charlotte = usersFixture.charlotte(builder -> builder.withAddress(new Address(workAddressType.getId(), "Fake first address line", "Fake second address line", "Fake city", "Fake region", "Fake postal code", "Fake country code")));
final IndividualResource james = usersFixture.james();
checkOutFixture.checkOutByBarcode(smallAngryPlanet, james);
IndividualResource createdRequest = requestsFixture.place(new RequestBuilder().recall().forItem(smallAngryPlanet).by(charlotte).deliverToAddress(workAddressType.getId()));
JsonObject representation = requestsFixture.getById(createdRequest.getId()).getJson();
assertThat(representation.getString("id"), is(not(emptyString())));
assertThat(representation.getString("requestType"), is("Recall"));
assertThat(representation.getString("fulfilmentPreference"), is("Delivery"));
assertThat(representation.getString("deliveryAddressTypeId"), is(workAddressType.getId()));
assertThat("Request should have a delivery address", representation.containsKey("deliveryAddress"), is(true));
final JsonObject deliveryAddress = representation.getJsonObject("deliveryAddress");
assertThat(deliveryAddress.getString("addressTypeId"), is(workAddressType.getId()));
assertThat(deliveryAddress.getString("addressLine1"), is("Fake first address line"));
assertThat(deliveryAddress.getString("addressLine2"), is("Fake second address line"));
assertThat(deliveryAddress.getString("city"), is("Fake city"));
assertThat(deliveryAddress.getString("region"), is("Fake region"));
assertThat(deliveryAddress.getString("postalCode"), is("Fake postal code"));
assertThat(deliveryAddress.getString("countryId"), is("Fake country code"));
}
use of api.support.builders.Address in project mod-circulation by folio-org.
the class RequestsAPIRetrievalTests method fulfilledByDeliveryIncludesAddressWhenFindingMultipleRequests.
@Test
void fulfilledByDeliveryIncludesAddressWhenFindingMultipleRequests() {
final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource workAddressType = addressTypesFixture.work();
final IndividualResource charlotte = usersFixture.charlotte(builder -> builder.withAddress(new Address(workAddressType.getId(), "Fake first address line", "Fake second address line", "Fake city", "Fake region", "Fake postal code", "Fake country code")));
final IndividualResource james = usersFixture.james();
checkOutFixture.checkOutByBarcode(smallAngryPlanet, james);
requestsFixture.place(new RequestBuilder().recall().forItem(smallAngryPlanet).deliverToAddress(workAddressType.getId()).by(charlotte));
final MultipleJsonRecords allRequests = requestsFixture.getAllRequests();
assertThat(allRequests.size(), is(1));
JsonObject representation = allRequests.getFirst();
assertThat(representation.getString("id"), is(not(emptyString())));
assertThat(representation.getString("requestType"), is("Recall"));
assertThat(representation.getString("fulfilmentPreference"), is("Delivery"));
assertThat(representation.getString("deliveryAddressTypeId"), is(workAddressType.getId()));
assertThat("Request should have a delivery address", representation.containsKey("deliveryAddress"), is(true));
final JsonObject deliveryAddress = representation.getJsonObject("deliveryAddress");
assertThat(deliveryAddress.getString("addressTypeId"), is(workAddressType.getId()));
assertThat(deliveryAddress.getString("addressLine1"), is("Fake first address line"));
assertThat(deliveryAddress.getString("addressLine2"), is("Fake second address line"));
assertThat(deliveryAddress.getString("city"), is("Fake city"));
assertThat(deliveryAddress.getString("region"), is("Fake region"));
assertThat(deliveryAddress.getString("postalCode"), is("Fake postal code"));
assertThat(deliveryAddress.getString("countryId"), is("Fake country code"));
}
use of api.support.builders.Address in project mod-circulation by folio-org.
the class RequestsAPIUpdatingTests method canReplaceAnExistingRequestWithDeliveryAddress.
// TODO: Check does not have pickup service point any more
@Test
void canReplaceAnExistingRequestWithDeliveryAddress() {
final ItemResource temeraire = itemsFixture.basedUponTemeraire();
checkOutFixture.checkOutByBarcode(temeraire);
final IndividualResource workAddressType = addressTypesFixture.work();
final IndividualResource charlotte = usersFixture.charlotte(userBuilder -> userBuilder.withAddress(new Address(workAddressType.getId(), "Fake first address line", "Fake second address line", "Fake city", "Fake region", "Fake postal code", "Fake country code")));
ZonedDateTime requestDate = ZonedDateTime.of(2017, 7, 22, 10, 22, 54, 0, UTC);
final IndividualResource exampleServicePoint = servicePointsFixture.cd1();
IndividualResource createdRequest = requestsClient.create(new RequestBuilder().recall().forItem(temeraire).by(charlotte).withRequestDate(requestDate).fulfilToHoldShelf(exampleServicePoint.getId()));
requestsClient.replace(createdRequest.getId(), RequestBuilder.from(createdRequest).hold().deliverToAddress(workAddressType.getId()));
Response getResponse = requestsClient.getById(createdRequest.getId());
assertThat(String.format("Failed to get request: %s", getResponse.getBody()), getResponse.getStatusCode(), is(HttpURLConnection.HTTP_OK));
JsonObject representation = getResponse.getJson();
assertThat(representation.getString("id"), is(createdRequest.getId()));
assertThat("has information taken from requesting user", representation.containsKey("requester"), is(true));
assertThat("Request should have a delivery address", representation.containsKey("deliveryAddress"), is(true));
final JsonObject deliveryAddress = representation.getJsonObject("deliveryAddress");
assertThat(deliveryAddress.getString("addressTypeId"), is(workAddressType.getId()));
assertThat(deliveryAddress.getString("addressLine1"), is("Fake first address line"));
assertThat(deliveryAddress.getString("addressLine2"), is("Fake second address line"));
assertThat(deliveryAddress.getString("city"), is("Fake city"));
assertThat(deliveryAddress.getString("region"), is("Fake region"));
assertThat(deliveryAddress.getString("postalCode"), is("Fake postal code"));
assertThat(deliveryAddress.getString("countryId"), is("Fake country code"));
}
use of api.support.builders.Address in project mod-circulation by folio-org.
the class CheckInByBarcodeTests method overdueRecallFineShouldBeChargedWhenItemIsOverdueAfterRecall.
@Test
void overdueRecallFineShouldBeChargedWhenItemIsOverdueAfterRecall() {
useFallbackPolicies(loanPoliciesFixture.canCirculateRolling().getId(), requestPoliciesFixture.allowAllRequestPolicy().getId(), noticePoliciesFixture.activeNotice().getId(), overdueFinePoliciesFixture.facultyStandardDoNotCountClosed().getId(), lostItemFeePoliciesFixture.facultyStandard().getId());
final IndividualResource james = usersFixture.james();
final UUID checkInServicePointId = servicePointsFixture.cd1().getId();
final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(item -> item.withPrimaryServicePoint(checkInServicePointId));
final IndividualResource nod = itemsFixture.basedUponNod(item -> item.withPermanentLocation(homeLocation.getId()));
ZonedDateTime checkOutDate = ZonedDateTime.of(2020, 1, 15, 0, 0, 0, 0, UTC);
ZonedDateTime recallRequestExpirationDate = checkOutDate.plusDays(5);
ZonedDateTime checkInDate = checkOutDate.plusDays(10);
mockClockManagerToReturnFixedDateTime(ZonedDateTime.of(2020, 1, 18, 0, 0, 0, 0, UTC));
checkOutFixture.checkOutByBarcode(nod, james, checkOutDate);
Address address = SiriusBlack();
IndividualResource requester = usersFixture.steve(builder -> builder.withAddress(address));
requestsFixture.place(new RequestBuilder().withId(UUID.randomUUID()).open().recall().forItem(nod).by(requester).fulfilToHoldShelf().withRequestExpiration(toLocalDate(recallRequestExpirationDate)).withHoldShelfExpiration(toLocalDate(recallRequestExpirationDate)).withPickupServicePointId(UUID.fromString(homeLocation.getJson().getString("primaryServicePoint"))).withTags(new RequestBuilder.Tags(asList("new", "important"))));
JsonObject servicePointOwner = new JsonObject();
servicePointOwner.put("value", homeLocation.getJson().getString("primaryServicePoint"));
servicePointOwner.put("label", "label");
UUID ownerId = UUID.randomUUID();
feeFineOwnersClient.create(new FeeFineOwnerBuilder().withId(ownerId).withOwner("fee-fine-owner").withServicePointOwner(Collections.singletonList(servicePointOwner)));
UUID feeFineId = UUID.randomUUID();
feeFinesClient.create(new FeeFineBuilder().withId(feeFineId).withFeeFineType("Overdue fine").withOwnerId(ownerId).withAutomatic(true));
CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).on(checkInDate).at(checkInServicePointId));
JsonObject checkedInLoan = checkInResponse.getLoan();
final var createdAccounts = waitAtMost(1, SECONDS).until(accountsClient::getAll, hasSize(1));
mockClockManagerToReturnDefaultDateTime();
JsonObject account = createdAccounts.get(0);
assertThat(account, isValidOverdueFine(checkedInLoan, nod, homeLocation.getJson().getString("name"), ownerId, feeFineId, 10.0));
}
Aggregations