DDMRESTDataProvider implements DDMDataProvider { protected Optional<DDMDataProviderInstance> fetchDDMDataProviderInstance( String ddmDataProviderInstanceId) throws PortalException { DDMDataProviderInstance ddmDataProviderInstance = ddmDataProviderInstanceService.fetchDataProviderInstanceByUuid( ddmDataProviderInstanceId); if ((ddmDataProviderInstance == null) && Validator.isNumber(ddmDataProviderInstanceId)) { ddmDataProviderInstance = ddmDataProviderInstanceService.fetchDataProviderInstance( Long.valueOf(ddmDataProviderInstanceId)); } return Optional.ofNullable(ddmDataProviderInstance); }  @Override DDMDataProviderResponse getData(
			DDMDataProviderRequest ddmDataProviderRequest); @Override Class<?> getSettings();  }
@Test public void testFetchDDMDataProviderInstanceNotFound1() throws Exception { DDMDataProviderInstanceService ddmDataProviderInstanceService = mock( DDMDataProviderInstanceService.class); _ddmRESTDataProvider.ddmDataProviderInstanceService = ddmDataProviderInstanceService; when( ddmDataProviderInstanceService.fetchDataProviderInstanceByUuid("id") ).thenReturn( null ); Optional<DDMDataProviderInstance> optional = _ddmRESTDataProvider.fetchDDMDataProviderInstance("id"); Assert.assertFalse(optional.isPresent()); }
@Test public void testFetchDDMDataProviderInstanceNotFound2() throws Exception { DDMDataProviderInstanceService ddmDataProviderInstanceService = mock( DDMDataProviderInstanceService.class); _ddmRESTDataProvider.ddmDataProviderInstanceService = ddmDataProviderInstanceService; when( ddmDataProviderInstanceService.fetchDataProviderInstanceByUuid("1") ).thenReturn( null ); DDMDataProviderInstance ddmDataProviderInstance = mock( DDMDataProviderInstance.class); when( ddmDataProviderInstanceService.fetchDataProviderInstance(1L) ).thenReturn( ddmDataProviderInstance ); Optional<DDMDataProviderInstance> optional = _ddmRESTDataProvider.fetchDDMDataProviderInstance("1"); Assert.assertTrue(optional.isPresent()); }