use of ddf.catalog.operation.SourceInfoRequest in project ddf by codice.
the class CatalogFrameworkImplTest method testGetAllSiteNames.
@Test
public void testGetAllSiteNames() {
String frameworkName = "DDF";
CatalogProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), true, new Date());
List<FederatedSource> federatedSources = createDefaultFederatedSourceList(true);
// Expected Set of Names
Set<String> expectedNameSet = new HashSet<String>();
for (FederatedSource curSite : federatedSources) {
expectedNameSet.add(curSite.getId());
}
// Mock register the provider in the container
// Mock the source poller
SourcePoller mockPoller = mock(SourcePoller.class);
when(mockPoller.getCachedSource(isA(Source.class))).thenReturn(null);
FrameworkProperties frameworkProperties = new FrameworkProperties();
frameworkProperties.setSourcePoller(mockPoller);
Map<String, FederatedSource> sources = new HashMap<>();
for (FederatedSource federatedSource : federatedSources) {
sources.put(federatedSource.getId(), federatedSource);
}
frameworkProperties.setFederatedSources(sources);
frameworkProperties.setCatalogProviders(Collections.singletonList(provider));
CatalogFrameworkImpl framework = createFramework(frameworkProperties);
framework.setId(frameworkName);
// Returned Set of Names
// Returned Sites
SourceInfoRequest request = new SourceInfoRequestEnterprise(true);
SourceInfoResponse response = null;
try {
response = framework.getSourceInfo(request);
} catch (SourceUnavailableException e) {
LOGGER.debug("SourceUnavilable", e);
fail();
}
assert (response != null);
Set<SourceDescriptor> sourceDescriptors = response.getSourceInfo();
// should contain ONLY the original federated sites
assertEquals(expectedNameSet.size(), sourceDescriptors.size());
Set<String> returnedSourceIds = new HashSet<String>();
for (SourceDescriptor sd : sourceDescriptors) {
returnedSourceIds.add(sd.getSourceId());
}
for (String id : returnedSourceIds) {
LOGGER.debug("returned sourceId: {}", id);
}
assertTrue(expectedNameSet.equals(returnedSourceIds));
}
use of ddf.catalog.operation.SourceInfoRequest in project ddf by codice.
the class CatalogFrameworkImplTest method testGetFederatedSources.
@Test
public void testGetFederatedSources() {
SourceInfoRequest request = new SourceInfoRequestEnterprise(true);
SourceInfoResponse response = null;
try {
response = framework.getSourceInfo(request);
} catch (SourceUnavailableException e) {
fail();
}
Set<SourceDescriptor> sourceDescriptors = response.getSourceInfo();
for (SourceDescriptor descriptor : sourceDescriptors) {
LOGGER.debug("Descriptor id: {}", descriptor.getSourceId());
}
// The "+1" is to account for the CatalogFramework source descriptor.
// Even if no local catalog provider is configured, the catalog framework's
// site info is included in the SourceDescriptos list.
assertEquals(federatedSources.size() + 1, sourceDescriptors.size());
}
Aggregations