use of org.folio.models.ReEncumbranceHolder in project mod-orders by folio-org.
the class ReEncumbranceHoldersBuilderTest method shouldPopulateReEncumbranceHolderFundWithNullIfCorrespondingFundsFound.
@Test
void shouldPopulateReEncumbranceHolderFundWithNullIfCorrespondingFundsFound() {
FundDistribution fundDistribution1 = new FundDistribution().withFundId(UUID.randomUUID().toString());
FundDistribution fundDistribution2 = new FundDistribution().withFundId(UUID.randomUUID().toString());
ReEncumbranceHolder holder1 = new ReEncumbranceHolder().withFundDistribution(fundDistribution1);
ReEncumbranceHolder holder2 = new ReEncumbranceHolder().withFundDistribution(fundDistribution2);
List<ReEncumbranceHolder> holders = Arrays.asList(holder1, holder2);
Fund fund1 = new Fund().withId(fundDistribution1.getFundId()).withLedgerId(UUID.randomUUID().toString());
when(fundService.getFunds(anyCollection(), any())).thenReturn(CompletableFuture.completedFuture(Collections.singletonList(fund1)));
List<ReEncumbranceHolder> resultHolders = reEncumbranceHoldersBuilder.withFundsData(holders, requestContext).join();
assertThat(resultHolders, hasItem(allOf(hasProperty("ledgerId", is(fund1.getLedgerId())), hasProperty("fundDistribution", is(fundDistribution1)))));
assertThat(resultHolders, hasItem(allOf(hasProperty("ledgerId", nullValue()), hasProperty("fundDistribution", is(fundDistribution2)))));
}
use of org.folio.models.ReEncumbranceHolder in project mod-orders by folio-org.
the class ReEncumbranceHoldersBuilderTest method shouldPopulateReEncumbranceHoldersWithOneTimeEncumbranceRolloverWhenOrderTypeOneTime.
@Test
void shouldPopulateReEncumbranceHoldersWithOneTimeEncumbranceRolloverWhenOrderTypeOneTime() {
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.ONE_TIME);
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(oneTimeEncumbranceRollover))));
}
use of org.folio.models.ReEncumbranceHolder in project mod-orders by folio-org.
the class ReEncumbranceHoldersBuilderTest method shouldNotPopulateCurrentFiscalYearForReEncumbranceHoldersIfNoneHolderHasFund.
@Test
void shouldNotPopulateCurrentFiscalYearForReEncumbranceHoldersIfNoneHolderHasFund() {
ReEncumbranceHolder holder1 = new ReEncumbranceHolder();
ReEncumbranceHolder holder2 = new ReEncumbranceHolder();
ReEncumbranceHolder holder3 = new ReEncumbranceHolder();
List<ReEncumbranceHolder> holders = Arrays.asList(holder1, holder2, holder3);
List<ReEncumbranceHolder> resultHolders = reEncumbranceHoldersBuilder.withCurrentFiscalYearData(holders, requestContext).join();
assertThat(resultHolders, everyItem(hasProperty("currentFiscalYearId", nullValue())));
assertThat(resultHolders, everyItem(hasProperty("currency", nullValue())));
verify(fiscalYearService, never()).getCurrentFiscalYear(anyString(), any());
}
use of org.folio.models.ReEncumbranceHolder in project mod-orders by folio-org.
the class ReEncumbranceHoldersBuilderTest method shouldCreateNewReEncumbranceHoldersForEveryFundDistributions.
@Test
void shouldCreateNewReEncumbranceHoldersForEveryFundDistributions() {
FundDistribution fundDistribution1 = new FundDistribution().withFundId(UUID.randomUUID().toString());
FundDistribution fundDistribution2 = new FundDistribution().withFundId(UUID.randomUUID().toString());
CompositePoLine compositePoLine1 = new CompositePoLine().withId(UUID.randomUUID().toString()).withFundDistribution(Arrays.asList(fundDistribution1, fundDistribution2));
CompositePoLine compositePoLine2 = new CompositePoLine().withId(UUID.randomUUID().toString());
CompositePurchaseOrder compPO = new CompositePurchaseOrder().withId(UUID.randomUUID().toString()).withCompositePoLines(Arrays.asList(compositePoLine1, compositePoLine2));
List<ReEncumbranceHolder> resultHolders = reEncumbranceHoldersBuilder.buildReEncumbranceHoldersWithOrdersData(compPO);
assertThat(resultHolders, hasSize(2));
assertThat(resultHolders, everyItem(allOf(hasProperty("purchaseOrder", is(compPO)), hasProperty("poLine", is(compositePoLine1)), hasProperty("fundDistribution", isOneOf(fundDistribution1, fundDistribution2)))));
}
use of org.folio.models.ReEncumbranceHolder in project mod-orders by folio-org.
the class ReEncumbranceHoldersBuilderTest method shouldPopulateReEncumbranceHoldersWithCorrespondingBudgetsForEveryHolderWithLedgerId.
@Test
void shouldPopulateReEncumbranceHoldersWithCorrespondingBudgetsForEveryHolderWithLedgerId() {
Fund fund1 = new Fund().withId(UUID.randomUUID().toString()).withLedgerId(UUID.randomUUID().toString());
Fund fund2 = new Fund().withId(UUID.randomUUID().toString()).withLedgerId(UUID.randomUUID().toString());
FundDistribution distribution1 = new FundDistribution().withFundId(fund1.getId());
FundDistribution distribution2 = new FundDistribution().withFundId(fund2.getId());
FundDistribution distribution3 = new FundDistribution().withFundId(UUID.randomUUID().toString());
ReEncumbranceHolder holder1 = new ReEncumbranceHolder().withLedgerId(fund1.getLedgerId()).withFundDistribution(distribution1);
ReEncumbranceHolder holder2 = new ReEncumbranceHolder().withLedgerId(fund2.getLedgerId()).withFundDistribution(distribution2);
ReEncumbranceHolder holder3 = new ReEncumbranceHolder().withFundDistribution(distribution3);
List<ReEncumbranceHolder> holders = Arrays.asList(holder1, holder2, holder3);
Budget budget1 = new Budget().withId(UUID.randomUUID().toString()).withFundId(fund1.getId());
Budget budget2 = new Budget().withId(UUID.randomUUID().toString()).withFundId(fund2.getId());
when(budgetService.fetchBudgetsByFundIds(anyList(), any())).thenReturn(CompletableFuture.completedFuture(Arrays.asList(budget1, budget2)));
List<ReEncumbranceHolder> resultHolders = reEncumbranceHoldersBuilder.withBudgets(holders, requestContext).join();
assertThat(resultHolders, hasItem(allOf(hasProperty("budget", is(budget1)), hasProperty("ledgerId", is(fund1.getLedgerId())))));
assertThat(resultHolders, hasItem(allOf(hasProperty("budget", is(budget2)), hasProperty("ledgerId", is(fund2.getLedgerId())))));
assertThat(resultHolders, hasItem(allOf(hasProperty("budget", nullValue()), hasProperty("ledgerId", nullValue()))));
}
Aggregations