Search in sources :

Example 51 with ContentType

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

the class SolrProviderContentTypes method testGetContentTypesOne.

@Test
public void testGetContentTypesOne() throws Exception {
    deleteAll(provider);
    MockMetacard metacard1 = new MockMetacard(Library.getFlagstaffRecord());
    metacard1.setContentTypeName(SAMPLE_CONTENT_TYPE_1);
    List<Metacard> list = Collections.singletonList(metacard1);
    create(list, provider);
    Set<ContentType> contentTypes = provider.getContentTypes();
    assertEquals(1, contentTypes.size());
    assertThat(contentTypes, hasItem((ContentType) new ContentTypeImpl(SAMPLE_CONTENT_TYPE_1, MockMetacard.DEFAULT_VERSION)));
}
Also used : ContentTypeImpl(ddf.catalog.data.impl.ContentTypeImpl) Metacard(ddf.catalog.data.Metacard) ContentType(ddf.catalog.data.ContentType) Test(org.junit.Test) SolrProviderTest(ddf.catalog.source.solr.SolrProviderTest)

Example 52 with ContentType

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

the class SolrProviderContentTypes method testGetContentTypesOneNoVersion.

@Test
public void testGetContentTypesOneNoVersion() throws Exception {
    deleteAll(provider);
    MockMetacard metacard1 = new MockMetacard(Library.getFlagstaffRecord());
    metacard1.setContentTypeName(SAMPLE_CONTENT_TYPE_1);
    metacard1.setContentTypeVersion(null);
    List<Metacard> list = Collections.singletonList(metacard1);
    create(list, provider);
    Set<ContentType> contentTypes = provider.getContentTypes();
    assertEquals(1, contentTypes.size());
    assertThat(contentTypes, hasItem((ContentType) new ContentTypeImpl(SAMPLE_CONTENT_TYPE_1, null)));
}
Also used : ContentTypeImpl(ddf.catalog.data.impl.ContentTypeImpl) Metacard(ddf.catalog.data.Metacard) ContentType(ddf.catalog.data.ContentType) Test(org.junit.Test) SolrProviderTest(ddf.catalog.source.solr.SolrProviderTest)

Example 53 with ContentType

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

the class SolrProviderContentTypes method testGetContentTypesComplicated.

@Test
public void testGetContentTypesComplicated() throws Exception {
    deleteAll(provider);
    List<Metacard> list = new ArrayList<>();
    // Single content type and version
    MockMetacard metacard1 = new MockMetacard(Library.getFlagstaffRecord());
    metacard1.setContentTypeName(SAMPLE_CONTENT_TYPE_1);
    metacard1.setContentTypeVersion(SAMPLE_CONTENT_VERSION_1);
    list.add(metacard1);
    // one content type with multiple versions
    metacard1 = new MockMetacard(Library.getFlagstaffRecord());
    metacard1.setContentTypeName(SAMPLE_CONTENT_TYPE_2);
    metacard1.setContentTypeVersion(SAMPLE_CONTENT_VERSION_1);
    list.add(metacard1);
    MockMetacard metacard2 = new MockMetacard(Library.getFlagstaffRecord());
    metacard2.setContentTypeName(SAMPLE_CONTENT_TYPE_2);
    metacard2.setContentTypeVersion(SAMPLE_CONTENT_VERSION_2);
    list.add(metacard2);
    // multiple records with different content type but same version
    metacard1 = new MockMetacard(Library.getFlagstaffRecord());
    metacard1.setContentTypeName(SAMPLE_CONTENT_TYPE_3);
    metacard1.setContentTypeVersion(SAMPLE_CONTENT_VERSION_3);
    list.add(metacard1);
    metacard2 = new MockMetacard(Library.getFlagstaffRecord());
    metacard2.setContentTypeName(SAMPLE_CONTENT_TYPE_3);
    metacard2.setContentTypeVersion(SAMPLE_CONTENT_VERSION_4);
    list.add(metacard2);
    // multiple records with different content type and different version
    metacard1 = new MockMetacard(Library.getFlagstaffRecord());
    metacard1.setContentTypeName(SAMPLE_CONTENT_TYPE_4);
    metacard1.setContentTypeVersion(SAMPLE_CONTENT_VERSION_1);
    list.add(metacard1);
    metacard2 = new MockMetacard(Library.getFlagstaffRecord());
    metacard2.setContentTypeName(SAMPLE_CONTENT_TYPE_1);
    metacard2.setContentTypeVersion(SAMPLE_CONTENT_VERSION_4);
    list.add(metacard2);
    metacard1 = new MockMetacard(Library.getFlagstaffRecord());
    metacard1.setContentTypeName(SAMPLE_CONTENT_TYPE_4);
    metacard1.setContentTypeVersion(SAMPLE_CONTENT_VERSION_1);
    list.add(metacard1);
    metacard2 = new MockMetacard(Library.getFlagstaffRecord());
    metacard2.setContentTypeName(SAMPLE_CONTENT_TYPE_1);
    metacard2.setContentTypeVersion(SAMPLE_CONTENT_VERSION_4);
    list.add(metacard2);
    create(list, provider);
    Set<ContentType> contentTypes = provider.getContentTypes();
    assertEquals(7, contentTypes.size());
    assertThat(contentTypes, hasItem((ContentType) new ContentTypeImpl(SAMPLE_CONTENT_TYPE_1, SAMPLE_CONTENT_VERSION_1)));
    assertThat(contentTypes, hasItem((ContentType) new ContentTypeImpl(SAMPLE_CONTENT_TYPE_2, SAMPLE_CONTENT_VERSION_1)));
    assertThat(contentTypes, hasItem((ContentType) new ContentTypeImpl(SAMPLE_CONTENT_TYPE_2, SAMPLE_CONTENT_VERSION_2)));
    assertThat(contentTypes, hasItem((ContentType) new ContentTypeImpl(SAMPLE_CONTENT_TYPE_3, SAMPLE_CONTENT_VERSION_3)));
    assertThat(contentTypes, hasItem((ContentType) new ContentTypeImpl(SAMPLE_CONTENT_TYPE_3, SAMPLE_CONTENT_VERSION_4)));
    assertThat(contentTypes, hasItem((ContentType) new ContentTypeImpl(SAMPLE_CONTENT_TYPE_4, SAMPLE_CONTENT_VERSION_1)));
    assertThat(contentTypes, hasItem((ContentType) new ContentTypeImpl(SAMPLE_CONTENT_TYPE_1, SAMPLE_CONTENT_VERSION_4)));
}
Also used : ContentTypeImpl(ddf.catalog.data.impl.ContentTypeImpl) Metacard(ddf.catalog.data.Metacard) ContentType(ddf.catalog.data.ContentType) ArrayList(java.util.ArrayList) Test(org.junit.Test) SolrProviderTest(ddf.catalog.source.solr.SolrProviderTest)

