Search in sources :

Example 11 with ContentType

use of ddf.catalog.data.ContentType in project ddf by codice.

the class WfsSource method getContentTypes.

@Override
public Set<ContentType> getContentTypes() {
    Set<QName> typeNames = featureTypeFilters.keySet();
    Set<ContentType> contentTypes = new HashSet<ContentType>();
    for (QName featureName : typeNames) {
        contentTypes.add(new ContentTypeImpl(featureName.getLocalPart(), getVersion()));
    }
    return contentTypes;
}
Also used : ContentTypeImpl(ddf.catalog.data.impl.ContentTypeImpl) ContentType(ddf.catalog.data.ContentType) QName(javax.xml.namespace.QName) HashSet(java.util.HashSet)

Example 12 with ContentType

use of ddf.catalog.data.ContentType in project ddf by codice.

the class CatalogFrameworkImplTest method testProviderRuntimeExceptionOnDeleteByID.

@Test(expected = IngestException.class)
public void testProviderRuntimeExceptionOnDeleteByID() throws IngestException {
    MockEventProcessor eventAdmin = new MockEventProcessor();
    // use exception provider instead of memory
    MockExceptionProvider provider = new MockExceptionProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), true, null);
    MockMemoryStorageProvider storageProvider = new MockMemoryStorageProvider();
    CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, eventAdmin, true);
    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
    try {
        framework.delete(request);
    } catch (SourceUnavailableException e) {
        fail();
    }
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) ContentType(ddf.catalog.data.ContentType) MockMemoryStorageProvider(ddf.catalog.content.impl.MockMemoryStorageProvider) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) CatalogFramework(ddf.catalog.CatalogFramework) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) DeleteRequest(ddf.catalog.operation.DeleteRequest) Test(org.junit.Test)

Example 13 with ContentType

use of ddf.catalog.data.ContentType in project ddf by codice.

the class CatalogFrameworkImplTest method testProviderRuntimeExceptionOnUpdateByID.

@Test(expected = IngestException.class)
public void testProviderRuntimeExceptionOnUpdateByID() throws IngestException {
    MockEventProcessor eventAdmin = new MockEventProcessor();
    // use exception provider instead of memory
    MockExceptionProvider provider = new MockExceptionProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), true, null);
    CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, eventAdmin, true);
    List<Entry<Object, Metacard>> metacards = new ArrayList<Entry<Object, Metacard>>();
    HashMap<Object, Metacard> map = new HashMap<Object, Metacard>();
    // expected to throw exception due to catalog provider being unavailable
    try {
        MetacardImpl newCard = new MetacardImpl();
        newCard.setId(null);
        newCard.setResourceURI(new URI("uri:///1234"));
        map.put(Metacard.ID, newCard);
        metacards.addAll(map.entrySet());
        UpdateRequest update = new UpdateRequestImpl(null, Metacard.ID, null);
        framework.update(update);
    } catch (URISyntaxException e) {
        fail();
    } catch (SourceUnavailableException e) {
        fail();
    }
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) ContentType(ddf.catalog.data.ContentType) HashMap(java.util.HashMap) 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) Entry(java.util.Map.Entry) SimpleEntry(java.util.AbstractMap.SimpleEntry) Matchers.hasEntry(org.hamcrest.Matchers.hasEntry) CatalogFramework(ddf.catalog.CatalogFramework) Matchers.anyObject(org.mockito.Matchers.anyObject) UpdateRequestImpl(ddf.catalog.operation.impl.UpdateRequestImpl) Test(org.junit.Test)

Example 14 with ContentType

use of ddf.catalog.data.ContentType in project ddf by codice.

the class TestCswSource method testAddingContentTypesOnQueries.

@Test
public void testAddingContentTypesOnQueries() throws CswException, UnsupportedQueryException, SecurityServiceException {
    Csw mockCsw = createMockCsw();
    List<String> expectedNames = new LinkedList<>(Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j"));
    ServiceRegistration<?> mockRegisteredMetacardType = (ServiceRegistration<?>) mock(ServiceRegistration.class);
    LOGGER.info("mockRegisteredMetacardType: {}", mockRegisteredMetacardType);
    doReturn(mockRegisteredMetacardType).when(mockContext).registerService(eq(MetacardType.class.getName()), any(MetacardType.class), Matchers.any());
    ServiceReference<?> mockServiceReference = (ServiceReference<?>) mock(ServiceReference.class);
    doReturn(mockServiceReference).when(mockRegisteredMetacardType).getReference();
    when(mockServiceReference.getProperty(eq(Metacard.CONTENT_TYPE))).thenReturn(expectedNames);
    AbstractCswSource source = getCswSource(mockCsw, mockContext);
    assertThat(source.getContentTypes(), hasSize(10));
    Set<ContentType> expected = generateContentType(expectedNames);
    assertThat(source.getContentTypes(), is(expected));
    CswRecordCollection collection = generateCswCollection("/getRecordsResponse.xml");
    when(mockCsw.getRecords(any(GetRecordsType.class))).thenReturn(collection);
    QueryImpl propertyIsLikeQuery = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text("*"));
    expectedNames.add("dataset");
    expectedNames.add("dataset 2");
    expectedNames.add("dataset 3");
    expected = generateContentType(expectedNames);
    source.query(new QueryRequestImpl(propertyIsLikeQuery));
    assertThat(source.getContentTypes(), hasSize(13));
    assertThat(source.getContentTypes(), is(expected));
}
Also used : ContentType(ddf.catalog.data.ContentType) Csw(org.codice.ddf.spatial.ogc.csw.catalog.common.Csw) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) Matchers.anyString(org.mockito.Matchers.anyString) LinkedList(java.util.LinkedList) MetacardType(ddf.catalog.data.MetacardType) ServiceReference(org.osgi.framework.ServiceReference) QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) CswRecordCollection(org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection) ServiceRegistration(org.osgi.framework.ServiceRegistration) Test(org.junit.Test)

Example 15 with ContentType

use of ddf.catalog.data.ContentType in project ddf by codice.

the class TestCswSourceBase method generateContentType.

protected Set<ContentType> generateContentType(List<String> names) {
    Set<ContentType> contentTypes = new HashSet<>();
    for (String name : names) {
        ContentType ct = new ContentTypeImpl(name, "");
        contentTypes.add(ct);
    }
    return contentTypes;
}
Also used : ContentTypeImpl(ddf.catalog.data.impl.ContentTypeImpl) ContentType(ddf.catalog.data.ContentType) Matchers.anyString(org.mockito.Matchers.anyString) HashSet(java.util.HashSet)

Aggregations

ContentType (ddf.catalog.data.ContentType)45 Test (org.junit.Test)34 CatalogFramework (ddf.catalog.CatalogFramework)17 ArrayList (java.util.ArrayList)17 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)14 Metacard (ddf.catalog.data.Metacard)12 ContentTypeImpl (ddf.catalog.data.impl.ContentTypeImpl)12 Source (ddf.catalog.source.Source)10 Date (java.util.Date)10 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)8 HashSet (java.util.HashSet)8 Matchers.anyString (org.mockito.Matchers.anyString)7 IngestException (ddf.catalog.source.IngestException)6 URI (java.net.URI)5 SourceInfoResponse (ddf.catalog.operation.SourceInfoResponse)4 CatalogProvider (ddf.catalog.source.CatalogProvider)4 SourceDescriptor (ddf.catalog.source.SourceDescriptor)4 SourcePoller (ddf.catalog.util.impl.SourcePoller)4 URISyntaxException (java.net.URISyntaxException)4 QName (javax.xml.namespace.QName)4