use of ddf.catalog.CatalogFramework in project ddf by codice.
the class CatalogFrameworkImplTest method testMetacardTransformWithTransformException.
@Test(expected = CatalogTransformerException.class)
public void testMetacardTransformWithTransformException() 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))).thenThrow(new CatalogTransformerException("Could not transform"));
CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, context, eventAdmin, true);
MetacardImpl newCard = new MetacardImpl();
newCard.setId(null);
framework.transform(newCard, "NONE", new HashMap<String, Serializable>());
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class CatalogFrameworkImplTest method testProviderUnavailableUpdateByIdentifier.
/**
* Tests that the framework properly throws a catalog exception when the local provider is not
* available for update by identifier.
*
* @throws IngestException
* @throws SourceUnavailableException
*/
@Test(expected = SourceUnavailableException.class)
public void testProviderUnavailableUpdateByIdentifier() 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<Metacard> metacards = new ArrayList<Metacard>();
List<URI> uris = new ArrayList<URI>();
// expected to throw exception due to catalog provider being unavailable
try {
MetacardImpl newCard = new MetacardImpl();
newCard.setId(null);
newCard.setResourceURI(new URI("uri:///1234"));
metacards.add(newCard);
uris.add(new URI("uri:////1234"));
UpdateRequest update = new UpdateRequestImpl((URI[]) uris.toArray(new URI[uris.size()]), metacards);
framework.update(update);
} catch (URISyntaxException e) {
fail();
} catch (IngestException e) {
fail();
}
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class CatalogFrameworkImplTest method testNullFederatedQuery.
/**
* Tests that the framework properly throws a catalog exception when the federated query being
* passed in is null.
*
* @throws UnsupportedQueryException
*/
@Test(expected = UnsupportedQueryException.class)
public void testNullFederatedQuery() throws UnsupportedQueryException {
boolean isAvailable = false;
CatalogProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), isAvailable, new Date());
createDefaultFederatedSourceList(isAvailable);
CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, null, true);
try {
framework.query(null, null);
} catch (FederationException e) {
fail();
} catch (SourceUnavailableException e) {
fail();
}
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class CatalogFrameworkImplTest method testNullEntriesCreate.
@Test(expected = IngestException.class)
public void testNullEntriesCreate() throws IngestException {
MockEventProcessor eventAdmin = new MockEventProcessor();
MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), true, new Date());
CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, eventAdmin, true);
// call framework with null request
try {
framework.create((CreateRequest) null);
} catch (SourceUnavailableException e) {
fail();
}
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class CatalogFrameworkImplTest method testQueryTransformWithInvalidSyntaxException.
@Test(expected = IllegalArgumentException.class)
public void testQueryTransformWithInvalidSyntaxException() throws Exception {
BundleContext context = mock(BundleContext.class);
when(context.getServiceReferences(anyString(), anyString())).thenThrow(new InvalidSyntaxException("Invalid Syntax", ""));
CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, context, eventAdmin, true);
framework.transform((SourceResponse) null, "NONE", new HashMap<String, Serializable>());
}
Aggregations