Search in sources :

Example 1 with ExternalServiceCallException

use of se.inera.intyg.common.support.modules.support.api.exception.ExternalServiceCallException in project webcert by sklintyg.

the class CertificateRevokeProcessorTest method testRevokeCertificateOnTransformationErrorResponse.

@Test(expected = PermanentException.class)
public void testRevokeCertificateOnTransformationErrorResponse() throws Exception {
    ModuleApi moduleApi = mock(ModuleApi.class);
    when(registry.getModuleApi(eq(INTYGS_TYP))).thenReturn(moduleApi);
    doThrow(new ExternalServiceCallException("message", ExternalServiceCallException.ErrorIdEnum.TRANSFORMATION_ERROR)).when(moduleApi).revokeCertificate(eq(BODY), eq(LOGICAL_ADDRESS1));
    certificateRevokeProcessor.process(BODY, INTYGS_ID1, LOGICAL_ADDRESS1, INTYGS_TYP);
}
Also used : ModuleApi(se.inera.intyg.common.support.modules.support.api.ModuleApi) ExternalServiceCallException(se.inera.intyg.common.support.modules.support.api.exception.ExternalServiceCallException) Test(org.junit.Test)

Example 2 with ExternalServiceCallException

use of se.inera.intyg.common.support.modules.support.api.exception.ExternalServiceCallException in project webcert by sklintyg.

the class CertificateRevokeProcessorTest method testRevokeCertificateOnValidationErrorResponse.

@Test(expected = PermanentException.class)
public void testRevokeCertificateOnValidationErrorResponse() throws Exception {
    ModuleApi moduleApi = mock(ModuleApi.class);
    when(registry.getModuleApi(eq(INTYGS_TYP))).thenReturn(moduleApi);
    doThrow(new ExternalServiceCallException("message", ExternalServiceCallException.ErrorIdEnum.VALIDATION_ERROR)).when(moduleApi).revokeCertificate(eq(BODY), eq(LOGICAL_ADDRESS1));
    certificateRevokeProcessor.process(BODY, INTYGS_ID1, LOGICAL_ADDRESS1, INTYGS_TYP);
}
Also used : ModuleApi(se.inera.intyg.common.support.modules.support.api.ModuleApi) ExternalServiceCallException(se.inera.intyg.common.support.modules.support.api.exception.ExternalServiceCallException) Test(org.junit.Test)

Example 3 with ExternalServiceCallException

use of se.inera.intyg.common.support.modules.support.api.exception.ExternalServiceCallException in project webcert by sklintyg.

the class CertificateRevokeProcessor method process.

public void process(@Body String xmlBody, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress, @Header(Constants.INTYGS_TYP) String intygsTyp) throws TemporaryException, PermanentException {
    checkArgument(!Strings.isNullOrEmpty(intygsId), "Message of type %s does not have a %s header.", Constants.REVOKE_MESSAGE, Constants.INTYGS_ID);
    checkArgument(!Strings.isNullOrEmpty(logicalAddress), "Message of type %s does not have a %s header.", Constants.REVOKE_MESSAGE, Constants.LOGICAL_ADDRESS);
    checkArgument(!Strings.isNullOrEmpty(intygsTyp), "Message of type %s does not have a %s header.", Constants.REVOKE_MESSAGE, Constants.INTYGS_TYP);
    try {
        ModuleApi moduleApi = registry.getModuleApi(intygsTyp);
        moduleApi.revokeCertificate(xmlBody, logicalAddress);
    } catch (ExternalServiceCallException e) {
        switch(e.getErroIdEnum()) {
            case TECHNICAL_ERROR:
            case APPLICATION_ERROR:
                throw new TemporaryException(e.getMessage());
            default:
                throw new PermanentException(e.getMessage());
        }
    } catch (ModuleException e) {
        throw new PermanentException(e.getMessage());
    } catch (WebServiceException e) {
        throw new TemporaryException(e.getMessage());
    } catch (Exception e) {
        throw new PermanentException(e.getMessage());
    }
}
Also used : ModuleApi(se.inera.intyg.common.support.modules.support.api.ModuleApi) TemporaryException(se.inera.intyg.webcert.common.sender.exception.TemporaryException) WebServiceException(javax.xml.ws.WebServiceException) PermanentException(se.inera.intyg.webcert.common.sender.exception.PermanentException) ModuleException(se.inera.intyg.common.support.modules.support.api.exception.ModuleException) ExternalServiceCallException(se.inera.intyg.common.support.modules.support.api.exception.ExternalServiceCallException) ModuleException(se.inera.intyg.common.support.modules.support.api.exception.ModuleException) TemporaryException(se.inera.intyg.webcert.common.sender.exception.TemporaryException) PermanentException(se.inera.intyg.webcert.common.sender.exception.PermanentException) WebServiceException(javax.xml.ws.WebServiceException) ExternalServiceCallException(se.inera.intyg.common.support.modules.support.api.exception.ExternalServiceCallException)

