Example #1
0
  @Test(dataProvider = "devices")
  public void invokeActions(LocalDevice device) {
    // We mostly care about the binding without exceptions, but let's also test invocation
    LocalService svc = device.getServices()[0];

    ActionInvocation setTargetInvocation = new ActionInvocation(svc.getAction("SetTarget"));
    setTargetInvocation.setInput("NewTargetValue", true);
    svc.getExecutor(setTargetInvocation.getAction()).execute(setTargetInvocation);
    assertEquals(setTargetInvocation.getFailure(), null);
    assertEquals(setTargetInvocation.getOutput().length, 0);

    ActionInvocation getStatusInvocation = new ActionInvocation(svc.getAction("GetStatus"));
    svc.getExecutor(getStatusInvocation.getAction()).execute(getStatusInvocation);
    assertEquals(getStatusInvocation.getFailure(), null);
    assertEquals(getStatusInvocation.getOutput().length, 1);
    assertEquals(getStatusInvocation.getOutput()[0].toString(), "1");

    setTargetInvocation = new ActionInvocation(svc.getAction("SetTarget"));
    setTargetInvocation.setInput("NewTargetValue", false);
    svc.getExecutor(setTargetInvocation.getAction()).execute(setTargetInvocation);
    assertEquals(setTargetInvocation.getFailure(), null);
    assertEquals(setTargetInvocation.getOutput().length, 0);

    ActionInvocation queryStateVariableInvocation =
        new ActionInvocation(svc.getAction("QueryStateVariable"));
    queryStateVariableInvocation.setInput("varName", "Status");
    svc.getExecutor(queryStateVariableInvocation.getAction()).execute(queryStateVariableInvocation);
    assertEquals(queryStateVariableInvocation.getFailure(), null);
    assertEquals(queryStateVariableInvocation.getOutput().length, 1);
    assertEquals(queryStateVariableInvocation.getOutput()[0].toString(), "0");
  }