Esempio n. 1
0
  @Test
  public void createNotificationWhenContainsAmazon() {
    String rule = "Create notification when discussion entry contains amazon";
    ksession.insert(new DiscussionEntryEvent("product", "wrong", "user"));
    ksession.fireAllRules();
    assertFalse(firedRules.isRuleFired(rule));

    ksession.insert(new DiscussionEntryEvent("product", "Amazon is better!", "user"));
    ksession.fireAllRules();
    assertEquals(1, firedRules.howManyTimesIsRuleFired(rule));
    assertEquals(1, notificationsGeneral.getCreatedNotifications());

    ksession.insert(new DiscussionEntryEvent("product", "kjdashkjaamazonajshd", "user"));
    ksession.fireAllRules();
    assertEquals(2, firedRules.howManyTimesIsRuleFired(rule));
    assertEquals(2, notificationsGeneral.getCreatedNotifications());
  }
Esempio n. 2
0
  @Test
  public void createNotificationWhenContainsHelp() {
    String rule = "Create notification when discussion entry contains help";
    ksession.insert(new DiscussionEntryEvent("product", "wrong", "user"));
    ksession.fireAllRules();
    assertFalse(firedRules.isRuleFired(rule));

    ksession.insert(new DiscussionEntryEvent("product", "I really need HELP!", "user"));
    ksession.fireAllRules();
    assertEquals(1, firedRules.howManyTimesIsRuleFired(rule));
    assertEquals(1, notificationsGeneral.getCreatedNotifications());

    ksession.insert(new DiscussionEntryEvent("product", "kjdashkjashdhelpkajshd", "user"));
    ksession.fireAllRules();
    assertEquals(2, firedRules.howManyTimesIsRuleFired(rule));
    assertEquals(2, notificationsGeneral.getCreatedNotifications());
  }