Search in sources :

Example 21 with FragaSvar

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());
}
Also used : FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) Test(org.junit.Test)

Example 22 with FragaSvar

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());
}
Also used : FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) Test(org.junit.Test)

Example 23 with FragaSvar

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);
    }
}
Also used : FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) Test(org.junit.Test)

Example 24 with FragaSvar

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);
    }
}
Also used : FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 25 with FragaSvar

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");
}
Also used : SendMedicalCertificateAnswerResponseType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

FragaSvar (se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar)71 Test (org.junit.Test)42 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)14 IntygsReferens (se.inera.intyg.webcert.persistence.fragasvar.model.IntygsReferens)11 Vardperson (se.inera.intyg.webcert.persistence.fragasvar.model.Vardperson)11 Produces (javax.ws.rs.Produces)7 AttributedURIType (org.w3.wsaddressing10.AttributedURIType)7 Path (javax.ws.rs.Path)6 Filter (se.inera.intyg.webcert.persistence.model.Filter)6 LocalDateTime (java.time.LocalDateTime)5 Consumes (javax.ws.rs.Consumes)5 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)5 ArendeListItem (se.inera.intyg.webcert.web.web.controller.api.dto.ArendeListItem)5 ArrayList (java.util.ArrayList)4 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)4 SendMedicalCertificateAnswerResponseType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType)4 SendMedicalCertificateAnswerType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerType)4 SendMedicalCertificateQuestionType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificatequestionresponder.v1.SendMedicalCertificateQuestionType)4 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)4 Amne (se.inera.intyg.webcert.persistence.fragasvar.model.Amne)4