use of io.imunity.furms.domain.invitations.InvitationId in project furms by unity-idm.
the class InvitatoryServiceTest method removeInvitationForNewUser.
@Test
void removeInvitationForNewUser() {
Role role = Role.FENIX_ADMIN;
ResourceId resourceId = new ResourceId((UUID) null, ResourceType.APP_LEVEL);
InvitationCode invitationCode = new InvitationCode("code");
InvitationId invitationId = new InvitationId(UUID.randomUUID());
Invitation invitation = Invitation.builder().id(invitationId).resourceId(resourceId).role(role).code(invitationCode).originator("originator").email("email@email.com").utcExpiredAt(getExpiredAt()).build();
when(invitationRepository.findBy(invitationId)).thenReturn(Optional.of(invitation));
invitatoryService.removeInvitation(invitationId);
verify(invitationRepository).deleteBy(invitationId);
verify(usersDAO).removeInvitation(invitationCode);
}
use of io.imunity.furms.domain.invitations.InvitationId in project furms by unity-idm.
the class InvitatoryServiceTest method shouldResendInvitationForNewUser.
@Test
void shouldResendInvitationForNewUser() {
Role role = Role.FENIX_ADMIN;
ResourceId resourceId = new ResourceId((UUID) null, ResourceType.APP_LEVEL);
InvitationCode invitationCode = new InvitationCode("code");
InvitationId invitationId = new InvitationId(UUID.randomUUID());
Invitation invitation = Invitation.builder().id(invitationId).resourceId(resourceId).role(role).code(invitationCode).originator("originator").email("email@email.com").utcExpiredAt(getExpiredAt()).build();
when(invitationRepository.findBy(invitationId)).thenReturn(Optional.of(invitation));
invitatoryService.resendInvitation(invitationId);
verify(usersDAO).resendInvitation(invitation, getExpiredAt().toInstant(ZoneOffset.UTC));
}
use of io.imunity.furms.domain.invitations.InvitationId in project furms by unity-idm.
the class InvitatoryServiceTest method shouldNotFindInvitationAssociationWithResourceId.
@Test
void shouldNotFindInvitationAssociationWithResourceId() {
ResourceId resourceId = new ResourceId(UUID.randomUUID(), ResourceType.SITE);
Invitation invitation = Invitation.builder().id(new InvitationId(UUID.randomUUID())).resourceId(resourceId).build();
when(invitationRepository.findBy(invitation.id)).thenReturn(Optional.of(invitation));
boolean associated = invitatoryService.checkAssociation(UUID.randomUUID().toString(), invitation.id);
assertFalse(associated);
}
use of io.imunity.furms.domain.invitations.InvitationId in project furms by unity-idm.
the class InvitatoryServiceTest method shouldUpdateInvitationRoleForExistingUser.
@Test
void shouldUpdateInvitationRoleForExistingUser() {
Role role = Role.SITE_ADMIN;
ResourceId resourceId = new ResourceId(UUID.randomUUID(), ResourceType.SITE);
InvitationId invitationId = new InvitationId(UUID.randomUUID());
PersistentId persistentId = new PersistentId("id");
FenixUserId fenixId = new FenixUserId("fenixId");
FURMSUser furmsUser = FURMSUser.builder().id(persistentId).fenixUserId(fenixId).email("email@email.com").build();
Invitation invitation = Invitation.builder().id(invitationId).resourceId(resourceId).userId(fenixId).role(role).originator("originator").email("email@email.com").utcExpiredAt(getExpiredAt()).build();
when(invitationRepository.findBy(invitationId)).thenReturn(Optional.of(invitation));
when(usersDAO.getAllUsers()).thenReturn(List.of(furmsUser));
invitatoryService.updateInvitationRole(invitationId, Role.SITE_SUPPORT);
verify(invitationRepository).updateExpiredAtAndRole(invitationId, getExpiredAt(), Role.SITE_SUPPORT);
verify(userInvitationNotificationService).notifyUserAboutNewRole(persistentId, Role.SITE_SUPPORT);
}
use of io.imunity.furms.domain.invitations.InvitationId in project furms by unity-idm.
the class InvitatoryServiceTest method shouldGetInvitations.
@Test
void shouldGetInvitations() {
UUID id = UUID.randomUUID();
Role role = Role.FENIX_ADMIN;
Invitation invitation = Invitation.builder().id(new InvitationId(UUID.randomUUID())).build();
when(invitationRepository.findAllBy(role, id)).thenReturn(Set.of(invitation));
Set<Invitation> invitations = invitatoryService.getInvitations(role, id);
assertEquals(Set.of(invitation), invitations);
}
Aggregations