在测试中使用vertx调用实际的API

时间:2018-07-19 05:54:18

标签: java vert.x

我想检查调用返回的数据,它应该是名称为“ data”的数组

"success": true,
  "serverName": "mma.tour.com",
  "data": [
    [
      "01.08.2018",
      [
        "01.08"
      ],
      "Ср",
      8,
      "09.08",
      [....... etc

我的api调用是这样的

  public static JsonObject clientTest() {
        Vertx vertx = Vertx.vertx();

        WebClient client = WebClient.create(vertx);

        client
            .get("https://www.mma-tour.com/tariffsearch/getResult?" +
                "priceMin=0&priceMax=1500000&currency=533067&nightsMin=6&nightsMax=8" +
                "&hotelClassId=269506&accommodationId=2&rAndBId=15350&tourType=1&" +
                "locale=ru&cityId=786&countryId=1104&after=01.08.2018&before=01.08.2018&" +
                "hotelInStop=false&specialInStop=false&version=2&tourId=1285&" +
                "tourId=12689&tourId=12706&tourId=143330&tourId=9004247&" +
                "tourId=4433&tourId=5736&tourId=139343&tourId=4434&tourId=12691&" +
                "tourId=21301&tourId=12705&tourId=149827&tourId=4151426&hotelClassBetter=true&" +
                "rAndBBetter=true&noTicketsTo=false&noTicketsFrom=false&searchTypeId=3&" +
                "recommendedFlag=false&salePrivateFlag=false&onlineConfirmFlag=false&contentCountryId=1102")
            .send(ar -> {
                if (ar.succeeded()) {
                    // Obtain response
                    HttpResponse<Buffer> response = ar.result();
                    Tour tour = new Tour.TourBuilder().build();
                    JsonObject myTourJson = response.bodyAsJsonObject();
                    myTourJson.getJsonArray("data"); //here

                } else {
                }
            });
        return null;
    }

以上,我尝试获取数据并编写测试以检查是否返回了某些数据,但是在调试过程中失败,甚至没有获取“数据”

0 个答案:

没有答案