public List<String> getFields() {
    List<String> fields = new LinkedList<>();

    JsonArray jsonFields = this.body.getJsonArray(FIELD_FIELDS);
    for (int i = 0; i < jsonFields.size(); i++) {
      fields.add(jsonFields.getString(i));
    }

    return fields;
  }
Пример #2
0
  @Test
  public void testWithJsonArray() {
    AtomicReference<JsonArray> result = new AtomicReference<>();
    Service service = Service.createProxy(consumerNode.get(), "my.service");
    TestDataObject data = new TestDataObject().setBool(true).setNumber(25).setString("vert.x");
    JsonArray array = new JsonArray();
    array.add("vert.x").add(data.toJson());

    service.methodWithJsonArray(
        array,
        ar -> {
          result.set(ar.result());
        });

    Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() -> result.get() != null);
    TestDataObject out = new TestDataObject(result.get().getJsonObject(1));
    assertThat(array.getString(0)).isEqualToIgnoringCase("vert.x");
    assertThat(out.getNumber()).isEqualTo(25);
    assertThat(out.isBool()).isTrue();
    assertThat(out.getString()).isEqualTo("vert.x");
  }