Search in sources :

Example 6 with ValueChangedCommand

use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.

the class TestOptimizedJsonCodec method shouldDecodeValueChangedCommandWithUuid.

@Test
public void shouldDecodeValueChangedCommandWithUuid() {
    final List<Command> commands = OptimizedJsonCodec.getInstance().decode("[{\"a_id\":\"3357S\",\"v\":\"{4b9e93fd-3738-4fe6-b2a4-1fea8d2e0dc4}\",\"id\":\"ValueChanged\"}]");
    final ValueChangedCommand command = (ValueChangedCommand) commands.get(0);
    assertThat(command.getAttributeId(), is("3357S"));
    assertThat(command.getNewValue().toString(), is("{4b9e93fd-3738-4fe6-b2a4-1fea8d2e0dc4}"));
}
Also used : ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) CallActionCommand(com.canoo.dp.impl.remoting.commands.CallActionCommand) Command(com.canoo.dp.impl.remoting.legacy.communication.Command) CreatePresentationModelCommand(com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand) EmptyCommand(com.canoo.dp.impl.remoting.legacy.communication.EmptyCommand) ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) Test(org.testng.annotations.Test)

Example 7 with ValueChangedCommand

use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.

the class TestOptimizedJsonCodec method shouldEncodeValueChangedCommandWithNulls.

@Test
public void shouldEncodeValueChangedCommandWithNulls() {
    final ValueChangedCommand command = new ValueChangedCommand();
    command.setNewValue(null);
    command.setAttributeId("3357S");
    final String actual = OptimizedJsonCodec.getInstance().encode(Collections.<Command>singletonList(command));
    assertThat(actual, is("[{\"a_id\":\"3357S\",\"id\":\"ValueChanged\"}]"));
}
Also used : ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) Test(org.testng.annotations.Test)

Example 8 with ValueChangedCommand

use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.

the class TestOptimizedJsonCodec method shouldDecodeValueChangedCommandWithIntegers.

@Test
public void shouldDecodeValueChangedCommandWithIntegers() {
    final List<Command> commands = OptimizedJsonCodec.getInstance().decode("[{\"a_id\":\"3357S\",\"v\":42,\"id\":\"ValueChanged\"}]");
    final ValueChangedCommand command = (ValueChangedCommand) commands.get(0);
    assertThat(command.getAttributeId(), is("3357S"));
    assertThat(((Number) command.getNewValue()).intValue(), is(42));
}
Also used : ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) CallActionCommand(com.canoo.dp.impl.remoting.commands.CallActionCommand) Command(com.canoo.dp.impl.remoting.legacy.communication.Command) CreatePresentationModelCommand(com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand) EmptyCommand(com.canoo.dp.impl.remoting.legacy.communication.EmptyCommand) ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) Test(org.testng.annotations.Test)

Example 9 with ValueChangedCommand

use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.

the class TestOptimizedJsonCodec method shouldEncodeValueChangedCommandWithLong.

@Test
public void shouldEncodeValueChangedCommandWithLong() {
    final ValueChangedCommand command = new ValueChangedCommand();
    command.setNewValue(987654321234567890L);
    command.setAttributeId("3357S");
    final String actual = OptimizedJsonCodec.getInstance().encode(Collections.<Command>singletonList(command));
    assertThat(actual, is("[{\"a_id\":\"3357S\",\"v\":987654321234567890,\"id\":\"ValueChanged\"}]"));
}
Also used : ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) Test(org.testng.annotations.Test)

Example 10 with ValueChangedCommand

use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.

the class TestOptimizedJsonCodec method shouldDecodeValueChangedCommandWithBigInteger.

@Test
public void shouldDecodeValueChangedCommandWithBigInteger() {
    final List<Command> commands = OptimizedJsonCodec.getInstance().decode("[{\"a_id\":\"3357S\",\"v\":987654321234567890,\"id\":\"ValueChanged\"}]");
    final ValueChangedCommand command = (ValueChangedCommand) commands.get(0);
    assertThat(command.getAttributeId(), is("3357S"));
    assertThat(((Number) command.getNewValue()).longValue(), is(987654321234567890L));
}
Also used : ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) CallActionCommand(com.canoo.dp.impl.remoting.commands.CallActionCommand) Command(com.canoo.dp.impl.remoting.legacy.communication.Command) CreatePresentationModelCommand(com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand) EmptyCommand(com.canoo.dp.impl.remoting.legacy.communication.EmptyCommand) ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) Test(org.testng.annotations.Test)

Aggregations

ValueChangedCommand (com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand)25 Test (org.testng.annotations.Test)22 CreatePresentationModelCommand (com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand)13 Command (com.canoo.dp.impl.remoting.legacy.communication.Command)12 EmptyCommand (com.canoo.dp.impl.remoting.legacy.communication.EmptyCommand)11 CallActionCommand (com.canoo.dp.impl.remoting.commands.CallActionCommand)9 ClientAttribute (com.canoo.dp.impl.client.legacy.ClientAttribute)4 ChangeAttributeMetadataCommand (com.canoo.dp.impl.remoting.legacy.communication.ChangeAttributeMetadataCommand)3 PresentationModelDeletedCommand (com.canoo.dp.impl.remoting.legacy.communication.PresentationModelDeletedCommand)3 CommandAndHandler (com.canoo.dp.impl.client.legacy.communication.CommandAndHandler)2 InterruptLongPollCommand (com.canoo.dp.impl.remoting.legacy.commands.InterruptLongPollCommand)2 StartLongPollCommand (com.canoo.dp.impl.remoting.legacy.commands.StartLongPollCommand)2 AttributeMetadataChangedCommand (com.canoo.dp.impl.remoting.legacy.communication.AttributeMetadataChangedCommand)2 DeletePresentationModelCommand (com.canoo.dp.impl.remoting.legacy.communication.DeletePresentationModelCommand)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 ArrayList (java.util.ArrayList)2 JsonParseException (com.google.gson.JsonParseException)1 CountDownLatch (java.util.concurrent.CountDownLatch)1