Search in sources :

Example 31 with WebServiceException

use of javax.xml.ws.WebServiceException in project webcert by sklintyg.

the class SendMessageToRecipientProcessorTest method processWebServiceExceptionTest.

@Test(expected = TemporaryException.class)
public void processWebServiceExceptionTest() throws Exception {
    when(sendMessageToRecipientResponder.sendMessageToRecipient(anyString(), any(SendMessageToRecipientType.class))).thenThrow(new WebServiceException());
    sendMessageProcessor.process(XML_BODY, INTYG_ID, LOGICAL_ADDRESS);
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) SendMessageToRecipientType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType) Test(org.junit.Test)

Example 32 with WebServiceException

use of javax.xml.ws.WebServiceException in project webcert by sklintyg.

the class CertificateRevokeProcessorTest method testRevokeCertificateWhenWebServiceExceptionIsThrown.

@Test(expected = TemporaryException.class)
public void testRevokeCertificateWhenWebServiceExceptionIsThrown() throws Exception {
    ModuleApi moduleApi = mock(ModuleApi.class);
    when(registry.getModuleApi(eq(INTYGS_TYP))).thenReturn(moduleApi);
    doThrow(new WebServiceException()).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) WebServiceException(javax.xml.ws.WebServiceException) Test(org.junit.Test)

Example 33 with WebServiceException

use of javax.xml.ws.WebServiceException in project webcert by sklintyg.

the class CertificateStoreProcessorTest method testStoreCertificateThrowsTemporaryOnWebServiceException.

@Test(expected = TemporaryException.class)
public void testStoreCertificateThrowsTemporaryOnWebServiceException() throws Exception {
    // Given
    doThrow(new WebServiceException()).when(moduleApi).registerCertificate(anyString(), anyString());
    // When
    certificateStoreProcessor.process(BODY, "fk7263", LOGICAL_ADDRESS1);
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) Test(org.junit.Test)

Example 34 with WebServiceException

use of javax.xml.ws.WebServiceException in project webcert by sklintyg.

the class SendMessageToRecipientProcessor method process.

public void process(@Body String xmlBody, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException {
    try {
        SendMessageToRecipientType parameters = SendMessageToRecipientTypeConverter.fromXml(xmlBody);
        SendMessageToRecipientResponseType response = sendMessageToRecipientResponder.sendMessageToRecipient(logicalAddress, parameters);
        ResultType result = response.getResult();
        switch(result.getResultCode()) {
            case OK:
            case INFO:
                return;
            case ERROR:
                switch(result.getErrorId()) {
                    case REVOKED:
                    case VALIDATION_ERROR:
                        LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}, ErrorId: {}." + " Rethrowing as PermanentException", intygsId, result.getResultText(), result.getErrorId());
                        throw new PermanentException(result.getResultText());
                    case APPLICATION_ERROR:
                    case TECHNICAL_ERROR:
                        LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}, ErrorId: {}." + " Rethrowing as TemporaryException", intygsId, result.getResultText(), result.getErrorId());
                        throw new TemporaryException(result.getResultText());
                }
        }
    } catch (JAXBException e) {
        LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}. Rethrowing as PermanentException", intygsId, e.getMessage());
        throw new PermanentException(e.getMessage());
    } catch (WebServiceException e) {
        LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}. Will retry", intygsId, e.getMessage());
        throw new TemporaryException(e.getMessage());
    }
}
Also used : TemporaryException(se.inera.intyg.webcert.common.sender.exception.TemporaryException) WebServiceException(javax.xml.ws.WebServiceException) PermanentException(se.inera.intyg.webcert.common.sender.exception.PermanentException) JAXBException(javax.xml.bind.JAXBException) SendMessageToRecipientType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType) ResultType(se.riv.clinicalprocess.healthcond.certificate.v3.ResultType) SendMessageToRecipientResponseType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientResponseType)

Example 35 with WebServiceException

use of javax.xml.ws.WebServiceException in project webcert by sklintyg.

the class IntygServiceTest method testThatIncompletePatientAddressIsNotUsedWhenIntygtjanstIsUnavailable.

@Test
public void testThatIncompletePatientAddressIsNotUsedWhenIntygtjanstIsUnavailable() throws Exception {
    // Given
    when(moduleFacade.getCertificate(anyString(), anyString())).thenThrow(new WebServiceException());
    when(utkastRepository.findOneByIntygsIdAndIntygsTyp(anyString(), anyString())).thenReturn(getIntyg(CERTIFICATE_ID, LocalDateTime.now(), null));
    String postadress = "ttipafpinuwiiu-postadress";
    String postort = "";
    String postnummer = "";
    Patient patientWithIncompleteAddress = buildPatient(false, false);
    patientWithIncompleteAddress.setPostadress(postadress);
    patientWithIncompleteAddress.setPostort(postort);
    patientWithIncompleteAddress.setPostnummer(postnummer);
    when(patientDetailsResolver.resolvePatient(any(Personnummer.class), anyString())).thenReturn(patientWithIncompleteAddress);
    // When
    IntygContentHolder intygData = intygService.fetchIntygData(CERTIFICATE_ID, CERTIFICATE_TYPE, false);
    // Then
    ArgumentCaptor<Patient> argumentCaptor = ArgumentCaptor.forClass(Patient.class);
    verify(moduleApi).updateBeforeSave(anyString(), argumentCaptor.capture());
    assertNotEquals(postadress, argumentCaptor.getValue().getPostadress());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) WebServiceException(javax.xml.ws.WebServiceException) IntygContentHolder(se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder) Patient(se.inera.intyg.common.support.model.common.internal.Patient) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

WebServiceException (javax.xml.ws.WebServiceException)378 Test (org.junit.Test)115 SOAPException (javax.xml.soap.SOAPException)59 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)59 SOAPMessage (javax.xml.soap.SOAPMessage)57 ConnectException (java.net.ConnectException)48 ErrorCode (org.olat.modules.vitero.model.ErrorCode)48 URL (java.net.URL)46 SOAPElement (javax.xml.soap.SOAPElement)46 IOException (java.io.IOException)43 SOAPBody (javax.xml.soap.SOAPBody)34 ArrayList (java.util.ArrayList)32 SOAPBodyElement (javax.xml.soap.SOAPBodyElement)32 BindingProvider (javax.xml.ws.BindingProvider)31 Retry (io.github.resilience4j.retry.Retry)29 Service (javax.xml.ws.Service)29 QName (javax.xml.namespace.QName)27 SOAPMessageContext (javax.xml.ws.handler.soap.SOAPMessageContext)21 DataHandler (javax.activation.DataHandler)17 RetryConfig (io.github.resilience4j.retry.RetryConfig)16