Search in sources :

Example 1 with RangeValidator

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

the class RangeValidatorTest method testHashCodeDifferentMin.

@Test
public void testHashCodeDifferentMin() {
    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.hashCode(), not(validator2.hashCode()));
}
Also used : RangeValidator(ddf.catalog.validation.impl.validator.RangeValidator) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 2 with RangeValidator

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

the class RangeValidatorTest method testEquals.

@Test
public void testEquals() {
    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.5"));
    assertThat(validator1.equals(validator2), is(true));
    assertThat(validator2.equals(validator1), is(true));
}
Also used : RangeValidator(ddf.catalog.validation.impl.validator.RangeValidator) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 3 with RangeValidator

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

the class RangeValidatorTest method testWithinLargeDecimalRange.

@Test
public void testWithinLargeDecimalRange() {
    final RangeValidator validator = new RangeValidator(new BigDecimal("-123456789123456.857"), new BigDecimal("987654321987654.923"), new BigDecimal("0.01"));
    validateNoErrors(new AttributeImpl("", -123456789123456.857), validator);
    validateNoErrors(new AttributeImpl("", 987654321987654.923), validator);
    validateNoErrors(new AttributeImpl("", 0), validator);
    validateNoErrors(new AttributeImpl("", -123456789123456L), validator);
    validateNoErrors(new AttributeImpl("", 987654321987654L), 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 4 with RangeValidator

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

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

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