use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class CatalogFrameworkImplTest method testDeleteWithStores.
// TODO (DDF-2436) -
@Ignore
@Test
public void testDeleteWithStores() throws Exception {
MockEventProcessor eventAdmin = new MockEventProcessor();
MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<>(), true, new Date());
List<CatalogStore> storeList = new ArrayList<>();
List<FederatedSource> sourceList = new ArrayList<>();
MockCatalogStore store = new MockCatalogStore("catalogStoreId-1", true);
storeList.add(store);
sourceList.add(store);
CatalogFramework framework = createDummyCatalogFramework(provider, storeList, sourceList, eventAdmin);
FilterFactory filterFactory = new FilterFactoryImpl();
Filter filter = filterFactory.like(filterFactory.property(Metacard.METADATA), "*", "*", "?", "/", false);
List<Metacard> metacards = new ArrayList<>();
String id = UUID.randomUUID().toString().replaceAll("-", "");
MetacardImpl newCard = new MetacardImpl();
newCard.setId(id);
newCard.setAttribute("myKey", "myValue1");
metacards.add(newCard);
Map<String, Serializable> reqProps = new HashMap<>();
HashSet<String> destinations = new HashSet<>();
destinations.add("mockMemoryProvider");
destinations.add("catalogStoreId-1");
framework.create(new CreateRequestImpl(metacards, reqProps, destinations));
DeleteRequest deleteRequest = new DeleteRequestImpl(Collections.singletonList(id), Metacard.ID, new HashMap<>(), destinations);
DeleteResponse response = framework.delete(deleteRequest);
assertThat(response.getDeletedMetacards().size(), is(1));
QueryResponse queryResponse = framework.query(new QueryRequestImpl(new QueryImpl(filter), true));
assertThat(queryResponse.getResults().size(), is(0));
}
use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class CatalogFrameworkImplTest method testUpdateWithDefaults.
@Test
public void testUpdateWithDefaults() throws Exception {
final String title = "some title";
final Date expiration = new Date();
List<Metacard> metacards = getMetacards(title, expiration);
CreateRequest createRequest = new CreateRequestImpl(metacards);
CreateResponse createResponse = framework.create(createRequest);
verifyDefaults(createResponse.getCreatedMetacards(), title, expiration, null, null, null, null);
registerDefaults();
List<Result> mockFederationResults = metacards.stream().map(m -> {
Result mockResult = mock(Result.class);
when(mockResult.getMetacard()).thenReturn(m);
return mockResult;
}).collect(Collectors.toList());
QueryResponseImpl queryResponse = new QueryResponseImpl(mock(QueryRequest.class), mockFederationResults, 1);
when(mockFederationStrategy.federate(anyList(), any())).thenReturn(queryResponse);
UpdateRequest updateRequest = new UpdateRequestImpl(new String[] { "1", "2", "3", "4", "5" }, createResponse.getCreatedMetacards());
UpdateResponse updateResponse = framework.update(updateRequest);
List<Metacard> updatedMetacards = updateResponse.getUpdatedMetacards().stream().map(Update::getNewMetacard).collect(Collectors.toList());
verifyDefaults(updatedMetacards, title, expiration, DEFAULT_TITLE, DEFAULT_EXPIRATION, DEFAULT_TITLE_CUSTOM, DEFAULT_EXPIRATION_CUSTOM);
}
use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class CatalogFrameworkImplTest method testCreate.
// Start testing MetacardWriter
/**
* Tests that the framework properly passes a create request to the local provider.
*/
@Test
public void testCreate() throws Exception {
List<Metacard> metacards = new ArrayList<>();
MetacardImpl newCard = new MetacardImpl();
newCard.setId(null);
metacards.add(newCard);
CreateResponse response = framework.create(new CreateRequestImpl(metacards, null));
assertEquals(response.getCreatedMetacards().size(), provider.size());
for (Metacard curCard : response.getCreatedMetacards()) {
assertNotNull(curCard.getId());
}
// make sure that the event was posted correctly
assertTrue(eventAdmin.wasEventPosted());
Metacard[] array = {};
array = response.getCreatedMetacards().toArray(array);
assertTrue(eventAdmin.wasEventPosted());
assertEquals(eventAdmin.getLastEvent(), array[array.length - 1]);
}
use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class CatalogFrameworkImplTest method testCreateWithDefaultValues.
@Test
public void testCreateWithDefaultValues() throws IngestException, SourceUnavailableException {
registerDefaults();
final String title = "some title";
final Date expiration = new Date();
CreateRequest createRequest = new CreateRequestImpl(getMetacards(title, expiration));
CreateResponse createResponse = framework.create(createRequest);
verifyDefaults(createResponse.getCreatedMetacards(), title, expiration, DEFAULT_TITLE, DEFAULT_EXPIRATION, DEFAULT_TITLE_CUSTOM, DEFAULT_EXPIRATION_CUSTOM);
}
use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class MetacardValidityMarkerPluginTest method testPreExistingMetacardErrors.
@Test
public void testPreExistingMetacardErrors() throws ValidationException, StopProcessingException, PluginExecutionException {
metacardValidators.add(getMockPassingValidator());
CreateRequestImpl request = new CreateRequestImpl(metacardsWithPreExistingAttributes(true, false), PROPERTIES, DESTINATIONS);
verifyCreate(request, expectError, expectNone, INVALID_TAG);
}
Aggregations