Skip to content

Commit

Permalink
added null check and fixed sonar issue
Browse files Browse the repository at this point in the history
  • Loading branch information
azizbekxm committed Nov 28, 2024
1 parent 27fbd10 commit 726bbeb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;

import io.vertx.core.Future;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.folio.okapi.common.GenericCompositeFuture;
Expand All @@ -30,6 +31,9 @@ public FinanceDataService(FundService fundService, BudgetService budgetService)
}

public Future<Void> update(FyFinanceDataCollection entity, RequestContext requestContext) {
if (CollectionUtils.isEmpty(entity.getFyFinanceData())) {
return Future.succeededFuture();
}
var dbClient = requestContext.toDBClient();
return dbClient
.withTrans(conn -> {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/folio/service/fund/StorageFundService.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ public Future<List<Fund>> getFundsByIds(List<String> ids, DBConn conn) {

@Override
public Future<Void> updateFund(Fund fund, RequestContext requestContext) {
logger.debug("Trying to update fund '{}'", fund.getId());
var dbClient = requestContext.toDBClient();
return dbClient.withTrans(conn ->
fundDAO.isFundStatusChanged(fund, conn)
.compose(statusChanged -> {
if (Boolean.TRUE.equals(statusChanged)) {
logger.info("updateFund:: Fund '{}' status has been changed to '{}'", fund.getId(), fund.getFundStatus());
return fundDAO.updateRelatedCurrentFYBudgets(fund, conn)
.compose(v -> fundDAO.updateFund(fund, conn));
}
Expand All @@ -46,6 +48,7 @@ public Future<Void> updateFund(Fund fund, RequestContext requestContext) {

@Override
public Future<Void> updateFundsWithMinChange(List<Fund> funds, DBConn conn) {
logger.debug("updateFundsWithMinChange:: Trying to update '{}' fund(s) with minimal changes", funds.size());
return fundDAO.updateFunds(funds, conn);
}
}
2 changes: 1 addition & 1 deletion src/test/java/org/folio/rest/impl/TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void testFetchingUpdatedEntity(String id, TestEntities subObject) {
.path(subObject.getUpdatedFieldName());

// Get string value of updated field and compare
assertThat(String.valueOf(prop), equalTo(subObject.getUpdatedFieldValue()));
assertEquals(String.valueOf(prop), subObject.getUpdatedFieldValue());
}

Response testEntitySuccessfullyFetched(String endpoint, String id) {
Expand Down

0 comments on commit 726bbeb

Please sign in to comment.