@Test
public void testUpdatePersonAndSendEmail() throws URISyntaxException {
long labHead = uc.createPaul(); //create lab3 & Paul - lab3's head
final long john = uc.createJohnWithoutLab(); // crate john - the user with no lab
UserLabMembershipRequestRepository repo = getUserLabMemebershipRequestRepository();
assertEquals(repo.findPendingByUser(john).size(), 0); //no requests
final String approveUrl = "testUrl";
UserManagement.LabMembershipConfirmationUrlProvider urlProvider = new UserManagement.LabMembershipConfirmationUrlProvider() {
@Override
public String getUrl(long user, long lab, long requestId, UserManagement.LabMembershipRequestActions action) throws URISyntaxException {
return approveUrl;
}
};
userManagement.updatePersonAndSendEmail(john, new UserManagement.PersonInfo("Joe", "J", "jjj@j.com"), ImmutableSet.of(uc.getLab3()), urlProvider);
Notifier notifier = notificator();
verify(notifier).sendLabMembershipRequest(eq(labHead), Matchers.any(String.class), eq(john), eq(approveUrl), Matchers.any(String.class));
assertEquals(repo.findPendingByUser(john).size(), 1); //one request
}