Search in sources :

Example 86 with Attribute

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

the class SaxEventHandlerUtilsTest method assertIdAttribute.

private void assertIdAttribute(List<Attribute> attributes) {
    Attribute idAttr = getAttributeByName(attributes, CoreAttributes.ID);
    assertThat(idAttr, notNullValue());
    assertThat(idAttr.getValues().size(), is(1));
}
Also used : Attribute(ddf.catalog.data.Attribute)

Example 87 with Attribute

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

the class SaxEventHandlerUtilsTest method testNullAttributeDescriptors.

@Test
public void testNullAttributeDescriptors() {
    List<Attribute> attributes = getTestAttributes();
    attributes.add(new AttributeImpl(CoreAttributes.LANGUAGE, "Dothraki"));
    List<Attribute> combinedAttributes = saxEventHandlerUtils.getCombinedMultiValuedAttributes(null, attributes);
    assertThat(combinedAttributes.size(), is(3));
    Attribute validationWarningAttr = getAttributeByName(combinedAttributes, ValidationAttributes.VALIDATION_WARNINGS);
    assertThat(validationWarningAttr, notNullValue());
    assertAttributeContainsString(validationWarningAttr, "No attribute descriptor was found for attribute");
    assertAttributeContainsString(validationWarningAttr, "Multiple values found for a non-multi-valued attribute.");
    assertIdAttribute(combinedAttributes);
    assertLanguageAttribute(combinedAttributes, 1);
}
Also used : Attribute(ddf.catalog.data.Attribute) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) Test(org.junit.Test)

Example 88 with Attribute

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

the class SaxEventHandlerUtilsTest method getTestAttributes.

private List<Attribute> getTestAttributes() {
    List<Attribute> attributes = new ArrayList<>();
    attributes.add(new AttributeImpl(CoreAttributes.ID, "id"));
    attributes.add(new AttributeImpl(CoreAttributes.LANGUAGE, "English"));
    return attributes;
}
Also used : Attribute(ddf.catalog.data.Attribute) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) ArrayList(java.util.ArrayList)

Example 89 with Attribute

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

the class SaxEventHandlerUtilsTest method testEmptyAttributeDescriptors.

@Test
public void testEmptyAttributeDescriptors() {
    List<Attribute> attributes = getTestAttributes();
    attributes.add(new AttributeImpl(CoreAttributes.LANGUAGE, "Dothraki"));
    List<Attribute> combinedAttributes = saxEventHandlerUtils.getCombinedMultiValuedAttributes(Collections.emptySet(), attributes);
    assertThat(combinedAttributes.size(), is(3));
    Attribute validationWarningAttr = getAttributeByName(combinedAttributes, ValidationAttributes.VALIDATION_WARNINGS);
    assertThat(validationWarningAttr, notNullValue());
    assertAttributeContainsString(validationWarningAttr, "No attribute descriptor was found for attribute");
    assertAttributeContainsString(validationWarningAttr, "Multiple values found for a non-multi-valued attribute.");
    assertIdAttribute(combinedAttributes);
    assertLanguageAttribute(combinedAttributes, 1);
}
Also used : Attribute(ddf.catalog.data.Attribute) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) Test(org.junit.Test)

Example 90 with Attribute

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

the class SaxEventHandlerUtilsTest method assertLanguageAttribute.

private void assertLanguageAttribute(List<Attribute> attributes, int size) {
    Attribute languageAttr = getAttributeByName(attributes, CoreAttributes.LANGUAGE);
    assertThat(languageAttr, notNullValue());
    assertThat(languageAttr.getValues().size(), is(size));
}
Also used : Attribute(ddf.catalog.data.Attribute)

Aggregations

Attribute (ddf.catalog.data.Attribute)103 Metacard (ddf.catalog.data.Metacard)39 Test (org.junit.Test)37 ArrayList (java.util.ArrayList)30 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)29 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)26 Serializable (java.io.Serializable)23 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)15 HashMap (java.util.HashMap)15 Result (ddf.catalog.data.Result)14 List (java.util.List)14 MetacardType (ddf.catalog.data.MetacardType)11 QueryResponse (ddf.catalog.operation.QueryResponse)11 Date (java.util.Date)11 Map (java.util.Map)11 HashSet (java.util.HashSet)10 Optional (java.util.Optional)8 Set (java.util.Set)8 Filter (org.opengis.filter.Filter)8 UpdateRequestImpl (ddf.catalog.operation.impl.UpdateRequestImpl)7