@Test public void testAppendEmptyArrayParameter() { writer.appendSet(shellId, "key", new JsonArray()); SetOperation operation = (SetOperation) getMessage().getOperation(0); assertEquals(0, operation.getProperty("key").asArray().size()); }
@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()); }
@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()); }
@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")); }