@Test public void testOpenAsUnhandledToFKNoAnsw() { FragaSvar fragaSvar = buildFragaSvar(1L, LocalDateTime.now(), LocalDateTime.now()); fragaSvar.setFrageStallare(FrageStallare.WEBCERT.getKod()); fragaSvar.setFrageText("Fråga till FK från WC"); fragaSvar.setStatus(Status.CLOSED); ArgumentCaptor<FragaSvar> capture = ArgumentCaptor.forClass(FragaSvar.class); when(fragasvarRepositoryMock.findById(1L)).thenReturn(Optional.of(fragaSvar)); when(fragasvarRepositoryMock.save(capture.capture())).thenReturn(fragaSvar); when(webCertUserService.getUser()).thenReturn(createUser()); service.openQuestionAsUnhandled(1L); verify(notificationServiceMock).sendNotificationForQAs(INTYG_ID, NotificationEvent.QUESTION_FROM_CARE_UNHANDLED); verify(fragasvarRepositoryMock).findById(1L); verify(fragasvarRepositoryMock).save(any(FragaSvar.class)); verify(certificateEventService).createCertificateEvent(anyString(), anyString(), eq(EventCode.HANFRFV), eq(NotificationEvent.QUESTION_FROM_CARE_UNHANDLED.name())); assertEquals(Status.PENDING_EXTERNAL_ACTION, capture.getValue().getStatus()); }
@Override public FragaSvar openQuestionAsUnhandled(Long frageSvarId) { FragaSvar fragaSvar = lookupFragaSvar(frageSvarId); if (!FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare()) && !Strings.isNullOrEmpty(fragaSvar.getSvarsText())) { throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "FS-011: Cant revert status for question " + frageSvarId); } NotificationEvent notificationEvent = determineNotificationEvent(fragaSvar); EventCode eventCode = determineEventCode(fragaSvar); if (!Strings.isNullOrEmpty(fragaSvar.getSvarsText())) { fragaSvar.setStatus(Status.ANSWERED); } else { if (FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare())) { fragaSvar.setStatus(Status.PENDING_EXTERNAL_ACTION); } else { fragaSvar.setStatus(Status.PENDING_INTERNAL_ACTION); } } FragaSvar openedFragaSvar = fragaSvarRepository.save(fragaSvar); sendNotification(openedFragaSvar, notificationEvent); certificateEventService .createCertificateEvent(fragaSvar.getIntygsReferens().getIntygsId(), webCertUserService.getUser().getHsaId(), eventCode, notificationEvent.name()); return openedFragaSvar; }
FragaSvarServiceImpl implements FragaSvarService { @Override public FragaSvar openQuestionAsUnhandled(Long frageSvarId) { FragaSvar fragaSvar = lookupFragaSvar(frageSvarId); if (!FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare()) && !Strings.isNullOrEmpty(fragaSvar.getSvarsText())) { throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "FS-011: Cant revert status for question " + frageSvarId); } NotificationEvent notificationEvent = determineNotificationEvent(fragaSvar); EventCode eventCode = determineEventCode(fragaSvar); if (!Strings.isNullOrEmpty(fragaSvar.getSvarsText())) { fragaSvar.setStatus(Status.ANSWERED); } else { if (FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare())) { fragaSvar.setStatus(Status.PENDING_EXTERNAL_ACTION); } else { fragaSvar.setStatus(Status.PENDING_INTERNAL_ACTION); } } FragaSvar openedFragaSvar = fragaSvarRepository.save(fragaSvar); sendNotification(openedFragaSvar, notificationEvent); certificateEventService .createCertificateEvent(fragaSvar.getIntygsReferens().getIntygsId(), webCertUserService.getUser().getHsaId(), eventCode, notificationEvent.name()); return openedFragaSvar; } }
FragaSvarServiceImpl implements FragaSvarService { @Override public FragaSvar openQuestionAsUnhandled(Long frageSvarId) { FragaSvar fragaSvar = lookupFragaSvar(frageSvarId); if (!FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare()) && !Strings.isNullOrEmpty(fragaSvar.getSvarsText())) { throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "FS-011: Cant revert status for question " + frageSvarId); } NotificationEvent notificationEvent = determineNotificationEvent(fragaSvar); EventCode eventCode = determineEventCode(fragaSvar); if (!Strings.isNullOrEmpty(fragaSvar.getSvarsText())) { fragaSvar.setStatus(Status.ANSWERED); } else { if (FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare())) { fragaSvar.setStatus(Status.PENDING_EXTERNAL_ACTION); } else { fragaSvar.setStatus(Status.PENDING_INTERNAL_ACTION); } } FragaSvar openedFragaSvar = fragaSvarRepository.save(fragaSvar); sendNotification(openedFragaSvar, notificationEvent); certificateEventService .createCertificateEvent(fragaSvar.getIntygsReferens().getIntygsId(), webCertUserService.getUser().getHsaId(), eventCode, notificationEvent.name()); return openedFragaSvar; }  }
FragaSvarServiceImpl implements FragaSvarService { @Override public FragaSvar openQuestionAsUnhandled(Long frageSvarId) { FragaSvar fragaSvar = lookupFragaSvar(frageSvarId); if (!FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare()) && !Strings.isNullOrEmpty(fragaSvar.getSvarsText())) { throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "FS-011: Cant revert status for question " + frageSvarId); } NotificationEvent notificationEvent = determineNotificationEvent(fragaSvar); EventCode eventCode = determineEventCode(fragaSvar); if (!Strings.isNullOrEmpty(fragaSvar.getSvarsText())) { fragaSvar.setStatus(Status.ANSWERED); } else { if (FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare())) { fragaSvar.setStatus(Status.PENDING_EXTERNAL_ACTION); } else { fragaSvar.setStatus(Status.PENDING_INTERNAL_ACTION); } } FragaSvar openedFragaSvar = fragaSvarRepository.save(fragaSvar); sendNotification(openedFragaSvar, notificationEvent); certificateEventService .createCertificateEvent(fragaSvar.getIntygsReferens().getIntygsId(), webCertUserService.getUser().getHsaId(), eventCode, notificationEvent.name()); return openedFragaSvar; }  @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 FragaSvar openQuestionAsUnhandled(Long frageSvarId) { FragaSvar fragaSvar = lookupFragaSvar(frageSvarId); if (!FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare()) && !Strings.isNullOrEmpty(fragaSvar.getSvarsText())) { throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "FS-011: Cant revert status for question " + frageSvarId); } NotificationEvent notificationEvent = determineNotificationEvent(fragaSvar); EventCode eventCode = determineEventCode(fragaSvar); if (!Strings.isNullOrEmpty(fragaSvar.getSvarsText())) { fragaSvar.setStatus(Status.ANSWERED); } else { if (FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare())) { fragaSvar.setStatus(Status.PENDING_EXTERNAL_ACTION); } else { fragaSvar.setStatus(Status.PENDING_INTERNAL_ACTION); } } FragaSvar openedFragaSvar = fragaSvarRepository.save(fragaSvar); sendNotification(openedFragaSvar, notificationEvent); certificateEventService .createCertificateEvent(fragaSvar.getIntygsReferens().getIntygsId(), webCertUserService.getUser().getHsaId(), eventCode, notificationEvent.name()); return openedFragaSvar; }  @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);  }