Search in sources :

Example 61 with AttributeDescriptor

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

the class MetacardTypeImplTest method testSerializationNullDescriptors.

@Test
public void testSerializationNullDescriptors() throws IOException, ClassNotFoundException {
    MetacardTypeImpl metacardType = new MetacardTypeImpl("basic", (Set<AttributeDescriptor>) null);
    String fileLocation = "target/metacardType.ser";
    Serializer<MetacardType> serializer = new Serializer<>();
    serializer.serialize(metacardType, fileLocation);
    MetacardType readMetacardType = serializer.deserialize(fileLocation);
    assertThat(metacardType.getName(), is(readMetacardType.getName()));
    Set<AttributeDescriptor> oldAd = metacardType.getAttributeDescriptors();
    Set<AttributeDescriptor> newAd = readMetacardType.getAttributeDescriptors();
    assertThat(oldAd.isEmpty(), is(true));
    assertThat(newAd.isEmpty(), is(true));
}
Also used : AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardType(ddf.catalog.data.MetacardType) Test(org.junit.Test)

Example 62 with AttributeDescriptor

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

the class MetacardTypeImplTest method assertMetacardAttributes.

private void assertMetacardAttributes(MetacardType metacardType, Set<AttributeDescriptor> expected) {
    Set<AttributeDescriptor> actual = metacardType.getAttributeDescriptors();
    assertThat(metacardType.getName(), is(TEST_NAME));
    for (AttributeDescriptor attributeDescriptor : expected) {
        assertThat(actual, hasItem(attributeDescriptor));
    }
}
Also used : AttributeDescriptor(ddf.catalog.data.AttributeDescriptor)

Example 63 with AttributeDescriptor

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

the class MetacardTypeRegistryTest method sampleMetacardTypeB.

private QualifiedMetacardType sampleMetacardTypeB() {
    Set<AttributeDescriptor> descriptors = new HashSet<AttributeDescriptor>();
    descriptors.add(new AttributeDescriptorImpl(COLUMNS_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.INTEGER_TYPE));
    descriptors.add(new AttributeDescriptorImpl(ROWS_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.INTEGER_TYPE));
    descriptors.add(new AttributeDescriptorImpl(DESCRIPTION_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.STRING_TYPE));
    descriptors.add(new AttributeDescriptorImpl(Metacard.ID, true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.STRING_TYPE));
    descriptors.add(new AttributeDescriptorImpl(Metacard.TITLE, true, /* indexed */
    true, /* stored */
    true, /* tokenized */
    false, /* multivalued */
    BasicTypes.STRING_TYPE));
    descriptors.add(new AttributeDescriptorImpl(REVIEWED_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    true, /* tokenized */
    false, /* multivalued */
    BasicTypes.BOOLEAN_TYPE));
    descriptors.add(new AttributeDescriptorImpl(PRECISE_LENGTH_METERS_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    true, /* tokenized */
    false, /* multivalued */
    BasicTypes.DOUBLE_TYPE));
    descriptors.add(new AttributeDescriptorImpl(PRECISE_HEIGHT_METERS_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    true, /* tokenized */
    false, /* multivalued */
    BasicTypes.FLOAT_TYPE));
    descriptors.add(new AttributeDescriptorImpl(NUMBER_REVIEWERS_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    true, /* tokenized */
    false, /* multivalued */
    BasicTypes.SHORT_TYPE));
    return new QualifiedMetacardTypeImpl(SAMPLE_B_METACARD_TYPE_NAMESPACE, SAMPLE_B_METACARD_TYPE_NAME, descriptors);
}
Also used : QualifiedMetacardTypeImpl(ddf.catalog.data.impl.QualifiedMetacardTypeImpl) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) HashSet(java.util.HashSet)

Example 64 with AttributeDescriptor

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

the class MetacardTypeRegistryTest method assertOnExpectedMetacardTypeFields.

