@Test public void testMatches() { NoteData note = new NoteData(); note.setUser(new DetailedUserData()); Long userId = new Random().nextLong(); note.getUser().setId(userId + 1); Matcher<NoteData> matcher = new UserIdsMatcher(userId); Assert.assertFalse(matcher.matches(note)); note.getUser().setId(userId); Assert.assertTrue(matcher.matches(note)); matcher = new UserIdsMatcher(userId, userId - 1); Assert.assertTrue(matcher.matches(note)); }
@Override public boolean matches(NoteData entity) { if (userIds == null || userIds.length == 0) { return true; } for (Long userAlias : userIds) { if (userAlias.equals(entity.getUser().getId())) { return true; } } return false; }
UserIdsMatcher extends Matcher<NoteData> { @Override public boolean matches(NoteData entity) { if (userIds == null || userIds.length == 0) { return true; } for (Long userAlias : userIds) { if (userAlias.equals(entity.getUser().getId())) { return true; } } return false; } }
UserIdsMatcher extends Matcher<NoteData> { @Override public boolean matches(NoteData entity) { if (userIds == null || userIds.length == 0) { return true; } for (Long userAlias : userIds) { if (userAlias.equals(entity.getUser().getId())) { return true; } } return false; } UserIdsMatcher(Long... userIds); }
UserIdsMatcher extends Matcher<NoteData> { @Override public boolean matches(NoteData entity) { if (userIds == null || userIds.length == 0) { return true; } for (Long userAlias : userIds) { if (userAlias.equals(entity.getUser().getId())) { return true; } } return false; } UserIdsMatcher(Long... userIds); @Override boolean matches(NoteData entity); }
UserIdsMatcher extends Matcher<NoteData> { @Override public boolean matches(NoteData entity) { if (userIds == null || userIds.length == 0) { return true; } for (Long userAlias : userIds) { if (userAlias.equals(entity.getUser().getId())) { return true; } } return false; } UserIdsMatcher(Long... userIds); @Override boolean matches(NoteData entity);  }