use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarServiceImplTest method testOpenAsUnhandledFromFK.
@Test
public void testOpenAsUnhandledFromFK() {
FragaSvar fragaSvar = buildFragaSvar(1L, LocalDateTime.now(), LocalDateTime.now());
fragaSvar.setFrageStallare(FrageStallare.FORSAKRINGSKASSAN.getKod());
fragaSvar.setFrageText("Fråga till WC från FK");
fragaSvar.setStatus(Status.CLOSED);
ArgumentCaptor<FragaSvar> capture = ArgumentCaptor.forClass(FragaSvar.class);
when(fragasvarRepositoryMock.findOne(1L)).thenReturn(fragaSvar);
when(fragasvarRepositoryMock.save(capture.capture())).thenReturn(fragaSvar);
service.openQuestionAsUnhandled(1L);
verify(notificationServiceMock).sendNotificationForQAs(INTYG_ID, NotificationEvent.QUESTION_FROM_RECIPIENT_UNHANDLED);
verify(fragasvarRepositoryMock).findOne(1L);
verify(fragasvarRepositoryMock).save(any(FragaSvar.class));
assertEquals(Status.PENDING_INTERNAL_ACTION, capture.getValue().getStatus());
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarServiceImplTest method testOpenAsUnhandledToFKNoAnsw.
@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.findOne(1L)).thenReturn(fragaSvar);
when(fragasvarRepositoryMock.save(capture.capture())).thenReturn(fragaSvar);
service.openQuestionAsUnhandled(1L);
verify(notificationServiceMock).sendNotificationForQAs(INTYG_ID, NotificationEvent.QUESTION_FROM_CARE_UNHANDLED);
verify(fragasvarRepositoryMock).findOne(1L);
verify(fragasvarRepositoryMock).save(any(FragaSvar.class));
assertEquals(Status.PENDING_EXTERNAL_ACTION, capture.getValue().getStatus());
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarServiceImplTest method testSaveFragaNotSentToFK.
@Test(expected = WebCertServiceException.class)
public void testSaveFragaNotSentToFK() {
FragaSvar fraga = buildFraga(1L, "frageText", Amne.OVRIGT, LocalDateTime.now());
// create mocked Utlatande from intygstjansten
when(intygServiceMock.fetchIntygData(fraga.getIntygsReferens().getIntygsId(), fraga.getIntygsReferens().getIntygsTyp(), false)).thenReturn(getIntygContentHolder());
when(webCertUserService.getUser()).thenReturn(createUser());
// test call
try {
service.saveNewQuestion(fraga.getIntygsReferens().getIntygsId(), fraga.getIntygsReferens().getIntygsTyp(), fraga.getAmne(), fraga.getFrageText());
} finally {
verifyZeroInteractions(fragasvarRepositoryMock);
verifyZeroInteractions(notificationServiceMock);
verifyZeroInteractions(arendeDraftService);
}
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarServiceImplTest method testSaveFragaOnRevokedCertificate.
@Test(expected = WebCertServiceException.class)
public void testSaveFragaOnRevokedCertificate() {
FragaSvar fraga = buildFraga(1L, "frageText", Amne.OVRIGT, LocalDateTime.now());
// create mocked Utlatande from intygstjansten
when(intygServiceMock.fetchIntygData(fraga.getIntygsReferens().getIntygsId(), fraga.getIntygsReferens().getIntygsTyp(), false)).thenReturn(getRevokedIntygContentHolder());
when(webCertUserService.getUser()).thenReturn(createUser());
when(webCertUserService.isAuthorizedForUnit(any(String.class), eq(false))).thenReturn(true);
// test call
try {
service.saveNewQuestion(fraga.getIntygsReferens().getIntygsId(), fraga.getIntygsReferens().getIntygsTyp(), fraga.getAmne(), fraga.getFrageText());
} finally {
verifyZeroInteractions(fragasvarRepositoryMock);
verifyZeroInteractions(notificationServiceMock);
verifyZeroInteractions(arendeDraftService);
}
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarServiceImplTest method testAnswerKomplNotPermitted.
@Test(expected = WebCertServiceException.class)
public void testAnswerKomplNotPermitted() {
FragaSvar fragaSvar = buildFragaSvar(1L, LocalDateTime.now(), LocalDateTime.now());
fragaSvar.setAmne(Amne.KOMPLETTERING_AV_LAKARINTYG);
fragaSvar.setFrageStallare(FrageStallare.FORSAKRINGSKASSAN.getKod());
SendMedicalCertificateAnswerResponseType wsResponse = new SendMedicalCertificateAnswerResponseType();
wsResponse.setResult(ResultOfCallUtil.okResult());
when(webCertUserService.isAuthorizedForUnit(any(String.class), eq(false))).thenReturn(true);
when(fragasvarRepositoryMock.findOne(eq(1L))).thenReturn(fragaSvar);
service.saveSvar(fragaSvar.getInternReferens(), "svarsText");
}
Aggregations