@Test public void testCloseAllNonClosedQuestions() { FragaSvar fragaSvarFromWc = buildFragaSvar(1L, LocalDateTime.now(), LocalDateTime.now()); fragaSvarFromWc.setFrageStallare(FrageStallare.WEBCERT.getKod()); fragaSvarFromWc.setStatus(Status.ANSWERED); FragaSvar fragaSvarFromFk = buildFragaSvar(2L, LocalDateTime.now(), LocalDateTime.now()); fragaSvarFromFk.setFrageStallare(FrageStallare.FORSAKRINGSKASSAN.getKod()); FragaSvar fragaSvarAlreadyClosed = buildFragaSvar(2L, LocalDateTime.now(), LocalDateTime.now()); fragaSvarAlreadyClosed.setStatus(Status.CLOSED); final String intygId = "intygId"; when(fragasvarRepositoryMock.findByIntygsReferensIntygsId(intygId)) .thenReturn(Arrays.asList(fragaSvarFromWc, fragaSvarFromFk, fragaSvarAlreadyClosed)); when(fragasvarRepositoryMock.save(any(FragaSvar.class))).thenAnswer(invocation -> invocation.getArguments()[0]); when(webCertUserService.getUser()).thenReturn(createUser()); service.closeAllNonClosedQuestions(intygId); verify(fragasvarRepositoryMock).findByIntygsReferensIntygsId(intygId); verify(notificationServiceMock).sendNotificationForQAs(INTYG_ID, NotificationEvent.QUESTION_FROM_RECIPIENT_HANDLED); verify(notificationServiceMock).sendNotificationForQAs(INTYG_ID, NotificationEvent.QUESTION_FROM_CARE_WITH_ANSWER_HANDLED); ArgumentCaptor<EventCode> eventCaptor = ArgumentCaptor.forClass(EventCode.class); ArgumentCaptor<String> messageCaptor = ArgumentCaptor.forClass(String.class); verify(certificateEventService, times(2)) .createCertificateEvent(anyString(), anyString(), eventCaptor.capture(), messageCaptor.capture()); assertEquals(EventCode.HANFRFV, eventCaptor.getAllValues().get(0)); assertEquals(NotificationEvent.QUESTION_FROM_CARE_WITH_ANSWER_HANDLED.name(), messageCaptor.getAllValues().get(0)); assertEquals(EventCode.HANFRFM, eventCaptor.getAllValues().get(1)); assertEquals(NotificationEvent.QUESTION_FROM_RECIPIENT_HANDLED.name(), messageCaptor.getAllValues().get(1)); ArgumentCaptor<FragaSvar> fragaSvarCaptor = ArgumentCaptor.forClass(FragaSvar.class); verify(fragasvarRepositoryMock, times(2)).save(fragaSvarCaptor.capture()); assertEquals(Status.CLOSED, fragaSvarCaptor.getAllValues().get(0).getStatus()); assertEquals(Status.CLOSED, fragaSvarCaptor.getAllValues().get(1).getStatus()); verify(arendeDraftService).delete(INTYG_ID, Long.toString(2L)); verifyNoMoreInteractions(arendeDraftService); }
@Override public void closeAllNonClosedQuestions(String intygsId) { List<FragaSvar> list = fragaSvarRepository.findByIntygsReferensIntygsId(intygsId); for (FragaSvar fragaSvar : list) { if (fragaSvar.getStatus() != Status.CLOSED) { closeQuestionAsHandled(fragaSvar); } } }
FragaSvarServiceImpl implements FragaSvarService { @Override public void closeAllNonClosedQuestions(String intygsId) { List<FragaSvar> list = fragaSvarRepository.findByIntygsReferensIntygsId(intygsId); for (FragaSvar fragaSvar : list) { if (fragaSvar.getStatus() != Status.CLOSED) { closeQuestionAsHandled(fragaSvar); } } } }
FragaSvarServiceImpl implements FragaSvarService { @Override public void closeAllNonClosedQuestions(String intygsId) { List<FragaSvar> list = fragaSvarRepository.findByIntygsReferensIntygsId(intygsId); for (FragaSvar fragaSvar : list) { if (fragaSvar.getStatus() != Status.CLOSED) { closeQuestionAsHandled(fragaSvar); } } }  }
FragaSvarServiceImpl implements FragaSvarService { @Override public void closeAllNonClosedQuestions(String intygsId) { List<FragaSvar> list = fragaSvarRepository.findByIntygsReferensIntygsId(intygsId); for (FragaSvar fragaSvar : list) { if (fragaSvar.getStatus() != Status.CLOSED) { closeQuestionAsHandled(fragaSvar); } } }  @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 closeAllNonClosedQuestions(String intygsId) { List<FragaSvar> list = fragaSvarRepository.findByIntygsReferensIntygsId(intygsId); for (FragaSvar fragaSvar : list) { if (fragaSvar.getStatus() != Status.CLOSED) { closeQuestionAsHandled(fragaSvar); } } }  @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);  }