use of org.apache.directory.api.ldap.model.schema.normalizers.NumericNormalizer in project directory-ldap-api by apache.
the class NumericNormalizerTest method testNumericNormalizerNull.
@Test
public void testNumericNormalizerNull() throws LdapException {
Normalizer normalizer = new NumericNormalizer();
assertEquals(null, normalizer.normalize((String) null));
}
use of org.apache.directory.api.ldap.model.schema.normalizers.NumericNormalizer in project directory-ldap-api by apache.
the class NumericNormalizerTest method testNumericNormalizerTwoSpaces.
@Test
public void testNumericNormalizerTwoSpaces() throws LdapException {
Normalizer normalizer = new NumericNormalizer();
assertEquals("", normalizer.normalize(" "));
}
use of org.apache.directory.api.ldap.model.schema.normalizers.NumericNormalizer in project directory-ldap-api by apache.
the class NumericNormalizerTest method testNumericNormalizerOneSpace.
@Test
public void testNumericNormalizerOneSpace() throws LdapException {
Normalizer normalizer = new NumericNormalizer();
assertEquals("", normalizer.normalize(" "));
}
use of org.apache.directory.api.ldap.model.schema.normalizers.NumericNormalizer in project directory-ldap-api by apache.
the class NumericNormalizerTest method testInsignifiantSpacesStringTwoChars.
@Test
public void testInsignifiantSpacesStringTwoChars() throws LdapException {
Normalizer normalizer = new NumericNormalizer();
assertEquals("11", normalizer.normalize("11"));
}
use of org.apache.directory.api.ldap.model.schema.normalizers.NumericNormalizer in project directory-ldap-api by apache.
the class IntegerComparator method compare.
/**
* Implementation of the Compare method
*/
private int compare(String backendValue, String assertValue) {
LOG.debug("comparing Integer objects '{}' with '{}'", backendValue, assertValue);
// reference the same object
if (backendValue == assertValue) {
return 0;
}
// have been caught by the previous test
if ((backendValue == null) || (assertValue == null)) {
return backendValue == null ? -1 : 1;
}
// Both objects must be stored as String for numeric.
// But we need to normalize the values first.
NumericNormalizer normalizer = new NumericNormalizer();
try {
backendValue = normalizer.normalize(backendValue);
} catch (LdapException le) {
throw new IllegalArgumentException(I18n.err(I18n.ERR_13724_INVALID_VALUE, backendValue), le);
}
try {
assertValue = normalizer.normalize(assertValue);
} catch (LdapException le) {
throw new IllegalArgumentException(I18n.err(I18n.ERR_13724_INVALID_VALUE, assertValue), le);
}
BigInteger b1 = new BigInteger(backendValue);
BigInteger b2 = new BigInteger(assertValue);
return b1.compareTo(b2);
}
Aggregations