Search in sources :

Example 16 with CatalogFramework

use of ddf.catalog.CatalogFramework in project ddf by codice.

the class CatalogFrameworkImplTest method testMetacardTransformWithNullMetacard.

@Test(expected = IllegalArgumentException.class)
public void testMetacardTransformWithNullMetacard() throws Exception {
    BundleContext context = mock(BundleContext.class);
    ServiceReference reference = mock(ServiceReference.class);
    ServiceReference[] serviceReferences = new ServiceReference[] { reference };
    when(context.getServiceReferences(anyString(), anyString())).thenReturn(serviceReferences);
    CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, context, eventAdmin, true);
    framework.transform((Metacard) null, "NONE", new HashMap<String, Serializable>());
}
Also used : Serializable(java.io.Serializable) CatalogFramework(ddf.catalog.CatalogFramework) Matchers.anyString(org.mockito.Matchers.anyString) BundleContext(org.osgi.framework.BundleContext) ServiceReference(org.osgi.framework.ServiceReference) Test(org.junit.Test)

Example 17 with CatalogFramework

use of ddf.catalog.CatalogFramework in project ddf by codice.

the class TestResourceMetacardTransformer method testGetResourceJpeg.

@Test
public void testGetResourceJpeg() throws Exception {
    String filePath = ABSOLUTE_PATH + TEST_PATH + JPEG_FILE_NAME_1;
    URI uri = getUri(filePath);
    Metacard metacard = getMockMetacard(uri);
    boolean expectSuccess = true;
    MimeType mimeType = getMimeType(JPEG_MIME_TYPE);
    CatalogFramework framework = getFramework(getResourceResponse(getResource(mimeType, uri)));
    testGetResource(metacard, filePath, mimeType, framework, expectSuccess);
}
Also used : Metacard(ddf.catalog.data.Metacard) CatalogFramework(ddf.catalog.CatalogFramework) URI(java.net.URI) MimeType(javax.activation.MimeType) Test(org.junit.Test)

Example 18 with CatalogFramework

use of ddf.catalog.CatalogFramework in project ddf by codice.

the class TestResourceMetacardTransformer method testGetResourceTransportStream.

@Test
public void testGetResourceTransportStream() throws Exception {
    String filePath = ABSOLUTE_PATH + TEST_PATH + TS_FILE_NAME_1;
    URI uri = getUri(filePath);
    Metacard metacard = getMockMetacard(uri);
    boolean expectSuccess = true;
    MimeType mimeType = getMimeType(VIDEO_MIME_TYPE);
    CatalogFramework framework = getFramework(getResourceResponse(getResource(mimeType, uri)));
    testGetResource(metacard, filePath, mimeType, framework, expectSuccess);
}
Also used : Metacard(ddf.catalog.data.Metacard) CatalogFramework(ddf.catalog.CatalogFramework) URI(java.net.URI) MimeType(javax.activation.MimeType) Test(org.junit.Test)

Example 19 with CatalogFramework

use of ddf.catalog.CatalogFramework in project ddf by codice.

the class TestResourceMetacardTransformer method testNullMetacardId.

@Test
public void testNullMetacardId() throws Exception {
    thrown.expect(CatalogTransformerException.class);
    thrown.expectMessage("Could not transform metacard to a resource because the metacard is not valid.");
    String filePath = ABSOLUTE_PATH + TEST_PATH + TS_FILE_NAME_1;
    URI uri = getUri(filePath);
    Metacard metacard = getMockMetacard(uri);
    when(metacard.getId()).thenReturn(null);
    boolean expectSuccess = false;
    MimeType mimeType = getMimeType(VIDEO_MIME_TYPE);
    CatalogFramework framework = getFramework(getResourceResponse(getResource(mimeType, uri)));
    testGetResource(metacard, filePath, mimeType, framework, expectSuccess);
}
Also used : Metacard(ddf.catalog.data.Metacard) CatalogFramework(ddf.catalog.CatalogFramework) URI(java.net.URI) MimeType(javax.activation.MimeType) Test(org.junit.Test)

Example 20 with CatalogFramework

use of ddf.catalog.CatalogFramework in project ddf by codice.

the class TestResourceMetacardTransformer method testNullResourceUri.

@Test
public void testNullResourceUri() throws Exception {
    thrown.expect(CatalogTransformerException.class);
    thrown.expectMessage("Unable to retrieve resource.");
    Metacard metacard = getMockMetacard(null);
    CatalogFramework framework = getFrameworkException(new ResourceNotFoundException(""));
    ResourceMetacardTransformer resourceTransformer = new ResourceMetacardTransformer(framework);
    resourceTransformer.transform(metacard, new HashMap<String, Serializable>());
}
Also used : Metacard(ddf.catalog.data.Metacard) Serializable(java.io.Serializable) CatalogFramework(ddf.catalog.CatalogFramework) ResourceNotFoundException(ddf.catalog.resource.ResourceNotFoundException) Test(org.junit.Test)

Aggregations

CatalogFramework (ddf.catalog.CatalogFramework)80 Test (org.junit.Test)63 Matchers.anyString (org.mockito.Matchers.anyString)30 Metacard (ddf.catalog.data.Metacard)27 QueryResponse (ddf.catalog.operation.QueryResponse)20 ArrayList (java.util.ArrayList)20 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)19 Serializable (java.io.Serializable)18 ContentType (ddf.catalog.data.ContentType)17 URI (java.net.URI)17 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)14 HashMap (java.util.HashMap)14 SourceInfoResponse (ddf.catalog.operation.SourceInfoResponse)12 Date (java.util.Date)12 BundleContext (org.osgi.framework.BundleContext)11 MimeType (javax.activation.MimeType)10 Response (javax.ws.rs.core.Response)10 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)9 ServiceReference (org.osgi.framework.ServiceReference)9 FilterBuilder (ddf.catalog.filter.FilterBuilder)8