Skip to content

Commit

Permalink
MODFIN-283. Methods renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
SerhiiNosko committed Nov 9, 2023
1 parent f694357 commit d4683af
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ public BudgetExpenseClass buildBudgetExpenseClass(StatusExpenseClass statusExpen
.withStatus(BudgetExpenseClass.Status.fromValue(statusExpenseClass.getStatus().value()));
}

public Future<List<BudgetExpenseClass>> getBudgetExpensesClass(List<String> budgetsIds, RequestContext requestContext) {
return collectResultsOnSuccess(ofSubLists(new ArrayList<>(budgetsIds), MAX_IDS_FOR_GET_RQ).map(ids -> getBudgetExpensesClassByIds(ids, requestContext)).collect(Collectors.toList()))
public Future<List<BudgetExpenseClass>> getBudgetExpenseClasses(List<String> budgetsIds, RequestContext requestContext) {
return collectResultsOnSuccess(ofSubLists(new ArrayList<>(budgetsIds), MAX_IDS_FOR_GET_RQ).map(ids -> getBudgetExpenseClassesByIds(ids, requestContext)).collect(Collectors.toList()))
.map(lists -> lists.stream()
.flatMap(Collection::stream)
.collect(toList()));
}

public Future<List<BudgetExpenseClass>> getBudgetExpensesClassByIds(List<String> ids, RequestContext requestContext) {
public Future<List<BudgetExpenseClass>> getBudgetExpenseClassesByIds(List<String> ids, RequestContext requestContext) {
String budgetId = "budgetId";
String query = convertIdsToCqlQuery(ids, budgetId);
var requestEntry = new RequestEntry(resourcesPath(BUDGET_EXPENSE_CLASSES))
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/folio/services/budget/BudgetService.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public BudgetService(RestClient restClient, BudgetExpenseClassService budgetExpe

public Future<BudgetsCollection> getBudgets(String query, int offset, int limit, RequestContext requestContext) {
var requestEntry = new RequestEntry(resourcesPath(BUDGETS_STORAGE))
.withLimit(limit)
.withOffset(offset)
.withLimit(limit)
.withQuery(query);
return restClient.get(requestEntry.buildEndpoint(), BudgetsCollection.class, requestContext);
}
Expand Down Expand Up @@ -83,7 +83,7 @@ private Future<Void> rollbackBudgetPutIfNeeded(Budget budgetFromStorage, Throwab
if (t == null) {
return succeededFuture(null);
}
return restClient.get(resourceByIdPath(BUDGETS_STORAGE, budgetFromStorage.getId()), Budget.class,requestContext)
return restClient.get(resourceByIdPath(BUDGETS_STORAGE, budgetFromStorage.getId()), Budget.class, requestContext)
.map(latestBudget -> {
budgetFromStorage.setVersion(latestBudget.getVersion());
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public Future<FundCodeExpenseClassesCollection> retrieveFundCodeVsExpenseClasses
.map(Budget::getId)
.collect(Collectors.toList()))
.map(fundCodeExpenseClassesHolder::withBudgetIds)
.compose(holder -> budgetExpenseClassService.getBudgetExpensesClass(holder.getBudgetIds(), requestContext))
.compose(holder -> budgetExpenseClassService.getBudgetExpenseClasses(holder.getBudgetIds(), requestContext))
.map(fundCodeExpenseClassesHolder::withBudgetExpenseClassList)
.compose(holder -> expenseClassService.getExpenseClassesByBudgetIds(holder.getBudgetIds(), requestContext))
.map(fundCodeExpenseClassesHolder::withExpenseClassList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public void testGetBudgetExpensesClass(VertxTestContext vertxTestContext) {
//When
when(restClient.get(anyString(), eq(BudgetExpenseClassCollection.class), any())).thenReturn(succeededFuture(budgetExpenseClassCollection));

var future = budgetExpenseClassService.getBudgetExpensesClass(budgetsIds, requestContextMock);
var future = budgetExpenseClassService.getBudgetExpenseClasses(budgetsIds, requestContextMock);
vertxTestContext.assertComplete(future)
.onComplete(result -> {
var budgetExpenseClassListFrom = result.result();
Expand All @@ -443,7 +443,7 @@ public void testGetBudgetExpensesClassByIds(VertxTestContext vertxTestContext) {
budgetExpenseClassCollection.setBudgetExpenseClasses(budgetExpenseClassList);
//When
when(restClient.get(anyString(), eq(BudgetExpenseClassCollection.class), any())).thenReturn(succeededFuture(budgetExpenseClassCollection));
var future = budgetExpenseClassService.getBudgetExpensesClassByIds(budgetsIds, requestContextMock);
var future = budgetExpenseClassService.getBudgetExpenseClassesByIds(budgetsIds, requestContextMock);
//Then
vertxTestContext.assertComplete(future)
.onComplete(result -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void shouldRetrieveCombinationFundCodeExpClassesWithFiscalYear(VertxTestC
.withStatus(BudgetExpenseClass.Status.ACTIVE);

List<BudgetExpenseClass> budgetExpenseClassList = new ArrayList(Arrays.asList(budgetExpenseClass1, budgetExpenseClass2));
when(budgetExpenseClassService.getBudgetExpensesClass(eq(budgetIds), eq(requestContext)))
when(budgetExpenseClassService.getBudgetExpenseClasses(eq(budgetIds), eq(requestContext)))
.thenReturn(succeededFuture(budgetExpenseClassList));

when(ledgerDetailsService.getCurrentFiscalYear(eq(ledgerId1), eq(requestContext)))
Expand Down Expand Up @@ -389,7 +389,7 @@ public void shouldRetrieveCombinationFundCodeExpClassesWithoutFiscalYear(VertxTe
when(budgetService.getBudgets(anyString(), eq(0), eq(Integer.MAX_VALUE),
eq(requestContext))).thenReturn(succeededFuture(budgetCollection));

when(budgetExpenseClassService.getBudgetExpensesClass(eq(budgetIds), eq(requestContext)))
when(budgetExpenseClassService.getBudgetExpenseClasses(eq(budgetIds), eq(requestContext)))
.thenReturn(succeededFuture(budgetExpenseClassList));

ExpenseClass expenseClass1 = new ExpenseClass()
Expand Down

0 comments on commit d4683af

Please sign in to comment.