Search in sources :

Example 11 with CreateRequest

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);
}
Also used : CreateRequest(ddf.catalog.operation.CreateRequest) CreateResponse(ddf.catalog.operation.CreateResponse) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) Matchers.anyString(org.mockito.Matchers.anyString) Date(java.util.Date) Test(org.junit.Test)

Example 12 with CreateRequest

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);
}
Also used : Metacard(ddf.catalog.data.Metacard) CreateRequest(ddf.catalog.operation.CreateRequest)

Example 13 with CreateRequest

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)));
}
Also used : Metacard(ddf.catalog.data.Metacard) CreateRequest(ddf.catalog.operation.CreateRequest) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 14 with CreateRequest

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;
}
Also used : Metacard(ddf.catalog.data.Metacard) CreateRequest(ddf.catalog.operation.CreateRequest)

Example 15 with CreateRequest

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()));
}
Also used : Metacard(ddf.catalog.data.Metacard) UpdateRequest(ddf.catalog.operation.UpdateRequest) CreateRequest(ddf.catalog.operation.CreateRequest) Test(org.junit.Test)

Aggregations

CreateRequest (ddf.catalog.operation.CreateRequest)63 Test (org.junit.Test)49 Metacard (ddf.catalog.data.Metacard)38 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)36 CreateResponse (ddf.catalog.operation.CreateResponse)26 ArrayList (java.util.ArrayList)16 HashMap (java.util.HashMap)16 CreateResponseImpl (ddf.catalog.operation.impl.CreateResponseImpl)12 Subject (ddf.security.Subject)12 Serializable (java.io.Serializable)10 IngestException (ddf.catalog.source.IngestException)9 List (java.util.List)9 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)8 HashSet (java.util.HashSet)7 UpdateRequest (ddf.catalog.operation.UpdateRequest)6 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)6 IOException (java.io.IOException)6 InputStream (java.io.InputStream)6 CatalogFramework (ddf.catalog.CatalogFramework)4 QueryRequest (ddf.catalog.operation.QueryRequest)4