Search in sources :

Example 41 with CreateRequest

use of ddf.catalog.operation.CreateRequest in project ddf by codice.

the class TestRegistryStore method testCreateWithExistingMetacard.

@Test
public void testCreateWithExistingMetacard() throws Exception {
    Metacard mcard = getDefaultMetacard();
    queryResults.add(new ResultImpl(mcard));
    CreateRequest request = new CreateRequestImpl(mcard);
    CreateResponse response = registryStore.create(request);
    assertThat(response.getCreatedMetacards().get(0), is(mcard));
}
Also used : Metacard(ddf.catalog.data.Metacard) CreateRequest(ddf.catalog.operation.CreateRequest) CreateResponse(ddf.catalog.operation.CreateResponse) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) ResultImpl(ddf.catalog.data.impl.ResultImpl) Test(org.junit.Test)

Example 42 with CreateRequest

use of ddf.catalog.operation.CreateRequest in project ddf by codice.

the class MetacardValidityMarkerPluginTest method testMetacardPassesEnforcedValidatorsNoDescribable.

@Test
public void testMetacardPassesEnforcedValidatorsNoDescribable() throws StopProcessingException, PluginExecutionException {
    MetacardValidator mockValidator = getMockPassingValidatorNoDescribable();
    metacardValidators.add(mockValidator);
    enforcedMetacardValidators.add(mockValidator.getClass().getCanonicalName());
    CreateRequest createRequest = getMockCreateRequest();
    List<Metacard> createdMetacards = createRequest.getMetacards();
    verifyEnforcedCreate(createRequest, createdMetacards);
    UpdateRequest updateRequest = getMockUpdateRequest();
    List<Metacard> updatedMetacards = getUpdatedMetacards(updateRequest);
    verifyEnforcedUpdate(updateRequest, updatedMetacards);
}
Also used : Metacard(ddf.catalog.data.Metacard) MetacardValidator(ddf.catalog.validation.MetacardValidator) UpdateRequest(ddf.catalog.operation.UpdateRequest) CreateRequest(ddf.catalog.operation.CreateRequest) Test(org.junit.Test)

Example 43 with CreateRequest

use of ddf.catalog.operation.CreateRequest in project ddf by codice.

the class MetacardValidityMarkerPluginTest method testMetacardPassesEnforcedValidators.

@Test
public void testMetacardPassesEnforcedValidators() throws StopProcessingException, PluginExecutionException {
    metacardValidators.add(getMockEnforcedPassingValidatorWithId(ID));
    enforcedMetacardValidators.add(ID);
    CreateRequest createRequest = getMockCreateRequest();
    List<Metacard> createdMetacards = createRequest.getMetacards();
    verifyEnforcedCreate(createRequest, createdMetacards);
    UpdateRequest updateRequest = getMockUpdateRequest();
    List<Metacard> updatedMetacards = getUpdatedMetacards(updateRequest);
    verifyEnforcedUpdate(updateRequest, updatedMetacards);
}
Also used : Metacard(ddf.catalog.data.Metacard) UpdateRequest(ddf.catalog.operation.UpdateRequest) CreateRequest(ddf.catalog.operation.CreateRequest) Test(org.junit.Test)

Example 44 with CreateRequest

use of ddf.catalog.operation.CreateRequest in project ddf by codice.

the class MetacardValidityMarkerPluginTest method verifyEnforcedCreate.

private void verifyEnforcedCreate(CreateRequest originalRequest, List<Metacard> expectedAllowedMetacards) throws PluginExecutionException, StopProcessingException {
    CreateRequest filteredRequest = plugin.process(originalRequest);
    List<Metacard> filteredMetacards = filteredRequest.getMetacards();
    verifyAllowedMetacards(filteredMetacards, expectedAllowedMetacards);
    verifyRequestPropertiesUnchanged(originalRequest, filteredRequest);
}
Also used : Metacard(ddf.catalog.data.Metacard) CreateRequest(ddf.catalog.operation.CreateRequest)

Example 45 with CreateRequest

use of ddf.catalog.operation.CreateRequest in project ddf by codice.

the class MetacardValidityMarkerPluginTest method testMultipleValidationTagsInvalid.

@Test
public void testMultipleValidationTagsInvalid() throws StopProcessingException, PluginExecutionException, ValidationException {
    metacardValidators.add(getMockFailingValidatorWithErrorsAndWarnings());
    CreateRequest request = getMockCreateRequest();
    Metacard m1 = request.getMetacards().get(0);
    Set<String> tags = m1.getTags();
    tags.add(VALID_TAG);
    m1.setAttribute(new AttributeImpl(Metacard.TAGS, new ArrayList<String>(tags)));
    CreateRequest filteredRequest = plugin.process(request);
    assertThat(filteredRequest.getMetacards().get(0).getTags(), hasItem(INVALID_TAG));
    assertThat(filteredRequest.getMetacards().get(0).getTags(), not(hasItem(VALID_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)

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