Example 4 with ExternalServiceCallException

use of se.inera.intyg.common.support.modules.support.api.exception.ExternalServiceCallException in project webcert by sklintyg.

the class CertificateRevokeProcessorTest method testRevokeCertificateOnApplicationErrorResponse.

@Test(expected = TemporaryException.class)
public void testRevokeCertificateOnApplicationErrorResponse() throws Exception {
    ModuleApi moduleApi = mock(ModuleApi.class);
    when(registry.getModuleApi(eq(INTYGS_TYP))).thenReturn(moduleApi);
    doThrow(new ExternalServiceCallException("message", ExternalServiceCallException.ErrorIdEnum.APPLICATION_ERROR)).when(moduleApi).revokeCertificate(eq(BODY), eq(LOGICAL_ADDRESS1));
    certificateRevokeProcessor.process(BODY, INTYGS_ID1, LOGICAL_ADDRESS1, INTYGS_TYP);
}
Also used : ModuleApi(se.inera.intyg.common.support.modules.support.api.ModuleApi) ExternalServiceCallException(se.inera.intyg.common.support.modules.support.api.exception.ExternalServiceCallException) Test(org.junit.Test)

Example 5 with ExternalServiceCallException

use of se.inera.intyg.common.support.modules.support.api.exception.ExternalServiceCallException in project webcert by sklintyg.

the class CertificateRevokeProcessorTest method testRevokeCertificateOnTechnicalErrorResponse.

@Test(expected = TemporaryException.class)
public void testRevokeCertificateOnTechnicalErrorResponse() throws Exception {
    ModuleApi moduleApi = mock(ModuleApi.class);
    when(registry.getModuleApi(eq(INTYGS_TYP))).thenReturn(moduleApi);
    doThrow(new ExternalServiceCallException("message", ExternalServiceCallException.ErrorIdEnum.TECHNICAL_ERROR)).when(moduleApi).revokeCertificate(eq(BODY), eq(LOGICAL_ADDRESS1));
    certificateRevokeProcessor.process(BODY, INTYGS_ID1, LOGICAL_ADDRESS1, INTYGS_TYP);
}
Also used : ModuleApi(se.inera.intyg.common.support.modules.support.api.ModuleApi) ExternalServiceCallException(se.inera.intyg.common.support.modules.support.api.exception.ExternalServiceCallException) Test(org.junit.Test)

Aggregations

ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)5 ExternalServiceCallException (se.inera.intyg.common.support.modules.support.api.exception.ExternalServiceCallException)5 Test (org.junit.Test)4 WebServiceException (javax.xml.ws.WebServiceException)1 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)1 PermanentException (se.inera.intyg.webcert.common.sender.exception.PermanentException)1 TemporaryException (se.inera.intyg.webcert.common.sender.exception.TemporaryException)1