use of io.imunity.furms.domain.generic_groups.GenericGroupId in project furms by unity-idm.
the class GenericGroupAuditLogServiceIntegrationTest method shouldDetectGroupUpdate.
@Test
void shouldDetectGroupUpdate() {
GenericGroupId genericGroupId = new GenericGroupId(UUID.randomUUID());
GenericGroup genericGroup = GenericGroup.builder().id(genericGroupId).communityId("communityId").name("name").description("description").build();
when(genericGroupRepository.findBy(genericGroupId)).thenReturn(Optional.of(genericGroup));
service.update(genericGroup);
ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
Mockito.verify(auditLogRepository).create(argument.capture());
assertEquals(Operation.GENERIC_GROUPS_MANAGEMENT, argument.getValue().operationCategory);
assertEquals(Action.UPDATE, argument.getValue().action);
}
use of io.imunity.furms.domain.generic_groups.GenericGroupId in project furms by unity-idm.
the class GenericGroupAuditLogServiceIntegrationTest method shouldDetectGroupDeletion.
@Test
void shouldDetectGroupDeletion() {
GenericGroupId groupId = new GenericGroupId(UUID.randomUUID());
when(genericGroupRepository.existsBy("communityId", groupId)).thenReturn(true);
GenericGroup genericGroup = GenericGroup.builder().id(groupId).build();
when(genericGroupRepository.findBy(groupId)).thenReturn(Optional.of(genericGroup));
service.delete("communityId", groupId);
ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
Mockito.verify(auditLogRepository).create(argument.capture());
assertEquals(Operation.GENERIC_GROUPS_MANAGEMENT, argument.getValue().operationCategory);
assertEquals(Action.DELETE, argument.getValue().action);
}
use of io.imunity.furms.domain.generic_groups.GenericGroupId in project furms by unity-idm.
the class GenericGroupServiceImplTest method deleteGenericGroup.
@Test
void deleteGenericGroup() {
GenericGroupId groupId = new GenericGroupId(UUID.randomUUID());
when(genericGroupRepository.existsBy("communityId", groupId)).thenReturn(true);
GenericGroup genericGroup = GenericGroup.builder().build();
when(genericGroupRepository.findBy(groupId)).thenReturn(Optional.of(genericGroup));
genericGroupService.delete("communityId", groupId);
verify(genericGroupRepository).delete(groupId);
verify(publisher).publishEvent(new GenericGroupRemovedEvent(genericGroup));
}
use of io.imunity.furms.domain.generic_groups.GenericGroupId in project furms by unity-idm.
the class GenericGroupServiceImplTest method shouldFindAllGenericGroupAssignmentWithUser.
@Test
void shouldFindAllGenericGroupAssignmentWithUser() {
GenericGroupId genericGroupId = new GenericGroupId(UUID.randomUUID());
FURMSUser furmsUser = FURMSUser.builder().email("email").fenixUserId(new FenixUserId("userId")).build();
GenericGroupMembership genericGroupMembership = GenericGroupMembership.builder().genericGroupId(genericGroupId).fenixUserId("userId").build();
when(genericGroupRepository.existsBy("communityId", genericGroupId)).thenReturn(true);
when(genericGroupRepository.findAllBy(genericGroupId)).thenReturn(Set.of(genericGroupMembership));
when(usersDAO.getAllUsers()).thenReturn(List.of(furmsUser));
Set<GenericGroupAssignmentWithUser> genericGroupServiceAll = genericGroupService.findAll("communityId", genericGroupId);
assertEquals(1, genericGroupServiceAll.size());
GenericGroupAssignmentWithUser next = genericGroupServiceAll.iterator().next();
assertEquals(furmsUser, next.furmsUser);
assertEquals(genericGroupMembership, next.membership);
}
use of io.imunity.furms.domain.generic_groups.GenericGroupId in project furms by unity-idm.
the class GenericGroupServiceImplTest method shouldFindBy.
@Test
void shouldFindBy() {
GenericGroupId genericGroupId = new GenericGroupId(UUID.randomUUID());
when(genericGroupRepository.existsBy("communityId", genericGroupId)).thenReturn(true);
genericGroupService.findBy("communityId", genericGroupId);
Mockito.verify(genericGroupRepository).findBy(genericGroupId);
}
Aggregations