@Test public void testMatches() { NoteData note = new NoteData(); Long user1Id = new Random().nextLong(); Long user2Id = user1Id + 1; note.setNotifiedUsers(new ArrayList<DetailedUserData>()); note.getNotifiedUsers().add(new DetailedUserData()); note.getNotifiedUsers().add(new DetailedUserData()); note.getNotifiedUsers().get(0).setId(user1Id); note.getNotifiedUsers().get(1).setId(user2Id); Matcher<NoteData> matcher = new UsersToBeNotifiedMatcher(); Assert.assertTrue(matcher.matches(note)); matcher = new UsersToBeNotifiedMatcher(user1Id - 1); Assert.assertFalse(matcher.matches(note)); matcher = new UsersToBeNotifiedMatcher(user1Id); Assert.assertTrue(matcher.matches(note)); matcher = new UsersToBeNotifiedMatcher(user2Id); Assert.assertTrue(matcher.matches(note)); matcher = new UsersToBeNotifiedMatcher(user1Id, user1Id); Assert.assertTrue(matcher.matches(note)); }
@Override public boolean matches(NoteData entity) { if (userToBeNotifiedIds.isEmpty()) { return true; } for (UserData notifiedUser : entity.getNotifiedUsers()) { if (userToBeNotifiedIds.contains(notifiedUser.getId())) { return true; } } return entity.isForMe() && (entity.isMentionDiscussionAuthors() || entity.isMentionTopicAuthors() || entity.isMentionTopicReaders() || entity.isMentionTopicManagers()); }
UsersToBeNotifiedMatcher extends Matcher<NoteData> { @Override public boolean matches(NoteData entity) { if (userToBeNotifiedIds.isEmpty()) { return true; } for (UserData notifiedUser : entity.getNotifiedUsers()) { if (userToBeNotifiedIds.contains(notifiedUser.getId())) { return true; } } return entity.isForMe() && (entity.isMentionDiscussionAuthors() || entity.isMentionTopicAuthors() || entity.isMentionTopicReaders() || entity.isMentionTopicManagers()); } }
UsersToBeNotifiedMatcher extends Matcher<NoteData> { @Override public boolean matches(NoteData entity) { if (userToBeNotifiedIds.isEmpty()) { return true; } for (UserData notifiedUser : entity.getNotifiedUsers()) { if (userToBeNotifiedIds.contains(notifiedUser.getId())) { return true; } } return entity.isForMe() && (entity.isMentionDiscussionAuthors() || entity.isMentionTopicAuthors() || entity.isMentionTopicReaders() || entity.isMentionTopicManagers()); } UsersToBeNotifiedMatcher(Collection<Long> userToBeNotifiedIds);  UsersToBeNotifiedMatcher(Long... userToBeNotifiedIds); }
UsersToBeNotifiedMatcher extends Matcher<NoteData> { @Override public boolean matches(NoteData entity) { if (userToBeNotifiedIds.isEmpty()) { return true; } for (UserData notifiedUser : entity.getNotifiedUsers()) { if (userToBeNotifiedIds.contains(notifiedUser.getId())) { return true; } } return entity.isForMe() && (entity.isMentionDiscussionAuthors() || entity.isMentionTopicAuthors() || entity.isMentionTopicReaders() || entity.isMentionTopicManagers()); } UsersToBeNotifiedMatcher(Collection<Long> userToBeNotifiedIds);  UsersToBeNotifiedMatcher(Long... userToBeNotifiedIds); @Override boolean matches(NoteData entity); }
UsersToBeNotifiedMatcher extends Matcher<NoteData> { @Override public boolean matches(NoteData entity) { if (userToBeNotifiedIds.isEmpty()) { return true; } for (UserData notifiedUser : entity.getNotifiedUsers()) { if (userToBeNotifiedIds.contains(notifiedUser.getId())) { return true; } } return entity.isForMe() && (entity.isMentionDiscussionAuthors() || entity.isMentionTopicAuthors() || entity.isMentionTopicReaders() || entity.isMentionTopicManagers()); } UsersToBeNotifiedMatcher(Collection<Long> userToBeNotifiedIds);  UsersToBeNotifiedMatcher(Long... userToBeNotifiedIds); @Override boolean matches(NoteData entity);  }