use of org.folio.models.ReEncumbranceHolder in project mod-orders by folio-org.
the class ReEncumbranceHoldersBuilderTest method shouldNotPopulateRestrictEncumbranceForReEncumbranceHoldersWithoutLedgerId.
@Test
void shouldNotPopulateRestrictEncumbranceForReEncumbranceHoldersWithoutLedgerId() {
Fund fund1 = new Fund().withId(UUID.randomUUID().toString()).withLedgerId(UUID.randomUUID().toString());
ReEncumbranceHolder holder1 = new ReEncumbranceHolder().withLedgerId(fund1.getLedgerId());
ReEncumbranceHolder holder2 = new ReEncumbranceHolder();
List<ReEncumbranceHolder> holders = Arrays.asList(holder1, holder2);
Ledger ledger1 = new Ledger().withId(fund1.getLedgerId()).withRestrictEncumbrance(true);
when(ledgerService.getLedgersByIds(anyCollection(), any())).thenReturn(CompletableFuture.completedFuture(Collections.singletonList(ledger1)));
List<ReEncumbranceHolder> resultHolders = reEncumbranceHoldersBuilder.withLedgersData(holders, requestContext).join();
assertThat(resultHolders, hasItem(hasProperty("restrictEncumbrance", is(false))));
assertThat(resultHolders, hasItem(hasProperty("restrictEncumbrance", is(true))));
}
use of org.folio.models.ReEncumbranceHolder in project mod-orders by folio-org.
the class ReEncumbranceHoldersBuilderTest method shouldPopulateEachReEncumbranceHolderContainingFundWithCorrespondingLedgerData.
@Test
void shouldPopulateEachReEncumbranceHolderContainingFundWithCorrespondingLedgerData() {
String ledgerId1 = UUID.randomUUID().toString();
String ledgerId2 = UUID.randomUUID().toString();
ReEncumbranceHolder holder1 = new ReEncumbranceHolder().withLedgerId(ledgerId1);
ReEncumbranceHolder holder2 = new ReEncumbranceHolder().withLedgerId(ledgerId2);
List<ReEncumbranceHolder> holders = Arrays.asList(holder1, holder2);
Ledger ledger1 = new Ledger().withId(ledgerId1).withRestrictEncumbrance(true);
Ledger ledger2 = new Ledger().withId(ledgerId2).withRestrictEncumbrance(false);
when(ledgerService.getLedgersByIds(anyCollection(), any())).thenReturn(CompletableFuture.completedFuture(Arrays.asList(ledger1, ledger2)));
reEncumbranceHoldersBuilder.withLedgersData(holders, requestContext).join();
assertTrue(holder1.getRestrictEncumbrance());
assertFalse(holder2.getRestrictEncumbrance());
}
use of org.folio.models.ReEncumbranceHolder in project mod-orders by folio-org.
the class ReEncumbranceHoldersBuilderTest method shouldPopulateCurrentFiscalYearDataForReEncumbranceHoldersIfAnyHolderHasFund.
@Test
void shouldPopulateCurrentFiscalYearDataForReEncumbranceHoldersIfAnyHolderHasFund() {
Fund fund2 = new Fund().withId(UUID.randomUUID().toString()).withLedgerId(UUID.randomUUID().toString());
Fund fund3 = new Fund().withId(UUID.randomUUID().toString()).withLedgerId(UUID.randomUUID().toString());
ReEncumbranceHolder holder1 = new ReEncumbranceHolder();
ReEncumbranceHolder holder2 = new ReEncumbranceHolder().withLedgerId(fund2.getLedgerId());
ReEncumbranceHolder holder3 = new ReEncumbranceHolder().withLedgerId(fund3.getLedgerId());
List<ReEncumbranceHolder> holders = Arrays.asList(holder1, holder2, holder3);
FiscalYear fiscalYear = new FiscalYear().withId(UUID.randomUUID().toString());
when(fiscalYearService.getCurrentFiscalYear(anyString(), any())).thenReturn(CompletableFuture.completedFuture(fiscalYear));
List<ReEncumbranceHolder> resultHolders = reEncumbranceHoldersBuilder.withCurrentFiscalYearData(holders, requestContext).join();
assertThat(resultHolders, everyItem(hasProperty("currentFiscalYearId", is(fiscalYear.getId()))));
assertThat(resultHolders, everyItem(hasProperty("currency", is(fiscalYear.getCurrency()))));
}
use of org.folio.models.ReEncumbranceHolder in project mod-orders by folio-org.
the class ReEncumbranceHoldersBuilderTest method shouldNotRetrieveRolloversIfReEncumbranceHoldersCurrentFundNull.
@Test
void shouldNotRetrieveRolloversIfReEncumbranceHoldersCurrentFundNull() {
ReEncumbranceHolder holder1 = new ReEncumbranceHolder();
List<ReEncumbranceHolder> holders = Collections.singletonList(holder1);
List<ReEncumbranceHolder> resultHolders = reEncumbranceHoldersBuilder.withRollovers(holders, requestContext).join();
assertThat(resultHolders, hasItem(allOf(hasProperty("rollover", nullValue()), hasProperty("ledgerId"))));
assertThat(resultHolders, hasItem(allOf(hasProperty("rollover", nullValue()), hasProperty("ledgerId"))));
verify(rolloverRetrieveService, never()).getLedgerFyRollovers(anyString(), anyList(), any());
}
use of org.folio.models.ReEncumbranceHolder in project mod-orders by folio-org.
the class ReEncumbranceHoldersBuilderTest method shouldPopulateReEncumbranceHoldersWithOngoingSubscriptionEncumbranceRolloverWhenOrderTypeOngoingAndSubscriptionTrue.
@Test
void shouldPopulateReEncumbranceHoldersWithOngoingSubscriptionEncumbranceRolloverWhenOrderTypeOngoingAndSubscriptionTrue() {
EncumbranceRollover oneTimeEncumbranceRollover = new EncumbranceRollover().withBasedOn(EncumbranceRollover.BasedOn.REMAINING).withOrderType(EncumbranceRollover.OrderType.ONE_TIME).withIncreaseBy(10d);
EncumbranceRollover ongoingEncumbranceRollover = new EncumbranceRollover().withBasedOn(EncumbranceRollover.BasedOn.EXPENDED).withOrderType(EncumbranceRollover.OrderType.ONGOING).withIncreaseBy(10d);
EncumbranceRollover subscriptionEncumbranceRollover = new EncumbranceRollover().withBasedOn(EncumbranceRollover.BasedOn.REMAINING).withOrderType(EncumbranceRollover.OrderType.ONGOING_SUBSCRIPTION).withIncreaseBy(10d);
CompositePurchaseOrder compPO = new CompositePurchaseOrder().withOrderType(CompositePurchaseOrder.OrderType.ONGOING).withOngoing(new Ongoing().withIsSubscription(true));
LedgerFiscalYearRollover rollover = new LedgerFiscalYearRollover().withEncumbrancesRollover(Arrays.asList(oneTimeEncumbranceRollover, ongoingEncumbranceRollover, subscriptionEncumbranceRollover));
ReEncumbranceHolder holder1 = new ReEncumbranceHolder().withPurchaseOrder(compPO).withRollover(rollover);
ReEncumbranceHolder holder2 = new ReEncumbranceHolder().withPurchaseOrder(compPO).withRollover(rollover);
List<ReEncumbranceHolder> holders = Arrays.asList(holder1, holder2);
List<ReEncumbranceHolder> resultHolders = reEncumbranceHoldersBuilder.withEncumbranceRollover(holders);
assertThat(resultHolders, everyItem(hasProperty("encumbranceRollover", is(subscriptionEncumbranceRollover))));
}
Aggregations