Skip to content

Commit

Permalink
Fixed finance_data_view and improved method names
Browse files Browse the repository at this point in the history
  • Loading branch information
azizbekxm committed Nov 29, 2024
1 parent a12f4d0 commit 78f290a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private Future<Void> processFundUpdate(FyFinanceDataCollection entity, DBConn co
.toList();
return fundService.getFundsByIds(fundIds, conn)
.map(funds -> setNewValuesForFunds(funds, entity))
.compose(funds -> fundService.updateFundsWithMinChange(funds, conn));
.compose(funds -> fundService.updateFunds(funds, conn));
}

private Future<Void> processBudgetUpdate(FyFinanceDataCollection entity, DBConn conn) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/folio/service/fund/FundService.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ public interface FundService {
Future<Fund> getFundById(String fundId, DBConn conn);
Future<List<Fund>> getFundsByIds(List<String> ids, DBConn conn);
Future<Void> updateFund(Fund fund, RequestContext requestContext);
Future<Void> updateFundsWithMinChange(List<Fund> fund, DBConn conn);
Future<Void> updateFunds(List<Fund> fund, DBConn conn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Future<Void> updateFund(Fund fund, RequestContext requestContext) {
}

@Override
public Future<Void> updateFundsWithMinChange(List<Fund> funds, DBConn conn) {
public Future<Void> updateFunds(List<Fund> funds, DBConn conn) {
logger.debug("updateFundsWithMinChange:: Trying to update '{}' fund(s) with minimal changes", funds.size());
return fundDAO.updateFunds(funds, conn);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ LEFT OUTER JOIN ${myuniversity}_${mymodule}.fund
LEFT OUTER JOIN ${myuniversity}_${mymodule}.budget
ON fund.id = budget.fundid
LEFT OUTER JOIN ${myuniversity}_${mymodule}.group_fund_fiscal_year
ON fund.id = (group_fund_fiscal_year.jsonb ->> 'fundId')::uuid
ON fund.id = group_fund_fiscal_year.fundid
LEFT OUTER JOIN ${myuniversity}_${mymodule}.groups
ON (group_fund_fiscal_year.jsonb ->> 'groupId')::uuid = groups.id;
ON group_fund_fiscal_year.groupid = groups.id;
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class FinanceDataServiceTest {
private AutoCloseable mockitoMocks;

@BeforeEach
void setUp(Vertx vertx) {
void setUp() {
mockitoMocks = MockitoAnnotations.openMocks(this);
}

Expand Down Expand Up @@ -101,7 +101,7 @@ void shouldFailUpdateWhenFundServiceFails(VertxTestContext testContext) {
testContext.verify(() -> {
assertEquals("Fund service error", error.getMessage());
verify(budgetService, never()).updateBatchBudgets(any(), any());
verify(fundService, never()).updateFundsWithMinChange(any(), any());
verify(fundService, never()).updateFunds(any(), any());
});
testContext.completeNow();
}));
Expand All @@ -115,7 +115,7 @@ private void setupMocks(Fund oldFund, Budget oldBudget) {
}).when(dbClient).withTrans(any());

when(fundService.getFundsByIds(any(), any())).thenReturn(Future.succeededFuture(List.of(oldFund)));
when(fundService.updateFundsWithMinChange(any(), any())).thenReturn(Future.succeededFuture());
when(fundService.updateFunds(any(), any())).thenReturn(Future.succeededFuture());
when(budgetService.getBudgetsByIds(any(), any())).thenReturn(Future.succeededFuture(List.of(oldBudget)));
when(budgetService.updateBatchBudgets(any(), any())).thenReturn(Future.succeededFuture());
}
Expand All @@ -137,7 +137,7 @@ private void verifyFundUpdates(FyFinanceDataCollection collection) {
assertEquals(collection.getFyFinanceData().get(0).getFundId(), fundIdsCaptor.getValue().get(0));

ArgumentCaptor<List<Fund>> fundCaptor = ArgumentCaptor.forClass(List.class);
verify(fundService).updateFundsWithMinChange(fundCaptor.capture(), eq(dbConn));
verify(fundService).updateFunds(fundCaptor.capture(), eq(dbConn));
Fund updatedFund = fundCaptor.getValue().get(0);

assertNotEquals("CODE CHANGED", updatedFund.getCode());
Expand Down

0 comments on commit 78f290a

Please sign in to comment.