String topicName = "TestRulesMayHaveAnActionAndFilter";
service.createTopic(new TopicInfo(topicName));
service.createSubscription(topicName, new SubscriptionInfo("sub"));
// Act
RuleInfo ruleOne = service.createRule(topicName, "sub",
new RuleInfo("One").withCorrelationIdFilter("my-id"))
.getValue();
RuleInfo ruleTwo = service.createRule(topicName, "sub",
new RuleInfo("Two").withTrueFilter()).getValue();
RuleInfo ruleThree = service.createRule(topicName, "sub",
new RuleInfo("Three").withFalseFilter()).getValue();
RuleInfo ruleFour = service.createRule(topicName, "sub",
new RuleInfo("Four").withEmptyRuleAction()).getValue();
RuleInfo ruleFive = service.createRule(topicName, "sub",
new RuleInfo("Five").withSqlRuleAction("SET x = 5")).getValue();
RuleInfo ruleSix = service.createRule(topicName, "sub",
new RuleInfo("Six").withSqlExpressionFilter("x != 5"))
.getValue();
// Assert
assertEquals(CorrelationFilter.class, ruleOne.getFilter().getClass());
assertEquals(TrueFilter.class, ruleTwo.getFilter().getClass());
assertEquals(FalseFilter.class, ruleThree.getFilter().getClass());
assertEquals(EmptyRuleAction.class, ruleFour.getAction().getClass());
assertEquals(SqlRuleAction.class, ruleFive.getAction().getClass());
assertEquals(SqlFilter.class, ruleSix.getFilter().getClass());
}