Example 54 with ContentType

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

the class CswSourceTest 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), 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(getQueryRequestWithSubject(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) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) LinkedList(java.util.LinkedList) MetacardType(ddf.catalog.data.MetacardType) ServiceReference(org.osgi.framework.ServiceReference) QueryImpl(ddf.catalog.operation.impl.QueryImpl) CswRecordCollection(org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection) ServiceRegistration(org.osgi.framework.ServiceRegistration) Test(org.junit.Test)

Example 55 with ContentType

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

the class WfsSourceTest method testConfigureFeatureTypes.

@Test
public void testConfigureFeatureTypes() throws WfsException {
    ArgumentCaptor<DescribeFeatureTypeRequest> captor = ArgumentCaptor.forClass(DescribeFeatureTypeRequest.class);
    WfsSource source = getWfsSource(ONE_TEXT_PROPERTY_SCHEMA, MockWfsServer.getFilterCapabilities(), 1);
    final String SAMPLE_FEATURE_NAME0 = SAMPLE_FEATURE_NAME + "0";
    verify(mockWfs).describeFeatureType(captor.capture());
    DescribeFeatureTypeRequest describeFeatureType = captor.getValue();
    // sample feature 0 does not have a prefix
    assertThat(SAMPLE_FEATURE_NAME0, equalTo(describeFeatureType.getTypeName()));
    assertTrue(source.isAvailable());
    assertThat(source.featureTypeFilters.size(), is(1));
    WfsFilterDelegate delegate = source.featureTypeFilters.get(new QName(SAMPLE_FEATURE_NAME0));
    assertThat(delegate, notNullValue());
    assertThat(source.getContentTypes().size(), is(1));
    List<ContentType> types = new ArrayList<>();
    types.addAll(source.getContentTypes());
    assertTrue(SAMPLE_FEATURE_NAME0.equals(types.get(0).getName()));
}
Also used : ContentType(ddf.catalog.data.ContentType) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString) DescribeFeatureTypeRequest(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.DescribeFeatureTypeRequest) Test(org.junit.Test)

Aggregations

ContentType (ddf.catalog.data.ContentType)55 Test (org.junit.Test)43 ArrayList (java.util.ArrayList)20 CatalogFramework (ddf.catalog.CatalogFramework)18 ContentTypeImpl (ddf.catalog.data.impl.ContentTypeImpl)18 Metacard (ddf.catalog.data.Metacard)17 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)14 Date (java.util.Date)10 HashSet (java.util.HashSet)9 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)8 Source (ddf.catalog.source.Source)7 QName (javax.xml.namespace.QName)7 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.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 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)4 SolrProviderTest (ddf.catalog.source.solr.SolrProviderTest)4