Skip to content

Commit

Permalink
test(smart_triggers): add test case for single-quoted duration
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Nov 29, 2023
1 parent 76e54ea commit 0be7f7e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/test/java/io/cryostat/agent/triggers/TriggerParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,30 @@ void testSingleComplexTrigger() {
MatcherAssert.assertThat(trigger.getTimeConditionFirstMet(), Matchers.nullValue());
}

@Test
void testSingleComplexTriggerSingleQuoted() {
Mockito.when(helper.isValidTemplate(Mockito.anyString())).thenReturn(true);
String[] in = new String[] {"[ProcessCpuLoad>0.2;TargetDuration>duration('30s')]~profile"};
List<SmartTrigger> out = parser.parse(in);

MatcherAssert.assertThat(out, Matchers.hasSize(1));
SmartTrigger trigger = out.get(0);

MatcherAssert.assertThat(
trigger.getExpression(),
Matchers.equalTo("ProcessCpuLoad>0.2;TargetDuration>duration('30s')"));
MatcherAssert.assertThat(trigger.getRecordingTemplateName(), Matchers.equalTo("profile"));
MatcherAssert.assertThat(
trigger.getDurationConstraint(),
Matchers.equalTo("TargetDuration>duration(\"30s\")"));
MatcherAssert.assertThat(
trigger.getTriggerCondition(), Matchers.equalTo("ProcessCpuLoad>0.2"));
MatcherAssert.assertThat(trigger.getState(), Matchers.equalTo(TriggerState.NEW));
MatcherAssert.assertThat(
trigger.getTargetDuration(), Matchers.equalTo(Duration.ofSeconds(30)));
MatcherAssert.assertThat(trigger.getTimeConditionFirstMet(), Matchers.nullValue());
}

@Test
void testSingleComplexTriggerWithWhitespace() {
Mockito.when(helper.isValidTemplate(Mockito.anyString())).thenReturn(true);
Expand Down

0 comments on commit 0be7f7e

Please sign in to comment.