private void assertOnExpectedMetacardTypeFields(QualifiedMetacardType qmtResult) {
    Set<AttributeDescriptor> attributeDescriptors = qmtResult.getAttributeDescriptors();
    assertNotNull(attributeDescriptors);
    assertEquals(QUALIFIED_METACARD_TYPE_DESCRIPTORS_SIZE, attributeDescriptors.size());
    AttributeDescriptor geoAD = qmtResult.getAttributeDescriptor(GEO_ATTRIBUTE_DESCRIPTOR_NAME);
    assertNotNull(geoAD);
    assertEquals(GEO_ATTRIBUTE_DESCRIPTOR_NAME, geoAD.getName());
    AttributeDescriptor metadataAD = qmtResult.getAttributeDescriptor(METADATA_ATTRIBUTE_DESCRIPTOR_NAME);
    assertNotNull(metadataAD);
    assertEquals(METADATA_ATTRIBUTE_DESCRIPTOR_NAME, metadataAD.getName());
}
Also used : AttributeDescriptor(ddf.catalog.data.AttributeDescriptor)

Example 65 with AttributeDescriptor

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

the class MetacardTypeRegistryTest method assertOnSampleMetacardTypeBExcpectedAttributes.

private void assertOnSampleMetacardTypeBExcpectedAttributes(QualifiedMetacardType qmt) {
    Set<AttributeDescriptor> attributeDescriptors = qmt.getAttributeDescriptors();
    assertNotNull(attributeDescriptors);
    assertEquals(NUM_ATTRIBUTES_SAMPLE_METACARD_TYPE_B, attributeDescriptors.size());
    AttributeDescriptor preciseHeight = qmt.getAttributeDescriptor(PRECISE_HEIGHT_METERS_ATTRIBUTE_KEY);
    assertNotNull(preciseHeight);
    assertEquals(PRECISE_HEIGHT_METERS_ATTRIBUTE_KEY, preciseHeight.getName());
    AttributeDescriptor reviewed = qmt.getAttributeDescriptor(REVIEWED_ATTRIBUTE_KEY);
    assertNotNull(reviewed);
    assertEquals(REVIEWED_ATTRIBUTE_KEY, reviewed.getName());
    AttributeDescriptor preciseLength = qmt.getAttributeDescriptor(PRECISE_LENGTH_METERS_ATTRIBUTE_KEY);
    assertNotNull(preciseLength);
    assertEquals(PRECISE_LENGTH_METERS_ATTRIBUTE_KEY, preciseLength.getName());
    AttributeDescriptor description = qmt.getAttributeDescriptor(DESCRIPTION_ATTRIBUTE_KEY);
    assertNotNull(description);
    assertEquals(DESCRIPTION_ATTRIBUTE_KEY, description.getName());
    AttributeDescriptor rows = qmt.getAttributeDescriptor(ROWS_ATTRIBUTE_KEY);
    assertNotNull(rows);
    assertEquals(ROWS_ATTRIBUTE_KEY, rows.getName());
    AttributeDescriptor columns = qmt.getAttributeDescriptor(COLUMNS_ATTRIBUTE_KEY);
    assertNotNull(columns);
    assertEquals(COLUMNS_ATTRIBUTE_KEY, columns.getName());
    AttributeDescriptor numReviewers = qmt.getAttributeDescriptor(NUMBER_REVIEWERS_ATTRIBUTE_KEY);
    assertNotNull(numReviewers);
    assertEquals(NUMBER_REVIEWERS_ATTRIBUTE_KEY, numReviewers.getName());
    AttributeDescriptor metacardId = qmt.getAttributeDescriptor(Metacard.ID);
    assertNotNull(metacardId);
    assertEquals(Metacard.ID, metacardId.getName());
    AttributeDescriptor metacardTitle = qmt.getAttributeDescriptor(Metacard.TITLE);
    assertNotNull(metacardTitle);
    assertEquals(Metacard.TITLE, metacardTitle.getName());
}
Also used : AttributeDescriptor(ddf.catalog.data.AttributeDescriptor)

Aggregations

AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)111 Test (org.junit.Test)51 MetacardType (ddf.catalog.data.MetacardType)40 Metacard (ddf.catalog.data.Metacard)38 HashSet (java.util.HashSet)29 Attribute (ddf.catalog.data.Attribute)26 AttributeDescriptorImpl (ddf.catalog.data.impl.AttributeDescriptorImpl)24 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)24 MetacardTypeImpl (ddf.catalog.data.impl.MetacardTypeImpl)24 ArrayList (java.util.ArrayList)23 Serializable (java.io.Serializable)16 FeatureMetacardType (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)9 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)7 IOException (java.io.IOException)7 Date (java.util.Date)7 List (java.util.List)7 QName (javax.xml.namespace.QName)7