Пример #1
0
  @Test
  public void testGoalIDByteAndStringConstructor() {
    assertEquals(new GoalID(new Time(10, 20), "test"), g1.getGoalID());
    assertEquals((byte) 30, g1.getStatus());
    assertEquals("test2", g1.getText());

    assertEquals(
        "{\"goal_id\":{\"stamp\":{\"secs\":10,\"nsecs\":20},\"id\":\"test\"},"
            + "\"status\":30,\"text\":\"test2\"}",
        g1.toString());

    assertEquals(3, g1.toJsonObject().size());
    assertEquals(
        new GoalID(new Time(10, 20), "test"),
        GoalID.fromJsonObject(g1.toJsonObject().getJsonObject(GoalStatus.FIELD_GOAL_ID)));
    assertEquals(
        (byte) 30, Primitive.toUInt8((short) g1.toJsonObject().getInt(GoalStatus.FIELD_STATUS)));
    assertEquals("test2", g1.toJsonObject().getString(GoalStatus.FIELD_TEXT));

    assertEquals(GoalStatus.TYPE, g1.getMessageType());
  }
Пример #2
0
  @Test
  public void testConstructor() {
    assertEquals(new GoalID(), empty.getGoalID());
    assertEquals((byte) 0, empty.getStatus());
    assertEquals("", empty.getText());

    assertEquals(
        "{\"goal_id\":{\"stamp\":{\"secs\":0,\"nsecs\":0},\"id\":\"\"},"
            + "\"status\":0,\"text\":\"\"}",
        empty.toString());

    assertEquals(3, empty.toJsonObject().size());
    assertEquals(
        new GoalID(),
        GoalID.fromJsonObject(empty.toJsonObject().getJsonObject(GoalStatus.FIELD_GOAL_ID)));
    assertEquals(
        (byte) 0, Primitive.toUInt8((short) empty.toJsonObject().getInt(GoalStatus.FIELD_STATUS)));
    assertEquals("", empty.toJsonObject().getString(GoalStatus.FIELD_TEXT));

    assertEquals(GoalStatus.TYPE, empty.getMessageType());
  }
Пример #3
0
  @Test
  public void testGoalIDByteAndStringConstructorNegative() {
    GoalStatus g = new GoalStatus(new GoalID(), (byte) -1, "");

    assertEquals(new GoalID(), g.getGoalID());
    assertEquals((byte) -1, g.getStatus());
    assertEquals("", g.getText());

    assertEquals(
        "{\"goal_id\":{\"stamp\":{\"secs\":0,\"nsecs\":0},\"id\":\"\"},"
            + "\"status\":255,\"text\":\"\"}",
        g.toString());

    assertEquals(3, g.toJsonObject().size());
    assertEquals(
        new GoalID(),
        GoalID.fromJsonObject(g.toJsonObject().getJsonObject(GoalStatus.FIELD_GOAL_ID)));
    assertEquals(
        (byte) -1, Primitive.toUInt8((short) g.toJsonObject().getInt(GoalStatus.FIELD_STATUS)));
    assertEquals("", g.toJsonObject().getString(GoalStatus.FIELD_TEXT));

    assertEquals(GoalStatus.TYPE, g.getMessageType());
  }