Search in sources :

Example 71 with WebCertServiceException

use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.

the class SendMessageToCareResponderImplTest method testSendRequestToServiceFailedExternalServiceProblem.

@Test
public void testSendRequestToServiceFailedExternalServiceProblem() throws WebCertServiceException {
    when(arendeService.processIncomingMessage(any())).thenThrow(new WebCertServiceException(WebCertServiceErrorCodeEnum.EXTERNAL_SYSTEM_PROBLEM, ""));
    SendMessageToCareResponseType response = responder.sendMessageToCare(DEFAULT_LOGICAL_ADDRESS, createNewRequest());
    assertNotNull(response.getResult());
    assertEquals(ResultCodeType.ERROR, response.getResult().getResultCode());
    assertEquals(ErrorIdType.VALIDATION_ERROR, response.getResult().getErrorId());
}
Also used : SendMessageToCareResponseType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToCare.v2.SendMessageToCareResponseType) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) Test(org.junit.Test)

Example 72 with WebCertServiceException

use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.

the class ArendeConverterTest method testDecorateArendeFromUtkastHsaNotGivingName.

@Test
public void testDecorateArendeFromUtkastHsaNotGivingName() {
    Utkast utkast = new Utkast();
    utkast.setIntygsTyp("intygstyp");
    utkast.setEnhetsId("enhetsid");
    utkast.setSignatur(mock(Signatur.class));
    when(utkast.getSignatur().getSigneradAv()).thenReturn("signeratav");
    when(hsaEmployeeService.getEmployee(anyString(), eq(null))).thenReturn(createHsaResponse(null, null));
    try {
        ArendeConverter.decorateArendeFromUtkast(new Arende(), utkast, LocalDateTime.now(), hsaEmployeeService);
        fail("Should throw");
    } catch (WebCertServiceException e) {
        assertEquals(WebCertServiceErrorCodeEnum.DATA_NOT_FOUND, e.getErrorCode());
    }
}
Also used : Signatur(se.inera.intyg.webcert.persistence.utkast.model.Signatur) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) Test(org.junit.Test)

Example 73 with WebCertServiceException

use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.

the class ArendeServiceTest method createQuestionUnauthorizedTest.

@Test
public void createQuestionUnauthorizedTest() {
    Utkast utkast = new Utkast();
    utkast.setSignatur(new Signatur());
    when(utkastRepository.findOne(anyString())).thenReturn(utkast);
    try {
        service.createMessage(INTYG_ID, ArendeAmne.KONTKT, "rubrik", "meddelande");
        fail("should throw exception");
    } catch (WebCertServiceException e) {
        assertEquals(WebCertServiceErrorCodeEnum.AUTHORIZATION_PROBLEM, e.getErrorCode());
        verifyZeroInteractions(arendeRepository);
        verifyZeroInteractions(notificationService);
        verifyZeroInteractions(arendeDraftService);
    }
}
Also used : Signatur(se.inera.intyg.webcert.persistence.utkast.model.Signatur) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) Test(org.junit.Test)

Example 74 with WebCertServiceException

use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.

the class ArendeServiceTest method testProcessIncomingMessageMEDDELANDE_IDNotUnique.

@Test
public void testProcessIncomingMessageMEDDELANDE_IDNotUnique() {
    when(arendeRepository.findOneByMeddelandeId(isNull())).thenReturn(new Arende());
    try {
        service.processIncomingMessage(new Arende());
        fail("Should throw");
    } catch (WebCertServiceException e) {
        assertEquals(WebCertServiceErrorCodeEnum.INVALID_STATE, e.getErrorCode());
        verify(arendeRepository, never()).save(any(Arende.class));
        verifyZeroInteractions(notificationService);
        verifyZeroInteractions(arendeDraftService);
    }
}
Also used : MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) Test(org.junit.Test)

Example 75 with WebCertServiceException

use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.

the class ArendeServiceTest method testProcessIncomingMessageThrowsExceptionIfCertificateIsRevoked.

@Test
public void testProcessIncomingMessageThrowsExceptionIfCertificateIsRevoked() throws WebCertServiceException {
    Utkast utkast = buildUtkast();
    utkast.setAterkalladDatum(LocalDateTime.now());
    when(utkastRepository.findOne(isNull())).thenReturn(utkast);
    try {
        service.processIncomingMessage(new Arende());
        fail("Should throw");
    } catch (WebCertServiceException e) {
        assertEquals(WebCertServiceErrorCodeEnum.CERTIFICATE_REVOKED, e.getErrorCode());
        verify(arendeRepository, never()).save(any(Arende.class));
        verifyZeroInteractions(notificationService);
        verifyZeroInteractions(arendeDraftService);
    }
}
Also used : Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) Test(org.junit.Test)

Aggregations

WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)85 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)35 Test (org.junit.Test)16 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)16 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)14 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)14 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)13 OptimisticLockException (javax.persistence.OptimisticLockException)12 MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)11 Personnummer (se.inera.intyg.schemas.contract.Personnummer)10 SignaturTicket (se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket)10 Path (javax.ws.rs.Path)9 Produces (javax.ws.rs.Produces)9 SekretessStatus (se.inera.intyg.webcert.common.model.SekretessStatus)9 OptimisticLockingFailureException (org.springframework.dao.OptimisticLockingFailureException)7 Transactional (org.springframework.transaction.annotation.Transactional)7 POST (javax.ws.rs.POST)6 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)6 Signatur (se.inera.intyg.webcert.persistence.utkast.model.Signatur)6 LocalDateTime (java.time.LocalDateTime)5