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();
}
Aggregations