@Test public void testGetMDByEnhetsIdOK() { String enhetsId = "enhet"; when(webCertUserService.isAuthorizedForUnit(any(String.class), eq(false))).thenReturn(true); List<Object[]> queryResult = new ArrayList<>(); queryResult.add(new Object[]{"HSA-1_ID", "NAMN1"}); queryResult.add(new Object[]{"HSA-2_ID", "NAMN2"}); queryResult.add(new Object[]{"HSA-3_ID", "NAMN3"}); queryResult.add(new Object[]{"HSA-4_ID", "NAMN4"}); when(fragasvarRepositoryMock.findDistinctFragaSvarHsaIdByEnhet(anyList())).thenReturn(queryResult); List<Lakare> result = service.getFragaSvarHsaIdByEnhet(enhetsId); ArgumentCaptor<String> capture = ArgumentCaptor.forClass(String.class); verify(webCertUserService).isAuthorizedForUnit(capture.capture(), eq(false)); verify(fragasvarRepositoryMock).findDistinctFragaSvarHsaIdByEnhet(anyList()); assertEquals(enhetsId, capture.getValue()); assertEquals(4, result.size()); }
@Override @Transactional(readOnly = true) public List<Lakare> getFragaSvarHsaIdByEnhet(String enhetsId) { List<String> enhetsIdParams = new ArrayList<>(); if (enhetsId != null) { verifyEnhetsAuth(enhetsId); enhetsIdParams.add(enhetsId); } else { WebCertUser user = webCertUserService.getUser(); enhetsIdParams.addAll(user.getIdsOfSelectedVardenhet()); } List<Lakare> mdList = new ArrayList<>(); List<Object[]> tempList = fragaSvarRepository.findDistinctFragaSvarHsaIdByEnhet(enhetsIdParams); for (Object[] obj : tempList) { mdList.add(new Lakare((String) obj[0], (String) obj[1])); } return mdList; }
FragaSvarServiceImpl implements FragaSvarService { @Override @Transactional(readOnly = true) public List<Lakare> getFragaSvarHsaIdByEnhet(String enhetsId) { List<String> enhetsIdParams = new ArrayList<>(); if (enhetsId != null) { verifyEnhetsAuth(enhetsId); enhetsIdParams.add(enhetsId); } else { WebCertUser user = webCertUserService.getUser(); enhetsIdParams.addAll(user.getIdsOfSelectedVardenhet()); } List<Lakare> mdList = new ArrayList<>(); List<Object[]> tempList = fragaSvarRepository.findDistinctFragaSvarHsaIdByEnhet(enhetsIdParams); for (Object[] obj : tempList) { mdList.add(new Lakare((String) obj[0], (String) obj[1])); } return mdList; } }
FragaSvarServiceImpl implements FragaSvarService { @Override @Transactional(readOnly = true) public List<Lakare> getFragaSvarHsaIdByEnhet(String enhetsId) { List<String> enhetsIdParams = new ArrayList<>(); if (enhetsId != null) { verifyEnhetsAuth(enhetsId); enhetsIdParams.add(enhetsId); } else { WebCertUser user = webCertUserService.getUser(); enhetsIdParams.addAll(user.getIdsOfSelectedVardenhet()); } List<Lakare> mdList = new ArrayList<>(); List<Object[]> tempList = fragaSvarRepository.findDistinctFragaSvarHsaIdByEnhet(enhetsIdParams); for (Object[] obj : tempList) { mdList.add(new Lakare((String) obj[0], (String) obj[1])); } return mdList; }  }
FragaSvarServiceImpl implements FragaSvarService { @Override @Transactional(readOnly = true) public List<Lakare> getFragaSvarHsaIdByEnhet(String enhetsId) { List<String> enhetsIdParams = new ArrayList<>(); if (enhetsId != null) { verifyEnhetsAuth(enhetsId); enhetsIdParams.add(enhetsId); } else { WebCertUser user = webCertUserService.getUser(); enhetsIdParams.addAll(user.getIdsOfSelectedVardenhet()); } List<Lakare> mdList = new ArrayList<>(); List<Object[]> tempList = fragaSvarRepository.findDistinctFragaSvarHsaIdByEnhet(enhetsIdParams); for (Object[] obj : tempList) { mdList.add(new Lakare((String) obj[0], (String) obj[1])); } return mdList; }  @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 List<Lakare> getFragaSvarHsaIdByEnhet(String enhetsId) { List<String> enhetsIdParams = new ArrayList<>(); if (enhetsId != null) { verifyEnhetsAuth(enhetsId); enhetsIdParams.add(enhetsId); } else { WebCertUser user = webCertUserService.getUser(); enhetsIdParams.addAll(user.getIdsOfSelectedVardenhet()); } List<Lakare> mdList = new ArrayList<>(); List<Object[]> tempList = fragaSvarRepository.findDistinctFragaSvarHsaIdByEnhet(enhetsIdParams); for (Object[] obj : tempList) { mdList.add(new Lakare((String) obj[0], (String) obj[1])); } return mdList; }  @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);  }