refs #200: Create accouting-lib library
https://support.d4science.org/issues/200 Fixing validators git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@115255 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4db4ebba0a
commit
0b1b2db21d
|
@ -394,7 +394,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
List<ValidatorAction> fieldValidators = validation.get(key);
|
||||
if(fieldValidators!=null){
|
||||
for(ValidatorAction fieldValidator : fieldValidators){
|
||||
checkedValue = fieldValidator.validate(checkedValue);
|
||||
checkedValue = fieldValidator.validate(key, checkedValue, this);
|
||||
}
|
||||
}
|
||||
return checkedValue;
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.decorators;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*/
|
||||
public interface AggregatedAction {
|
||||
|
||||
public Serializable manage(String key, Serializable manage, UsageRecord usageRecord);
|
||||
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.decorators;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*/
|
||||
public interface DeprecatedAction {
|
||||
|
||||
public Serializable manage(String key, Serializable manage, UsageRecord usageRecord);
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package org.gcube.accounting.datamodel.decorators;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Inherited
|
||||
public @interface DeprecatedField {
|
||||
|
||||
Class<? extends DeprecatedAction> action();
|
||||
|
||||
}
|
|
@ -5,19 +5,25 @@ package org.gcube.accounting.datamodel.decorators;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*/
|
||||
public interface ValidatorAction {
|
||||
|
||||
|
||||
/**
|
||||
* Validate (and convert if needed) the provided property
|
||||
* @param toValidate the property to validate
|
||||
* @return the validated (and converted property)
|
||||
* @throws InvalidValueException if the validation (or conversion) fails
|
||||
* Validate (and eventually convert) the value of the property identified by
|
||||
* the key.
|
||||
* @param key The key of the property
|
||||
* @param value The value to be validated (and eventually converted) of the
|
||||
* property
|
||||
* @param usageRecord the Usage Record the property is attached
|
||||
* @return the validated (and eventually converted) value of the property
|
||||
* @throws InvalidValueException if the validation or the eventual
|
||||
* conversion fails
|
||||
*/
|
||||
public Serializable validate(Serializable toValidate) throws InvalidValueException;
|
||||
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException;
|
||||
|
||||
}
|
||||
|
|
|
@ -7,12 +7,11 @@ import java.util.Calendar;
|
|||
|
||||
import org.gcube.accounting.datamodel.RawUsageRecord;
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
import org.gcube.accounting.datamodel.decorators.DeprecatedField;
|
||||
import org.gcube.accounting.datamodel.decorators.RequiredField;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidInteger;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
|
||||
import org.gcube.accounting.datamodel.validations.validators.ConvertToOperationResult;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidOperationResult;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
/**
|
||||
|
@ -41,7 +40,7 @@ public class JobUsageRecord extends RawUsageRecord implements SingleUsageRecord
|
|||
@RequiredField @ValidLong
|
||||
public static final String JOB_END_TIME = "jobEndTime";
|
||||
|
||||
@DeprecatedField(action=ConvertToOperationResult.class) @NotEmpty //TODO
|
||||
@ValidOperationResult
|
||||
protected static final String JOB_STATUS = "jobStatus";
|
||||
|
||||
@ValidInteger
|
||||
|
|
|
@ -5,11 +5,10 @@ package org.gcube.accounting.datamodel.implementations;
|
|||
|
||||
import org.gcube.accounting.datamodel.RawUsageRecord;
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
import org.gcube.accounting.datamodel.decorators.DeprecatedField;
|
||||
import org.gcube.accounting.datamodel.decorators.RequiredField;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.DeprecatedWarning;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.NotEmptyIfNotNull;
|
||||
import org.gcube.accounting.datamodel.validations.validators.WarningAlert;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
/**
|
||||
|
@ -23,7 +22,7 @@ public class PortletUsageRecord extends RawUsageRecord implements SingleUsageRec
|
|||
*/
|
||||
private static final long serialVersionUID = 8339324883678974869L;
|
||||
|
||||
@DeprecatedField(action=WarningAlert.class) @NotEmptyIfNotNull
|
||||
@DeprecatedWarning @NotEmptyIfNotNull
|
||||
protected static final String USER_ID = "userId";
|
||||
|
||||
@RequiredField @NotEmpty
|
||||
|
|
|
@ -5,12 +5,11 @@ package org.gcube.accounting.datamodel.implementations;
|
|||
|
||||
import org.gcube.accounting.datamodel.RawUsageRecord;
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
import org.gcube.accounting.datamodel.decorators.DeprecatedField;
|
||||
import org.gcube.accounting.datamodel.decorators.RequiredField;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.DeprecatedWarning;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidIP;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidInteger;
|
||||
import org.gcube.accounting.datamodel.validations.validators.WarningAlert;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
/**
|
||||
|
@ -32,7 +31,7 @@ public class ServiceUsageRecord extends RawUsageRecord implements SingleUsageRec
|
|||
public static final String REF_HOST = "refHost";
|
||||
@RequiredField @NotEmpty
|
||||
public static final String REF_VM = "refVM";
|
||||
@DeprecatedField(action=WarningAlert.class) @NotEmpty
|
||||
@DeprecatedWarning @NotEmpty
|
||||
public static final String DOMAIN = "domain";
|
||||
@ValidInteger
|
||||
protected static final String INVOCATION_COUNT = "invocationCount";
|
||||
|
|
|
@ -7,13 +7,12 @@ import java.util.Calendar;
|
|||
|
||||
import org.gcube.accounting.datamodel.RawUsageRecord;
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
import org.gcube.accounting.datamodel.decorators.DeprecatedField;
|
||||
import org.gcube.accounting.datamodel.decorators.RequiredField;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.DeprecatedWarning;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidInteger;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
|
||||
import org.gcube.accounting.datamodel.validations.validators.ConvertToOperationResult;
|
||||
import org.gcube.accounting.datamodel.validations.validators.WarningAlert;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidOperationResult;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
/**
|
||||
|
@ -28,7 +27,7 @@ public class TaskUsageRecord extends RawUsageRecord implements SingleUsageRecord
|
|||
private static final long serialVersionUID = -2208425042550641240L;
|
||||
|
||||
public static enum USAGE_PHASE {
|
||||
completed, failed
|
||||
completed, failed
|
||||
};
|
||||
|
||||
@RequiredField @NotEmpty
|
||||
|
@ -37,13 +36,13 @@ public class TaskUsageRecord extends RawUsageRecord implements SingleUsageRecord
|
|||
public static final String REF_HOST = "refHost";
|
||||
@RequiredField @NotEmpty
|
||||
public static final String REF_VM = "refVM";
|
||||
@DeprecatedField(action=WarningAlert.class)
|
||||
@DeprecatedWarning
|
||||
protected static final String DOMAIN = "domain";
|
||||
@RequiredField @ValidLong
|
||||
public static final String USAGE_START_TIME = "usageStartTime";
|
||||
@RequiredField @ValidLong
|
||||
public static final String USAGE_END_TIME = "usageEndTime";
|
||||
@DeprecatedField(action=ConvertToOperationResult.class) @NotEmpty
|
||||
@ValidOperationResult
|
||||
public static final String USAGE_PHASE = "usagePhase";
|
||||
@ValidInteger
|
||||
public static final String INPUT_FILES_NUMBER = "inputFilesNumber";
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package org.gcube.accounting.datamodel.validations.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorField;
|
||||
import org.gcube.accounting.datamodel.validations.validators.DeprecatedWarningValidator;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ValidatorField(managed=DeprecatedWarningValidator.class)
|
||||
public @interface DeprecatedWarning {
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.validations.validators;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.decorators.DeprecatedAction;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public class ConvertToOperationResult implements DeprecatedAction {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Serializable manage(String key, Serializable manage, UsageRecord usageRecord) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.validations.validators;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorAction;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public class DeprecatedWarningValidator implements ValidatorAction {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(DeprecatedWarningValidator.class);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
|
||||
logger.warn("The field {} is deprecated for {}. Anyway the field will be included in the document",
|
||||
key, usageRecord.getClass().getSimpleName());
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package org.gcube.accounting.datamodel.validations.validators;
|
|||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorAction;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
|
@ -23,11 +24,14 @@ public class NotEmptyValidator implements ValidatorAction{
|
|||
} else return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Serializable validate(Serializable toValidate) throws InvalidValueException {
|
||||
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
|
||||
try{
|
||||
if(isValid(toValidate)){
|
||||
return toValidate;
|
||||
if(isValid(value)){
|
||||
return value;
|
||||
}
|
||||
}catch(Exception e){
|
||||
throw new InvalidValueException(ERROR, e.getCause());
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.accounting.datamodel.validations.validators;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorAction;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
|
@ -9,10 +10,13 @@ public class NotNullValidator implements ValidatorAction {
|
|||
|
||||
private static final String ERROR = "Is Null";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Serializable validate(Serializable toValidate) throws InvalidValueException {
|
||||
if(toValidate!=null){
|
||||
return toValidate;
|
||||
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
|
||||
if(value!=null){
|
||||
return value;
|
||||
}
|
||||
throw new InvalidValueException(ERROR);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.io.Serializable;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorAction;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -42,11 +43,14 @@ public class ValidIPValidator implements ValidatorAction{
|
|||
return ipV6Matcher.matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Serializable validate(Serializable toValidate) throws InvalidValueException {
|
||||
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
|
||||
try {
|
||||
if(isIpAddress((String) toValidate)){
|
||||
return (String) toValidate;
|
||||
if(isIpAddress((String) value)){
|
||||
return (String) value;
|
||||
}
|
||||
}catch (Exception e) {
|
||||
throw new InvalidValueException(ERROR, e.getCause());
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.accounting.datamodel.validations.validators;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorAction;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
|
@ -10,12 +11,15 @@ public class ValidIntegerValidator implements ValidatorAction {
|
|||
|
||||
private static final String ERROR = String.format("Not Instance of %s", Integer.class.getSimpleName());
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Serializable validate(Serializable toValidate) throws InvalidValueException {
|
||||
if(toValidate instanceof Integer){
|
||||
return toValidate;
|
||||
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
|
||||
if(value instanceof Integer){
|
||||
return value;
|
||||
}
|
||||
Integer integerObj = Integer.getInteger((String) toValidate);
|
||||
Integer integerObj = Integer.getInteger((String) value);
|
||||
if(integerObj!=null){
|
||||
return integerObj;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.accounting.datamodel.validations.validators;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorAction;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
|
@ -10,13 +11,16 @@ public class ValidLongValidator implements ValidatorAction {
|
|||
|
||||
private static final String ERROR = String.format("Not Instance of %s", Integer.class.getSimpleName());
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Serializable validate(Serializable toValidate) throws InvalidValueException {
|
||||
if(toValidate instanceof Long){
|
||||
return toValidate;
|
||||
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
|
||||
if(value instanceof Long){
|
||||
return value;
|
||||
}
|
||||
try {
|
||||
Long longObj = Long.getLong((String) toValidate);
|
||||
Long longObj = Long.getLong((String) value);
|
||||
if(longObj!=null){
|
||||
return longObj;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.accounting.datamodel.validations.validators;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.UsageRecord.OperationResult;
|
||||
import org.gcube.accounting.datamodel.decorators.ValidatorAction;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
@ -10,16 +11,20 @@ public class ValidOperationResultValidator implements ValidatorAction {
|
|||
|
||||
private static final String ERROR = String.format("Not Instance of %s", OperationResult.class.getSimpleName());
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Serializable validate(Serializable toValidate) throws InvalidValueException {
|
||||
if(toValidate instanceof OperationResult){
|
||||
return toValidate;
|
||||
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
|
||||
if(value instanceof OperationResult){
|
||||
return value;
|
||||
}
|
||||
|
||||
try {
|
||||
if(toValidate instanceof String){
|
||||
if(value instanceof String){
|
||||
try{
|
||||
OperationResult operationResult = OperationResult.valueOf((String) toValidate);
|
||||
OperationResult operationResult = OperationResult.valueOf((String) value);
|
||||
if(operationResult !=null){
|
||||
return operationResult;
|
||||
}
|
||||
|
@ -28,17 +33,21 @@ public class ValidOperationResultValidator implements ValidatorAction {
|
|||
}
|
||||
|
||||
try{
|
||||
Integer integer = Integer.getInteger((String) toValidate);
|
||||
Integer integer = Integer.getInteger((String) value);
|
||||
if(integer!=null){
|
||||
toValidate = integer;
|
||||
value = integer;
|
||||
}
|
||||
} catch(Exception e){
|
||||
// Trying another way
|
||||
}
|
||||
}
|
||||
|
||||
if(toValidate instanceof Integer){
|
||||
return OperationResult.values()[(Integer) toValidate];
|
||||
if(value instanceof Integer){
|
||||
return OperationResult.values()[(Integer) value];
|
||||
}
|
||||
|
||||
if(value instanceof Enum){
|
||||
return OperationResult.values()[((Enum) value).ordinal()];
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.validations.validators;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.decorators.DeprecatedAction;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public class WarningAlert implements DeprecatedAction {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(WarningAlert.class);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Serializable manage(String key, Serializable manage, UsageRecord usageRecord) {
|
||||
logger.warn("The field {} is deprecated for the {}. Anyway the field will be included in the document",
|
||||
key, usageRecord.getClass().getSimpleName());
|
||||
return manage;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.validators;
|
||||
package org.gcube.accounting.datamodel.validations.validators;
|
||||
|
||||
import org.gcube.accounting.datamodel.validations.validators.ValidLongValidator;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
@ -17,20 +17,20 @@ public class ValidTimeValidatorTest {
|
|||
public void testPrimitiveLong() throws InvalidValueException{
|
||||
ValidLongValidator validTimeValidator = new ValidLongValidator();
|
||||
long myLong = 4;
|
||||
validTimeValidator.validate(myLong);
|
||||
validTimeValidator.validate(null, myLong, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassLong() throws InvalidValueException{
|
||||
ValidLongValidator validTimeValidator = new ValidLongValidator();
|
||||
Long myLong = new Long(4);
|
||||
validTimeValidator.validate(myLong);
|
||||
validTimeValidator.validate(null, myLong, null);
|
||||
}
|
||||
|
||||
@Test(expected=InvalidValueException.class)
|
||||
public void testWrongValue() throws InvalidValueException {
|
||||
ValidLongValidator validTimeValidator = new ValidLongValidator();
|
||||
validTimeValidator.validate("test");
|
||||
validTimeValidator.validate(null, "test", null);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue