use of ddf.catalog.CatalogFramework in project ddf by codice.
the class SeedCommandTest method setUp.
@Before
public void setUp() throws Exception {
catalogFramework = mock(CatalogFramework.class);
doReturn(mockResourceResponse()).when(catalogFramework).getResource(any(ResourceRequest.class), anyString());
seedCommand = new SeedCommand();
seedCommand.catalogFramework = catalogFramework;
seedCommand.filterBuilder = new GeotoolsFilterBuilder();
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class CatalogFrameworkImplTest method testProviderUnavailableDeleteByID.
/**
* Tests that the framework properly throws a catalog exception when the local provider is not
* available for delete by id.
*
* @throws IngestException
* @throws SourceUnavailableException
*/
@Test(expected = SourceUnavailableException.class)
public void testProviderUnavailableDeleteByID() 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<String> ids = new ArrayList<String>();
ids.add("1234");
DeleteRequest request = new DeleteRequestImpl((String[]) ids.toArray(new String[ids.size()]));
// expected to throw exception due to catalog provider being unavailable
try {
framework.delete(request);
} catch (IngestException e) {
fail();
}
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class CatalogFrameworkImplTest method testMetacardTransformWithBadShortname.
@Ignore
@Test(expected = CatalogTransformerException.class)
public void testMetacardTransformWithBadShortname() throws CatalogTransformerException {
MockEventProcessor eventAdmin = new MockEventProcessor();
MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), true, new Date());
// TODO pass in bundle context
CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, 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 testProviderRuntimeExceptionOnUpdateByIdentifier.
@Test(expected = IngestException.class)
public void testProviderRuntimeExceptionOnUpdateByIdentifier() throws IngestException {
MockEventProcessor eventAdmin = new MockEventProcessor();
// use exception provider instead of memory
MockExceptionProvider provider = new MockExceptionProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), true, null);
CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, eventAdmin, true);
List<Entry<Object, Metacard>> metacards = new ArrayList<Entry<Object, Metacard>>();
HashMap<Object, Metacard> map = new HashMap<Object, Metacard>();
try {
MetacardImpl newCard = new MetacardImpl();
newCard.setId(null);
newCard.setResourceURI(new URI("uri:///1234"));
map.put(Metacard.ID, newCard);
metacards.addAll(map.entrySet());
UpdateRequest update = new UpdateRequestImpl(null, Metacard.RESOURCE_URI, null);
framework.update(update);
} catch (URISyntaxException e) {
fail();
} catch (SourceUnavailableException e) {
fail();
}
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class CatalogFrameworkImplTest method testProviderRuntimeExceptionOnDeleteByIdentifier.
@Test(expected = IngestException.class)
public void testProviderRuntimeExceptionOnDeleteByIdentifier() throws IngestException {
MockEventProcessor eventAdmin = new MockEventProcessor();
// use exception provider instead of memory
MockExceptionProvider provider = new MockExceptionProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), true, null);
CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, eventAdmin, true);
// List<MetacardType> identifiers = new ArrayList<MetacardType>();
// identifiers.add( new MetacardTypeImpl( "id", "1234" ) );
ArrayList<URI> uris = new ArrayList<URI>();
DeleteRequest request = new DeleteRequestImpl((URI[]) uris.toArray(new URI[uris.size()]));
// expected to throw exception due to catalog provider being unavailable
try {
framework.delete(request);
} catch (SourceUnavailableException e) {
fail();
}
}
Aggregations