Fixing internals
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@122626 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
51cc51f546
commit
d106fe5b4c
|
@ -58,7 +58,7 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
|
|||
super();
|
||||
}
|
||||
|
||||
public BasicUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
|
||||
public BasicUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
|||
super();
|
||||
}
|
||||
|
||||
public AggregatedJobUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException{
|
||||
public AggregatedJobUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException{
|
||||
super(properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
|||
super();
|
||||
}
|
||||
|
||||
public AggregatedPortletUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException{
|
||||
public AggregatedPortletUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException{
|
||||
super(properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
super();
|
||||
}
|
||||
|
||||
public AggregatedServiceUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException{
|
||||
public AggregatedServiceUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException{
|
||||
super(properties);
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,6 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
AggregationUtility<AggregatedServiceUsageRecord> aggregationUtility = new AggregationUtility<AggregatedServiceUsageRecord>(this);
|
||||
aggregationUtility.aggregate(record);
|
||||
|
||||
setDuration(durationWeightedAverage(record));
|
||||
|
||||
|
@ -149,6 +148,12 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
if(min < this.getMinInvocationTime()){
|
||||
this.setMinInvocationTime(min);
|
||||
}
|
||||
|
||||
// This statement is at the end because the aggregate method
|
||||
// sum operation counts. If this statement is moved at the
|
||||
// beginning the weighted average is not calculated correctly
|
||||
aggregationUtility.aggregate(record);
|
||||
|
||||
} catch(NotAggregatableRecordsExceptions e){
|
||||
throw e;
|
||||
} catch(Exception ex){
|
||||
|
|
|
@ -38,7 +38,7 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
|||
super();
|
||||
}
|
||||
|
||||
public AggregatedStorageUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException{
|
||||
public AggregatedStorageUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException{
|
||||
super(properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implement
|
|||
super();
|
||||
}
|
||||
|
||||
public AggregatedTaskUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException{
|
||||
public AggregatedTaskUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException{
|
||||
super(properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.gcube.documentstore.records.implementation.validations.validators.Not
|
|||
public class MoveToConsumerIdAction implements FieldAction {
|
||||
|
||||
@Override
|
||||
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, Record record) throws InvalidValueException {
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
NotEmptyIfNotNullValidator neinnv = new NotEmptyIfNotNullValidator();
|
||||
value = neinnv.validate(key, value, record);
|
||||
record.setResourceProperty(UsageRecord.CONSUMER_ID, (String) value);
|
||||
|
|
|
@ -22,7 +22,7 @@ public class MoveToOperationResultAction implements FieldAction {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, Record record) throws InvalidValueException {
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
ValidOperationResultValidator vorv = new ValidOperationResultValidator();
|
||||
value = vorv.validate(key, value, record);
|
||||
record.setResourceProperty(UsageRecord.OPERATION_RESULT, (OperationResult) value);
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.gcube.documentstore.records.implementation.FieldAction;
|
|||
public class MoveToRecordTypeAction implements FieldAction {
|
||||
|
||||
@Override
|
||||
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, Record record) throws InvalidValueException {
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
if(value instanceof String && value!= null && !((String) value).isEmpty()){
|
||||
record.setResourceProperty(Record.RECORD_TYPE, value);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ public class MoveToTaskEndTimeAction implements FieldAction {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Comparable<? extends Serializable> validate(String key,
|
||||
Comparable<? extends Serializable> value, Record record)
|
||||
public Serializable validate(String key,
|
||||
Serializable value, Record record)
|
||||
throws InvalidValueException {
|
||||
record.setResourceProperty(AbstractTaskUsageRecord.TASK_END_TIME, value);
|
||||
return null;
|
||||
|
|
|
@ -20,8 +20,8 @@ public class MoveToTaskStartTimeAction implements FieldAction {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Comparable<? extends Serializable> validate(String key,
|
||||
Comparable<? extends Serializable> value, Record record)
|
||||
public Serializable validate(String key,
|
||||
Serializable value, Record record)
|
||||
throws InvalidValueException {
|
||||
record.setResourceProperty(AbstractTaskUsageRecord.TASK_START_TIME, value);
|
||||
return null;
|
||||
|
|
|
@ -34,19 +34,19 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
|
|||
@NotEmptyIfNotNull
|
||||
public static final String JOB_QUALIFIER = "jobQualifier";
|
||||
|
||||
@RequiredField @ValidLong @CalculateJobWallDuration
|
||||
@RequiredField @ValidLong
|
||||
public static final String JOB_START_TIME = "jobStartTime";
|
||||
@RequiredField @ValidLong @CalculateJobWallDuration
|
||||
@RequiredField @ValidLong
|
||||
public static final String JOB_END_TIME = "jobEndTime";
|
||||
@RequiredField @ValidLong @CalculateJobWallDuration @ComputedField
|
||||
protected static final String WALL_DURATION = "_wallDuration";
|
||||
@ComputedField(action=CalculateJobWallDurationAction.class) @ValidLong
|
||||
public static final String WALL_DURATION = "_wallDuration";
|
||||
|
||||
|
||||
public AbstractJobUsageRecord(){
|
||||
super();
|
||||
}
|
||||
|
||||
public AbstractJobUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException{
|
||||
public AbstractJobUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException{
|
||||
super(properties);
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,7 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
|
|||
long endTime = (Long) this.resourceProperties.get(JOB_END_TIME);
|
||||
long startTime = (Long) this.resourceProperties.get(JOB_START_TIME);
|
||||
long wallDuration = endTime - startTime;
|
||||
setResourceProperty(AbstractJobUsageRecord.WALL_DURATION, wallDuration);
|
||||
return wallDuration;
|
||||
}catch(Exception e){
|
||||
throw new InvalidValueException(String.format("To calculate Wall Duration both %s and %s must be set",
|
||||
|
|
|
@ -38,7 +38,7 @@ public abstract class AbstractPortletUsageRecord extends BasicUsageRecord {
|
|||
super();
|
||||
}
|
||||
|
||||
public AbstractPortletUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
|
||||
public AbstractPortletUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public abstract class AbstractServiceUsageRecord extends BasicUsageRecord {
|
|||
super();
|
||||
}
|
||||
|
||||
public AbstractServiceUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
|
||||
public AbstractServiceUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
|||
super();
|
||||
}
|
||||
|
||||
public AbstractStorageUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
|
||||
public AbstractStorageUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ package org.gcube.accounting.datamodel.basetypes;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.datamodel.BasicUsageRecord;
|
||||
|
@ -36,22 +37,21 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
|||
@NotEmptyIfNotNull
|
||||
public static final String REF_HOSTING_NODE_ID = "refHostingNodeId";
|
||||
|
||||
@RequiredField @ValidLong @CalculateTaskWallDuration
|
||||
@RequiredField @ValidLong
|
||||
public static final String TASK_START_TIME = "taskStartTime";
|
||||
@RequiredField @ValidLong @CalculateTaskWallDuration
|
||||
@RequiredField @ValidLong
|
||||
public static final String TASK_END_TIME = "taskEndTime";
|
||||
@ComputedField(action=CalculateTaskWallDurationAction.class) @ValidLong
|
||||
public static final String WALL_DURATION = "_wallDuration";
|
||||
|
||||
@RequiredField @ValidLong @CalculateTaskWallDuration @ComputedField
|
||||
protected static final String WALL_DURATION = "wallDuration";
|
||||
|
||||
@RequiredField //@ValidMap
|
||||
@NotEmptyIfNotNull
|
||||
public static final String INPUT_PARAMETERS = "inputParameters";
|
||||
|
||||
public AbstractTaskUsageRecord(){
|
||||
super();
|
||||
}
|
||||
|
||||
public AbstractTaskUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
|
||||
public AbstractTaskUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
|
@ -155,13 +155,12 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, ? extends Object> getInputParameters(){
|
||||
return (Map<String, Object>) getResourceProperty(INPUT_PARAMETERS);
|
||||
public Map<String, Serializable> getInputParameters(){
|
||||
return (HashMap<String, Serializable>) getResourceProperty(INPUT_PARAMETERS);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setInputParameters(Map<String, ? extends Object> inputParameters) throws InvalidValueException{
|
||||
setResourceProperty(INPUT_PARAMETERS, (Comparable<? extends Serializable>) inputParameters);
|
||||
public void setInputParameters(HashMap<String, Serializable> inputParameters) throws InvalidValueException{
|
||||
setResourceProperty(INPUT_PARAMETERS, inputParameters);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class CalculateJobWallDurationAction implements FieldAction {
|
|||
private static final Logger logger = LoggerFactory.getLogger(CalculateJobWallDurationAction.class);
|
||||
|
||||
@Override
|
||||
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, Record record) throws InvalidValueException {
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
try {
|
||||
long wallDuration = ((AbstractJobUsageRecord) record).calculateWallDuration();
|
||||
if(key.compareTo(AbstractJobUsageRecord.WALL_DURATION)==0){
|
||||
|
|
|
@ -16,13 +16,15 @@ public class CalculateTaskWallDurationAction implements FieldAction {
|
|||
private static final Logger logger = LoggerFactory.getLogger(CalculateTaskWallDurationAction.class);
|
||||
|
||||
@Override
|
||||
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, Record record) throws InvalidValueException {
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
try {
|
||||
long wallDuration = ((AbstractTaskUsageRecord) record).calculateWallDuration();
|
||||
if(key.compareTo(AbstractTaskUsageRecord.WALL_DURATION)==0){
|
||||
logger.warn("{} is automatically computed using {} and {}. This invocation has the only effect of recalculating the value. Any provided value is ignored.",
|
||||
AbstractTaskUsageRecord.WALL_DURATION, AbstractTaskUsageRecord.TASK_START_TIME, AbstractTaskUsageRecord.TASK_END_TIME);
|
||||
value = wallDuration;
|
||||
}else{
|
||||
record.setResourceProperty(AbstractTaskUsageRecord.WALL_DURATION, wallDuration);
|
||||
}
|
||||
}catch(InvalidValueException e){ }
|
||||
return value;
|
||||
|
|
|
@ -8,7 +8,6 @@ import java.net.URI;
|
|||
import java.net.URISyntaxException;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord.OperationResult;
|
||||
|
@ -71,12 +70,6 @@ public class TestUsageRecord {
|
|||
*/
|
||||
public static ServiceUsageRecord createTestServiceUsageRecordExplicitScope() throws InvalidValueException {
|
||||
ServiceUsageRecord usageRecord = createTestServiceUsageRecordAutomaticScope();
|
||||
try {
|
||||
usageRecord.setScope(TEST_SCOPE);
|
||||
} catch (InvalidValueException e) {
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Setting the Scope", e);
|
||||
throw e;
|
||||
}
|
||||
return usageRecord;
|
||||
|
||||
}
|
||||
|
@ -123,12 +116,6 @@ public class TestUsageRecord {
|
|||
*/
|
||||
public static StorageUsageRecord createTestStorageUsageRecordExplicitScope() {
|
||||
StorageUsageRecord usageRecord = createTestStorageUsageRecordAutomaticScope();
|
||||
try {
|
||||
usageRecord.setScope(TEST_SCOPE);
|
||||
} catch (InvalidValueException e) {
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Setting the Scope", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return usageRecord;
|
||||
|
||||
}
|
||||
|
@ -169,14 +156,7 @@ public class TestUsageRecord {
|
|||
* @return
|
||||
*/
|
||||
public static JobUsageRecord createTestJobUsageRecordExplicitScope() {
|
||||
|
||||
JobUsageRecord usageRecord = createTestJobUsageRecordAutomaticScope();
|
||||
try {
|
||||
usageRecord.setScope(TEST_SCOPE);
|
||||
} catch (InvalidValueException e) {
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Setting the Scope", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return usageRecord;
|
||||
}
|
||||
|
||||
|
@ -217,14 +197,7 @@ public class TestUsageRecord {
|
|||
* @return
|
||||
*/
|
||||
public static TaskUsageRecord createTestTaskUsageRecordExplicitScope() {
|
||||
|
||||
TaskUsageRecord usageRecord = createTestTaskUsageRecordAutomaticScope();
|
||||
try {
|
||||
usageRecord.setScope(TEST_SCOPE);
|
||||
} catch (InvalidValueException e) {
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Setting the Scope", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return usageRecord;
|
||||
}
|
||||
|
||||
|
@ -252,11 +225,11 @@ public class TestUsageRecord {
|
|||
usageRecord.setTaskStartTime(startTime);
|
||||
usageRecord.setTaskEndTime(endTime);
|
||||
|
||||
Map<String, Serializable> inputParameters = new HashMap<>();
|
||||
HashMap<String, Serializable> inputParameters = new HashMap<>();
|
||||
inputParameters.put(TEST_PROPERTY_NAME, TEST_PROPERTY_VALUE);
|
||||
inputParameters.put(TEST_PROPERTY_VALUE, TEST_PROPERTY_NAME);
|
||||
|
||||
HashMap<String, Comparable<? extends Serializable>> parameter = new HashMap<>();
|
||||
HashMap<String, Serializable> parameter = new HashMap<>();
|
||||
parameter.put(TEST_PROPERTY_NAME, TEST_PROPERTY_VALUE);
|
||||
parameter.put(TEST_PROPERTY_VALUE, TEST_PROPERTY_NAME);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public class DeprecatedWarningAction implements FieldAction {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, Record record) throws InvalidValueException {
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
logger.trace("The field {} is deprecated for {}. Anyway the field will be included in the SingleUsageRecord. The field can be lost during aggregation.",
|
||||
key, record.getClass().getSimpleName());
|
||||
return value;
|
||||
|
|
|
@ -17,7 +17,7 @@ public class JobUsageRecord extends AbstractJobUsageRecord {
|
|||
super();
|
||||
}
|
||||
|
||||
public JobUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException{
|
||||
public JobUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException{
|
||||
super(properties);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class PortletUsageRecord extends AbstractPortletUsageRecord {
|
|||
super();
|
||||
}
|
||||
|
||||
public PortletUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
|
||||
public PortletUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public class ServiceUsageRecord extends AbstractServiceUsageRecord {
|
|||
super();
|
||||
}
|
||||
|
||||
public ServiceUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
|
||||
public ServiceUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException {
|
||||
super(properties);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class StorageUsageRecord extends AbstractStorageUsageRecord {
|
|||
super();
|
||||
}
|
||||
|
||||
public StorageUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
|
||||
public StorageUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public class TaskUsageRecord extends AbstractTaskUsageRecord {
|
|||
super();
|
||||
}
|
||||
|
||||
public TaskUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
|
||||
public TaskUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException {
|
||||
super(properties);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class FixDataVolumeSignAction implements FieldAction {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, Record record) throws InvalidValueException {
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
try {
|
||||
|
||||
if(key.compareTo(AbstractStorageUsageRecord.DATA_VOLUME)==0){
|
||||
|
|
|
@ -16,7 +16,7 @@ public class ValidDataTypeValidator implements FieldAction {
|
|||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, Record record) throws InvalidValueException {
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
if(value instanceof DataType){
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class ValidIPValidator implements FieldAction {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, Record record) throws InvalidValueException {
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
try {
|
||||
if(isIpAddress((String) value)){
|
||||
return (String) value;
|
||||
|
|
|
@ -15,7 +15,7 @@ public class ValidMapValidator implements FieldAction {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, Record record) throws InvalidValueException {
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
|
||||
try {
|
||||
if(value instanceof Map){
|
||||
|
|
|
@ -16,7 +16,7 @@ public class ValidOperationResultValidator implements FieldAction {
|
|||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, Record record) throws InvalidValueException {
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
if(value instanceof OperationResult){
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class ValidOperationTypeValidator implements FieldAction {
|
|||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, Record record) throws InvalidValueException {
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
if(value instanceof OperationType){
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ public class ValidURIValidator implements FieldAction {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, Record record) throws InvalidValueException {
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
try {
|
||||
if(value instanceof URI){
|
||||
return value;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
*/
|
||||
package org.gcube.accounting.datamodel;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.records.RecordUtility;
|
||||
|
@ -23,7 +22,7 @@ public class UsageRecordTest {
|
|||
Assert.assertEquals(0, usageRecord.compareTo(ur));
|
||||
Assert.assertEquals(0, ur.compareTo(usageRecord));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCompareToEqualsObject() throws Exception {
|
||||
UsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope();
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
public class AggregatedServiceUsageRecordTest {
|
||||
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(AggregatedServiceUsageRecordTest.class);
|
||||
|
||||
@Test
|
||||
|
|
|
@ -20,11 +20,8 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
public class AggregatedStorageUsageRecordTest {
|
||||
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(AggregatedStorageUsageRecordTest.class);
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void secondAsNotAggregated() throws InvalidValueException, NotAggregatableRecordsExceptions {
|
||||
ScopeProvider.instance.set(TestUsageRecord.TEST_SCOPE);
|
||||
|
|
|
@ -12,15 +12,33 @@ import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
|
|||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public class JobUsageRecordTest {
|
||||
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(JobUsageRecordTest.class);
|
||||
|
||||
@Before
|
||||
public void before(){
|
||||
ScopeProvider.instance.set(TestUsageRecord.TEST_SCOPE);
|
||||
logger.trace("Setting {} scope", TestUsageRecord.TEST_SCOPE);
|
||||
}
|
||||
|
||||
@After
|
||||
public void after(){
|
||||
ScopeProvider.instance.reset();
|
||||
logger.trace("Scope reset");
|
||||
}
|
||||
|
||||
public static Set<String> getExpectedRequiredFields(){
|
||||
Set<String> expectedRequiredFields = new HashSet<String>();
|
||||
expectedRequiredFields.add(Record.ID);
|
||||
|
@ -32,40 +50,49 @@ public class JobUsageRecordTest {
|
|||
expectedRequiredFields.add(AbstractJobUsageRecord.JOB_ID);
|
||||
expectedRequiredFields.add(AbstractJobUsageRecord.JOB_START_TIME);
|
||||
expectedRequiredFields.add(AbstractJobUsageRecord.JOB_END_TIME);
|
||||
|
||||
return expectedRequiredFields;
|
||||
}
|
||||
|
||||
@Test(expected=InvalidValueException.class)
|
||||
public void scopeNotSetValidationError() throws InvalidValueException {
|
||||
ScopeProvider.instance.reset();
|
||||
JobUsageRecord jobUsageRecord = TestUsageRecord.createTestJobUsageRecordAutomaticScope();
|
||||
jobUsageRecord.validate();
|
||||
JobUsageRecord usageRecord = TestUsageRecord.createTestJobUsageRecordAutomaticScope();
|
||||
usageRecord.validate();
|
||||
logger.debug("{}", usageRecord);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequiredFields() throws InvalidValueException{
|
||||
ScopeProvider.instance.set(TestUsageRecord.TEST_SCOPE);
|
||||
JobUsageRecord jobUsageRecord = TestUsageRecord.createTestJobUsageRecordAutomaticScope();
|
||||
JobUsageRecord usageRecord = TestUsageRecord.createTestJobUsageRecordAutomaticScope();
|
||||
|
||||
Set<String> expectedRequiredFields = getExpectedRequiredFields();
|
||||
Set<String> gotRequiredFields = jobUsageRecord.getRequiredFields();
|
||||
|
||||
logger.debug("Expected Required Fields : {}", expectedRequiredFields);
|
||||
|
||||
Set<String> gotRequiredFields = usageRecord.getRequiredFields();
|
||||
logger.debug("Got Required Fields : {}", gotRequiredFields);
|
||||
|
||||
Assert.assertTrue(expectedRequiredFields.containsAll(gotRequiredFields));
|
||||
Assert.assertTrue(gotRequiredFields.containsAll(expectedRequiredFields));
|
||||
|
||||
jobUsageRecord.validate();
|
||||
usageRecord.validate();
|
||||
logger.debug("{}", usageRecord);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequiredFieldsWithScopeSetExplicitely() throws InvalidValueException{
|
||||
JobUsageRecord jobUsageRecord = TestUsageRecord.createTestJobUsageRecordAutomaticScope();
|
||||
jobUsageRecord.setScope(TestUsageRecord.TEST_SCOPE);
|
||||
Set<String> expectedRequiredFields = getExpectedRequiredFields();
|
||||
ScopeProvider.instance.reset();
|
||||
JobUsageRecord usageRecord = TestUsageRecord.createTestJobUsageRecordAutomaticScope();
|
||||
Assert.assertTrue(usageRecord.getScope()==null);
|
||||
usageRecord.setScope(TestUsageRecord.TEST_SCOPE);
|
||||
|
||||
Set<String> gotRequiredFields = jobUsageRecord.getRequiredFields();
|
||||
Set<String> expectedRequiredFields = getExpectedRequiredFields();
|
||||
Set<String> gotRequiredFields = usageRecord.getRequiredFields();
|
||||
|
||||
Assert.assertTrue(expectedRequiredFields.containsAll(gotRequiredFields));
|
||||
Assert.assertTrue(gotRequiredFields.containsAll(expectedRequiredFields));
|
||||
|
||||
jobUsageRecord.validate();
|
||||
usageRecord.validate();
|
||||
logger.debug("{}", usageRecord);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,8 +12,12 @@ import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
|
|||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
|
@ -21,6 +25,20 @@ import org.junit.Test;
|
|||
*/
|
||||
public class ServiceUsageRecordTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ServiceUsageRecordTest.class);
|
||||
|
||||
@Before
|
||||
public void before(){
|
||||
ScopeProvider.instance.set(TestUsageRecord.TEST_SCOPE);
|
||||
logger.trace("Setting {} scope", TestUsageRecord.TEST_SCOPE);
|
||||
}
|
||||
|
||||
@After
|
||||
public void after(){
|
||||
ScopeProvider.instance.reset();
|
||||
logger.trace("Scope reset");
|
||||
}
|
||||
|
||||
public static Set<String> getExpectedRequiredFields(){
|
||||
Set<String> expectedRequiredFields = new HashSet<String>();
|
||||
expectedRequiredFields.add(Record.ID);
|
||||
|
@ -41,34 +59,43 @@ public class ServiceUsageRecordTest {
|
|||
@Test(expected=InvalidValueException.class)
|
||||
public void scopeNotSetValidationError() throws InvalidValueException {
|
||||
ScopeProvider.instance.reset();
|
||||
ServiceUsageRecord serviceUsageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope();
|
||||
serviceUsageRecord.validate();
|
||||
ServiceUsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope();
|
||||
usageRecord.validate();
|
||||
logger.debug("{}", usageRecord);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequiredFields() throws InvalidValueException{
|
||||
ScopeProvider.instance.set(TestUsageRecord.TEST_SCOPE);
|
||||
ServiceUsageRecord serviceUsageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope();
|
||||
ServiceUsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope();
|
||||
|
||||
Set<String> expectedRequiredFields = getExpectedRequiredFields();
|
||||
Set<String> gotRequiredFields = serviceUsageRecord.getRequiredFields();
|
||||
|
||||
logger.debug("Expected Required Fields : {}", expectedRequiredFields);
|
||||
|
||||
Set<String> gotRequiredFields = usageRecord.getRequiredFields();
|
||||
logger.debug("Got Required Fields : {}", gotRequiredFields);
|
||||
|
||||
Assert.assertTrue(expectedRequiredFields.containsAll(gotRequiredFields));
|
||||
Assert.assertTrue(gotRequiredFields.containsAll(expectedRequiredFields));
|
||||
|
||||
serviceUsageRecord.validate();
|
||||
usageRecord.validate();
|
||||
logger.debug("{}", usageRecord);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequiredFieldsWithScopeSetExplicitely() throws InvalidValueException{
|
||||
ServiceUsageRecord serviceUsageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope();
|
||||
serviceUsageRecord.setScope(TestUsageRecord.TEST_SCOPE);
|
||||
Set<String> expectedRequiredFields = getExpectedRequiredFields();
|
||||
ScopeProvider.instance.reset();
|
||||
ServiceUsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope();
|
||||
Assert.assertTrue(usageRecord.getScope()==null);
|
||||
usageRecord.setScope(TestUsageRecord.TEST_SCOPE);
|
||||
|
||||
Set<String> gotRequiredFields = serviceUsageRecord.getRequiredFields();
|
||||
Set<String> expectedRequiredFields = getExpectedRequiredFields();
|
||||
Set<String> gotRequiredFields = usageRecord.getRequiredFields();
|
||||
|
||||
Assert.assertTrue(expectedRequiredFields.containsAll(gotRequiredFields));
|
||||
Assert.assertTrue(gotRequiredFields.containsAll(expectedRequiredFields));
|
||||
|
||||
serviceUsageRecord.validate();
|
||||
usageRecord.validate();
|
||||
logger.debug("{}", usageRecord);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractJobUsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
|
@ -47,59 +47,57 @@ public class StorageUsageRecordTest {
|
|||
expectedRequiredFields.add(UsageRecord.RECORD_TYPE);
|
||||
expectedRequiredFields.add(UsageRecord.SCOPE);
|
||||
expectedRequiredFields.add(UsageRecord.OPERATION_RESULT);
|
||||
expectedRequiredFields.add(AbstractJobUsageRecord.JOB_ID);
|
||||
expectedRequiredFields.add(AbstractJobUsageRecord.JOB_QUALIFIER);
|
||||
expectedRequiredFields.add(AbstractJobUsageRecord.JOB_NAME);
|
||||
expectedRequiredFields.add(AbstractJobUsageRecord.JOB_START_TIME);
|
||||
expectedRequiredFields.add(AbstractJobUsageRecord.JOB_END_TIME);
|
||||
expectedRequiredFields.add(AbstractStorageUsageRecord.RESOURCE_OWNER);
|
||||
expectedRequiredFields.add(AbstractStorageUsageRecord.RESOURCE_SCOPE);
|
||||
expectedRequiredFields.add(AbstractStorageUsageRecord.RESOURCE_URI);
|
||||
expectedRequiredFields.add(AbstractStorageUsageRecord.PROVIDER_URI);
|
||||
expectedRequiredFields.add(AbstractStorageUsageRecord.OPERATION_TYPE);
|
||||
expectedRequiredFields.add(AbstractStorageUsageRecord.DATA_TYPE);
|
||||
expectedRequiredFields.add(AbstractStorageUsageRecord.DATA_VOLUME);
|
||||
|
||||
return expectedRequiredFields;
|
||||
}
|
||||
|
||||
@Test(expected=InvalidValueException.class)
|
||||
public void scopeNotSetValidationError() throws InvalidValueException {
|
||||
ScopeProvider.instance.reset();
|
||||
JobUsageRecord jobUsageRecord = TestUsageRecord.createTestJobUsageRecordAutomaticScope();
|
||||
jobUsageRecord.validate();
|
||||
StorageUsageRecord usageRecord = TestUsageRecord.createTestStorageUsageRecordAutomaticScope();
|
||||
usageRecord.validate();
|
||||
logger.debug("{}", usageRecord);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequiredFields() throws InvalidValueException{
|
||||
JobUsageRecord jobUsageRecord = TestUsageRecord.createTestJobUsageRecordAutomaticScope();
|
||||
StorageUsageRecord usageRecord = TestUsageRecord.createTestStorageUsageRecordAutomaticScope();
|
||||
|
||||
Set<String> expectedRequiredFields = getExpectedRequiredFields();
|
||||
|
||||
logger.debug("Expected Required Fields : {}", expectedRequiredFields);
|
||||
|
||||
Set<String> gotRequiredFields = jobUsageRecord.getRequiredFields();
|
||||
|
||||
Set<String> gotRequiredFields = usageRecord.getRequiredFields();
|
||||
logger.debug("Got Required Fields : {}", gotRequiredFields);
|
||||
|
||||
Assert.assertTrue(expectedRequiredFields.containsAll(gotRequiredFields));
|
||||
Assert.assertTrue(gotRequiredFields.containsAll(expectedRequiredFields));
|
||||
|
||||
jobUsageRecord.validate();
|
||||
usageRecord.validate();
|
||||
logger.debug("{}", usageRecord);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequiredFieldsWithScopeSetExplicitely() throws InvalidValueException{
|
||||
ScopeProvider.instance.reset();
|
||||
JobUsageRecord jobUsageRecord = TestUsageRecord.createTestJobUsageRecordAutomaticScope();
|
||||
Assert.assertTrue(jobUsageRecord.getScope()==null);
|
||||
jobUsageRecord.setScope(TestUsageRecord.TEST_SCOPE);
|
||||
StorageUsageRecord usageRecord = TestUsageRecord.createTestStorageUsageRecordExplicitScope();
|
||||
Assert.assertTrue(usageRecord.getScope()==null);
|
||||
usageRecord.setScope(TestUsageRecord.TEST_SCOPE);
|
||||
|
||||
Set<String> expectedRequiredFields = getExpectedRequiredFields();
|
||||
Set<String> gotRequiredFields = jobUsageRecord.getRequiredFields();
|
||||
Set<String> gotRequiredFields = usageRecord.getRequiredFields();
|
||||
|
||||
Assert.assertTrue(expectedRequiredFields.containsAll(gotRequiredFields));
|
||||
Assert.assertTrue(gotRequiredFields.containsAll(expectedRequiredFields));
|
||||
|
||||
jobUsageRecord.validate();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWallDuration() throws InvalidValueException{
|
||||
JobUsageRecord jobUsageRecord = TestUsageRecord.createTestJobUsageRecordAutomaticScope();
|
||||
Assert.assertTrue(jobUsageRecord.getWallDuration()==(TestUsageRecord.HALF_DURATION*2));
|
||||
jobUsageRecord.validate();
|
||||
usageRecord.validate();
|
||||
logger.debug("{}", usageRecord);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,8 +12,12 @@ import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
|
|||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
|
@ -21,6 +25,20 @@ import org.junit.Test;
|
|||
*/
|
||||
public class TaskUsageRecordTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(TaskUsageRecordTest.class);
|
||||
|
||||
@Before
|
||||
public void before(){
|
||||
ScopeProvider.instance.set(TestUsageRecord.TEST_SCOPE);
|
||||
logger.trace("Setting {} scope", TestUsageRecord.TEST_SCOPE);
|
||||
}
|
||||
|
||||
@After
|
||||
public void after(){
|
||||
ScopeProvider.instance.reset();
|
||||
logger.trace("Scope reset");
|
||||
}
|
||||
|
||||
public static Set<String> getExpectedRequiredFields(){
|
||||
Set<String> expectedRequiredFields = new HashSet<String>();
|
||||
expectedRequiredFields.add(Record.ID);
|
||||
|
@ -32,41 +50,50 @@ public class TaskUsageRecordTest {
|
|||
expectedRequiredFields.add(AbstractTaskUsageRecord.TASK_ID);
|
||||
expectedRequiredFields.add(AbstractTaskUsageRecord.TASK_START_TIME);
|
||||
expectedRequiredFields.add(AbstractTaskUsageRecord.TASK_END_TIME);
|
||||
|
||||
return expectedRequiredFields;
|
||||
}
|
||||
|
||||
@Test(expected=InvalidValueException.class)
|
||||
public void scopeNotSetValidationError() throws InvalidValueException {
|
||||
ScopeProvider.instance.reset();
|
||||
TaskUsageRecord taskUsageRecord = TestUsageRecord.createTestTaskUsageRecordAutomaticScope();
|
||||
taskUsageRecord.validate();
|
||||
TaskUsageRecord usageRecord = TestUsageRecord.createTestTaskUsageRecordAutomaticScope();
|
||||
usageRecord.validate();
|
||||
logger.debug("{}", usageRecord);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequiredFields() throws InvalidValueException{
|
||||
ScopeProvider.instance.set(TestUsageRecord.TEST_SCOPE);
|
||||
TaskUsageRecord taskUsageRecord = TestUsageRecord.createTestTaskUsageRecordAutomaticScope();
|
||||
TaskUsageRecord usageRecord = TestUsageRecord.createTestTaskUsageRecordAutomaticScope();
|
||||
|
||||
Set<String> expectedRequiredFields = getExpectedRequiredFields();
|
||||
Set<String> gotRequiredFields = taskUsageRecord.getRequiredFields();
|
||||
|
||||
logger.debug("Expected Required Fields : {}", expectedRequiredFields);
|
||||
|
||||
Set<String> gotRequiredFields = usageRecord.getRequiredFields();
|
||||
logger.debug("Got Required Fields : {}", gotRequiredFields);
|
||||
|
||||
Assert.assertTrue(expectedRequiredFields.containsAll(gotRequiredFields));
|
||||
Assert.assertTrue(gotRequiredFields.containsAll(expectedRequiredFields));
|
||||
|
||||
taskUsageRecord.validate();
|
||||
usageRecord.validate();
|
||||
logger.debug("{}", usageRecord);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequiredFieldsWithScopeSetExplicitely() throws InvalidValueException{
|
||||
TaskUsageRecord taskUsageRecord = TestUsageRecord.createTestTaskUsageRecordExplicitScope();
|
||||
taskUsageRecord.setScope(TestUsageRecord.TEST_SCOPE);
|
||||
ScopeProvider.instance.reset();
|
||||
TaskUsageRecord usageRecord = TestUsageRecord.createTestTaskUsageRecordExplicitScope();
|
||||
Assert.assertTrue(usageRecord.getScope()==null);
|
||||
usageRecord.setScope(TestUsageRecord.TEST_SCOPE);
|
||||
|
||||
Set<String> expectedRequiredFields = getExpectedRequiredFields();
|
||||
Set<String> gotRequiredFields = taskUsageRecord.getRequiredFields();
|
||||
Set<String> gotRequiredFields = usageRecord.getRequiredFields();
|
||||
|
||||
Assert.assertTrue(expectedRequiredFields.containsAll(gotRequiredFields));
|
||||
Assert.assertTrue(gotRequiredFields.containsAll(expectedRequiredFields));
|
||||
|
||||
taskUsageRecord.validate();
|
||||
usageRecord.validate();
|
||||
logger.debug("{}", usageRecord);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,13 +19,13 @@ public class NotEmptyIfNotNullValidatorTest {
|
|||
@Test
|
||||
public void testBoolean() throws InvalidValueException{
|
||||
NotEmptyIfNotNullValidator notEmptyIfNotNullValidator = new NotEmptyIfNotNullValidator();
|
||||
Comparable<? extends Serializable> primitiveTrue = notEmptyIfNotNullValidator.validate(null, true, null);
|
||||
Serializable primitiveTrue = notEmptyIfNotNullValidator.validate(null, true, null);
|
||||
Assert.assertTrue((Boolean) primitiveTrue);
|
||||
Comparable<? extends Serializable> primitiveFalse = notEmptyIfNotNullValidator.validate(null, false, null);
|
||||
Serializable primitiveFalse = notEmptyIfNotNullValidator.validate(null, false, null);
|
||||
Assert.assertFalse((Boolean) primitiveFalse);
|
||||
Comparable<? extends Serializable> booleanClassTrue = notEmptyIfNotNullValidator.validate(null, Boolean.TRUE, null);
|
||||
Serializable booleanClassTrue = notEmptyIfNotNullValidator.validate(null, Boolean.TRUE, null);
|
||||
Assert.assertTrue((Boolean) booleanClassTrue);
|
||||
Comparable<? extends Serializable> booleanClassFalse = notEmptyIfNotNullValidator.validate(null, Boolean.FALSE, null);
|
||||
Serializable booleanClassFalse = notEmptyIfNotNullValidator.validate(null, Boolean.FALSE, null);
|
||||
Assert.assertFalse((Boolean) booleanClassFalse);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,14 +34,12 @@ public class AggregationSchedulerTest {
|
|||
}
|
||||
|
||||
public static PersistenceExecutor persistenceExecutor = new PersistenceExecutor(){
|
||||
|
||||
@Override
|
||||
public void persist(Record... records) throws Exception {
|
||||
for(Record record : records){
|
||||
logger.debug("Storing : {}", record.toString());
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
protected void madeAssertion(Map<String, List<Record>> bufferedRecords, List<String> types, int size, int count) {
|
||||
|
|
Loading…
Reference in New Issue