Search in sources :

Example 61 with IngestException

use of ddf.catalog.source.IngestException in project ddf by codice.

the class CatalogMetricsTest method catalogCreateExceptionMetric.

@Test
public void catalogCreateExceptionMetric() throws Exception {
    Iterable<Tag> createExceptionTags = Tags.of("type", IngestException.class.getName(), "source", "source2");
    CreateRequest request = mock(CreateRequest.class);
    CreateResponse response = mock(CreateResponse.class);
    mockCatalogResponseExceptions(request, response, new ProcessingDetailsImpl("source2", new IngestException()));
    catalogMetrics.process(response);
    assertThat(meterRegistry.counter("ddf.catalog.create.exceptions", createExceptionTags).count(), is(1.0));
}
Also used : CreateRequest(ddf.catalog.operation.CreateRequest) CreateResponse(ddf.catalog.operation.CreateResponse) IngestException(ddf.catalog.source.IngestException) Tag(io.micrometer.core.instrument.Tag) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) Test(org.junit.Test)

Example 62 with IngestException

use of ddf.catalog.source.IngestException in project ddf by codice.

the class ExceptionsTest method testIngestException.

@Test
public void testIngestException() {
    IngestException ie = new IngestException();
    assertNotNull(ie);
    ie = new IngestException(msg);
    assertEquals(ie.getMessage(), msg);
    ie = new IngestException(testCause);
    assertEquals(ie.getCause(), testCause);
    ie = new IngestException(msg, testCause);
    assertEquals(ie.getMessage(), msg);
    assertEquals(ie.getCause(), testCause);
}
Also used : IngestException(ddf.catalog.source.IngestException) Test(org.junit.Test)

Example 63 with IngestException

use of ddf.catalog.source.IngestException in project ddf by codice.

the class CatalogFrameworkImplTest method testProviderUnavailableDeleteByIdentifier.

/**
 * Tests that the framework properly throws a catalog exception when the local provider is not
 * available for delete by identifier.
 *
 * @throws IngestException
 * @throws SourceUnavailableException
 */
@Test(expected = SourceUnavailableException.class)
public void testProviderUnavailableDeleteByIdentifier() throws SourceUnavailableException {
    MockEventProcessor eventAdmin = new MockEventProcessor();
    MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), false, null);
    CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, eventAdmin, false);
    List<URI> uris = new ArrayList<URI>();
    try {
        uris.add(new URI("id://1234"));
        DeleteRequest request = new DeleteRequestImpl((URI[]) uris.toArray(new URI[uris.size()]));
        // expected to throw exception due to catalog provider being
        // unavailable
        framework.delete(request);
    } catch (URISyntaxException e) {
        fail();
    } catch (IngestException e) {
        fail();
    }
}
Also used : ContentType(ddf.catalog.data.ContentType) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) CatalogFramework(ddf.catalog.CatalogFramework) ArrayList(java.util.ArrayList) IngestException(ddf.catalog.source.IngestException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) DeleteRequest(ddf.catalog.operation.DeleteRequest) Test(org.junit.Test)

Example 64 with IngestException

use of ddf.catalog.source.IngestException in project ddf by codice.

the class CatalogFrameworkImplTest method testProviderUnavailableUpdateByID.

/**
 * Tests that the framework properly throws a catalog exception when the local provider is not
 * available for update by id.
 *
 * @throws IngestException
 * @throws SourceUnavailableException
 */
@Test(expected = SourceUnavailableException.class)
public void testProviderUnavailableUpdateByID() throws SourceUnavailableException {
    MockEventProcessor eventAdmin = new MockEventProcessor();
    MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), false, null);
    CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, eventAdmin, false);
    List<Metacard> metacards = new ArrayList<Metacard>();
    List<URI> uris = new ArrayList<URI>();
    // expected to throw exception due to catalog provider being unavailable
    try {
        MetacardImpl newCard = new MetacardImpl();
        newCard.setId(null);
        newCard.setResourceURI(new URI("uri:///1234"));
        metacards.add(newCard);
        uris.add(new URI("uri:///1234"));
        UpdateRequest update = new UpdateRequestImpl((URI[]) uris.toArray(new URI[uris.size()]), metacards);
        framework.update(update);
    } catch (URISyntaxException e) {
        fail();
    } catch (IngestException e) {
        fail();
    }
}
Also used : ContentType(ddf.catalog.data.ContentType) UpdateRequest(ddf.catalog.operation.UpdateRequest) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Metacard(ddf.catalog.data.Metacard) CatalogFramework(ddf.catalog.CatalogFramework) IngestException(ddf.catalog.source.IngestException) UpdateRequestImpl(ddf.catalog.operation.impl.UpdateRequestImpl) Test(org.junit.Test)

Example 65 with IngestException

use of ddf.catalog.source.IngestException in project ddf by codice.

the class CatalogFrameworkImplTest method testProviderUnavailableDeleteByID.

/**
 * Tests that the framework properly throws a catalog exception when the local provider is not
 * available for delete by id.
 *
 * @throws IngestException
 * @throws SourceUnavailableException
 */
@Test(expected = SourceUnavailableException.class)
public void testProviderUnavailableDeleteByID() throws SourceUnavailableException {
    MockEventProcessor eventAdmin = new MockEventProcessor();
    MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), false, null);
    CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, eventAdmin, false);
    List<String> ids = new ArrayList<String>();
    ids.add("1234");
    DeleteRequest request = new DeleteRequestImpl((String[]) ids.toArray(new String[ids.size()]));
    // expected to throw exception due to catalog provider being unavailable
    try {
        framework.delete(request);
    } catch (IngestException e) {
        fail();
    }
}
Also used : ContentType(ddf.catalog.data.ContentType) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) CatalogFramework(ddf.catalog.CatalogFramework) ArrayList(java.util.ArrayList) IngestException(ddf.catalog.source.IngestException) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DeleteRequest(ddf.catalog.operation.DeleteRequest) Test(org.junit.Test)

Aggregations

IngestException (ddf.catalog.source.IngestException)70 Metacard (ddf.catalog.data.Metacard)42 ArrayList (java.util.ArrayList)36 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)29 HashMap (java.util.HashMap)25 CreateResponse (ddf.catalog.operation.CreateResponse)21 IOException (java.io.IOException)21 Test (org.junit.Test)19 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)17 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)16 CreateRequest (ddf.catalog.operation.CreateRequest)15 InternalIngestException (ddf.catalog.source.InternalIngestException)15 Serializable (java.io.Serializable)15 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)14 Map (java.util.Map)13 DeleteResponse (ddf.catalog.operation.DeleteResponse)12 UpdateRequest (ddf.catalog.operation.UpdateRequest)12 FederationException (ddf.catalog.federation.FederationException)11 QueryResponse (ddf.catalog.operation.QueryResponse)11 UpdateResponse (ddf.catalog.operation.UpdateResponse)11