Search in sources :

Example 1 with WebCertServiceException

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

the class ArendeServiceTest method createQuestionInvalidCertificateTypeTest.

@Test
public void createQuestionInvalidCertificateTypeTest() {
    Utkast utkast = new Utkast();
    utkast.setSignatur(new Signatur());
    utkast.setIntygsTyp("fk7263");
    when(utkastRepository.findOne(anyString())).thenReturn(utkast);
    try {
        service.createMessage(INTYG_ID, ArendeAmne.KONTKT, "rubrik", "meddelande");
        fail("should throw exception");
    } catch (WebCertServiceException e) {
        assertEquals(WebCertServiceErrorCodeEnum.INVALID_STATE, 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 2 with WebCertServiceException

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

the class ArendeServiceTest method createQuestionCertificateNotSignedTest.

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

Example 3 with WebCertServiceException

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

the class ArendeServiceTest method testCreateQuestionIfCertificateIsRevoked.

@Test
public void testCreateQuestionIfCertificateIsRevoked() throws WebCertServiceException {
    Utkast utkast = buildUtkast();
    utkast.setAterkalladDatum(LocalDateTime.now());
    when(utkastRepository.findOne(anyString())).thenReturn(utkast);
    try {
        service.createMessage(INTYG_ID, ArendeAmne.KONTKT, "rubrik", "meddelande");
        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) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) Test(org.junit.Test)

Example 4 with WebCertServiceException

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

the class ArendeServiceTest method testProcessIncomingMessageCertificateNotFound.

@Test
public void testProcessIncomingMessageCertificateNotFound() {
    try {
        service.processIncomingMessage(new Arende());
        fail("Should throw");
    } catch (WebCertServiceException e) {
        assertEquals(WebCertServiceErrorCodeEnum.DATA_NOT_FOUND, 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 5 with WebCertServiceException

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

the class ArendeServiceTest method testProcessIncomingMessageCertificateNotSigned.

@Test
public void testProcessIncomingMessageCertificateNotSigned() {
    when(utkastRepository.findOne(isNull())).thenReturn(new Utkast());
    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 : 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