DDMDataProviderInvokerImpl implements DDMDataProviderInvoker { protected DDMDataProviderResponse doInvoke( DDMDataProviderRequest ddmDataProviderRequest) throws Exception { String ddmDataProviderId = ddmDataProviderRequest.getDDMDataProviderId(); Optional<DDMDataProviderInstance> ddmDataProviderInstanceOptional = fetchDDMDataProviderInstanceOptional(ddmDataProviderId); DDMDataProvider ddmDataProvider = getDDMDataProvider( ddmDataProviderId, ddmDataProviderInstanceOptional); if (ddmDataProviderInstanceOptional.isPresent()) { return doInvokeExternal( ddmDataProviderInstanceOptional.get(), ddmDataProvider, ddmDataProviderRequest); } return ddmDataProvider.getData(ddmDataProviderRequest); }  @Override DDMDataProviderResponse invoke(
		DDMDataProviderRequest ddmDataProviderRequest);  }
@Test public void testDoInvoke() throws Exception { DDMDataProviderInvokerImpl ddmDataProviderInvokerImpl = mock( DDMDataProviderInvokerImpl.class); DDMDataProviderRequest.Builder builder = DDMDataProviderRequest.Builder.newBuilder(); DDMDataProviderRequest ddmDataProviderRequest = builder.withDDMDataProviderId( "2" ).build(); Optional<DDMDataProviderInstance> optional = Optional.empty(); when( ddmDataProviderInvokerImpl.fetchDDMDataProviderInstanceOptional("2") ).thenReturn( optional ); DDMDataProvider ddmDataProvider = mock(DDMDataProvider.class); when( ddmDataProviderInvokerImpl.getDDMDataProvider("2", optional) ).thenReturn( ddmDataProvider ); DDMDataProviderResponse.Builder responseBuilder = DDMDataProviderResponse.Builder.newBuilder(); when( ddmDataProvider.getData(ddmDataProviderRequest) ).thenReturn( responseBuilder.withOutput( "output", 2 ).build() ); when( ddmDataProviderInvokerImpl.doInvoke(ddmDataProviderRequest) ).thenCallRealMethod(); DDMDataProviderResponse ddmDataProviderResponse = ddmDataProviderInvokerImpl.doInvoke(ddmDataProviderRequest); Optional<Number> outputOptional = ddmDataProviderResponse.getOutputOptional("output", Number.class); Assert.assertEquals(2, outputOptional.get()); }