Search in sources :

Example 51 with MetacardType

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

the class MetacardImplTest method testSerializingEmptyMetacard.

@Test
public void testSerializingEmptyMetacard() throws IOException, ClassNotFoundException {
    MetacardImpl metacard = new MetacardImpl();
    Serializer<Metacard> serializer = new Serializer<Metacard>();
    serializer.serialize(metacard, DEFAULT_SERIALIZATION_FILE_LOCATION);
    Metacard readMetacard = serializer.deserialize(DEFAULT_SERIALIZATION_FILE_LOCATION);
    MetacardType metacardType = metacard.getMetacardType();
    MetacardType readMetacardType = readMetacard.getMetacardType();
    assertEquals(metacardType.getName(), readMetacardType.getName());
    for (AttributeDescriptor ad : readMetacardType.getAttributeDescriptors()) {
        assertNull(readMetacard.getAttribute(ad.getName()));
    }
}
Also used : Metacard(ddf.catalog.data.Metacard) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardType(ddf.catalog.data.MetacardType) Test(org.junit.Test)

Example 52 with MetacardType

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

the class MetacardImplTest method testSerializingWithEmptyMetacardType.

@Test
public void testSerializingWithEmptyMetacardType() throws IOException, ClassNotFoundException {
    MetacardImpl metacard = new MetacardImpl(new EmptyMetacardType());
    Serializer<Metacard> serializer = new Serializer<Metacard>();
    serializer.serialize(metacard, DEFAULT_SERIALIZATION_FILE_LOCATION);
    Metacard readMetacard = serializer.deserialize(DEFAULT_SERIALIZATION_FILE_LOCATION);
    MetacardType metacardType = metacard.getMetacardType();
    MetacardType readMetacardType = readMetacard.getMetacardType();
    assertEquals(metacardType.getName(), readMetacardType.getName());
    assertTrue(readMetacardType.getAttributeDescriptors().isEmpty());
    assertEquals(metacardType.getAttributeDescriptor(null), readMetacardType.getAttributeDescriptor(null));
    assertTrue(readMetacardType.getName() == null);
    assertTrue(readMetacardType.getAttributeDescriptor(null) == null);
}
Also used : Metacard(ddf.catalog.data.Metacard) MetacardType(ddf.catalog.data.MetacardType) Test(org.junit.Test)

Example 53 with MetacardType

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

the class MetacardTypeImplTest method testExtendingMetacardTypeCombinesDescriptors.

@Test
public void testExtendingMetacardTypeCombinesDescriptors() {
    final Set<AttributeDescriptor> additionalDescriptors = new HashSet<>();
    additionalDescriptors.add(new AttributeDescriptorImpl("foo", true, false, true, false, BasicTypes.BOOLEAN_TYPE));
    additionalDescriptors.add(new AttributeDescriptorImpl("bar", false, true, false, true, BasicTypes.STRING_TYPE));
    final String metacardTypeName = "extended";
    final MetacardType extended = new MetacardTypeImpl(metacardTypeName, BASIC_METACARD, additionalDescriptors);
    assertThat(extended.getName(), is(metacardTypeName));
    final Set<AttributeDescriptor> expectedDescriptors = new HashSet<>(BASIC_METACARD.getAttributeDescriptors());
    expectedDescriptors.addAll(additionalDescriptors);
    assertThat(extended.getAttributeDescriptors(), is(expectedDescriptors));
}
Also used : AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardType(ddf.catalog.data.MetacardType) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 54 with MetacardType

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

the class MetacardTypeImplTest method testContactType.

@Test
public void testContactType() {
    List<MetacardType> metacardTypeList = new ArrayList<>();
    metacardTypeList.add(CONTACT_ATTRIBUTES);
    MetacardType metacardType = new MetacardTypeImpl(TEST_NAME, metacardTypeList);
    assertMetacardAttributes(metacardType, CORE_ATTRIBUTES.getAttributeDescriptors());
    assertMetacardAttributes(metacardType, CONTACT_ATTRIBUTES.getAttributeDescriptors());
}
Also used : ArrayList(java.util.ArrayList) MetacardType(ddf.catalog.data.MetacardType) Test(org.junit.Test)

Example 55 with MetacardType

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

the class MetacardTypeImplTest method testLocationType.

@Test
public void testLocationType() {
    List<MetacardType> metacardTypeList = new ArrayList<>();
    metacardTypeList.add(LOCATION_ATTRIBUTES);
    MetacardType metacardType = new MetacardTypeImpl(TEST_NAME, metacardTypeList);
    assertMetacardAttributes(metacardType, CORE_ATTRIBUTES.getAttributeDescriptors());
    assertMetacardAttributes(metacardType, LOCATION_ATTRIBUTES.getAttributeDescriptors());
}
Also used : ArrayList(java.util.ArrayList) MetacardType(ddf.catalog.data.MetacardType) Test(org.junit.Test)

Aggregations

MetacardType (ddf.catalog.data.MetacardType)88 Test (org.junit.Test)57 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)41 Metacard (ddf.catalog.data.Metacard)35 ArrayList (java.util.ArrayList)29 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)20 MetacardTypeImpl (ddf.catalog.data.impl.MetacardTypeImpl)17 HashSet (java.util.HashSet)15 Attribute (ddf.catalog.data.Attribute)12 Serializable (java.io.Serializable)10 IOException (java.io.IOException)8 Date (java.util.Date)8 HashMap (java.util.HashMap)8 List (java.util.List)8 Map (java.util.Map)8 AttributeDescriptorImpl (ddf.catalog.data.impl.AttributeDescriptorImpl)7 InputStream (java.io.InputStream)7 Set (java.util.Set)7 ContentItem (ddf.catalog.content.data.ContentItem)6 ContentItemImpl (ddf.catalog.content.data.impl.ContentItemImpl)6