use of ddf.catalog.data.ContentType in project ddf by codice.
the class SourcePollerRunnerTest method testNonExistantWithUnknownTitleIsntFound.
@Test
public void testNonExistantWithUnknownTitleIsntFound() {
SourcePollerRunner runner = new SourcePollerRunner();
Set<ContentType> types = createContentTypes();
Source source = createDefaultFederatedSource(true, types, "src", "1");
Source source2 = createDefaultFederatedSource(true, types, "src2", "1");
CachedSource cached = null;
runner.bind(source);
SourceStatus status = null;
do {
Thread.yield();
cached = runner.getCachedSource(source);
if (cached != null) {
status = cached.getSourceStatus();
}
} while (status == null || status == SourceStatus.UNCHECKED);
assertNull(runner.getCachedSource(source2));
}
use of ddf.catalog.data.ContentType in project ddf by codice.
the class SourcePollerRunnerTest method testNonExistantWithDuplicateTitleButWrongVersionIsntFound.
@Test
public void testNonExistantWithDuplicateTitleButWrongVersionIsntFound() {
SourcePollerRunner runner = new SourcePollerRunner();
Set<ContentType> types = createContentTypes();
Source source = createDefaultFederatedSource(true, types, "src", "1");
Source source2 = createDefaultFederatedSource(true, types, "src", "2");
CachedSource cached = null;
runner.bind(source);
SourceStatus status = null;
do {
Thread.yield();
cached = runner.getCachedSource(source);
if (cached != null) {
status = cached.getSourceStatus();
}
} while (status == null || status == SourceStatus.UNCHECKED);
assertNull(runner.getCachedSource(source2));
}
use of ddf.catalog.data.ContentType in project ddf by codice.
the class CatalogFrameworkImplTest method testProviderUnavailableUpdateByID.
/**
* Tests that the framework properly throws a catalog exception when the local provider is not
* available for update by id.
*
* @throws IngestException
* @throws SourceUnavailableException
*/
@Test(expected = SourceUnavailableException.class)
public void testProviderUnavailableUpdateByID() 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.data.ContentType 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.data.ContentType in project ddf by codice.
the class CatalogFrameworkQueryTest method initFramework.
@Before
public void initFramework() {
MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), true, new Date());
// Mock register the provider in the container
// Mock the source poller
SourcePoller mockPoller = mock(SourcePoller.class);
CachedSource source = mock(CachedSource.class);
when(source.isAvailable()).thenReturn(Boolean.TRUE);
when(mockPoller.getCachedSource(isA(Source.class))).thenReturn(source);
ArrayList<PostIngestPlugin> postIngestPlugins = new ArrayList<>();
FrameworkProperties props = new FrameworkProperties();
props.setCatalogProviders(Collections.singletonList(provider));
props.setPostIngest(postIngestPlugins);
props.setFederationStrategy(new MockFederationStrategy());
props.setQueryResponsePostProcessor(mock(QueryResponsePostProcessor.class));
props.setSourcePoller(mockPoller);
props.setFilterBuilder(new GeotoolsFilterBuilder());
props.setDefaultAttributeValueRegistry(new DefaultAttributeValueRegistryImpl());
UuidGenerator uuidGenerator = mock(UuidGenerator.class);
when(uuidGenerator.generateUuid()).thenReturn(UUID.randomUUID().toString());
OperationsSecuritySupport opsSecurity = new OperationsSecuritySupport();
MetacardFactory metacardFactory = new MetacardFactory(props.getMimeTypeToTransformerMapper(), uuidGenerator);
OperationsMetacardSupport opsMetacard = new OperationsMetacardSupport(props, metacardFactory);
SourceOperations sourceOperations = new SourceOperations(props);
QueryOperations queryOperations = new QueryOperations(props, sourceOperations, opsSecurity, opsMetacard);
ResourceOperations resourceOperations = new ResourceOperations(props, queryOperations, opsSecurity);
TransformOperations transformOperations = new TransformOperations(props);
OperationsCatalogStoreSupport opsCatStore = new OperationsCatalogStoreSupport(props, sourceOperations);
OperationsStorageSupport opsStorage = new OperationsStorageSupport(sourceOperations, queryOperations);
CreateOperations createOperations = new CreateOperations(props, queryOperations, sourceOperations, opsSecurity, opsMetacard, opsCatStore, opsStorage);
UpdateOperations updateOperations = new UpdateOperations(props, queryOperations, sourceOperations, opsSecurity, opsMetacard, opsCatStore, opsStorage);
DeleteOperations deleteOperations = new DeleteOperations(props, queryOperations, sourceOperations, opsSecurity, opsMetacard);
Historian historian = new Historian();
historian.setHistoryEnabled(false);
opsStorage.setHistorian(historian);
updateOperations.setHistorian(historian);
deleteOperations.setHistorian(historian);
deleteOperations.setOpsCatStoreSupport(opsCatStore);
framework = new CatalogFrameworkImpl(createOperations, updateOperations, deleteOperations, queryOperations, resourceOperations, sourceOperations, transformOperations);
sourceOperations.bind(provider);
}
Aggregations