InviteManager { public Invite getInvite(String domainId, String instanceId, String email) throws NotFoundException, ServerException { requireNonNull(domainId, "Required non-null domain id"); requireNonNull(instanceId, "Required non-null instance id"); requireNonNull(email, "Required non-null email"); return inviteDao.getInvite(domainId, instanceId, email); } @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 shouldReturnInvite() throws Exception { InviteImpl toBeReturned = new InviteImpl( "user@test.com", OrganizationDomain.DOMAIN_ID, "test123", singletonList("read")); doReturn(toBeReturned).when(inviteDao).getInvite(anyString(), anyString(), anyString()); Invite fetchedInvite = inviteManager.getInvite(OrganizationDomain.DOMAIN_ID, "test123", "user@test.com"); assertEquals(fetchedInvite, toBeReturned); verify(inviteDao).getInvite(OrganizationDomain.DOMAIN_ID, "test123", "user@test.com"); }
@Test( expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "Required non-null domain id" ) public void shouldThrowOnFetchingInviteByNullDomain() throws Exception { inviteManager.getInvite(null, "test123", "user@test.com"); }
@Test( expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "Required non-null instance id" ) public void shouldThrowOnFetchingInviteByNullInstance() throws Exception { inviteManager.getInvite("test", null, "user@test.com"); }
@Test( expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "Required non-null email" ) public void shouldThrowOnFetchingInviteByNullEmail() throws Exception { inviteManager.getInvite("test", "test123", null); }