use of ddf.catalog.source.CatalogProvider in project ddf by codice.
the class HistorianTest method setup.
@Before
public void setup() {
historian = new Historian();
uuidGenerator = mock(UuidGenerator.class);
when(uuidGenerator.generateUuid()).thenReturn(UUID.randomUUID().toString());
historian.setUuidGenerator(uuidGenerator);
catalogProvider = mock(CatalogProvider.class);
historian.setCatalogProviders(Collections.singletonList(catalogProvider));
storageProvider = new InMemoryStorageProvider();
historian.setStorageProviders(Collections.singletonList(storageProvider));
historian.setMetacardTypes(Collections.singletonList(MetacardImpl.BASIC_METACARD));
SubjectIdentity subjectIdentity = mock(SubjectIdentity.class);
when(subjectIdentity.getUniqueIdentifier(any())).thenReturn("test");
historian.setSubjectIdentity(subjectIdentity);
SubjectOperations subjectOperations = mock(SubjectOperations.class);
when(subjectOperations.getEmailAddress(any(Subject.class))).thenReturn("test@test.com");
when(subjectOperations.getName(any(Subject.class))).thenReturn("test");
historian.setSubjectOperations(subjectOperations);
historian.setSecurityLogger(mock(SecurityLogger.class));
Security security = mock(Security.class);
Subject subject = mock(MockSubject.class);
when(subject.execute(any(Callable.class))).thenCallRealMethod();
when(security.runAsAdmin(any(PrivilegedAction.class))).thenReturn(subject);
historian.setSecurity(security);
}
use of ddf.catalog.source.CatalogProvider in project ddf by codice.
the class GeoNamesCatalogIndexer method removeGeoNamesMetacardsFromCatalog.
private void removeGeoNamesMetacardsFromCatalog(String resource, ProgressCallback extractionCallback) throws UnsupportedQueryException, SourceUnavailableException, FederationException, IngestException {
extractionCallback.updateProgress(0);
Optional<CatalogProvider> catalogProviderOptional = catalogProviders.stream().findFirst();
if (catalogProviderOptional.isPresent()) {
CatalogProvider catalogProvider = catalogProviderOptional.get();
if (StringUtils.isNotBlank(resource)) {
filter = filterBuilder.allOf(filterBuilder.attribute(GeoEntryAttributes.IMPORT_LOCATION).is().equalTo().text(resource), filter);
}
while (true) {
Query query = new QueryImpl(filter, 1, BATCH_SIZE, SortBy.NATURAL_ORDER, false, TimeUnit.SECONDS.toMillis(90));
QueryRequest queryRequest = new QueryRequestImpl(query);
LOGGER.trace("Removing existing geonames data with filter: {}", filter);
QueryResponse response = catalogFramework.query(queryRequest);
List<Serializable> metacardsToDelete = response.getResults().stream().map(Result::getMetacard).map(Metacard::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(metacardsToDelete)) {
break;
}
LOGGER.trace("Deleting {} GeoNames metacards", metacardsToDelete.size());
removeMetacards(catalogProvider, extractionCallback, metacardsToDelete);
}
}
extractionCallback.updateProgress(50);
}
use of ddf.catalog.source.CatalogProvider in project ddf by codice.
the class GeoNamesCatalogIndexerTest method setUp.
@Before
public void setUp() throws Exception {
geoEntryCreator = mock(GeoEntryCreator.class);
when(geoEntryCreator.createGeoEntry(anyString(), anyString())).thenReturn(GEO_ENTRY);
geoEntryExtractor = new GeoNamesFileExtractor();
geoEntryExtractor.setGeoEntryCreator(geoEntryCreator);
catalogFramework = mock(CatalogFramework.class);
uuidGenerator = mock(UuidGenerator.class);
createResponse = mock(CreateResponse.class);
when(createResponse.getCreatedMetacards()).thenReturn(Collections.singletonList(METACARD));
when(catalogFramework.create(any(CreateRequest.class))).thenReturn(createResponse);
when(uuidGenerator.generateUuid()).thenReturn(UUID.randomUUID().toString());
catalogProvider = mock(CatalogProvider.class);
DeleteResponse deleteResponse = mock(DeleteResponse.class);
when(deleteResponse.getDeletedMetacards()).thenReturn(Collections.singletonList(METACARD));
when(catalogProvider.delete(any(DeleteRequest.class))).thenReturn(deleteResponse);
queryResponse = mock(QueryResponse.class);
when(queryResponse.getResults()).thenReturn(Collections.singletonList(new ResultImpl(new MetacardImpl())));
when(catalogFramework.query(any(QueryRequest.class))).thenReturn(queryResponse);
progressCallback = progress -> {
};
geoNamesCatalogIndexer = new GeoNamesCatalogIndexer(catalogFramework, uuidGenerator, new GeoEntryAttributes(), new GeotoolsFilterBuilder(), Collections.singletonList(catalogProvider));
}
use of ddf.catalog.source.CatalogProvider in project ddf by codice.
the class DescribeCommandTest method setUp.
@Before
public void setUp() throws Exception {
describeCommand = new DescribeCommand();
CatalogProvider catalogProvider = mock(CatalogProvider.class);
doReturn(TEST_CATALOG_PROVIDER_TITLE).when(catalogProvider).getTitle();
doReturn(TEST_CATALOG_PROVIDER_DESCRIPTION).when(catalogProvider).getDescription();
doReturn(TEST_CATALOG_PROVIDER_ID).when(catalogProvider).getId();
doReturn(TEST_CATALOG_PROVIDER_VERSION).when(catalogProvider).getVersion();
describeCommand.catalogProvider = catalogProvider;
CatalogFramework catalogFramework = mock(CatalogFramework.class);
doReturn(TEST_CATALOG_FRAMEWORK_TITLE).when(catalogFramework).getTitle();
doReturn(TEST_CATALOG_FRAMEWORK_DESCRIPTION).when(catalogFramework).getDescription();
doReturn(TEST_CATALOG_FRAMEWORK_ID).when(catalogFramework).getId();
doReturn(TEST_CATALOG_FRAMEWORK_VERSION).when(catalogFramework).getVersion();
describeCommand.catalogFramework = catalogFramework;
}
use of ddf.catalog.source.CatalogProvider in project ddf by codice.
the class TestQueryMonitor method testActiveSearchConstructorValidInputs.
@Test
public void testActiveSearchConstructorValidInputs() {
CatalogProvider mockSource = mock(CatalogProvider.class);
uuid = UUID.randomUUID();
as = new ActiveSearch(CQL_TEXT, mockSource, uuid, CLIENT_TEXT);
assertThat(as.getCQL(), is(CQL_TEXT));
assertThat(as.getSource(), is(mockSource));
assertThat(as.getUniqueID(), is(uuid));
assertThat(as.getClientInfo(), is(CLIENT_TEXT));
}
Aggregations