use of ddf.catalog.operation.CreateRequest 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.CreateRequest in project ddf by codice.
the class MetacardValidityMarkerPluginTest method verifyCreate.
private void verifyCreate(CreateRequest originalRequest, Consumer<Attribute> errorExpectation, Consumer<Attribute> warningExpectation, String expectedTag) throws PluginExecutionException, StopProcessingException {
CreateRequest filteredRequest = plugin.process(originalRequest);
List<Metacard> filteredMetacards = filteredRequest.getMetacards();
verifyMetacardErrorsAndWarnings(filteredMetacards, errorExpectation, warningExpectation, expectedTag);
verifyRequestPropertiesUnchanged(originalRequest, filteredRequest);
}
use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class MetacardValidityMarkerPluginTest method testMultipleValidationTagsValid.
@Test
public void testMultipleValidationTagsValid() throws StopProcessingException, PluginExecutionException {
metacardValidators.add(getMockPassingValidator());
CreateRequest request = getMockCreateRequest();
Metacard m1 = request.getMetacards().get(0);
Set<String> tags = m1.getTags();
tags.add(INVALID_TAG);
m1.setAttribute(new AttributeImpl(Metacard.TAGS, new ArrayList<String>(tags)));
CreateRequest filteredRequest = plugin.process(request);
assertThat(filteredRequest.getMetacards().get(0).getTags(), hasItem(VALID_TAG));
assertThat(filteredRequest.getMetacards().get(0).getTags(), not(hasItem(INVALID_TAG)));
}
use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class MetacardValidityMarkerPluginTest method markerPluginResponseHelper.
private List<Metacard> markerPluginResponseHelper(MetacardValidator validator, boolean enforceErrors, boolean enforceWarnings, int numNotFiltered) throws Exception {
String validatorName = plugin.getValidatorName(validator);
metacardValidators.add(validator);
enforcedMetacardValidators.add(validatorName);
plugin.setMetacardValidators(metacardValidators);
plugin.setEnforcedMetacardValidators(enforcedMetacardValidators);
plugin.setEnforceErrors(enforceErrors);
plugin.setEnforceWarnings(enforceWarnings);
CreateRequest createRequest = plugin.process(getMockCreateRequest());
List<Metacard> createdMetacards = createRequest.getMetacards();
assertThat(createdMetacards.size(), is(numNotFiltered));
//reset
metacardValidators.remove(validator);
enforcedMetacardValidators.remove(validatorName);
plugin.setEnforceErrors(true);
plugin.setEnforceWarnings(false);
return createdMetacards;
}
use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class MetacardValidityMarkerPluginTest method testMetacardFailsEnforcedValidator.
@Test
public void testMetacardFailsEnforcedValidator() throws ValidationException, StopProcessingException, PluginExecutionException {
metacardValidators.add(getMockEnforcedFailingValidatorWithId(ID));
enforcedMetacardValidators.add(ID);
CreateRequest createRequest = getMockCreateRequest();
List<Metacard> createdMetacards = createRequest.getMetacards();
verifyEnforcedCreate(createRequest, createdMetacards.subList(1, createdMetacards.size()));
UpdateRequest updateRequest = getMockUpdateRequest();
List<Metacard> updatedMetacards = getUpdatedMetacards(updateRequest);
verifyEnforcedUpdate(updateRequest, updatedMetacards.subList(1, updatedMetacards.size()));
}
Aggregations