use of ddf.catalog.data.MetacardType in project ddf by codice.
the class TestXmlInputTransformer method testFallbackToBasicMetacardForUnknowMetacardType.
@Test
public void testFallbackToBasicMetacardForUnknowMetacardType() throws FileNotFoundException, IOException, CatalogTransformerException, ParseException {
List<MetacardType> metacardTypes = new ArrayList<MetacardType>(1);
metacardTypes.add(BasicTypes.BASIC_METACARD);
xit.setMetacardTypes(metacardTypes);
Metacard metacard = xit.transform(new FileInputStream("src/test/resources/unknownMetacard1.xml"));
LOGGER.info("ID: {}", metacard.getId());
LOGGER.info("Type: {}", metacard.getMetacardType().getName());
LOGGER.info("Source: {}", metacard.getSourceId());
LOGGER.info("Attributes: ");
for (AttributeDescriptor descriptor : metacard.getMetacardType().getAttributeDescriptors()) {
Attribute attribute = metacard.getAttribute(descriptor.getName());
LOGGER.info("\t" + descriptor.getName() + ": " + ((attribute == null) ? attribute : attribute.getValue()));
}
assertThat(metacard.getMetacardType().getName(), is(BasicTypes.BASIC_METACARD.getName()));
assertThat("1234567890987654321", is(metacard.getId()));
assertThat("foobar", is(metacard.getSourceId()));
assertThat("POLYGON ((35 10, 10 20, 15 40, 45 45, 35 10), (20 30, 35 35, 30 20, 20 30))", is(metacard.getAttribute(Metacard.GEOGRAPHY).getValue()));
assertThat("Title!", is(metacard.getAttribute(Metacard.TITLE).getValue()));
assertArrayEquals(Base64.getDecoder().decode("AAABAAABAQEAAQAAAQEBAAEAAAEBAQABAAABAQEAAQAAAQEBAAEAAAEBAQABAAABAQE="), (byte[]) metacard.getAttribute(Metacard.THUMBNAIL).getValue());
assertThat(metacard.getAttribute(Metacard.METADATA).getValue().toString(), startsWith("<foo xmlns=\"http://foo.com\">"));
assertThat((new SimpleDateFormat("MMM d, yyyy HH:mm:ss.SSS z")).parse("Dec 27, 2012 16:31:01.641 MST"), is(metacard.getAttribute(Metacard.EXPIRATION).getValue()));
assertEquals(DESCRIPTION, metacard.getAttribute("description").getValue());
assertEquals(POINT_OF_CONTACT, metacard.getAttribute("point-of-contact").getValue());
}
use of ddf.catalog.data.MetacardType in project ddf by codice.
the class TestXmlMetacardTransformer method testMetacardTypeNameEmpty.
@Test
public void testMetacardTypeNameEmpty() throws Exception {
Metacard mc = mock(Metacard.class);
MetacardType mct = mock(MetacardType.class);
when(mct.getName()).thenReturn("");
when(mct.getAttributeDescriptors()).thenReturn(Collections.<AttributeDescriptor>emptySet());
when(mc.getMetacardType()).thenReturn(mct);
when(mc.getId()).thenReturn(null);
when(mc.getSourceId()).thenReturn(null);
String outputXml = transform(mc);
assertXpathEvaluatesTo(MetacardType.DEFAULT_METACARD_TYPE_NAME, "/m:metacard/m:type", outputXml);
}
use of ddf.catalog.data.MetacardType in project ddf by codice.
the class TestMetacardTypeAdapter method testUnmarshalWithDdfMetacardTypeName.
@Test
public void testUnmarshalWithDdfMetacardTypeName() throws CatalogTransformerException {
MetacardType unknownMetacardType = new MetacardTypeImpl(KNOWN_TYPE_NAME, (Set<AttributeDescriptor>) null);
List<MetacardType> metacardTypes = new ArrayList<MetacardType>(1);
metacardTypes.add(unknownMetacardType);
MetacardTypeAdapter metacardTypeAdpater = new MetacardTypeAdapter(metacardTypes);
MetacardType metacardType = metacardTypeAdpater.unmarshal(DDF_METACARD_TYPE_NAME);
assertThat(metacardType.getName(), is(BasicTypes.BASIC_METACARD.getName()));
}
use of ddf.catalog.data.MetacardType in project ddf by codice.
the class TestMetacardTypeAdapter method testUnmarshalWithEmptyTypeName.
@Test
public void testUnmarshalWithEmptyTypeName() throws CatalogTransformerException {
MetacardTypeAdapter metacardTypeAdpater = new MetacardTypeAdapter();
MetacardType metacardType = metacardTypeAdpater.unmarshal(EMPTY_TYPE_NAME);
assertThat(metacardType.getName(), is(BasicTypes.BASIC_METACARD.getName()));
}
use of ddf.catalog.data.MetacardType in project ddf by codice.
the class TestMetacardTypeAdapter method testUnmarshalWithNullTypeName.
@Test
public void testUnmarshalWithNullTypeName() throws CatalogTransformerException {
MetacardTypeAdapter metacardTypeAdpater = new MetacardTypeAdapter();
MetacardType metacardType = metacardTypeAdpater.unmarshal(NULL_TYPE_NAME);
assertThat(metacardType.getName(), is(BasicTypes.BASIC_METACARD.getName()));
}
Aggregations