Search in sources :

Example 6 with AttributeImpl

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

the class RangeValidatorTest method testOutsideLargeDecimalRange.

@Test
public void testOutsideLargeDecimalRange() {
    final RangeValidator validator = new RangeValidator(new BigDecimal("-123456789123456.857"), new BigDecimal("987654321987654.923"), new BigDecimal("0.01"));
    validateWithErrors(new AttributeImpl("", -123456789123456.87), validator, 1);
    validateWithErrors(new AttributeImpl("", 987654321987654.94), validator, 1);
    validateWithErrors(new AttributeImpl("", -123456789123457L), validator, 1);
    validateWithErrors(new AttributeImpl("", 987654321987655L), validator, 1);
}
Also used : AttributeImpl(ddf.catalog.data.impl.AttributeImpl) RangeValidator(ddf.catalog.validation.impl.validator.RangeValidator) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 7 with AttributeImpl

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

the class RangeValidatorTest method testOutsideSmallDecimalRange.

@Test
public void testOutsideSmallDecimalRange() {
    final RangeValidator validator = new RangeValidator(new BigDecimal("1.2457515"), new BigDecimal("1.2487595"), new BigDecimal("1E-7"));
    validateWithErrors(new AttributeImpl("", 1.24575135), validator, 1);
    validateWithErrors(new AttributeImpl("", 1.24875965), validator, 1);
    validateWithErrors(new AttributeImpl("", 1), validator, 1);
    validateWithErrors(new AttributeImpl("", 2), validator, 1);
}
Also used : AttributeImpl(ddf.catalog.data.impl.AttributeImpl) RangeValidator(ddf.catalog.validation.impl.validator.RangeValidator) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 8 with AttributeImpl

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

the class RangeValidatorTest method testOutsideIntegerRange.

@Test
public void testOutsideIntegerRange() {
    final RangeValidator validator = new RangeValidator(new BigDecimal("-123456789123456"), new BigDecimal("987654321987654"));
    validateWithErrors(new AttributeImpl("", -123456789123457L), validator, 1);
    validateWithErrors(new AttributeImpl("", 987654321987655L), validator, 1);
    validateWithErrors(new AttributeImpl("", -123456789123456.1), validator, 1);
    validateWithErrors(new AttributeImpl("", 987654321987654.1), validator, 1);
}
Also used : AttributeImpl(ddf.catalog.data.impl.AttributeImpl) RangeValidator(ddf.catalog.validation.impl.validator.RangeValidator) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 9 with AttributeImpl

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

the class RangeValidatorTest method testWithinIntegerRange.

@Test
public void testWithinIntegerRange() {
    final RangeValidator validator = new RangeValidator(new BigDecimal("-123456789123456"), new BigDecimal("987654321987654"));
    validateNoErrors(new AttributeImpl("", -123456789123456L), validator);
    validateNoErrors(new AttributeImpl("", 987654321987654L), validator);
    validateNoErrors(new AttributeImpl("", 0), validator);
    validateNoErrors(new AttributeImpl("", -123456789123455.9), validator);
    validateNoErrors(new AttributeImpl("", 987654321987653.9), validator);
}
Also used : AttributeImpl(ddf.catalog.data.impl.AttributeImpl) RangeValidator(ddf.catalog.validation.impl.validator.RangeValidator) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 10 with AttributeImpl

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

the class RequiredAttributesMetacardValidatorTest method testValidMetacard.

@Test
public void testValidMetacard() {
    final Metacard metacard = new MetacardImpl();
    metacard.setAttribute(new AttributeImpl("title", "test"));
    metacard.setAttribute(new AttributeImpl("created", new Date()));
    metacard.setAttribute(new AttributeImpl("thumbnail", new byte[] { 1, 2, 3, 4 }));
    validateNoErrors(metacard, Sets.newHashSet("title", "created", "thumbnail"));
}
Also used : Metacard(ddf.catalog.data.Metacard) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Date(java.util.Date) Test(org.junit.Test)

Aggregations

AttributeImpl (ddf.catalog.data.impl.AttributeImpl)181 Metacard (ddf.catalog.data.Metacard)109 Test (org.junit.Test)75 ArrayList (java.util.ArrayList)56 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)49 Serializable (java.io.Serializable)30 Date (java.util.Date)30 Attribute (ddf.catalog.data.Attribute)29 List (java.util.List)23 HashMap (java.util.HashMap)20 IOException (java.io.IOException)18 InputStream (java.io.InputStream)17 Result (ddf.catalog.data.Result)15 HashSet (java.util.HashSet)15 PolicyResponse (ddf.catalog.plugin.PolicyResponse)14 ResultImpl (ddf.catalog.data.impl.ResultImpl)11 UpdateRequestImpl (ddf.catalog.operation.impl.UpdateRequestImpl)11 Set (java.util.Set)11 ContentItem (ddf.catalog.content.data.ContentItem)10 QueryResponse (ddf.catalog.operation.QueryResponse)10