Skip to content

Commit b17d620

Browse files
committed
test
1 parent 0e4ee63 commit b17d620

File tree

2 files changed

+78
-2
lines changed

2 files changed

+78
-2
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright The Cryostat Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package itest;
17+
18+
import java.io.File;
19+
import java.util.concurrent.CompletableFuture;
20+
import java.util.concurrent.TimeUnit;
21+
22+
import com.fasterxml.jackson.databind.JsonNode;
23+
import com.fasterxml.jackson.databind.ObjectMapper;
24+
import io.quarkus.test.junit.QuarkusIntegrationTest;
25+
import io.vertx.core.buffer.Buffer;
26+
import io.vertx.core.json.JsonArray;
27+
import io.vertx.ext.web.client.HttpRequest;
28+
import itest.bases.StandardSelfTest;
29+
import org.hamcrest.MatcherAssert;
30+
import org.hamcrest.Matchers;
31+
import org.junit.jupiter.api.Test;
32+
33+
@QuarkusIntegrationTest
34+
public class PresetRulesIT extends StandardSelfTest {
35+
36+
@Test
37+
public void shouldListPresetRules() throws Exception {
38+
CompletableFuture<JsonArray> future = new CompletableFuture<>();
39+
HttpRequest<Buffer> req = webClient.get("/api/v4/rules");
40+
req.send(
41+
ar -> {
42+
if (ar.failed()) {
43+
future.completeExceptionally(ar.cause());
44+
return;
45+
}
46+
future.complete(ar.result().bodyAsJsonArray());
47+
});
48+
JsonArray response = future.get(REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS);
49+
MatcherAssert.assertThat(response.size(), Matchers.equalTo(1));
50+
}
51+
52+
@Test
53+
public void shouldHavePresetQuarkusRule() throws Exception {
54+
String url = "/api/v4/rules/quarkus";
55+
File file =
56+
downloadFile(url, "quarkus", ".json")
57+
.get(REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS)
58+
.toFile();
59+
60+
ObjectMapper mapper = new ObjectMapper();
61+
JsonNode json = mapper.readTree(file);
62+
63+
MatcherAssert.assertThat(json.get("name").asText(), Matchers.equalTo("quarkus"));
64+
MatcherAssert.assertThat(
65+
json.get("description").asText(),
66+
Matchers.equalTo(
67+
"Preset Automated Rule for enabling Quarkus framework-specific events when"
68+
+ " available"));
69+
MatcherAssert.assertThat(
70+
json.get("eventSpecifier").asText(),
71+
Matchers.equalTo("template=Quarkus,type=PRESET"));
72+
MatcherAssert.assertThat(
73+
json.get("matchExpression").asText(),
74+
Matchers.equalTo("jfrEventTypeIds(target).exists(x, x.contains(\"quarkus\"))"));
75+
MatcherAssert.assertThat(json.get("enabled").asBoolean(), Matchers.is(false));
76+
}
77+
}

src/test/java/itest/PresetTemplatesIT.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ public void shouldListPresetTemplates() throws Exception {
5555

5656
@Test
5757
public void shouldHavePresetQuarkusTemplate() throws Exception {
58-
String url =
59-
String.format("/api/v4/event_templates/PRESET/Quarkus", getSelfReferenceTargetId());
58+
String url = "/api/v4/event_templates/PRESET/Quarkus";
6059
File file =
6160
downloadFile(url, "quarkus", ".jfc")
6261
.get(REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS)

0 commit comments

Comments
 (0)