use of ddf.catalog.source.Source in project admin-console-beta by connexta.
the class SourceUtilCommons method getAllSourceReferences.
public static List<Source> getAllSourceReferences(ConfiguratorFactory configuratorFactory) {
List<Source> sources = new ArrayList<>();
ConfigReader configReader = configuratorFactory.getConfigReader();
sources.addAll(configReader.getServices(FederatedSource.class, null));
sources.addAll(configReader.getServices(ConnectedSource.class, null));
return sources;
}
use of ddf.catalog.source.Source in project ddf by codice.
the class CatalogBundle method waitForSource.
private <T extends Source> T waitForSource(String id, Class<T> type) throws InterruptedException, InvalidSyntaxException {
T source = null;
long timeoutLimit = System.currentTimeMillis() + CATALOG_PROVIDER_TIMEOUT;
boolean available = false;
while (!available) {
ServiceReference<CatalogFramework> frameworkRef = serviceManager.getServiceReference(CatalogFramework.class);
CatalogFramework framework = null;
if (frameworkRef != null) {
framework = serviceManager.getService(frameworkRef);
}
if (source == null) {
source = serviceManager.getServiceReferences(type, null).stream().map(serviceManager::getService).filter(src -> id.equals(src.getId())).findFirst().orElse(null);
}
if (source != null && framework != null) {
SourceInfoRequestEnterprise sourceInfoRequestEnterprise = new SourceInfoRequestEnterprise(true);
try {
SourceInfoResponse sources = framework.getSourceInfo(sourceInfoRequestEnterprise);
Set<SourceDescriptor> sourceInfo = sources.getSourceInfo();
for (SourceDescriptor sourceDescriptor : sourceInfo) {
if (sourceDescriptor.getSourceId().equals(source.getId())) {
available = sourceDescriptor.isAvailable() && source.isAvailable();
LOGGER.info("Source.isAvailable = {} Framework.isAvailable = {}", source.isAvailable(), sourceDescriptor.isAvailable());
}
}
} catch (SourceUnavailableException e) {
available = false;
}
} else {
LOGGER.info("Currently no source of type {} and name {} could be found", type.getName(), id);
}
if (!available) {
if (System.currentTimeMillis() > timeoutLimit) {
fail("Source (" + id + ") was not created in a timely manner.");
}
Thread.sleep(1000);
}
}
LOGGER.info("Source {} is available.", id);
return source;
}
use of ddf.catalog.source.Source in project ddf by codice.
the class TagsFilterQueryPluginTest method setup.
@Before
public void setup() {
CatalogProvider catProvider1 = mock(CatalogProvider.class);
CatalogProvider catProvider2 = mock(CatalogProvider.class);
CatalogProvider catProvider3 = mock(CatalogProvider.class);
when(catProvider1.getId()).thenReturn("cat1");
when(catProvider2.getId()).thenReturn("cat2");
when(catProvider3.getId()).thenReturn("cat3");
ImmutableList<CatalogProvider> catalogProviders = ImmutableList.of(catProvider1, catProvider2, catProvider3);
filterAdapter = mock(FilterAdapter.class);
filterBuilder = mock(FilterBuilder.class);
plugin = new TagsFilterQueryPlugin(catalogProviders, filterAdapter, filterBuilder);
source = mock(Source.class);
when(source.getId()).thenReturn("cat2");
cache = mock(SourceCache.class);
when(cache.getId()).thenReturn("cache");
queryRequest = mock(QueryRequest.class);
query = mock(Query.class);
when(queryRequest.getQuery()).thenReturn(query);
}
use of ddf.catalog.source.Source in project ddf by codice.
the class CatalogFrameworkImplTest method createDummyCatalogFramework.
private CatalogFramework createDummyCatalogFramework(CatalogProvider provider, StorageProvider storageProvider, BundleContext context, MockEventProcessor admin, boolean sourceAvailability) {
// Mock register the provider in the container
// Mock the source poller
SourcePoller mockPoller = mock(SourcePoller.class);
CachedSource mockSource = mock(CachedSource.class);
when(mockSource.isAvailable()).thenReturn(sourceAvailability);
when(mockPoller.getCachedSource(isA(Source.class))).thenReturn(mockSource);
FrameworkProperties frameworkProperties = new FrameworkProperties();
frameworkProperties.setCatalogProviders(Collections.singletonList(provider));
frameworkProperties.setStorageProviders(Collections.singletonList(storageProvider));
frameworkProperties.setSourcePoller(mockPoller);
frameworkProperties.setBundleContext(context);
frameworkProperties.setDefaultAttributeValueRegistry(defaultAttributeValueRegistry);
return createFramework(frameworkProperties);
}
use of ddf.catalog.source.Source in project ddf by codice.
the class CachingFederationStrategyTest method testFederateQueryNoUpdateToCache.
@Test
public void testFederateQueryNoUpdateToCache() throws Exception {
properties.put(QUERY_MODE, NATIVE_QUERY_MODE);
QueryRequest fedQueryRequest = new QueryRequestImpl(mockQuery, properties);
Source mockSource = mock(Source.class);
when(mockSource.query(any(QueryRequest.class))).thenReturn(mockResponse);
QueryResponse federateResponse = strategy.federate(Arrays.asList(mockSource), fedQueryRequest);
assertThat(requestArgumentCaptor.getValue().getPropertyValue(QUERY_MODE), is(NATIVE_QUERY_MODE));
verify(mockSource).query(any(QueryRequest.class));
verify(cache, times(0)).query(any(QueryRequest.class));
verifyCacheNotUpdated();
assertThat(federateResponse.getRequest().getQuery(), is(requestArgumentCaptor.getValue().getQuery()));
}
Aggregations