use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarServiceImplTest method testSaveSvarForPaminnelse.
@Test(expected = WebCertServiceException.class)
public void testSaveSvarForPaminnelse() {
FragaSvar fragaSvar = buildFragaSvar(1L, LocalDateTime.now(), LocalDateTime.now());
fragaSvar.setAmne(Amne.PAMINNELSE);
when(fragasvarRepositoryMock.findOne(1L)).thenReturn(fragaSvar);
try {
service.saveSvar(1L, "svarsText");
} finally {
verify(fragasvarRepositoryMock, never()).save(any(FragaSvar.class));
verifyZeroInteractions(notificationServiceMock);
}
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarServiceImplTest method testSaveSvarWsHTMLError.
@Test(expected = WebCertServiceException.class)
public void testSaveSvarWsHTMLError() throws Exception {
FragaSvar fragaSvar = buildFragaSvar(1L, LocalDateTime.now(), LocalDateTime.now());
when(webCertUserService.getUser()).thenReturn(createUser());
when(fragasvarRepositoryMock.findOne(1L)).thenReturn(fragaSvar);
when(webCertUserService.getUser()).thenReturn(createUser());
when(webCertUserService.isAuthorizedForUnit(any(String.class), eq(false))).thenReturn(true);
when(fragasvarRepositoryMock.save(fragaSvar)).thenReturn(fragaSvar);
// mock error with content type html
SOAPFault soapFault = SOAPFactory.newInstance().createFault();
soapFault.setFaultString("Response was of unexpected text/html ContentType.");
when(sendAnswerToFKClientMock.sendMedicalCertificateAnswer(any(AttributedURIType.class), any(SendMedicalCertificateAnswerType.class))).thenThrow(new SOAPFaultException(soapFault));
try {
service.saveSvar(1L, "svarsText");
} finally {
verifyZeroInteractions(notificationServiceMock);
}
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarServiceImplTest method testCloseAllNonClosedQuestions.
@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]);
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<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);
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarConverterTest method testConvertQuestion.
@Test
public void testConvertQuestion() throws Exception {
FragaSvar fragaSvar = new FragaSvarConverter().convert(question("FragaSvarConverterTest/question.xml"));
compareObjectWithReferenceFile(fragaSvar, "FragaSvarConverterTest/question.json");
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarConverterTest method testConvertQuestionLongMeddelandeRubrik.
@Test
public void testConvertQuestionLongMeddelandeRubrik() throws Exception {
FragaSvar fragaSvar = new FragaSvarConverter().convert(question("FragaSvarConverterTest/question_long_meddelande_rubrik.xml"));
compareObjectWithReferenceFile(fragaSvar, "FragaSvarConverterTest/question_long_meddelande_rubrik.json");
}
Aggregations