Search in sources :

Example 16 with UpdateResponseImpl

use of ddf.catalog.operation.impl.UpdateResponseImpl in project ddf by codice.

the class CatalogComponentFrameworkTest method testUpdateWithSingleMetacard.

@Test
public /**
 * Operation: UPDATE Body contains: Metacard
 */
void testUpdateWithSingleMetacard() throws Exception {
    resetMocks();
    // Setup expectations to verify
    final MockEndpoint mockVerifierEndpoint = getMockEndpoint("mock:result");
    mockVerifierEndpoint.expectedMessageCount(1);
    final List<Metacard> metacards = new ArrayList<Metacard>();
    metacards.add(metacard1);
    // setup mock catalog framework
    final Update update = new UpdateImpl(metacard1, metacard2);
    List<Update> updates = new ArrayList<Update>();
    updates.add(update);
    final String[] metacardIds = new String[metacards.size()];
    for (int i = 0; i < metacards.size(); i++) {
        metacardIds[i] = metacards.get(i).getId();
    }
    UpdateRequest updateRequest = new UpdateRequestImpl(metacardIds, metacards);
    UpdateResponse updateResponse = new UpdateResponseImpl(updateRequest, new HashMap(), updates);
    when(catalogFramework.update(any(UpdateRequest.class))).thenReturn(updateResponse);
    // Exercise the route with a UPDATE operation
    template.sendBodyAndHeader("direct:sampleInput", metacard1, "Operation", "UPDATE");
    // Verify that the number of metacards in the exchange after the records
    // is identical to the input
    assertListSize(mockVerifierEndpoint.getExchanges(), 1);
    final Exchange exchange = mockVerifierEndpoint.getExchanges().get(0);
    final List<Update> cardsUpdated = (List<Update>) exchange.getIn().getBody();
    assertListSize(cardsUpdated, 1);
    mockVerifierEndpoint.assertIsSatisfied();
}
Also used : UpdateImpl(ddf.catalog.operation.impl.UpdateImpl) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) UpdateRequest(ddf.catalog.operation.UpdateRequest) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Update(ddf.catalog.operation.Update) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Exchange(org.apache.camel.Exchange) UpdateResponse(ddf.catalog.operation.UpdateResponse) Metacard(ddf.catalog.data.Metacard) UpdateResponseImpl(ddf.catalog.operation.impl.UpdateResponseImpl) ArrayList(java.util.ArrayList) List(java.util.List) UpdateRequestImpl(ddf.catalog.operation.impl.UpdateRequestImpl) Test(org.junit.Test)

Aggregations

UpdateResponseImpl (ddf.catalog.operation.impl.UpdateResponseImpl)16 UpdateResponse (ddf.catalog.operation.UpdateResponse)13 ArrayList (java.util.ArrayList)12 Update (ddf.catalog.operation.Update)11 Test (org.junit.Test)11 HashMap (java.util.HashMap)10 Metacard (ddf.catalog.data.Metacard)9 UpdateImpl (ddf.catalog.operation.impl.UpdateImpl)9 UpdateRequest (ddf.catalog.operation.UpdateRequest)7 Serializable (java.io.Serializable)7 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)5 UpdateRequestImpl (ddf.catalog.operation.impl.UpdateRequestImpl)5 IngestException (ddf.catalog.source.IngestException)5 TransactionResponseType (net.opengis.cat.csw.v_2_0_2.TransactionResponseType)5 CswTransactionRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest)5 InputStream (java.io.InputStream)4 HttpHeaders (javax.ws.rs.core.HttpHeaders)4 TransactionSummaryType (net.opengis.cat.csw.v_2_0_2.TransactionSummaryType)4 Entry (java.util.Map.Entry)3 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)3