use of ddf.catalog.CatalogFramework in project ddf by codice.
the class CatalogFrameworkImplTest method testQueryTransformWithNullResponse.
@Test(expected = IllegalArgumentException.class)
public void testQueryTransformWithNullResponse() throws Exception {
BundleContext context = mock(BundleContext.class);
ServiceReference reference = mock(ServiceReference.class);
ServiceReference[] serviceReferences = new ServiceReference[] { reference };
when(context.getServiceReferences(anyString(), anyString())).thenReturn(serviceReferences);
CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, context, eventAdmin, true);
framework.transform((SourceResponse) null, "NONE", new HashMap<String, Serializable>());
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class CatalogFrameworkImplTest method testMetacardTransform.
@Test
public void testMetacardTransform() throws Exception {
BundleContext context = mock(BundleContext.class);
MetacardTransformer transformer = mock(MetacardTransformer.class);
ServiceReference reference = mock(ServiceReference.class);
ServiceReference[] serviceReferences = new ServiceReference[] { reference };
when(context.getServiceReferences(anyString(), anyString())).thenReturn(serviceReferences);
when(context.getService(isA(ServiceReference.class))).thenReturn(transformer);
when(transformer.transform(isA(Metacard.class), isA(Map.class))).thenReturn(new BinaryContentImpl(null));
CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, context, eventAdmin, true);
MetacardImpl newCard = new MetacardImpl();
newCard.setId(null);
BinaryContent content = framework.transform(newCard, "NONE", new HashMap<String, Serializable>());
assertNotNull(content);
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class CatalogFrameworkImplTest method testProviderUnavailableDeleteByIdentifier.
/**
* Tests that the framework properly throws a catalog exception when the local provider is not
* available for delete by identifier.
*
* @throws IngestException
* @throws SourceUnavailableException
*/
@Test(expected = SourceUnavailableException.class)
public void testProviderUnavailableDeleteByIdentifier() throws SourceUnavailableException {
MockEventProcessor eventAdmin = new MockEventProcessor();
MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), false, null);
CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, eventAdmin, false);
List<URI> uris = new ArrayList<URI>();
try {
uris.add(new URI("id://1234"));
DeleteRequest request = new DeleteRequestImpl((URI[]) uris.toArray(new URI[uris.size()]));
// expected to throw exception due to catalog provider being
// unavailable
framework.delete(request);
} catch (URISyntaxException e) {
fail();
} catch (IngestException e) {
fail();
}
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class FtpRequestHandlerTest method testMimeTypeMapperNull.
@Test(expected = IllegalArgumentException.class)
public void testMimeTypeMapperNull() {
String mimeType;
catalogFramework = mock(CatalogFramework.class);
FtpRequestHandler ftplett = new FtpRequestHandler(catalogFramework, null, uuidGenerator);
mimeType = ftplett.getMimeType("xml", new TemporaryFileBackedOutputStream());
assertEquals("", mimeType);
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class SeedCommandTest method mockQueryResponse.
private void mockQueryResponse(int stopReturningResultsAtIndex, String[] ids, boolean[] cached) throws Exception {
List<Result> results = new ArrayList<>();
for (int i = 0; i < ids.length; ++i) {
String id = ids[i];
Result mockResult = mock(Result.class);
MetacardImpl metacard = new MetacardImpl();
metacard.setId(id);
metacard.setSourceId(id);
metacard.setAttribute("internal.local-resource", cached[i]);
when(mockResult.getMetacard()).thenReturn(metacard);
results.add(mockResult);
}
QueryResponse response = mock(QueryResponse.class);
when(response.getResults()).thenReturn(results);
doReturn(response).when(catalogFramework).query(argThat(is(queryWithStartIndex(request -> request.getQuery().getStartIndex() < stopReturningResultsAtIndex))));
QueryResponse noResults = mock(QueryResponse.class);
when(noResults.getResults()).thenReturn(Collections.emptyList());
doReturn(noResults).when(catalogFramework).query(argThat(is(queryWithStartIndex(request -> request.getQuery().getStartIndex() >= stopReturningResultsAtIndex))));
}
Aggregations