Search in sources :

Example 1 with Address

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"));
}
Also used : ItemBuilder(api.support.builders.ItemBuilder) Address(api.support.builders.Address) MoveRequestBuilder(api.support.builders.MoveRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(api.support.http.IndividualResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 2 with Address

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"));
}
Also used : ItemBuilder(api.support.builders.ItemBuilder) Address(api.support.builders.Address) RequestBuilder(api.support.builders.RequestBuilder) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(api.support.http.IndividualResource) Test(org.junit.jupiter.api.Test)

Example 3 with Address

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"));
}
Also used : MultipleJsonRecords(api.support.MultipleJsonRecords) Address(api.support.builders.Address) RequestBuilder(api.support.builders.RequestBuilder) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(api.support.http.IndividualResource) Test(org.junit.jupiter.api.Test)

Example 4 with Address

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"));
}
Also used : Response(org.folio.circulation.support.http.client.Response) Address(api.support.builders.Address) RequestBuilder(api.support.builders.RequestBuilder) ZonedDateTime(java.time.ZonedDateTime) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(api.support.http.IndividualResource) ItemResource(api.support.http.ItemResource) Test(org.junit.jupiter.api.Test)

Example 5 with Address

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));
}
Also used : Address(api.support.builders.Address) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) JsonObject(io.vertx.core.json.JsonObject) FeeFineBuilder(api.support.builders.FeeFineBuilder) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) CheckInByBarcodeResponse(api.support.CheckInByBarcodeResponse) FeeFineOwnerBuilder(api.support.builders.FeeFineOwnerBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Aggregations

Address (api.support.builders.Address)9 JsonObject (io.vertx.core.json.JsonObject)9 RequestBuilder (api.support.builders.RequestBuilder)8 Test (org.junit.jupiter.api.Test)8 IndividualResource (api.support.http.IndividualResource)7 ZonedDateTime (java.time.ZonedDateTime)5 ItemResource (api.support.http.ItemResource)3 UUID (java.util.UUID)3 CheckInByBarcodeResponse (api.support.CheckInByBarcodeResponse)2 CheckInByBarcodeRequestBuilder (api.support.builders.CheckInByBarcodeRequestBuilder)2 ItemBuilder (api.support.builders.ItemBuilder)2 UserBuilder (api.support.builders.UserBuilder)2 User (org.folio.circulation.domain.User)2 InstanceMapper (org.folio.circulation.storage.mappers.InstanceMapper)2 Response (org.folio.circulation.support.http.client.Response)2 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)2 MultipleJsonRecords (api.support.MultipleJsonRecords)1 FeeFineBuilder (api.support.builders.FeeFineBuilder)1 FeeFineOwnerBuilder (api.support.builders.FeeFineOwnerBuilder)1 MoveRequestBuilder (api.support.builders.MoveRequestBuilder)1