Search in sources :

Example 1 with GenericGroupId

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);
}
Also used : GenericGroupId(io.imunity.furms.domain.generic_groups.GenericGroupId) GenericGroup(io.imunity.furms.domain.generic_groups.GenericGroup) AuditLog(io.imunity.furms.domain.audit_log.AuditLog) AuditLogServiceImplTest(io.imunity.furms.core.audit_log.AuditLogServiceImplTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with GenericGroupId

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);
}
Also used : GenericGroupId(io.imunity.furms.domain.generic_groups.GenericGroupId) GenericGroup(io.imunity.furms.domain.generic_groups.GenericGroup) AuditLog(io.imunity.furms.domain.audit_log.AuditLog) AuditLogServiceImplTest(io.imunity.furms.core.audit_log.AuditLogServiceImplTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with GenericGroupId

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));
}
Also used : GenericGroupId(io.imunity.furms.domain.generic_groups.GenericGroupId) GenericGroup(io.imunity.furms.domain.generic_groups.GenericGroup) GenericGroupRemovedEvent(io.imunity.furms.domain.generic_groups.GenericGroupRemovedEvent) Test(org.junit.jupiter.api.Test)

Example 4 with GenericGroupId

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);
}
Also used : GenericGroupAssignmentWithUser(io.imunity.furms.domain.generic_groups.GenericGroupAssignmentWithUser) GenericGroupMembership(io.imunity.furms.domain.generic_groups.GenericGroupMembership) FenixUserId(io.imunity.furms.domain.users.FenixUserId) GenericGroupId(io.imunity.furms.domain.generic_groups.GenericGroupId) FURMSUser(io.imunity.furms.domain.users.FURMSUser) Test(org.junit.jupiter.api.Test)

Example 5 with GenericGroupId

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);
}
Also used : GenericGroupId(io.imunity.furms.domain.generic_groups.GenericGroupId) Test(org.junit.jupiter.api.Test)

Aggregations

GenericGroupId (io.imunity.furms.domain.generic_groups.GenericGroupId)31 Test (org.junit.jupiter.api.Test)25 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)15 GenericGroup (io.imunity.furms.domain.generic_groups.GenericGroup)12 DBIntegrationTest (io.imunity.furms.db.DBIntegrationTest)10 FenixUserId (io.imunity.furms.domain.users.FenixUserId)8 AuditLogServiceImplTest (io.imunity.furms.core.audit_log.AuditLogServiceImplTest)5 AuditLog (io.imunity.furms.domain.audit_log.AuditLog)5 BreadCrumbParameter (io.imunity.furms.ui.components.layout.BreadCrumbParameter)3 BeforeEvent (com.vaadin.flow.router.BeforeEvent)2 OptionalParameter (com.vaadin.flow.router.OptionalParameter)2 Route (com.vaadin.flow.router.Route)2 GenericGroupService (io.imunity.furms.api.generic_groups.GenericGroupService)2 GenericGroupCreatedEvent (io.imunity.furms.domain.generic_groups.GenericGroupCreatedEvent)2 GenericGroupMembership (io.imunity.furms.domain.generic_groups.GenericGroupMembership)2 PersistentId (io.imunity.furms.domain.users.PersistentId)2 FurmsViewComponent (io.imunity.furms.ui.components.FurmsViewComponent)2 PageTitle (io.imunity.furms.ui.components.PageTitle)2 NotificationUtils.showErrorNotification (io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification)2 ResourceGetter.getCurrentResourceId (io.imunity.furms.ui.utils.ResourceGetter.getCurrentResourceId)2