Esempio n. 1
0
  /** Test the sending of a notification. */
  @Test
  public void testEventConsuming() {

    // set up
    service.removeAdaptor(adaptor);

    final DummyNotificationAdaptor adaptor1 = new DummyNotificationAdaptor();
    final DummyNotificationAdaptor adaptor2 = new DummyNotificationAdaptor();

    service.addAdaptor(adaptor1);
    service.addAdaptor(adaptor2);

    final Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("test", "test01");
    final Notification notification =
        new Notification(DummyNotificationAdaptor.TEST_TYPE, parameters);

    // test not consume
    adaptor1.setConsumeEvent(false);
    adaptor2.setConsumeEvent(false);

    service.send(notification);

    boolean adaptor1Contains = adaptor1.getNotifications().contains(notification);
    boolean adaptor2Contains = adaptor2.getNotifications().contains(notification);
    Assert.assertTrue(adaptor1Contains);
    Assert.assertTrue(adaptor2Contains);

    // clean notifications
    adaptor1.getNotifications().clear();
    adaptor2.getNotifications().clear();

    // test consume
    adaptor1.setConsumeEvent(true);
    adaptor2.setConsumeEvent(true);

    service.send(notification);
    adaptor1Contains = adaptor1.getNotifications().contains(notification);
    adaptor2Contains = adaptor2.getNotifications().contains(notification);
    Assert.assertFalse(adaptor1Contains && adaptor2Contains);
    Assert.assertTrue(adaptor1Contains || adaptor2Contains);

    // clean up
    service.removeAdaptor(adaptor1);
    service.removeAdaptor(adaptor2);

    service.addAdaptor(adaptor);
  }
Esempio n. 2
0
  /** Test the sending of a notification. */
  @Test
  public void testSend() {
    final Map<String, String> parameters = new HashMap<String, String>();
    final Notification notification =
        new Notification(DummyNotificationAdaptor.TEST_TYPE, parameters);
    service.send(notification);

    final List<Notification> sentNotifications = adaptor.getNotifications();
    Assert.assertTrue(sentNotifications.contains(notification));
  }
 public void send(String message) {
   service.send("email: " + message);
 }