InviteManager { public Page<? extends Invite> getInvites(String email, int maxItems, long skipCount) throws ServerException { requireNonNull(email, "Required non-null email"); return inviteDao.getInvites(email, maxItems, skipCount); } @Inject  InviteManager(
      PermissionsManager permissionsManager,
      UserManager userManager,
      InviteDao inviteDao,
      EventService eventService); @Transactional(rollbackOn = {RuntimeException.class, ServerException.class}) void store(Invite invite); Invite getInvite(String domainId, String instanceId, String email); Page<? extends Invite> getInvites(String email, int maxItems, long skipCount); Page<? extends Invite> getInvites(
      String domainId, String instanceId, long skipCount, int maxItems); void remove(String domainId, String instanceId, String email);  }
@Test public void shouldReturnInvitesByEmail() throws Exception { doReturn(invitesPage).when(inviteDao).getInvites(anyString(), anyInt(), anyLong()); Page<? extends Invite> fetchedPage = inviteManager.getInvites("user@test.com", 10, 5); assertEquals(fetchedPage, invitesPage); verify(inviteDao).getInvites("user@test.com", 10, 5); }
@Test( expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "Required non-null email" ) public void shouldThrowOnFetchingInvitesByNullEmail() throws Exception { inviteManager.getInvites(null, 0, 0); }
@Test public void shouldReturnInvitesByInstance() throws Exception { doReturn(invitesPage).when(inviteDao).getInvites(anyString(), anyString(), anyLong(), anyInt()); Page<? extends Invite> fetchedPage = inviteManager.getInvites("test", "test123", 5, 10); assertEquals(fetchedPage, invitesPage); verify(inviteDao).getInvites("test", "test123", 5, 10); }
@Test( expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "Required non-null domain id" ) public void shouldThrowOnFetchingInvitesByNullDomain() throws Exception { inviteManager.getInvites(null, "test123", 0, 0); }
@Test( expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "Required non-null instance id" ) public void shouldThrowOnFetchingInvitesByNullInstance() throws Exception { inviteManager.getInvites("test", null, 0, 0); }