Search in sources :

Example 31 with UpdateRequest

use of ddf.catalog.operation.UpdateRequest 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 32 with UpdateRequest

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

the class MetacardValidityMarkerPluginTest method verifyEnforcedUpdate.

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

Example 33 with UpdateRequest

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

the class MetacardValidityMarkerPluginTest method verifyUpdate.

private void verifyUpdate(UpdateRequest originalRequest, Consumer<Attribute> errorExpectation, Consumer<Attribute> warningExpectation, String expectedTag) throws PluginExecutionException, StopProcessingException {
    UpdateRequest filteredRequest = plugin.process(originalRequest);
    List<Metacard> filteredMetacards = getUpdatedMetacards(filteredRequest);
    verifyMetacardErrorsAndWarnings(filteredMetacards, errorExpectation, warningExpectation, expectedTag);
    verifyRequestPropertiesUnchanged(originalRequest, filteredRequest);
}
Also used : Metacard(ddf.catalog.data.Metacard) UpdateRequest(ddf.catalog.operation.UpdateRequest)

Example 34 with UpdateRequest

use of ddf.catalog.operation.UpdateRequest 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 35 with UpdateRequest

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

the class TestMetacardGroomerPlugin method testUpdateSingleUpdateNull.

@Test
public void testUpdateSingleUpdateNull() throws PluginExecutionException, StopProcessingException {
    UpdateRequest request = mock(UpdateRequest.class);
    List<Entry<Serializable, Metacard>> updates = new ArrayList<>();
    updates.add(null);
    when(request.getUpdates()).thenReturn(updates);
    UpdateRequest returnedRequest = plugin.process(request);
    assertThat(returnedRequest, is(request));
}
Also used : Entry(java.util.Map.Entry) UpdateRequest(ddf.catalog.operation.UpdateRequest) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

UpdateRequest (ddf.catalog.operation.UpdateRequest)61 Test (org.junit.Test)44 Metacard (ddf.catalog.data.Metacard)41 ArrayList (java.util.ArrayList)32 Serializable (java.io.Serializable)25 UpdateResponse (ddf.catalog.operation.UpdateResponse)23 UpdateRequestImpl (ddf.catalog.operation.impl.UpdateRequestImpl)23 HashMap (java.util.HashMap)21 Update (ddf.catalog.operation.Update)17 List (java.util.List)16 Entry (java.util.Map.Entry)16 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)15 Map (java.util.Map)12 SimpleEntry (java.util.AbstractMap.SimpleEntry)11 IngestException (ddf.catalog.source.IngestException)10 URI (java.net.URI)10 Result (ddf.catalog.data.Result)9 CreateRequest (ddf.catalog.operation.CreateRequest)9 CatalogFramework (ddf.catalog.CatalogFramework)8 CreateResponse (ddf.catalog.operation.CreateResponse)8