Skip to content

Commit

Permalink
Last unit tests for EventCondition
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasponce authored and jshaughn committed Sep 28, 2015
1 parent 83e57db commit 06cf81d
Showing 1 changed file with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,73 @@ public void testCtimeExpression() {
assertFalse(condition.match(event3));
}

@Test
public void testContextExpression() {
EventCondition condition = new EventCondition("trigger-1", "context.server == 'MyServer'");

Event event1 = new Event();
event1.addContext("server", "MyServer");

assertTrue(condition.match(event1));

condition.setExpression("context.server != 'MyServer'");

assertFalse(condition.match(event1));

condition.setExpression("context.quantity >= 11");

event1.addContext("quantity", "11");

assertTrue(condition.match(event1));

event1.addContext("quantity", "12");

assertTrue(condition.match(event1));

event1.addContext("quantity", "10");

assertFalse(condition.match(event1));

condition.setExpression("context.log.category starts 'WARN'");

event1.addContext("log.category", "WARNING");

assertTrue(condition.match(event1));
}

@Test
public void testTagExpression() {
EventCondition condition = new EventCondition("trigger-1", "tags.server == 'MyServer'");

Event event1 = new Event();
event1.addTag("server", "MyServer");

assertTrue(condition.match(event1));

condition.setExpression("tags.server != 'MyServer'");

assertFalse(condition.match(event1));

condition.setExpression("tags.quantity >= 11");

event1.addTag("quantity", "11");

assertTrue(condition.match(event1));

event1.addTag("quantity", "12");

assertTrue(condition.match(event1));

event1.addTag("quantity", "10");

assertFalse(condition.match(event1));

condition.setExpression("tags.log.category starts 'WARN'");

event1.addTag("log.category", "WARNING");

assertTrue(condition.match(event1));
}


}

0 comments on commit 06cf81d

Please sign in to comment.