Search in sources :

Example 1 with SourceInfoRequestSources

use of ddf.catalog.operation.impl.SourceInfoRequestSources in project ddf by codice.

the class CatalogFrameworkImplTest method testGetSites.

@Test
public void testGetSites() {
    framework.setId("ddf");
    framework.getSourceOperations().setId("ddf");
    Set<String> ids = new HashSet<String>();
    for (FederatedSource source : federatedSources) {
        ids.add(source.getId());
    }
    ids.add(framework.getId());
    SourceInfoRequest request = new SourceInfoRequestSources(true, ids);
    SourceInfoResponse response = null;
    try {
        response = framework.getSourceInfo(request);
    } catch (SourceUnavailableException e) {
        fail();
    }
    Set<SourceDescriptor> sourceDescriptors = response.getSourceInfo();
    List<String> siteNames = new ArrayList<String>();
    for (SourceDescriptor descriptor : sourceDescriptors) {
        LOGGER.debug("Descriptor id: {}", descriptor.getSourceId());
        siteNames.add(descriptor.getSourceId());
    }
    // add a plus one for now to simulate that the framework is ad
    // assertTrue( sourceDescriptor.containsAll( federatedSources ) );
    // assertTrue( sourceDescriptor.containsAll( expectedSourceSet ) );
    assertEquals(ids.size(), sourceDescriptors.size());
    String[] expectedOrdering = { "A", "B", "C", framework.getId() };
    assertArrayEquals(expectedOrdering, siteNames.toArray(new String[siteNames.size()]));
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) SourceDescriptor(ddf.catalog.source.SourceDescriptor) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) FederatedSource(ddf.catalog.source.FederatedSource) SourceInfoRequestSources(ddf.catalog.operation.impl.SourceInfoRequestSources) SourceInfoRequest(ddf.catalog.operation.SourceInfoRequest) SourceInfoResponse(ddf.catalog.operation.SourceInfoResponse) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

SourceInfoRequest (ddf.catalog.operation.SourceInfoRequest)1 SourceInfoResponse (ddf.catalog.operation.SourceInfoResponse)1 SourceInfoRequestSources (ddf.catalog.operation.impl.SourceInfoRequestSources)1 FederatedSource (ddf.catalog.source.FederatedSource)1 SourceDescriptor (ddf.catalog.source.SourceDescriptor)1 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1