package io.quarkus.it.rest.client;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.equalTo;

import org.junit.jupiter.api.Test;

import io.quarkus.test.common.http.TestHTTPResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;

@QuarkusTest
public class BasicTest {

    @TestHTTPResource("/apples")
    String appleUrl;

    @Test
    public void shouldWork() {
        RestAssured.with().body(appleUrl).post("/call-client")
                .then()
                .statusCode(200)
                .contentType("application/json")
                .body("size()", is(9))
                .body("[0].cultivar", equalTo("cortland"))
                .body("[1].cultivar", equalTo("cortland2"))
                .body("[2].cultivar", equalTo("cortland3"))
                .body("[3].cultivar", equalTo("cortland"))
                .body("[4].cultivar", equalTo("cortland2"))
                .body("[5].cultivar", equalTo("cortland3"))
                .body("[6].cultivar", equalTo("cortland"))
                .body("[7].cultivar", equalTo("cortland2"))
                .body("[8].cultivar", equalTo("cortland3"));
    }
}

@@ -47,81 +47,237 @@
 tic 
-org.hamcrest.CoreMatchers.is;%0Aimport static org.hamcrest.Matchers.equalTo
+java.util.stream.Collectors.counting;%0Aimport static org.assertj.core.api.Assertions.assertThat;%0Aimport static org.assertj.core.api.Assertions.entry;%0A%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.stream.Collectors
 ;%0A%0Ai
@@ -536,16 +536,67 @@
 leUrl;%0A%0A
+    @SuppressWarnings(%7B %22rawtypes%22, %22unchecked%22 %7D)%0A
     @Tes
@@ -635,16 +635,36 @@
 %0A       
+ List%3CMap%3E results =
  RestAss
@@ -838,208 +838,173 @@
    .
-body(%22size()%22, is(9))%0A                .body(%22%5B0%5D.cultivar%22, equalTo(%22cortland%22))%0A                .body(%22%5B1%5D.cultivar%22, equalTo(%22cortland2%22))%0A                .body(%22%5B2%5D.cultivar%22, equalTo(%22cortland3%22))
+extract().body().jsonPath().getList(%22.%22, Map.class);%0A        assertThat(results).hasSize(9).allSatisfy(m -%3E %7B%0A            assertThat(m).containsOnlyKeys(%22cultivar%22);
 %0A   
@@ -1004,32 +1004,36 @@
 %22);%0A        
+%7D);%0A
         
 .body(%22%5B3%5D.c
@@ -1024,138 +1024,100 @@
     
-.body(%22%5B3%5D.cultivar%22, equalTo(%22cortland%22))%0A                .body(%22%5B4%5D.cultivar%22, equalTo(%22cortland2%22))%0A                .body(%22%5B5%5D.
+Map%3CObject, Long%3E valueByCount = results.stream().collect(Collectors.groupingBy(m -%3E m.get(%22
 cult
@@ -1125,196 +1125,123 @@
 var%22
+)
 , 
-equalTo(%22cortland3%22))%0A                .body(%22%5B6%5D.cultivar%22, equalTo(%22cortland%22))%0A                .body(%22%5B7%5D.cultivar%22, equalTo(%22cortland2%22))%0A                .body(%22%5B8%5D.cultivar%22, equalTo
+counting()));%0A        assertThat(valueByCount).containsOnly(entry(%22cortland%22, 3L), entry(%22cortland2%22, 3L), entry
 (%22co
@@ -1248,16 +1248,20 @@
 rtland3%22
+, 3L
 ));%0A    

Fix flaky rest-client test