Skip to content

Commit 14893fb

Browse files
authored
Merge pull request #1 from marko-bekhta/pr-42422
Update bulk ES tests
2 parents b8fd2b6 + 0e4c395 commit 14893fb

File tree

2 files changed

+33
-31
lines changed

2 files changed

+33
-31
lines changed

integration-tests/elasticsearch-java-client/src/test/java/io/quarkus/it/elasticsearch/FruitResourceTest.java

+23-22
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,27 @@ public void testEndpoint() {
4545
Fruit result = get("/fruits/1").as(Fruit.class);
4646
assertThat(result).isNotNull().isEqualTo(fruit);
4747

48+
// search the Fruit
49+
List<Fruit> results = get("/fruits/search?color=Green").as(LIST_OF_FRUIT_TYPE_REF);
50+
assertThat(results).hasSize(1).contains(fruit);
51+
52+
results = get("/fruits/search?name=Apple").as(LIST_OF_FRUIT_TYPE_REF);
53+
assertThat(results).hasSize(1).contains(fruit);
54+
55+
results = RestAssured.given().queryParam("json",
56+
"{\n" +
57+
"\"query\": {\n" +
58+
" \"prefix\": {\n" +
59+
" \"name\": {\n" +
60+
" \"value\": \"app\"\n" +
61+
" }\n" +
62+
" }\n" +
63+
"}\n" +
64+
"}\n")
65+
.get("/fruits/search/unsafe").as(LIST_OF_FRUIT_TYPE_REF);
66+
assertThat(results).hasSize(1).contains(fruit);
4867
});
4968

50-
// search the Fruit
51-
List<Fruit> results = get("/fruits/search?color=Green").as(LIST_OF_FRUIT_TYPE_REF);
52-
assertThat(results).hasSize(1).contains(fruit);
53-
54-
results = get("/fruits/search?name=Apple").as(LIST_OF_FRUIT_TYPE_REF);
55-
assertThat(results).hasSize(1).contains(fruit);
56-
57-
results = RestAssured.given().queryParam("json",
58-
"{\n" +
59-
"\"query\": {\n" +
60-
" \"prefix\": {\n" +
61-
" \"name\": {\n" +
62-
" \"value\": \"app\"\n" +
63-
" }\n" +
64-
" }\n" +
65-
"}\n" +
66-
"}\n")
67-
.get("/fruits/search/unsafe").as(LIST_OF_FRUIT_TYPE_REF);
68-
assertThat(results).hasSize(1).contains(fruit);
69-
7069
//create new fruit index via bulk operation
7170
Fruit pomegranate = new Fruit();
7271
pomegranate.id = "2";
@@ -96,8 +95,10 @@ public void testEndpoint() {
9695
.statusCode(200);
9796

9897
await().atMost(2, TimeUnit.SECONDS).pollDelay(500, TimeUnit.MILLISECONDS).untilAsserted(() -> {
99-
Fruit result = get("/fruits/2").as(Fruit.class);
100-
assertThat(result).isNull();
98+
// search the removed Fruit should yield no results
99+
// using a simple get-doc-by-id won't work since we will get an 500 error response:
100+
List<Fruit> results = get("/fruits/search?color=Red").as(LIST_OF_FRUIT_TYPE_REF);
101+
assertThat(results).isEmpty();
101102
});
102103

103104
}

integration-tests/elasticsearch-rest-client/src/test/java/io/quarkus/it/elasticsearch/FruitResourceTest.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,13 @@ public void testEndpoint() {
4343

4444
assertThat(result).isNotNull().isEqualTo(fruit);
4545

46-
});
47-
48-
// search the Fruit
49-
List<Fruit> results = get("/fruits/search?color=Green").as(LIST_OF_FRUIT_TYPE_REF);
50-
assertThat(results).hasSize(1).contains(fruit);
46+
// search the Fruit
47+
List<Fruit> results = get("/fruits/search?color=Green").as(LIST_OF_FRUIT_TYPE_REF);
48+
assertThat(results).hasSize(1).contains(fruit);
5149

52-
results = get("/fruits/search?name=Apple").as(LIST_OF_FRUIT_TYPE_REF);
53-
assertThat(results).hasSize(1).contains(fruit);
50+
results = get("/fruits/search?name=Apple").as(LIST_OF_FRUIT_TYPE_REF);
51+
assertThat(results).hasSize(1).contains(fruit);
52+
});
5453

5554
//create new fruit index via bulk operation
5655
Fruit pomegranate = new Fruit();
@@ -80,8 +79,10 @@ public void testEndpoint() {
8079
.statusCode(200);
8180

8281
await().atMost(2, TimeUnit.SECONDS).pollDelay(500, TimeUnit.MILLISECONDS).untilAsserted(() -> {
83-
Fruit result = get("/fruits/2").as(Fruit.class);
84-
assertThat(result).isNull();
82+
// search the removed Fruit should yield no results
83+
// using a simple get-doc-by-id won't work since we will get an 500 error response:
84+
List<Fruit> results = get("/fruits/search?color=Red").as(LIST_OF_FRUIT_TYPE_REF);
85+
assertThat(results).isEmpty();
8586
});
8687

8788
}

0 commit comments

Comments
 (0)