1616package itest ;
1717
1818import java .io .File ;
19+ import java .util .Arrays ;
20+ import java .util .List ;
1921import java .util .concurrent .CompletableFuture ;
2022import java .util .concurrent .TimeUnit ;
2123
2931import org .hamcrest .MatcherAssert ;
3032import org .hamcrest .Matchers ;
3133import org .junit .jupiter .api .Test ;
34+ import org .junit .jupiter .params .ParameterizedTest ;
35+ import org .junit .jupiter .params .provider .MethodSource ;
3236
3337@ QuarkusIntegrationTest
3438public class PresetRulesIT extends StandardSelfTest {
3539
40+ static final String [] RULE_NAMES = new String [] {"quarkus" , "hibernate" };
41+
3642 @ Test
3743 public void shouldListPresetRules () throws Exception {
3844 CompletableFuture <JsonArray > future = new CompletableFuture <>();
@@ -46,32 +52,26 @@ public void shouldListPresetRules() throws Exception {
4652 future .complete (ar .result ().bodyAsJsonArray ());
4753 });
4854 JsonArray response = future .get (REQUEST_TIMEOUT_SECONDS , TimeUnit .SECONDS );
49- MatcherAssert .assertThat (response .size (), Matchers .equalTo (1 ));
55+ MatcherAssert .assertThat (response .size (), Matchers .equalTo (RULE_NAMES . length ));
5056 }
5157
52- @ Test
53- public void shouldHavePresetQuarkusRule () throws Exception {
54- String url = "/api/v4/rules/quarkus" ;
58+ static List <String > ruleNames () {
59+ return Arrays .asList (RULE_NAMES );
60+ }
61+
62+ @ ParameterizedTest
63+ @ MethodSource ("ruleNames" )
64+ public void shouldHavePresetRules (String ruleName ) throws Exception {
65+ String url = String .format ("/api/v4/rules/%s" , ruleName );
5566 File file =
56- downloadFile (url , "quarkus" , ".json" )
67+ downloadFile (url , ruleName , ".json" )
5768 .get (REQUEST_TIMEOUT_SECONDS , TimeUnit .SECONDS )
5869 .toFile ();
5970
6071 ObjectMapper mapper = new ObjectMapper ();
6172 JsonNode json = mapper .readTree (file );
6273
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.startsWith(\" quarkus\" ))" ));
74+ MatcherAssert .assertThat (json .get ("name" ).asText (), Matchers .equalTo (ruleName ));
7575 MatcherAssert .assertThat (json .get ("enabled" ).asBoolean (), Matchers .is (false ));
7676 }
7777}
0 commit comments