//int intStatus = 0;
// TODO: check for datastore notification!
// create source datapoint
VirtualDataPoint source = new VirtualDataPoint(
CosDpValueTypeEnum.TypeBoolean);
source.keyId = keyId++;
source.name = "source-datapoint";
// create list of datapoint
DataPointList dpList = new DataPointList();
dpList.add(source);
// calculated-boolean datapoint
datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeBoolean);
datapoint.keyId = keyId++;
datapoint.name = "calculated-boolean";
// initial value
Assert.assertEquals(false, datapoint.isInhibit());
Assert.assertEquals(false, datapoint.getSourceValue().boolValue());
Assert.assertEquals(0, datapoint.getSourceTimestamp());
Assert.assertEquals(CosDpQualityEnum.QualityBad, datapoint
.getSourceQuality());
Assert.assertEquals(false, datapoint.getValue().boolValue());
Assert.assertEquals(0, datapoint.getTimestamp());
Assert.assertEquals(CosDpQualityEnum.QualityBad, datapoint
.getQuality());
Assert.assertEquals(0, datapoint.getUpdateTimestamp());
sourceTs = datapoint.getSourceTimestamp();
outputTs = datapoint.getTimestamp();
updateTs = Calendar.getInstance().getTimeInMillis();
sleep(1);
// set calculated expression
boolStatus = datapoint.setExpression("{{source-datapoint}}", dpList);
Assert.assertEquals(true, boolStatus);
// source quality is set to good, source timestamp is set to current
// time
Assert.assertTrue(datapoint.getSourceTimestamp() > updateTs);
Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
.getSourceQuality());
Assert.assertEquals(false, datapoint.getSourceValue().boolValue());
// output quality/output timestamp is synchronized
Assert.assertEquals(datapoint.getSourceTimestamp(), datapoint
.getTimestamp());
Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
.getQuality());
Assert.assertEquals(false, datapoint.getValue().boolValue());
// update-time is set to current time
Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);
sourceTs = datapoint.getSourceTimestamp();
outputTs = datapoint.getTimestamp();
updateTs = Calendar.getInstance().getTimeInMillis();
sleep(1);
// set the inhibit flag
boolStatus = datapoint.setInhibit();
Assert.assertEquals(true, boolStatus);
// inhibit flag is set
Assert.assertEquals(true, datapoint.isInhibit());
// no update on source value/quality/timestamp
Assert.assertEquals(false, datapoint.getSourceValue().boolValue());
Assert.assertTrue(datapoint.getSourceTimestamp() == sourceTs);
Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
.getSourceQuality());
// output quality is set to QualityInhibit,
// output timestamp is set to current time
Assert.assertEquals(false, datapoint.getValue().boolValue());
Assert.assertTrue(datapoint.getTimestamp() > updateTs);
Assert.assertEquals(CosDpQualityEnum.QualityInhibit, datapoint
.getQuality());
// update-timestamp is set to current time
Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);
// TODO: check for datapoint notification
sourceTs = datapoint.getSourceTimestamp();
outputTs = datapoint.getTimestamp();
updateTs = Calendar.getInstance().getTimeInMillis();
sleep(1);
// set the source datapoint with new value (this will trigger the update
// in the calculated point)
source.setBooleanValue(true);
// source value is updated, source timestamp is updated to current time
Assert.assertEquals(true, datapoint.getSourceValue().boolValue());
Assert.assertTrue(datapoint.getSourceTimestamp() > updateTs);
Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
.getSourceQuality());