assertNotNull(ss);
List<Integer> quarks = ss.getQuarks("*");
- assertEquals(4, quarks.size());
+ assertEquals(5, quarks.size());
for (Integer quark : quarks) {
String name = ss.getAttributeName(quark);
XmlUtilsTest.verifyStateIntervals("checkpoint", ss, quark, expectedStarts, expectedValues);
}
break;
- case "or_three_operands": {
+ case "and_three_operands": {
final int[] expectedStarts = { 1, 5, 7, 7 };
ITmfStateValue[] expectedValues = { TmfStateValue.newValueLong(1), TmfStateValue.newValueLong(0), TmfStateValue.newValueLong(1) };
- XmlUtilsTest.verifyStateIntervals("or_three_operands", ss, quark, expectedStarts, expectedValues);
+ XmlUtilsTest.verifyStateIntervals("and_three_operands", ss, quark, expectedStarts, expectedValues);
+ }
+ break;
+ case "not_operand": {
+ final int[] expectedStarts = { 1, 5, 7, 7 };
+ ITmfStateValue[] expectedValues = { TmfStateValue.newValueLong(0), TmfStateValue.newValueLong(1), TmfStateValue.newValueLong(0) };
+ XmlUtilsTest.verifyStateIntervals("not_operand", ss, quark, expectedStarts, expectedValues);
}
break;
default:
<tmfxml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="xmlDefinition.xsd">
+<!-- ***************************************************************************
+* The following represents the state of the attributes in the system after the
+* analysis.
+*
+* n corresponds to a null state value
+*
+* Timestamp | 1 | 3 | 5 | 7 |
+* -events and field value-
+* ev.test | 10 20
+* ev.test1 | 100 200
+* -states-
+* test | 1 0
+* test1 | n 0 1
+* checkpoint | 0 1 0
+* or_three_operands | 1 0 1
+* not_operand | 0 1 0
+*
+*************************************************************************** -->
+
<stateProvider id="test.xml.conditions" version="1">
<eventHandler eventName="test">
<stateChange>
</and>
</if>
<then>
- <stateAttribute type="constant" value="or_three_operands" />
+ <stateAttribute type="constant" value="and_three_operands" />
<stateValue type="long" value="0" />
</then>
<else>
- <stateAttribute type="constant" value="or_three_operands" />
+ <stateAttribute type="constant" value="and_three_operands" />
<stateValue type="long" value="1" />
</else>
</stateChange>
</eventHandler>
+ <eventHandler eventName="*">
+ <stateChange>
+ <if>
+ <not>
+ <condition>
+ <stateAttribute type="constant" value="and_three_operands" />
+ <stateValue type="long" value="1" />
+ </condition>
+ </not>
+ </if>
+ <then>
+ <stateAttribute type="constant" value="not_operand" />
+ <stateValue type="long" value="1" />
+ </then>
+ <else>
+ <stateAttribute type="constant" value="not_operand" />
+ <stateValue type="long" value="0" />
+ </else>
+ </stateChange>
+ </eventHandler>
</stateProvider>
</tmfxml>
\ No newline at end of file
Element rootNode = node;
/* Process the conditions: in each case, only process Element nodes */
List<@Nullable Element> childElements = XmlUtils.getChildElements(rootNode);
- final Element firstElement = NonNullUtils.checkNotNull(childElements.get(0));
/*
* If the node is an if, take the child as the root condition
if (childElements.isEmpty()) {
throw new IllegalArgumentException("TmfXmlCondition constructor: IF node with no child element"); //$NON-NLS-1$
}
- rootNode = firstElement;
+ rootNode = NonNullUtils.checkNotNull(childElements.get(0));
childElements = XmlUtils.getChildElements(rootNode);
}
fStateValues = new ArrayList<>();
fOperator = LogicalOperator.NOT;
fConditionOperator = ConditionOperator.NONE;
- Element element = firstElement;
+ Element element = NonNullUtils.checkNotNull(childElements.get(0));
fConditions.add(modelFactory.createCondition(element, fContainer));
break;
case TmfXmlStrings.AND: