@Test
  /** Operation: CREATE Body contains: Metacard */
  public void testCreateWithIngestException() 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);

    // Mock catalog framework
    final CreateRequest createRequest = new CreateRequestImpl(metacards);
    final CreateResponse createResponse =
        new CreateResponseImpl(createRequest, new HashMap(), metacards);
    when(catalogFramework.create(any(CreateRequest.class))).thenThrow(new IngestException());

    // Exercise the route with a CREATE operation
    template.sendBodyAndHeader("direct:sampleInput", metacard1, "Operation", "CREATE");

    // 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<Metacard> cardsCreated = (List<Metacard>) exchange.getIn().getBody();
    assertListSize(cardsCreated, 0);

    mockVerifierEndpoint.assertIsSatisfied();
  }
Пример #2
0
 private void store(List<Metacard> metacards) throws PluginExecutionException {
   try {
     catalogFramework.create(new CreateRequestImpl(metacards));
   } catch (SourceUnavailableException | IngestException e) {
     throw new PluginExecutionException(e);
   }
 }