use of ddf.catalog.source.CatalogStore in project ddf by codice.
the class CatalogFrameworkImplTest method testFederatedQueryPermissions.
@Test
public void testFederatedQueryPermissions() throws Exception {
MockEventProcessor eventAdmin = new MockEventProcessor();
MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<>(), true, new Date());
Map<String, CatalogStore> storeMap = new HashMap<>();
Map<String, FederatedSource> sourceMap = new HashMap<>();
Map<String, Set<String>> securityAttributes = new HashMap<>();
securityAttributes.put("role", Collections.singleton("myRole"));
MockCatalogStore store = new MockCatalogStore("catalogStoreId-1", true, securityAttributes);
storeMap.put(store.getId(), store);
sourceMap.put(store.getId(), store);
CatalogFramework framework = createDummyCatalogFramework(provider, storeMap, sourceMap, eventAdmin);
List<Metacard> metacards = new ArrayList<>();
MetacardImpl newCard = new MetacardImpl();
newCard.setId(null);
newCard.setContentTypeName("someType");
metacards.add(newCard);
Map<String, Serializable> reqProps = new HashMap<>();
HashSet<String> destinations = new HashSet<>();
//==== test writing to store and not local ====
destinations.add("catalogStoreId-1");
framework.create(new CreateRequestImpl(metacards, reqProps, destinations));
FilterBuilder builder = new GeotoolsFilterBuilder();
Subject subject = mock(Subject.class);
when(subject.isPermitted(any(KeyValueCollectionPermission.class))).thenReturn(true);
HashMap<String, Serializable> properties = new HashMap<>();
properties.put(SecurityConstants.SECURITY_SUBJECT, subject);
QueryImpl query = new QueryImpl(builder.attribute(Metacard.CONTENT_TYPE).is().like().text("someType"));
QueryRequestImpl request = new QueryRequestImpl(query, false, Collections.singletonList("catalogStoreId-1"), properties);
QueryResponse response = framework.query(request);
assertThat(response.getResults().size(), is(1));
}
use of ddf.catalog.source.CatalogStore in project ddf by codice.
the class RemoteDeleteOperationsTest method testNonEmptyStoreAvailableExpectsCaughtIngestException.
@Test
public void testNonEmptyStoreAvailableExpectsCaughtIngestException() throws Exception {
when(opsCatStoreSupport.isCatalogStoreRequest(deleteRequest)).thenReturn(true);
remoteDeleteOperations.setOpsCatStoreSupport(opsCatStoreSupport);
CatalogStore catalogStoreMock = mock(CatalogStore.class);
ArrayList<CatalogStore> stores = new ArrayList<>();
stores.add(catalogStoreMock);
IngestException ingestException = new IngestException();
when(opsCatStoreSupport.getCatalogStoresForRequest(any(), any())).thenReturn(stores);
when(catalogStoreMock.isAvailable()).thenReturn(true);
when(catalogStoreMock.delete(any())).thenThrow(ingestException);
DeleteResponse resultDeleteResponse = remoteDeleteOperations.performRemoteDelete(deleteRequest, deleteResponse);
assertThat("Assert caught IngestException", resultDeleteResponse.getProcessingErrors().size() >= 1);
verify(opsCatStoreSupport).isCatalogStoreRequest(deleteRequest);
verify(opsCatStoreSupport).getCatalogStoresForRequest(any(), any());
verify(catalogStoreMock).isAvailable();
verify(catalogStoreMock).delete(any());
}
Aggregations