Search in sources :

Example 6 with RangeValidator

use of ddf.catalog.validation.impl.validator.RangeValidator 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 7 with RangeValidator

use of ddf.catalog.validation.impl.validator.RangeValidator in project ddf by codice.

the class RangeValidatorTest method testEqualsDifferentMin.

@Test
public void testEqualsDifferentMin() {
    final RangeValidator validator1 = new RangeValidator(new BigDecimal("1.5"), new BigDecimal("2.5"));
    final RangeValidator validator2 = new RangeValidator(new BigDecimal("1.1"), new BigDecimal("2.5"));
    assertThat(validator1.equals(validator2), is(false));
    assertThat(validator2.equals(validator1), is(false));
}
Also used : RangeValidator(ddf.catalog.validation.impl.validator.RangeValidator) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 8 with RangeValidator

use of ddf.catalog.validation.impl.validator.RangeValidator in project ddf by codice.

the class RangeValidatorTest method testEqualsDifferentMax.

@Test
public void testEqualsDifferentMax() {
    final RangeValidator validator1 = new RangeValidator(new BigDecimal("1.5"), new BigDecimal("2.5"));
    final RangeValidator validator2 = new RangeValidator(new BigDecimal("1.5"), new BigDecimal("2.1"));
    assertThat(validator1.equals(validator2), is(false));
    assertThat(validator2.equals(validator1), is(false));
}
Also used : RangeValidator(ddf.catalog.validation.impl.validator.RangeValidator) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 9 with RangeValidator

use of ddf.catalog.validation.impl.validator.RangeValidator 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 RangeValidator

use of ddf.catalog.validation.impl.validator.RangeValidator in project ddf by codice.

the class RangeValidatorTest method testEqualsNull.

@Test
public void testEqualsNull() {
    final RangeValidator validator = new RangeValidator(new BigDecimal("1.5"), new BigDecimal("2.5"));
    assertThat(validator.equals(null), is(false));
}
Also used : RangeValidator(ddf.catalog.validation.impl.validator.RangeValidator) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

RangeValidator (ddf.catalog.validation.impl.validator.RangeValidator)14 BigDecimal (java.math.BigDecimal)14 Test (org.junit.Test)14 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)6