@Test public void testFilterFragaSvarWithEnhetsIdAsParam() { WebCertUser webCertUser = createUser(); List<FragaSvar> queryResults = new ArrayList<>(); queryResults.add(buildFragaSvar(1L, MAY, null)); queryResults.add(buildFragaSvar(2L, MAY, null)); when(fragasvarRepositoryMock.filterFragaSvar(any(Filter.class))).thenReturn(queryResults); when(fragasvarRepositoryMock.filterCountFragaSvar(any(Filter.class))).thenReturn(queryResults.size()); Filter params = new Filter(); params.setEnhetsIds(Collections.singletonList(webCertUser.getValdVardenhet().getId())); QueryFragaSvarResponse response = service.filterFragaSvar(params); verify(fragasvarRepositoryMock).filterFragaSvar(any(Filter.class)); verify(fragasvarRepositoryMock).filterCountFragaSvar(any(Filter.class)); assertNotNull(response); assertEquals(2, response.getResults().size()); }
@Override @Transactional(readOnly = true) public QueryFragaSvarResponse filterFragaSvar(Filter filter) { List<ArendeListItem> results = fragaSvarRepository.filterFragaSvar(filter).stream() .map(ArendeListItemConverter::convert) .filter(Objects::nonNull) .collect(Collectors.toList()); int totalResultsCount = fragaSvarRepository.filterCountFragaSvar(filter); QueryFragaSvarResponse response = new QueryFragaSvarResponse(); response.setResults(results); response.setTotalCount(totalResultsCount); return response; }
FragaSvarServiceImpl implements FragaSvarService { @Override @Transactional(readOnly = true) public QueryFragaSvarResponse filterFragaSvar(Filter filter) { List<ArendeListItem> results = fragaSvarRepository.filterFragaSvar(filter).stream() .map(ArendeListItemConverter::convert) .filter(Objects::nonNull) .collect(Collectors.toList()); int totalResultsCount = fragaSvarRepository.filterCountFragaSvar(filter); QueryFragaSvarResponse response = new QueryFragaSvarResponse(); response.setResults(results); response.setTotalCount(totalResultsCount); return response; } }
FragaSvarServiceImpl implements FragaSvarService { @Override @Transactional(readOnly = true) public QueryFragaSvarResponse filterFragaSvar(Filter filter) { List<ArendeListItem> results = fragaSvarRepository.filterFragaSvar(filter).stream() .map(ArendeListItemConverter::convert) .filter(Objects::nonNull) .collect(Collectors.toList()); int totalResultsCount = fragaSvarRepository.filterCountFragaSvar(filter); QueryFragaSvarResponse response = new QueryFragaSvarResponse(); response.setResults(results); response.setTotalCount(totalResultsCount); return response; }  }
FragaSvarServiceImpl implements FragaSvarService { @Override @Transactional(readOnly = true) public QueryFragaSvarResponse filterFragaSvar(Filter filter) { List<ArendeListItem> results = fragaSvarRepository.filterFragaSvar(filter).stream() .map(ArendeListItemConverter::convert) .filter(Objects::nonNull) .collect(Collectors.toList()); int totalResultsCount = fragaSvarRepository.filterCountFragaSvar(filter); QueryFragaSvarResponse response = new QueryFragaSvarResponse(); response.setResults(results); response.setTotalCount(totalResultsCount); return response; }  @Override FragaSvar processIncomingQuestion(FragaSvar fragaSvar); @Override FragaSvar processIncomingAnswer(Long internId, String svarsText, LocalDateTime svarSigneringsDatum); @Override @Transactional(readOnly = true) List<FragaSvarView> getFragaSvar(String intygId); @Override FragaSvar saveSvar(Long fragaSvarsId, String svarsText); @Override List<FragaSvarView> answerKomplettering(final String intygsId, final String svarsText); @Override FragaSvar saveNewQuestion(String intygId, String typ, Amne amne, String frageText); @Override List<FragaSvar> setVidareBefordrad(final String intygsId); @Override FragaSvar closeQuestionAsHandled(Long frageSvarId); @Override void closeCompletionsAsHandled(String intygId); @Override void closeAllNonClosedQuestions(String intygsId); @Override FragaSvar openQuestionAsUnhandled(Long frageSvarId); @Override @Transactional(readOnly = true) QueryFragaSvarResponse filterFragaSvar(Filter filter); @Override @Transactional(readOnly = true) List<Lakare> getFragaSvarHsaIdByEnhet(String enhetsId); @Override Map<String, Long> getNbrOfUnhandledFragaSvarForCareUnits(List<String> vardenheterIds, Set<String> intygsTyper); }
FragaSvarServiceImpl implements FragaSvarService { @Override @Transactional(readOnly = true) public QueryFragaSvarResponse filterFragaSvar(Filter filter) { List<ArendeListItem> results = fragaSvarRepository.filterFragaSvar(filter).stream() .map(ArendeListItemConverter::convert) .filter(Objects::nonNull) .collect(Collectors.toList()); int totalResultsCount = fragaSvarRepository.filterCountFragaSvar(filter); QueryFragaSvarResponse response = new QueryFragaSvarResponse(); response.setResults(results); response.setTotalCount(totalResultsCount); return response; }  @Override FragaSvar processIncomingQuestion(FragaSvar fragaSvar); @Override FragaSvar processIncomingAnswer(Long internId, String svarsText, LocalDateTime svarSigneringsDatum); @Override @Transactional(readOnly = true) List<FragaSvarView> getFragaSvar(String intygId); @Override FragaSvar saveSvar(Long fragaSvarsId, String svarsText); @Override List<FragaSvarView> answerKomplettering(final String intygsId, final String svarsText); @Override FragaSvar saveNewQuestion(String intygId, String typ, Amne amne, String frageText); @Override List<FragaSvar> setVidareBefordrad(final String intygsId); @Override FragaSvar closeQuestionAsHandled(Long frageSvarId); @Override void closeCompletionsAsHandled(String intygId); @Override void closeAllNonClosedQuestions(String intygsId); @Override FragaSvar openQuestionAsUnhandled(Long frageSvarId); @Override @Transactional(readOnly = true) QueryFragaSvarResponse filterFragaSvar(Filter filter); @Override @Transactional(readOnly = true) List<Lakare> getFragaSvarHsaIdByEnhet(String enhetsId); @Override Map<String, Long> getNbrOfUnhandledFragaSvarForCareUnits(List<String> vardenheterIds, Set<String> intygsTyper);  }