Search in sources :

Example 6 with OperatorContext

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

the class EqualsTest method testScalarWithImplicitConversion.

@Test
public void testScalarWithImplicitConversion() 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(42L));
    when(context.resolve(op0, eventNode)).thenReturn(42);
    when(context.resolve(op1, eventNode)).thenReturn(42L);
    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 7 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 8 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)

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