@Test public void testCheckMatch() { final Rule rule = Rule.builder().withMatchOn("first_name").build(); final Matcher matcher = new Matcher(rule, notification); final Notification n1 = Notification.builder().withProperties(ImmutableMap.of("first_name", "Bob")).build(); final Notification n2 = Notification.builder().withProperties(ImmutableMap.of("first_name", "Ted")).build(); final Notification n3 = Notification.builder().withProperties(ImmutableMap.of("last_name", "Smith")).build(); final Notification n4 = Notification.builder().build(); final Notification n5 = Notification.builder("like").build(); assertThat(matcher.checkMatch(n1)).isTrue(); assertThat(matcher.checkMatch(n2)).isFalse(); assertThat(matcher.checkMatch(n3)).isFalse(); assertThat(matcher.checkMatch(n4)).isFalse(); assertThat(matcher.checkMatch(n5)).isFalse(); }
public boolean checkMatch(final Notification notification) { if (!rule.getMatchOn().isPresent()) { return true; } if (matchOn == null || matchValue == null) { return false; } final Map<String, String> properties = notification.getProperties(); return properties.containsKey(matchOn) && Objects.equals(properties.get(matchOn), matchValue); }
Matcher implements Predicate<Notification>, Comparable<Matcher> { public boolean checkMatch(final Notification notification) { if (!rule.getMatchOn().isPresent()) { return true; } if (matchOn == null || matchValue == null) { return false; } final Map<String, String> properties = notification.getProperties(); return properties.containsKey(matchOn) && Objects.equals(properties.get(matchOn), matchValue); } }
Matcher implements Predicate<Notification>, Comparable<Matcher> { public boolean checkMatch(final Notification notification) { if (!rule.getMatchOn().isPresent()) { return true; } if (matchOn == null || matchValue == null) { return false; } final Map<String, String> properties = notification.getProperties(); return properties.containsKey(matchOn) && Objects.equals(properties.get(matchOn), matchValue); } Matcher(final Rule rule, final Notification notification); }
Matcher implements Predicate<Notification>, Comparable<Matcher> { public boolean checkMatch(final Notification notification) { if (!rule.getMatchOn().isPresent()) { return true; } if (matchOn == null || matchValue == null) { return false; } final Map<String, String> properties = notification.getProperties(); return properties.containsKey(matchOn) && Objects.equals(properties.get(matchOn), matchValue); } 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> { public boolean checkMatch(final Notification notification) { if (!rule.getMatchOn().isPresent()) { return true; } if (matchOn == null || matchValue == null) { return false; } final Map<String, String> properties = notification.getProperties(); return properties.containsKey(matchOn) && Objects.equals(properties.get(matchOn), matchValue); } 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);  }