@Test public void testMatch() { final Rule rule = Rule.builder().withMatchOn("first_name").build(); final Matcher matcher = new Matcher(rule, notification); final Notification n1 = Notification.builder("new-follower") .withId("2") .withProperties(ImmutableMap.of("first_name", "Bob")) .build(); final Notification n2 = Notification.builder("new-follower") .withId("3") .withProperties(ImmutableMap.of("first_name", "Ted")) .build(); final Notification n3 = Notification.builder("new-follower") .withId("4") .withProperties(ImmutableMap.of("last_name", "Smith")) .build(); final Notification n4 = Notification.builder().build(); final Notification n5 = Notification.builder("like").withId("5").build(); assertThat(matcher.test(n1)).isTrue(); assertThat(matcher.test(n2)).isFalse(); assertThat(matcher.test(n3)).isFalse(); assertThat(matcher.test(n4)).isFalse(); assertThat(matcher.test(n5)).isFalse(); }
@Override public boolean test(final Notification notification) { if (notification != null && notification.getId().isPresent() && checkCategory(notification) && !isFull() && checkDuration(notification) && checkMatch(notification)) { return notifications.add(notification); } return false; }
Matcher implements Predicate<Notification>, Comparable<Matcher> { @Override public boolean test(final Notification notification) { if (notification != null && notification.getId().isPresent() && checkCategory(notification) && !isFull() && checkDuration(notification) && checkMatch(notification)) { return notifications.add(notification); } return false; } }
Matcher implements Predicate<Notification>, Comparable<Matcher> { @Override public boolean test(final Notification notification) { if (notification != null && notification.getId().isPresent() && checkCategory(notification) && !isFull() && checkDuration(notification) && checkMatch(notification)) { return notifications.add(notification); } return false; } Matcher(final Rule rule, final Notification notification); }
Matcher implements Predicate<Notification>, Comparable<Matcher> { @Override public boolean test(final Notification notification) { if (notification != null && notification.getId().isPresent() && checkCategory(notification) && !isFull() && checkDuration(notification) && checkMatch(notification)) { return notifications.add(notification); } return false; } Matcher(final Rule rule, final Notification notification); boolean checkMatch(final Notification notification); boolean isFull(); boolean checkCategory(final Notification notification); boolean checkDuration(final Notification notification); @Override boolean test(final Notification notification); Notification getNotification(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); @Override int compareTo(final Matcher that); }
Matcher implements Predicate<Notification>, Comparable<Matcher> { @Override public boolean test(final Notification notification) { if (notification != null && notification.getId().isPresent() && checkCategory(notification) && !isFull() && checkDuration(notification) && checkMatch(notification)) { return notifications.add(notification); } return false; } Matcher(final Rule rule, final Notification notification); boolean checkMatch(final Notification notification); boolean isFull(); boolean checkCategory(final Notification notification); boolean checkDuration(final Notification notification); @Override boolean test(final Notification notification); Notification getNotification(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); @Override int compareTo(final Matcher that);  }