コード例 #1
0
  @Test
  public void testAppendEmptyArrayParameter() {
    writer.appendSet(shellId, "key", new JsonArray());

    SetOperation operation = (SetOperation) getMessage().getOperation(0);
    assertEquals(0, operation.getProperty("key").asArray().size());
  }
コード例 #2
0
  @Test
  public void testAppendArrayParameter() {
    writer.appendSet(shellId, "key", new JsonArray().add(1).add(2));

    SetOperation operation = (SetOperation) getMessage().getOperation(0);
    JsonArray property = operation.getProperty("key").asArray();
    assertEquals(1, property.get(0).asInt());
    assertEquals(2, property.get(1).asInt());
  }
コード例 #3
0
  @Test
  public void testAppendsToExistingSetOperation() {
    writer.appendSet(shellId, "key1", "value1");
    writer.appendSet(shellId, "key2", "value2");

    Message message = getMessage();
    SetOperation operation = (SetOperation) message.getOperation(0);
    assertEquals("value1", operation.getProperty("key1").asString());
    assertEquals("value2", operation.getProperty("key2").asString());
  }
コード例 #4
0
  @Test
  public void testDoesNotAppendToOtherWidgetsOperation() {
    Button button = new Button(shell, SWT.PUSH);
    String buttonId = WidgetUtil.getId(button);

    writer.appendSet(shellId, "key1", "value1");
    writer.appendSet(buttonId, "key2", "value2");

    Message message = getMessage();
    SetOperation firstOperation = (SetOperation) message.getOperation(0);
    assertEquals("value1", firstOperation.getProperty("key1").asString());
    assertFalse(firstOperation.getPropertyNames().contains("key2"));
  }