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()));
}
}
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);
}
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));
}
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());
}
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());
}
Aggregations