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