@Test public void testHandleMessage_Successes_Given_XDS_Returns_Success_Response() throws Throwable { String consentIdMock = "1"; byte[] revokedConsentPdf = new byte[1]; RevokedConsentDto policyIdDto = mock(RevokedConsentDto.class); when(policyIdDto.getPatientEid()).thenReturn("FAM.123"); when(policyIdDto.getXacmlCcdId()).thenReturn("PolicyId"); when(policyIdDto.getPatientMrn()).thenReturn("locPolicyId"); when(policyIdDto.getRevokedPdfConsent()).thenReturn(revokedConsentPdf); when(consentGetterMock.getRevokedConsentDto(1)).thenReturn(policyIdDto); when( marshallerMock .marshalWithoutRootElement(isA(XdsSrcSubmitRsp.class))) .thenReturn("marshalledXmlMock"); XdsSrcSubmitRsp responsemock = mock(XdsSrcSubmitRsp.class); EhrResponseDetail responseDetailMock = mock(EhrResponseDetail.class); List<String> listSuccess = new ArrayList<String>(); listSuccess.add("Success 1"); when(responsemock.getResponseDetail()).thenReturn(responseDetailMock); when(responseDetailMock.getListSuccess()).thenReturn(listSuccess); when( spiritAdapter.deprecatePolicy("PolicyId", "locPolicyId", revokedConsentPdf)).thenReturn(responsemock); assertEquals("Consent is successfully revoked in XDS.b repository", sut.handleMessage(consentIdMock)); verify(endpointStopperMock, times(1)).setCounter(0); }
@Override public String handleMessage(String data) throws Throwable { final String messageId = generateMessageId(); logger.debug("Consent Revoked Message Received: ConsentId " + new String(data)); final Long consentId = Long.parseLong(data); final RevokedConsentDto policyIdDto = consentGetter .getRevokedConsentDto(consentId); final String patientEid = policyIdDto.getPatientEid(); final String patientMrn = policyIdDto.getPatientMrn(); final String xacmlCcdId = policyIdDto.getXacmlCcdId(); final byte[] revokedPdfConsent = policyIdDto.getRevokedPdfConsent(); Assert.notNull(patientEid); Assert.notNull(patientMrn); Assert.notNull(xacmlCcdId); Assert.notNull(revokedPdfConsent); Assert.isTrue(revokedPdfConsent.length > 0); XdsSrcSubmitRsp response = null; try { response = spiritAdapter.deprecatePolicy(xacmlCcdId, patientMrn, revokedPdfConsent); audit(messageId, policyIdDto, response); } catch (final Throwable e) { logger.error("Failed to revoke consent in XDS.b repository", e); throw e; } if (response.getResponseDetail().getListSuccess().isEmpty()) { final String errorMessage = "Failed to revoke consent in XDS.b repository becuase response status is not " + URN_RESPONSE_SUCCESS; logger.error(errorMessage); throw new Exception(errorMessage); } endpointStopper.setCounter(0); return "Consent is successfully revoked in XDS.b repository"; }
ConsentRevokedMessageHandler extends AbstractConsentMessageHandler { @Override public String handleMessage(String data) throws Throwable { final String messageId = generateMessageId(); logger.debug("Consent Revoked Message Received: ConsentId " + new String(data)); final Long consentId = Long.parseLong(data); final RevokedConsentDto policyIdDto = consentGetter .getRevokedConsentDto(consentId); final String patientEid = policyIdDto.getPatientEid(); final String patientMrn = policyIdDto.getPatientMrn(); final String xacmlCcdId = policyIdDto.getXacmlCcdId(); final byte[] revokedPdfConsent = policyIdDto.getRevokedPdfConsent(); Assert.notNull(patientEid); Assert.notNull(patientMrn); Assert.notNull(xacmlCcdId); Assert.notNull(revokedPdfConsent); Assert.isTrue(revokedPdfConsent.length > 0); XdsSrcSubmitRsp response = null; try { response = spiritAdapter.deprecatePolicy(xacmlCcdId, patientMrn, revokedPdfConsent); audit(messageId, policyIdDto, response); } catch (final Throwable e) { logger.error("Failed to revoke consent in XDS.b repository", e); throw e; } if (response.getResponseDetail().getListSuccess().isEmpty()) { final String errorMessage = "Failed to revoke consent in XDS.b repository becuase response status is not " + URN_RESPONSE_SUCCESS; logger.error(errorMessage); throw new Exception(errorMessage); } endpointStopper.setCounter(0); return "Consent is successfully revoked in XDS.b repository"; } }
ConsentRevokedMessageHandler extends AbstractConsentMessageHandler { @Override public String handleMessage(String data) throws Throwable { final String messageId = generateMessageId(); logger.debug("Consent Revoked Message Received: ConsentId " + new String(data)); final Long consentId = Long.parseLong(data); final RevokedConsentDto policyIdDto = consentGetter .getRevokedConsentDto(consentId); final String patientEid = policyIdDto.getPatientEid(); final String patientMrn = policyIdDto.getPatientMrn(); final String xacmlCcdId = policyIdDto.getXacmlCcdId(); final byte[] revokedPdfConsent = policyIdDto.getRevokedPdfConsent(); Assert.notNull(patientEid); Assert.notNull(patientMrn); Assert.notNull(xacmlCcdId); Assert.notNull(revokedPdfConsent); Assert.isTrue(revokedPdfConsent.length > 0); XdsSrcSubmitRsp response = null; try { response = spiritAdapter.deprecatePolicy(xacmlCcdId, patientMrn, revokedPdfConsent); audit(messageId, policyIdDto, response); } catch (final Throwable e) { logger.error("Failed to revoke consent in XDS.b repository", e); throw e; } if (response.getResponseDetail().getListSuccess().isEmpty()) { final String errorMessage = "Failed to revoke consent in XDS.b repository becuase response status is not " + URN_RESPONSE_SUCCESS; logger.error(errorMessage); throw new Exception(errorMessage); } endpointStopper.setCounter(0); return "Consent is successfully revoked in XDS.b repository"; } ConsentRevokedMessageHandler(); }
ConsentRevokedMessageHandler extends AbstractConsentMessageHandler { @Override public String handleMessage(String data) throws Throwable { final String messageId = generateMessageId(); logger.debug("Consent Revoked Message Received: ConsentId " + new String(data)); final Long consentId = Long.parseLong(data); final RevokedConsentDto policyIdDto = consentGetter .getRevokedConsentDto(consentId); final String patientEid = policyIdDto.getPatientEid(); final String patientMrn = policyIdDto.getPatientMrn(); final String xacmlCcdId = policyIdDto.getXacmlCcdId(); final byte[] revokedPdfConsent = policyIdDto.getRevokedPdfConsent(); Assert.notNull(patientEid); Assert.notNull(patientMrn); Assert.notNull(xacmlCcdId); Assert.notNull(revokedPdfConsent); Assert.isTrue(revokedPdfConsent.length > 0); XdsSrcSubmitRsp response = null; try { response = spiritAdapter.deprecatePolicy(xacmlCcdId, patientMrn, revokedPdfConsent); audit(messageId, policyIdDto, response); } catch (final Throwable e) { logger.error("Failed to revoke consent in XDS.b repository", e); throw e; } if (response.getResponseDetail().getListSuccess().isEmpty()) { final String errorMessage = "Failed to revoke consent in XDS.b repository becuase response status is not " + URN_RESPONSE_SUCCESS; logger.error(errorMessage); throw new Exception(errorMessage); } endpointStopper.setCounter(0); return "Consent is successfully revoked in XDS.b repository"; } ConsentRevokedMessageHandler(); @Override String handleMessage(String data); }
ConsentRevokedMessageHandler extends AbstractConsentMessageHandler { @Override public String handleMessage(String data) throws Throwable { final String messageId = generateMessageId(); logger.debug("Consent Revoked Message Received: ConsentId " + new String(data)); final Long consentId = Long.parseLong(data); final RevokedConsentDto policyIdDto = consentGetter .getRevokedConsentDto(consentId); final String patientEid = policyIdDto.getPatientEid(); final String patientMrn = policyIdDto.getPatientMrn(); final String xacmlCcdId = policyIdDto.getXacmlCcdId(); final byte[] revokedPdfConsent = policyIdDto.getRevokedPdfConsent(); Assert.notNull(patientEid); Assert.notNull(patientMrn); Assert.notNull(xacmlCcdId); Assert.notNull(revokedPdfConsent); Assert.isTrue(revokedPdfConsent.length > 0); XdsSrcSubmitRsp response = null; try { response = spiritAdapter.deprecatePolicy(xacmlCcdId, patientMrn, revokedPdfConsent); audit(messageId, policyIdDto, response); } catch (final Throwable e) { logger.error("Failed to revoke consent in XDS.b repository", e); throw e; } if (response.getResponseDetail().getListSuccess().isEmpty()) { final String errorMessage = "Failed to revoke consent in XDS.b repository becuase response status is not " + URN_RESPONSE_SUCCESS; logger.error(errorMessage); throw new Exception(errorMessage); } endpointStopper.setCounter(0); return "Consent is successfully revoked in XDS.b repository"; } ConsentRevokedMessageHandler(); @Override String handleMessage(String data);  }