Search in sources :

Example 1 with SendMessageToCareResponseType

use of se.riv.clinicalprocess.healthcond.certificate.sendMessageToCare.v2.SendMessageToCareResponseType in project webcert by sklintyg.

the class SendMessageToCareResponderImplTest method testSendRequestToService.

@Test
public void testSendRequestToService() throws WebCertServiceException {
    when(arendeService.processIncomingMessage(any())).thenReturn(new Arende());
    SendMessageToCareResponseType response = responder.sendMessageToCare(DEFAULT_LOGICAL_ADDRESS, createNewRequest());
    assertNotNull(response.getResult());
    assertEquals(response.getResult().getResultCode(), ResultCodeType.OK);
}
Also used : SendMessageToCareResponseType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToCare.v2.SendMessageToCareResponseType) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) Test(org.junit.Test)

Example 2 with SendMessageToCareResponseType

use of se.riv.clinicalprocess.healthcond.certificate.sendMessageToCare.v2.SendMessageToCareResponseType in project webcert by sklintyg.

the class SendMessageToCareResponderImplTest method testSendRequestToServiceFailedNotFound.

@Test
public void testSendRequestToServiceFailedNotFound() throws WebCertServiceException {
    when(arendeService.processIncomingMessage(any())).thenThrow(new WebCertServiceException(WebCertServiceErrorCodeEnum.DATA_NOT_FOUND, ""));
    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 3 with SendMessageToCareResponseType

use of se.riv.clinicalprocess.healthcond.certificate.sendMessageToCare.v2.SendMessageToCareResponseType in project webcert by sklintyg.

the class SendMessageToCareResponderImplTest method testSendRequestToServiceFailedNotSigned.

@Test
public void testSendRequestToServiceFailedNotSigned() throws WebCertServiceException {
    when(arendeService.processIncomingMessage(any())).thenThrow(new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, ""));
    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 4 with SendMessageToCareResponseType

use of se.riv.clinicalprocess.healthcond.certificate.sendMessageToCare.v2.SendMessageToCareResponseType in project webcert by sklintyg.

the class SendMessageToCareResponderImpl method sendMessageToCare.

@Override
public SendMessageToCareResponseType sendMessageToCare(String logicalAddress, SendMessageToCareType request) {
    LOG.debug("Received new message to care");
    SendMessageToCareResponseType response = new SendMessageToCareResponseType();
    ResultType result = new ResultType();
    try {
        arendeService.processIncomingMessage(ArendeConverter.convert(request));
        result.setResultCode(ResultCodeType.OK);
    } catch (WebCertServiceException e) {
        result.setResultCode(ResultCodeType.ERROR);
        switch(e.getErrorCode()) {
            case INVALID_STATE:
            case DATA_NOT_FOUND:
            case EXTERNAL_SYSTEM_PROBLEM:
                result.setErrorId(ErrorIdType.VALIDATION_ERROR);
                result.setResultText(e.getMessage());
                LOG.warn("{}: {}", e.getErrorCode().name(), e.getMessage());
                break;
            default:
                result.setErrorId(ErrorIdType.APPLICATION_ERROR);
                result.setResultText(e.getMessage());
                LOG.error("Could not process incoming message to care. Cause is: {}", e.getMessage());
                break;
        }
    }
    response.setResult(result);
    return response;
}
Also used : SendMessageToCareResponseType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToCare.v2.SendMessageToCareResponseType) ResultType(se.riv.clinicalprocess.healthcond.certificate.v3.ResultType) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Example 5 with SendMessageToCareResponseType

use of se.riv.clinicalprocess.healthcond.certificate.sendMessageToCare.v2.SendMessageToCareResponseType in project webcert by sklintyg.

the class SendMessageToCareResponderImplTest method testSendRequestToServiceFailed.

@Test
public void testSendRequestToServiceFailed() throws WebCertServiceException {
    when(arendeService.processIncomingMessage(any())).thenThrow(new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, ""));
    SendMessageToCareResponseType response = responder.sendMessageToCare(DEFAULT_LOGICAL_ADDRESS, createNewRequest());
    assertNotNull(response.getResult());
    assertEquals(ResultCodeType.ERROR, response.getResult().getResultCode());
    assertEquals(ErrorIdType.APPLICATION_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)

Aggregations

SendMessageToCareResponseType (se.riv.clinicalprocess.healthcond.certificate.sendMessageToCare.v2.SendMessageToCareResponseType)6 Test (org.junit.Test)5 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)5 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)1 ResultType (se.riv.clinicalprocess.healthcond.certificate.v3.ResultType)1