Search in sources :

Example 11 with MetacardTypeImpl

use of ddf.catalog.data.impl.MetacardTypeImpl in project ddf by codice.

the class TestMetacardTypeAdapter method testUnmarshalWithKnownMetacardType.

@Test
public void testUnmarshalWithKnownMetacardType() throws CatalogTransformerException {
    MetacardType knownMetacardType = new MetacardTypeImpl(KNOWN_TYPE_NAME, (Set<AttributeDescriptor>) null);
    List<MetacardType> metacardTypes = new ArrayList<MetacardType>(1);
    metacardTypes.add(knownMetacardType);
    MetacardTypeAdapter metacardTypeAdpater = new MetacardTypeAdapter(metacardTypes);
    MetacardType metacardType = metacardTypeAdpater.unmarshal(KNOWN_TYPE_NAME);
    assertThat(metacardType.getName(), is(knownMetacardType.getName()));
}
Also used : ArrayList(java.util.ArrayList) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardTypeAdapter(ddf.catalog.transformer.xml.adapter.MetacardTypeAdapter) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) MetacardType(ddf.catalog.data.MetacardType) Test(org.junit.Test)

Example 12 with MetacardTypeImpl

use of ddf.catalog.data.impl.MetacardTypeImpl in project ddf by codice.

the class TestMetacardTypeAdapter method testUnmarshalWithUnknownTypeName.

@Test
public void testUnmarshalWithUnknownTypeName() 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(UNKNOWN_TYPE_NAME);
    assertThat(metacardType.getName(), is(BasicTypes.BASIC_METACARD.getName()));
}
Also used : ArrayList(java.util.ArrayList) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardTypeAdapter(ddf.catalog.transformer.xml.adapter.MetacardTypeAdapter) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) MetacardType(ddf.catalog.data.MetacardType) Test(org.junit.Test)

Example 13 with MetacardTypeImpl

use of ddf.catalog.data.impl.MetacardTypeImpl in project ddf by codice.

the class TestXmlInputTransformer method testTransformWithExtensibleMetacardType.

@Test
public void testTransformWithExtensibleMetacardType() throws IOException, CatalogTransformerException {
    List<MetacardType> metacardTypes = new ArrayList<MetacardType>(1);
    MetacardType extensibleType = new MetacardTypeImpl("extensible.metacard", BasicTypes.BASIC_METACARD.getAttributeDescriptors());
    metacardTypes.add(extensibleType);
    xit.setMetacardTypes(metacardTypes);
    Metacard metacard = xit.transform(new FileInputStream("src/test/resources/extensibleMetacard.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()));
    }
}
Also used : Metacard(ddf.catalog.data.Metacard) Attribute(ddf.catalog.data.Attribute) ArrayList(java.util.ArrayList) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) MetacardType(ddf.catalog.data.MetacardType) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 14 with MetacardTypeImpl

use of ddf.catalog.data.impl.MetacardTypeImpl in project ddf by codice.

the class CachedResourceMetacardComparatorTest method isNotSameWhenMetacardsHaveAttributeDescriptorListsOfDifferentSizes.

@Test
public void isNotSameWhenMetacardsHaveAttributeDescriptorListsOfDifferentSizes() {
    cachedMetacard.setType(new MetacardTypeImpl(MetacardType.DEFAULT_METACARD_TYPE_NAME, new HashSet<>()));
    assertThat(isSame(cachedMetacard, updatedMetacard), is(false));
}
Also used : MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 15 with MetacardTypeImpl

use of ddf.catalog.data.impl.MetacardTypeImpl in project ddf by codice.

the class MetacardCreatorTest method testNullIntAttribute.

@Test
public void testNullIntAttribute() {
    Set<AttributeDescriptor> extraAttributes = new HashSet<>();
    extraAttributes.add(new AttributeDescriptorImpl(Media.DURATION, false, false, false, false, BasicTypes.INTEGER_TYPE));
    final Metadata metadata = new Metadata();
    metadata.add(MetacardCreator.COMPRESSION_TYPE_METADATA_KEY, null);
    MetacardTypeImpl extendedMetacardType = new MetacardTypeImpl(BasicTypes.BASIC_METACARD.getName(), BasicTypes.BASIC_METACARD, extraAttributes);
    final String id = "id";
    final String metadataXml = "<xml>test</xml>";
    Metacard metacard = MetacardCreator.createMetacard(metadata, id, metadataXml, extendedMetacardType);
    assertThat(metacard.getMetadata(), is(metadataXml));
    assertThat(metacard.getAttribute(Media.COMPRESSION), is(nullValue()));
}
Also used : Metacard(ddf.catalog.data.Metacard) Metadata(org.apache.tika.metadata.Metadata) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

MetacardTypeImpl (ddf.catalog.data.impl.MetacardTypeImpl)40 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)22 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)21 Test (org.junit.Test)21 Metacard (ddf.catalog.data.Metacard)20 HashSet (java.util.HashSet)16 ArrayList (java.util.ArrayList)15 MetacardType (ddf.catalog.data.MetacardType)14 AttributeDescriptorImpl (ddf.catalog.data.impl.AttributeDescriptorImpl)10 URI (java.net.URI)9 HashMap (java.util.HashMap)6 List (java.util.List)6 Metadata (org.apache.tika.metadata.Metadata)6 URISyntaxException (java.net.URISyntaxException)5 SourceResponse (ddf.catalog.operation.SourceResponse)4 QueryImpl (ddf.catalog.operation.impl.QueryImpl)3 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)3 MetacardTypeAdapter (ddf.catalog.transformer.xml.adapter.MetacardTypeAdapter)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 ContentItem (ddf.catalog.content.data.ContentItem)2