ConsentExportServiceImpl implements ConsentExportService { @Override public String exportConsent2XACML(Long consentId) throws ConsentGenException { return consentBuilder.buildConsent2Xacml(consentId); } ConsentExportServiceImpl(ConsentBuilder consentBuilder); @Override String exportConsent2CDAR2(Long consentId); @Override String exportConsent2XACML(Long consentId); @Override String exportConsent2XACML(Consent consent); @Override String exportConsent2XacmlPdfConsentFrom(Consent consent); @Override String exportConsent2XacmlPdfConsentTo(Consent consent);  }
@Test public void testExportConsent2XACML() throws ConsentGenException { long consentId = 1; String xacmlMock = "xacml"; when(consentBuilderMock.buildConsent2Xacml(anyLong())).thenReturn( xacmlMock); String xacml = sut.exportConsent2XACML(consentId); assertEquals(xacmlMock, xacml); }
@Test public void testExportConsent2XACML_ConsentGenException() throws ConsentGenException { thrown.expect(ConsentGenException.class); long consentId = 1; when(consentBuilderMock.buildConsent2Xacml(anyLong())).thenThrow( new ConsentGenException("Error in export consent to cdar2")); sut.exportConsent2XACML(consentId); }
@Test public void testExportConsent2XACML_Object() throws ConsentGenException { Consent consent = mock(Consent.class); String xacmlMock = "xacml"; when(consentBuilderMock.buildConsent2Xacml(consent)).thenReturn( xacmlMock); String xacml = sut.exportConsent2XACML(consent); assertEquals(xacmlMock, xacml); }
@Test public void testExportConsent2XACML_Object_ConsentGenException() throws ConsentGenException { thrown.expect(ConsentGenException.class); Consent consent = mock(Consent.class); when(consentBuilderMock.buildConsent2Xacml(consent)).thenThrow( new ConsentGenException("Error in export consent to cdar2")); sut.exportConsent2XACML(consent); }