From 78f290a62cb0971bf9e3ad19bed08f813d7fc25c Mon Sep 17 00:00:00 2001 From: Azizbek Khushvakov Date: Fri, 29 Nov 2024 16:30:37 +0500 Subject: [PATCH] Fixed finance_data_view and improved method names --- .../org/folio/service/financedata/FinanceDataService.java | 2 +- src/main/java/org/folio/service/fund/FundService.java | 2 +- .../java/org/folio/service/fund/StorageFundService.java | 2 +- .../templates/db_scripts/all_finance_data_view.sql | 4 ++-- .../service/fianancedata/FinanceDataServiceTest.java | 8 ++++---- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/folio/service/financedata/FinanceDataService.java b/src/main/java/org/folio/service/financedata/FinanceDataService.java index 551ebdd7..66d11a2e 100644 --- a/src/main/java/org/folio/service/financedata/FinanceDataService.java +++ b/src/main/java/org/folio/service/financedata/FinanceDataService.java @@ -52,7 +52,7 @@ private Future 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 processBudgetUpdate(FyFinanceDataCollection entity, DBConn conn) { diff --git a/src/main/java/org/folio/service/fund/FundService.java b/src/main/java/org/folio/service/fund/FundService.java index f5103e22..9988c2f9 100644 --- a/src/main/java/org/folio/service/fund/FundService.java +++ b/src/main/java/org/folio/service/fund/FundService.java @@ -11,5 +11,5 @@ public interface FundService { Future getFundById(String fundId, DBConn conn); Future> getFundsByIds(List ids, DBConn conn); Future updateFund(Fund fund, RequestContext requestContext); - Future updateFundsWithMinChange(List fund, DBConn conn); + Future updateFunds(List fund, DBConn conn); } diff --git a/src/main/java/org/folio/service/fund/StorageFundService.java b/src/main/java/org/folio/service/fund/StorageFundService.java index 843f9c45..eeb757d3 100644 --- a/src/main/java/org/folio/service/fund/StorageFundService.java +++ b/src/main/java/org/folio/service/fund/StorageFundService.java @@ -47,7 +47,7 @@ public Future updateFund(Fund fund, RequestContext requestContext) { } @Override - public Future updateFundsWithMinChange(List funds, DBConn conn) { + public Future updateFunds(List funds, DBConn conn) { logger.debug("updateFundsWithMinChange:: Trying to update '{}' fund(s) with minimal changes", funds.size()); return fundDAO.updateFunds(funds, conn); } diff --git a/src/main/resources/templates/db_scripts/all_finance_data_view.sql b/src/main/resources/templates/db_scripts/all_finance_data_view.sql index 8fabd814..4c6492a9 100644 --- a/src/main/resources/templates/db_scripts/all_finance_data_view.sql +++ b/src/main/resources/templates/db_scripts/all_finance_data_view.sql @@ -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; diff --git a/src/test/java/org/folio/service/fianancedata/FinanceDataServiceTest.java b/src/test/java/org/folio/service/fianancedata/FinanceDataServiceTest.java index da8e2b6a..1887ccef 100644 --- a/src/test/java/org/folio/service/fianancedata/FinanceDataServiceTest.java +++ b/src/test/java/org/folio/service/fianancedata/FinanceDataServiceTest.java @@ -58,7 +58,7 @@ public class FinanceDataServiceTest { private AutoCloseable mockitoMocks; @BeforeEach - void setUp(Vertx vertx) { + void setUp() { mockitoMocks = MockitoAnnotations.openMocks(this); } @@ -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(); })); @@ -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()); } @@ -137,7 +137,7 @@ private void verifyFundUpdates(FyFinanceDataCollection collection) { assertEquals(collection.getFyFinanceData().get(0).getFundId(), fundIdsCaptor.getValue().get(0)); ArgumentCaptor> 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());