ConsentExportServiceImpl implements ConsentExportService { @Override public String exportConsent2CDAR2(Long consentId) throws ConsentGenException { return consentBuilder.buildConsent2Cdar2(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 testExportConsent2CDAR2() throws ConsentGenException { long consentId = 1; String cdar2Mock = "cdar2"; when(consentBuilderMock.buildConsent2Cdar2(anyLong())).thenReturn( cdar2Mock); String cdar2 = sut.exportConsent2CDAR2(consentId); assertEquals(cdar2Mock, cdar2); }
@Test public void testExportConsent2CDAR2_ConsentGenException() throws ConsentGenException { thrown.expect(ConsentGenException.class); long consentId = 1; when(consentBuilderMock.buildConsent2Cdar2(anyLong())).thenThrow( new ConsentGenException("Error in export consent to cdar2")); sut.exportConsent2CDAR2(consentId); }