Search in sources :

Example 36 with UpdateRequest

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

the class TestMetacardGroomerPlugin method testUpdateWithNullRequest.

@Test
public void testUpdateWithNullRequest() throws PluginExecutionException, StopProcessingException {
    UpdateRequest returnedRequest = plugin.process((UpdateRequest) null);
    assertThat(returnedRequest, nullValue());
}
Also used : UpdateRequest(ddf.catalog.operation.UpdateRequest) Test(org.junit.Test)

Example 37 with UpdateRequest

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

the class TestMetacardGroomerPlugin method testUpdateSingleUpdateKeyNull.

@Test
public void testUpdateSingleUpdateKeyNull() throws PluginExecutionException, StopProcessingException {
    UpdateRequest request = mock(UpdateRequest.class);
    List<Entry<Serializable, Metacard>> updates = new ArrayList<>();
    updates.add(new Entry<Serializable, Metacard>() {

        @Override
        public Metacard setValue(Metacard value) {
            return null;
        }

        @Override
        public Metacard getValue() {
            return null;
        }

        @Override
        public Serializable getKey() {
            return null;
        }
    });
    when(request.getUpdates()).thenReturn(updates);
    UpdateRequest returnedRequest = plugin.process(request);
    assertThat(returnedRequest, is(request));
}
Also used : Entry(java.util.Map.Entry) Serializable(java.io.Serializable) Metacard(ddf.catalog.data.Metacard) UpdateRequest(ddf.catalog.operation.UpdateRequest) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 38 with UpdateRequest

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

the class TestMetacardGroomerPlugin method testUpdateSingleUpdateValueNull.

@Test
public void testUpdateSingleUpdateValueNull() throws PluginExecutionException, StopProcessingException {
    UpdateRequest request = mock(UpdateRequest.class);
    List<Entry<Serializable, Metacard>> updates = new ArrayList<>();
    updates.add(new Entry<Serializable, Metacard>() {

        @Override
        public Metacard setValue(Metacard value) {
            return null;
        }

        @Override
        public Metacard getValue() {
            return null;
        }

        @Override
        public Serializable getKey() {
            return SAMPLE_ID;
        }
    });
    when(request.getUpdates()).thenReturn(updates);
    UpdateRequest returnedRequest = plugin.process(request);
    assertThat(returnedRequest, is(request));
}
Also used : Entry(java.util.Map.Entry) Serializable(java.io.Serializable) Metacard(ddf.catalog.data.Metacard) UpdateRequest(ddf.catalog.operation.UpdateRequest) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 39 with UpdateRequest

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

the class TestMetacardGroomerPlugin method processUpdate.

private Metacard processUpdate(Metacard inputMetacard) throws PluginExecutionException, StopProcessingException {
    UpdateRequestImpl inputRequest = new UpdateRequestImpl(SAMPLE_ID, copy(inputMetacard));
    UpdateRequest returnedRequest = plugin.process(inputRequest);
    assertNotNull(returnedRequest);
    assertThat(returnedRequest.getUpdates().size(), is(1));
    return returnedRequest.getUpdates().get(0).getValue();
}
Also used : UpdateRequest(ddf.catalog.operation.UpdateRequest) UpdateRequestImpl(ddf.catalog.operation.impl.UpdateRequestImpl)

Example 40 with UpdateRequest

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

the class CatalogMetricsTest method catalogUpdateMetric.

@Test
public void catalogUpdateMetric() throws Exception {
    UpdateRequest request = mock(UpdateRequest.class);
    UpdateResponse response = mock(UpdateResponse.class);
    List<Update> updatedList = mock(List.class);
    when(updatedList.size()).thenReturn(100);
    when(response.getRequest()).thenReturn(request);
    when(response.getUpdatedMetacards()).thenReturn(updatedList);
    underTest.process(response);
    assertThat(underTest.updatedMetacards.getCount(), is(100L));
}
Also used : UpdateResponse(ddf.catalog.operation.UpdateResponse) UpdateRequest(ddf.catalog.operation.UpdateRequest) Update(ddf.catalog.operation.Update) 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