DDMDataProviderInvokerImpl implements DDMDataProviderInvoker { protected DDMDataProvider getDDMDataProvider( String ddmDataProviderInstanceId, Optional<DDMDataProviderInstance> ddmDataProviderInstanceOptional) { Optional<DDMDataProvider> ddmDataProviderTypeOptional = ddmDataProviderInstanceOptional.map( ddmDataProviderInstance -> ddmDataProviderTracker.getDDMDataProvider( ddmDataProviderInstance.getType())); return ddmDataProviderTypeOptional.orElseGet( () -> ddmDataProviderTracker.getDDMDataProviderByInstanceId( ddmDataProviderInstanceId)); }  @Override DDMDataProviderResponse invoke(
		DDMDataProviderRequest ddmDataProviderRequest);  }
@Test public void testGetDDMDataProviderByInstanceId() { DDMDataProviderInvokerImpl ddmDataProviderInvokerImpl = new DDMDataProviderInvokerImpl(); DDMDataProviderTracker ddmDataProviderTracker = mock( DDMDataProviderTracker.class); ddmDataProviderInvokerImpl.ddmDataProviderTracker = ddmDataProviderTracker; when( ddmDataProviderTracker.getDDMDataProvider(Matchers.anyString()) ).thenReturn( null ); DDMDataProvider ddmDataProvider = mock(DDMDataProvider.class); when( ddmDataProviderTracker.getDDMDataProviderByInstanceId("1") ).thenReturn( ddmDataProvider ); DDMDataProvider result = ddmDataProviderInvokerImpl.getDDMDataProvider( "1", Optional.empty()); Assert.assertNotNull(result); Mockito.verify( ddmDataProviderTracker, Mockito.times(1) ).getDDMDataProviderByInstanceId( "1" ); }
@Test public void testGetDDMDataProviderFromTracker() { DDMDataProviderInvokerImpl ddmDataProviderInvokerImpl = new DDMDataProviderInvokerImpl(); DDMDataProviderTracker ddmDataProviderTracker = mock( DDMDataProviderTracker.class); ddmDataProviderInvokerImpl.ddmDataProviderTracker = ddmDataProviderTracker; DDMDataProviderInstance ddmDataProviderInstance = mock( DDMDataProviderInstance.class); when( ddmDataProviderInstance.getType() ).thenReturn( "rest" ); DDMDataProvider ddmDataProvider = mock(DDMDataProvider.class); when( ddmDataProviderTracker.getDDMDataProvider("rest") ).thenReturn( ddmDataProvider ); DDMDataProvider result = ddmDataProviderInvokerImpl.getDDMDataProvider( "1", Optional.of(ddmDataProviderInstance)); Assert.assertNotNull(result); Mockito.verify( ddmDataProviderTracker, Mockito.times(1) ).getDDMDataProvider( "rest" ); }