@Test /** Operation: UPDATE Body contains: Metacard */ public void testUpdateWithIngestException() 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))).thenThrow(new IngestException()); // Exercise the route with a UPDATE operation template.sendBodyAndHeader("direct:sampleInput", metacards, "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, 0); mockVerifierEndpoint.assertIsSatisfied(); }