Search in sources :

Example 1 with OperatorContext

use of org.eclipse.milo.opcua.sdk.server.events.OperatorContext in project milo by eclipse.

the class EqualsTest method testScalar.

@Test
public void testScalar() throws Exception {
    OperatorContext context = mock(OperatorContext.class);
    BaseEventTypeNode eventNode = mock(BaseEventTypeNode.class);
    FilterOperand op0 = new LiteralOperand(new Variant(42));
    FilterOperand op1 = new LiteralOperand(new Variant(42));
    when(context.resolve(op0, eventNode)).thenReturn(42);
    when(context.resolve(op1, eventNode)).thenReturn(42);
    Boolean result = Operators.EQUALS.apply(context, eventNode, new FilterOperand[] { op0, op1 });
    assertNotNull(result);
    assertTrue(result);
}
Also used : Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) BaseEventTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.objects.BaseEventTypeNode) LiteralOperand(org.eclipse.milo.opcua.stack.core.types.structured.LiteralOperand) OperatorContext(org.eclipse.milo.opcua.sdk.server.events.OperatorContext) FilterOperand(org.eclipse.milo.opcua.stack.core.types.structured.FilterOperand) Test(org.testng.annotations.Test)

Example 2 with OperatorContext

use of org.eclipse.milo.opcua.sdk.server.events.OperatorContext in project milo by eclipse.

the class IsNullTest method testNonNullValue.

@Test
public void testNonNullValue() throws Exception {
    OperatorContext context = mock(OperatorContext.class);
    BaseEventTypeNode eventNode = mock(BaseEventTypeNode.class);
    FilterOperand op0 = new LiteralOperand(new Variant(42));
    when(context.resolve(op0, eventNode)).thenReturn(42);
    Boolean result = Operators.IS_NULL.apply(context, eventNode, new FilterOperand[] { op0 });
    assertNotNull(result);
    assertFalse(result);
}
Also used : Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) BaseEventTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.objects.BaseEventTypeNode) LiteralOperand(org.eclipse.milo.opcua.stack.core.types.structured.LiteralOperand) OperatorContext(org.eclipse.milo.opcua.sdk.server.events.OperatorContext) FilterOperand(org.eclipse.milo.opcua.stack.core.types.structured.FilterOperand) Test(org.testng.annotations.Test)

Example 3 with OperatorContext

use of org.eclipse.milo.opcua.sdk.server.events.OperatorContext in project milo by eclipse.

the class IsNullTest method testNullValue.

@Test
public void testNullValue() throws Exception {
    OperatorContext context = mock(OperatorContext.class);
    BaseEventTypeNode eventNode = mock(BaseEventTypeNode.class);
    FilterOperand op0 = new LiteralOperand(new Variant(null));
    when(context.resolve(op0, eventNode)).thenReturn(null);
    Boolean result = Operators.IS_NULL.apply(context, eventNode, new FilterOperand[] { op0 });
    assertNotNull(result);
    assertTrue(result);
}
Also used : Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) BaseEventTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.objects.BaseEventTypeNode) LiteralOperand(org.eclipse.milo.opcua.stack.core.types.structured.LiteralOperand) OperatorContext(org.eclipse.milo.opcua.sdk.server.events.OperatorContext) FilterOperand(org.eclipse.milo.opcua.stack.core.types.structured.FilterOperand) Test(org.testng.annotations.Test)

Example 4 with OperatorContext

use of org.eclipse.milo.opcua.sdk.server.events.OperatorContext in project milo by eclipse.

the class EqualsTest method testScalarNotEqual.

@Test
public void testScalarNotEqual() throws Exception {
    OperatorContext context = mock(OperatorContext.class);
    BaseEventTypeNode eventNode = mock(BaseEventTypeNode.class);
    FilterOperand op0 = new LiteralOperand(new Variant(1));
    FilterOperand op1 = new LiteralOperand(new Variant(2));
    when(context.resolve(op0, eventNode)).thenReturn(1);
    when(context.resolve(op1, eventNode)).thenReturn(2);
    Boolean result = Operators.EQUALS.apply(context, eventNode, new FilterOperand[] { op0, op1 });
    assertNotNull(result);
    assertFalse(result);
}
Also used : Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) BaseEventTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.objects.BaseEventTypeNode) LiteralOperand(org.eclipse.milo.opcua.stack.core.types.structured.LiteralOperand) OperatorContext(org.eclipse.milo.opcua.sdk.server.events.OperatorContext) FilterOperand(org.eclipse.milo.opcua.stack.core.types.structured.FilterOperand) Test(org.testng.annotations.Test)

Example 5 with OperatorContext

use of org.eclipse.milo.opcua.sdk.server.events.OperatorContext in project milo by eclipse.

the class EqualsTest method testArray.

@Test
public void testArray() throws Exception {
    OperatorContext context = mock(OperatorContext.class);
    BaseEventTypeNode eventNode = mock(BaseEventTypeNode.class);
    FilterOperand op0 = new LiteralOperand(new Variant(new int[] { 1, 2, 3 }));
    FilterOperand op1 = new LiteralOperand(new Variant(new int[] { 1, 2, 3 }));
    when(context.resolve(op0, eventNode)).thenReturn(new int[] { 1, 2, 3 });
    when(context.resolve(op1, eventNode)).thenReturn(new int[] { 1, 2, 3 });
    Boolean result = Operators.EQUALS.apply(context, eventNode, new FilterOperand[] { op0, op1 });
    assertNotNull(result);
    assertTrue(result);
}
Also used : Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) BaseEventTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.objects.BaseEventTypeNode) LiteralOperand(org.eclipse.milo.opcua.stack.core.types.structured.LiteralOperand) OperatorContext(org.eclipse.milo.opcua.sdk.server.events.OperatorContext) FilterOperand(org.eclipse.milo.opcua.stack.core.types.structured.FilterOperand) Test(org.testng.annotations.Test)

Aggregations

OperatorContext (org.eclipse.milo.opcua.sdk.server.events.OperatorContext)8 BaseEventTypeNode (org.eclipse.milo.opcua.sdk.server.model.nodes.objects.BaseEventTypeNode)8 Variant (org.eclipse.milo.opcua.stack.core.types.builtin.Variant)8 FilterOperand (org.eclipse.milo.opcua.stack.core.types.structured.FilterOperand)8 LiteralOperand (org.eclipse.milo.opcua.stack.core.types.structured.LiteralOperand)8 Test (org.testng.annotations.Test)8