ConsentRevokedMessageHandlerPolRep 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 policyId = policyIdDto.getXacmlCcdId(); Assert.notNull(patientEid); Assert.notNull(policyId); try { polRepClient.deletePolicy(policyId); audit(messageId, policyIdDto, Optional.empty()); } catch (final HttpStatusCodeException e) { logger.error( "Failed to delete consent in policy repository with status code: " + e.getStatusCode().toString(), e); audit(messageId, policyIdDto, Optional.of(e)); throw e; } catch (final Exception e) { logger.error("Failed to delete consent in policy repository", e); throw e; } return "Consent is deleted from policy repository"; }  @Override String handleMessage(String data);  }
@Test public void testHandleMessage() throws Throwable { final String data = "1"; final long dataLong = 1L; final String patientEid = "patientEid"; final String xacmlCcdId = "xacmlCcdId"; final String patientMrn = "patientMrn"; final RevokedConsentDto revokedConsentDto = mock(RevokedConsentDto.class); when(consentGetter.getRevokedConsentDto(dataLong)).thenReturn( revokedConsentDto); when(revokedConsentDto.getPatientEid()).thenReturn(patientEid); when(revokedConsentDto.getXacmlCcdId()).thenReturn(xacmlCcdId); when(revokedConsentDto.getPatientMrn()).thenReturn(patientMrn); sut.handleMessage(data); verify(polRepClient, times(1)).deletePolicy(xacmlCcdId); verify(auditService, times(1)).audit(eq(sut), anyString(), eq(POLREP_DELETE_CONSENT), eq(patientMrn), anyMapOf(PredicateKey.class, String.class)); }