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());
}
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());
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations