32 lines
1.2 KiB
Java
32 lines
1.2 KiB
Java
/**
|
|
*
|
|
*/
|
|
package org.gcube.accounting.datamodel.validations.validators;
|
|
|
|
import java.io.Serializable;
|
|
|
|
import org.gcube.accounting.datamodel.validations.validators.NotEmptyIfNotNullValidator;
|
|
import org.gcube.documentstore.exception.InvalidValueException;
|
|
import org.junit.Assert;
|
|
import org.junit.Test;
|
|
|
|
/**
|
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
|
*
|
|
*/
|
|
public class NotEmptyIfNotNullValidatorTest {
|
|
|
|
@Test
|
|
public void testBoolean() throws InvalidValueException{
|
|
NotEmptyIfNotNullValidator notEmptyIfNotNullValidator = new NotEmptyIfNotNullValidator();
|
|
Comparable<? extends Serializable> primitiveTrue = notEmptyIfNotNullValidator.validate(null, true, null);
|
|
Assert.assertTrue((Boolean) primitiveTrue);
|
|
Comparable<? extends Serializable> primitiveFalse = notEmptyIfNotNullValidator.validate(null, false, null);
|
|
Assert.assertFalse((Boolean) primitiveFalse);
|
|
Comparable<? extends Serializable> booleanClassTrue = notEmptyIfNotNullValidator.validate(null, Boolean.TRUE, null);
|
|
Assert.assertTrue((Boolean) booleanClassTrue);
|
|
Comparable<? extends Serializable> booleanClassFalse = notEmptyIfNotNullValidator.validate(null, Boolean.FALSE, null);
|
|
Assert.assertFalse((Boolean) booleanClassFalse);
|
|
}
|
|
}
|