use of ddf.catalog.data.MetacardType in project ddf by codice.
the class QualifiedMetacardTypeTest method testDefaultNamespace.
@Test
public void testDefaultNamespace() {
MetacardType mt1 = new MetacardTypeImpl(QUALIFIED_METACARD_TYPE_NAME_3, qmtAttributes);
QualifiedMetacardTypeImpl qmt1 = new QualifiedMetacardTypeImpl(QualifiedMetacardType.DEFAULT_METACARD_TYPE_NAMESPACE, mt1);
MetacardType mt2 = new MetacardTypeImpl(QUALIFIED_METACARD_TYPE_NAME_3, qmtAttributes);
QualifiedMetacardTypeImpl qmt2 = new QualifiedMetacardTypeImpl(null, mt2);
assertTrue(qmt1.equals(qmt2));
assertTrue(qmt2.equals(qmt1));
assertTrue(qmt1.hashCode() == qmt2.hashCode());
}
use of ddf.catalog.data.MetacardType in project ddf by codice.
the class RequiredAttributesMetacardValidator method validateMetacard.
@Override
public Optional<MetacardValidationReport> validateMetacard(final Metacard metacard) {
Preconditions.checkArgument(metacard != null, "The metacard cannot be null.");
final MetacardType metacardType = metacard.getMetacardType();
if (metacardTypeName.equals(metacardType.getName())) {
final Set<ValidationViolation> violations = new HashSet<>();
for (final String attributeName : requiredAttributes) {
final Attribute attribute = metacard.getAttribute(attributeName);
if (attribute != null) {
final AttributeDescriptor descriptor = metacardType.getAttributeDescriptor(attributeName);
if (descriptor.isMultiValued()) {
if (attribute.getValues().size() == 0) {
addRequiredAttributeViolation(attributeName, violations);
}
} else if (attribute.getValue() == null) {
addRequiredAttributeViolation(attributeName, violations);
}
} else {
addRequiredAttributeViolation(attributeName, violations);
}
}
if (violations.size() > 0) {
return getReport(violations);
}
}
return Optional.empty();
}
use of ddf.catalog.data.MetacardType in project ddf by codice.
the class MetacardTypeImplTest method testValidationType.
@Test
public void testValidationType() {
List<MetacardType> metacardTypeList = new ArrayList<>();
metacardTypeList.add(VALIDATION_ATTRIBUTES);
MetacardType metacardType = new MetacardTypeImpl(TEST_NAME, metacardTypeList);
assertMetacardAttributes(metacardType, CORE_ATTRIBUTES.getAttributeDescriptors());
assertMetacardAttributes(metacardType, VALIDATION_ATTRIBUTES.getAttributeDescriptors());
}
use of ddf.catalog.data.MetacardType in project ddf by codice.
the class MetacardTypeImplTest method testTopicType.
@Test
public void testTopicType() {
List<MetacardType> metacardTypeList = new ArrayList<>();
metacardTypeList.add(TOPIC_ATTRIBUTES);
MetacardType metacardType = new MetacardTypeImpl(TEST_NAME, metacardTypeList);
assertMetacardAttributes(metacardType, CORE_ATTRIBUTES.getAttributeDescriptors());
assertMetacardAttributes(metacardType, TOPIC_ATTRIBUTES.getAttributeDescriptors());
}
use of ddf.catalog.data.MetacardType in project ddf by codice.
the class MetacardTypeImplTest method testMediaType.
@Test
public void testMediaType() {
List<MetacardType> metacardTypeList = new ArrayList<>();
metacardTypeList.add(MEDIA_ATTRIBUTES);
MetacardType metacardType = new MetacardTypeImpl(TEST_NAME, metacardTypeList);
assertMetacardAttributes(metacardType, CORE_ATTRIBUTES.getAttributeDescriptors());
assertMetacardAttributes(metacardType, MEDIA_ATTRIBUTES.getAttributeDescriptors());
}
Aggregations