Search in sources :

Example 86 with CreateResponse

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

the class CatalogMetricsTest method catalogCreateMetric.

@Test
public void catalogCreateMetric() throws Exception {
    CreateRequest request = mock(CreateRequest.class);
    CreateResponse response = mock(CreateResponse.class);
    List<Metacard> createdList = mock(List.class);
    when(createdList.size()).thenReturn(100);
    when(response.getRequest()).thenReturn(request);
    when(response.getCreatedMetacards()).thenReturn(createdList);
    catalogMetrics.process(response);
    assertThat(meterRegistry.counter("ddf.catalog.create").count(), is(100.0));
}
Also used : Metacard(ddf.catalog.data.Metacard) CreateRequest(ddf.catalog.operation.CreateRequest) CreateResponse(ddf.catalog.operation.CreateResponse) Test(org.junit.Test)

Example 87 with CreateResponse

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

the class ResponseMetacardActionSplitter method split.

public List<Metacard> split(Response response) {
    List<Metacard> metacards = new ArrayList<>();
    if (response instanceof CreateResponse) {
        CreateResponse createResponse = (CreateResponse) response;
        metacards.addAll(createResponse.getCreatedMetacards());
    } else if (response instanceof UpdateResponse) {
        UpdateResponse updateResponse = (UpdateResponse) response;
        List<Update> updates = updateResponse.getUpdatedMetacards();
        for (Update update : updates) {
            metacards.add(update.getNewMetacard());
        }
    } else if (response instanceof DeleteResponse) {
        DeleteResponse deleteResponse = (DeleteResponse) response;
        metacards.addAll(deleteResponse.getDeletedMetacards());
    }
    return metacards;
}
Also used : UpdateResponse(ddf.catalog.operation.UpdateResponse) Metacard(ddf.catalog.data.Metacard) DeleteResponse(ddf.catalog.operation.DeleteResponse) CreateResponse(ddf.catalog.operation.CreateResponse) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Update(ddf.catalog.operation.Update)

Example 88 with CreateResponse

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

the class PluginTest method testCreateBadTransform.

@Test(expected = PluginExecutionException.class)
public void testCreateBadTransform() throws PluginExecutionException, CatalogTransformerException, IOException, IngestException, SourceUnavailableException {
    // given
    when(transformer.transform(isA(Metacard.class), isA(Map.class))).thenThrow(CatalogTransformerException.class);
    CreateResponse createResponse = new CreateResponseImpl(new CreateRequestImpl(metacard), null, Arrays.asList(metacard));
    // when
    plugin.process(createResponse);
}
Also used : Metacard(ddf.catalog.data.Metacard) CreateResponse(ddf.catalog.operation.CreateResponse) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) Map(java.util.Map) CreateResponseImpl(ddf.catalog.operation.impl.CreateResponseImpl) Test(org.junit.Test)

Example 89 with CreateResponse

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

the class PluginTest method testCreate.

@Test
@Ignore
public void testCreate() throws PluginExecutionException, CatalogTransformerException, IOException, IngestException, SourceUnavailableException {
    // given
    CreateResponse createResponse = new CreateResponseImpl(new CreateRequestImpl(metacard), null, Arrays.asList(metacard));
    // when
    CreateResponse response = plugin.process(createResponse);
    // then
    verify(endpoint).addDocument(isA(HttpHeaders.class), isA(UriInfo.class), isA(InputStream.class));
    assertThat(response, sameInstance(createResponse));
}
Also used : HttpHeaders(javax.ws.rs.core.HttpHeaders) CreateResponse(ddf.catalog.operation.CreateResponse) InputStream(java.io.InputStream) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) UriInfo(javax.ws.rs.core.UriInfo) CreateResponseImpl(ddf.catalog.operation.impl.CreateResponseImpl) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 90 with CreateResponse

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

the class PluginTest method testCreateNullParent.

@Test
@Ignore
public void testCreateNullParent() throws PluginExecutionException, IngestException, SourceUnavailableException {
    // given
    CreateResponse createResponse = new CreateResponseImpl(new CreateRequestImpl(metacard), null, Arrays.asList(metacard));
    // when
    plugin.process(createResponse);
    // then
    verify(endpoint, never()).addDocument(isA(HttpHeaders.class), isA(UriInfo.class), isA(InputStream.class));
}
Also used : HttpHeaders(javax.ws.rs.core.HttpHeaders) CreateResponse(ddf.catalog.operation.CreateResponse) InputStream(java.io.InputStream) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) UriInfo(javax.ws.rs.core.UriInfo) CreateResponseImpl(ddf.catalog.operation.impl.CreateResponseImpl) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

CreateResponse (ddf.catalog.operation.CreateResponse)111 Test (org.junit.Test)82 Metacard (ddf.catalog.data.Metacard)76 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)44 ArrayList (java.util.ArrayList)42 CreateRequest (ddf.catalog.operation.CreateRequest)36 QueryImpl (ddf.catalog.operation.impl.QueryImpl)29 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)29 CreateResponseImpl (ddf.catalog.operation.impl.CreateResponseImpl)27 HashMap (java.util.HashMap)25 Serializable (java.io.Serializable)23 List (java.util.List)23 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)22 DeleteResponse (ddf.catalog.operation.DeleteResponse)22 UpdateResponse (ddf.catalog.operation.UpdateResponse)21 Filter (org.opengis.filter.Filter)21 IngestException (ddf.catalog.source.IngestException)20 SourceResponse (ddf.catalog.operation.SourceResponse)18 QueryRequest (ddf.catalog.operation.QueryRequest)17 MetacardType (ddf.catalog.data.MetacardType)16