@Test public void testCloseCompletionsAsHandled() { final String intygId = "intygId"; FragaSvar fragaSvar1 = buildFragaSvar(1L, LocalDateTime.now(), LocalDateTime.now()); fragaSvar1.setAmne(Amne.KOMPLETTERING_AV_LAKARINTYG); fragaSvar1.setFrageStallare(FrageStallare.FORSAKRINGSKASSAN.getKod()); FragaSvar fragaSvar2 = buildFragaSvar(2L, LocalDateTime.now(), LocalDateTime.now()); fragaSvar2.setAmne(Amne.KONTAKT); fragaSvar2.setFrageStallare(FrageStallare.FORSAKRINGSKASSAN.getKod()); FragaSvar fragaSvar3 = buildFragaSvar(3L, LocalDateTime.now(), LocalDateTime.now()); fragaSvar3.setAmne(Amne.KOMPLETTERING_AV_LAKARINTYG); fragaSvar3.setFrageStallare(FrageStallare.FORSAKRINGSKASSAN.getKod()); FragaSvar fragaSvar4 = buildFragaSvar(4L, LocalDateTime.now(), LocalDateTime.now()); fragaSvar4.setAmne(Amne.KOMPLETTERING_AV_LAKARINTYG); fragaSvar4.setStatus(Status.CLOSED); fragaSvar4.setFrageStallare(FrageStallare.FORSAKRINGSKASSAN.getKod()); when(fragasvarRepositoryMock.findByIntygsReferensIntygsId(intygId)) .thenReturn(Arrays.asList(fragaSvar1, fragaSvar2, fragaSvar3, fragaSvar4)); ArgumentCaptor<FragaSvar> fsCapture = ArgumentCaptor.forClass(FragaSvar.class); when(fragasvarRepositoryMock.save(fsCapture.capture())).thenAnswer(invocation -> invocation.getArguments()[0]); when(webCertUserService.getUser()).thenReturn(createUser()); service.closeCompletionsAsHandled(intygId); verify(fragasvarRepositoryMock).findByIntygsReferensIntygsId(intygId); verify(fragasvarRepositoryMock, times(2)).save(any(FragaSvar.class)); assertEquals(fragaSvar1.getInternReferens(), fsCapture.getAllValues().get(0).getInternReferens()); assertEquals(Status.CLOSED, fsCapture.getAllValues().get(0).getStatus()); assertEquals(fragaSvar3.getInternReferens(), fsCapture.getAllValues().get(1).getInternReferens()); assertEquals(Status.CLOSED, fsCapture.getAllValues().get(1).getStatus()); verify(notificationServiceMock, times(2)).sendNotificationForQAs(INTYG_ID, NotificationEvent.QUESTION_FROM_RECIPIENT_HANDLED); verify(certificateEventService, times(2)).createCertificateEvent(anyString(), anyString(), eq(EventCode.HANFRFM), eq(NotificationEvent.QUESTION_FROM_RECIPIENT_HANDLED.name())); verify(arendeDraftService, times(2)).delete(eq(INTYG_ID), anyString()); verifyNoMoreInteractions(arendeDraftService); }
@Override public void closeCompletionsAsHandled(String intygId) { List<FragaSvar> completionFragaSvar = fragaSvarRepository.findByIntygsReferensIntygsId(intygId).stream() .filter(fs -> Amne.KOMPLETTERING_AV_LAKARINTYG == fs.getAmne()).collect(Collectors.toList()); for (FragaSvar completion : completionFragaSvar) { if (Status.CLOSED != completion.getStatus()) { closeQuestionAsHandled(completion); } } }
FragaSvarServiceImpl implements FragaSvarService { @Override public void closeCompletionsAsHandled(String intygId) { List<FragaSvar> completionFragaSvar = fragaSvarRepository.findByIntygsReferensIntygsId(intygId).stream() .filter(fs -> Amne.KOMPLETTERING_AV_LAKARINTYG == fs.getAmne()).collect(Collectors.toList()); for (FragaSvar completion : completionFragaSvar) { if (Status.CLOSED != completion.getStatus()) { closeQuestionAsHandled(completion); } } } }
FragaSvarServiceImpl implements FragaSvarService { @Override public void closeCompletionsAsHandled(String intygId) { List<FragaSvar> completionFragaSvar = fragaSvarRepository.findByIntygsReferensIntygsId(intygId).stream() .filter(fs -> Amne.KOMPLETTERING_AV_LAKARINTYG == fs.getAmne()).collect(Collectors.toList()); for (FragaSvar completion : completionFragaSvar) { if (Status.CLOSED != completion.getStatus()) { closeQuestionAsHandled(completion); } } }  }
FragaSvarServiceImpl implements FragaSvarService { @Override public void closeCompletionsAsHandled(String intygId) { List<FragaSvar> completionFragaSvar = fragaSvarRepository.findByIntygsReferensIntygsId(intygId).stream() .filter(fs -> Amne.KOMPLETTERING_AV_LAKARINTYG == fs.getAmne()).collect(Collectors.toList()); for (FragaSvar completion : completionFragaSvar) { if (Status.CLOSED != completion.getStatus()) { closeQuestionAsHandled(completion); } } }  @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 public void closeCompletionsAsHandled(String intygId) { List<FragaSvar> completionFragaSvar = fragaSvarRepository.findByIntygsReferensIntygsId(intygId).stream() .filter(fs -> Amne.KOMPLETTERING_AV_LAKARINTYG == fs.getAmne()).collect(Collectors.toList()); for (FragaSvar completion : completionFragaSvar) { if (Status.CLOSED != completion.getStatus()) { closeQuestionAsHandled(completion); } } }  @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);  }