Skip to content

Commit

Permalink
#813 | Fix test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
himeshr committed Dec 13, 2024
1 parent a6203e6 commit b6d65cc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils;

import java.math.BigInteger;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -52,7 +53,7 @@ public List<Map<String, Object>> search(SubjectSearchRequest searchRequest, Sear
}

@Transactional
public Long getTotalCount(SubjectSearchRequest searchRequest, SearchBuilder searchBuilder) {
public BigInteger getTotalCount(SubjectSearchRequest searchRequest, SearchBuilder searchBuilder) {
SubjectType subjectType = StringUtils.isEmpty(searchRequest.getSubjectType()) ? null : subjectTypeRepository.findByUuid(searchRequest.getSubjectType());
SqlQuery query = searchBuilder.getSQLCountQuery(searchRequest, subjectType);
try {
Expand All @@ -62,7 +63,7 @@ public Long getTotalCount(SubjectSearchRequest searchRequest, SearchBuilder sear
sql.setParameter(name, value);
});

return (Long) sql.getSingleResult();
return (BigInteger) sql.getSingleResult();
} finally {
setRoleBackToUser();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigInteger;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
Expand Down Expand Up @@ -40,7 +41,7 @@ public LinkedHashMap<String, Object> search(SubjectSearchRequest subjectSearchRe
return constructIndividual(searchResults,totalCount);
}

private LinkedHashMap<String, Object> constructIndividual(List<Map<String, Object>> individualList,BigInteger totalCount) {
private LinkedHashMap<String, Object> constructIndividual(List<Map<String, Object>> individualList, BigInteger totalCount) {
LinkedHashMap<String, Object> recordsMap = new LinkedHashMap<String, Object>();
List<Long> individualIds = individualList.stream()
.map(individualRecord -> Long.valueOf((Integer) individualRecord.get("id")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
import org.springframework.stereotype.Service;

import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -123,7 +124,7 @@ public LinkedHashMap<String, Object> searchSubjects(SubjectSearchRequest subject
searchResult.put("addressLevel", titleLineages.get((Long) searchResult.get("addressId")));
}

Long totalCount = subjectSearchRepository.getTotalCount(subjectSearchRequest, new SubjectAssignmentSearchQueryBuilder());
BigInteger totalCount = subjectSearchRepository.getTotalCount(subjectSearchRequest, new SubjectAssignmentSearchQueryBuilder());

LinkedHashMap<String, Object> recordsMap = new LinkedHashMap<>();
recordsMap.put("totalElements", totalCount);
Expand Down

0 comments on commit b6d65cc

Please sign in to comment.