use of io.imunity.furms.domain.projects.Project in project furms by unity-idm.
the class ProjectAuditLogServiceIntegrationTest method shouldDetectProjectCreation.
@Test
void shouldDetectProjectCreation() {
// given
String id = UUID.randomUUID().toString();
PersistentId projectLeaderId = new PersistentId(UUID.randomUUID().toString());
Project request = Project.builder().id(id).communityId("id").name("userFacingName").acronym("acronym").researchField("research field").utcStartTime(LocalDateTime.now()).utcEndTime(LocalDateTime.now().plusWeeks(1)).leaderId(projectLeaderId).build();
when(communityRepository.exists("id")).thenReturn(true);
when(projectRepository.isNamePresent(request.getCommunityId(), request.getName())).thenReturn(true);
when(projectRepository.findById(id)).thenReturn(Optional.of(request));
when(projectRepository.create(request)).thenReturn(id);
when(usersDAO.findById(projectLeaderId)).thenReturn(Optional.of(FURMSUser.builder().id(projectLeaderId).email("email").build()));
// when
service.create(request);
ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
Mockito.verify(auditLogRepository, times(2)).create(argument.capture());
assertEquals(Operation.PROJECTS_MANAGEMENT, argument.getAllValues().get(1).operationCategory);
assertEquals(Action.CREATE, argument.getAllValues().get(1).action);
assertEquals(Operation.ROLE_ASSIGNMENT, argument.getAllValues().get(0).operationCategory);
assertEquals(Action.GRANT, argument.getAllValues().get(0).action);
}
use of io.imunity.furms.domain.projects.Project in project furms by unity-idm.
the class ProjectAuditLogServiceIntegrationTest method shouldDetectUserRemoval.
@Test
void shouldDetectUserRemoval() {
UUID communityId = UUID.randomUUID();
UUID projectId = UUID.randomUUID();
PersistentId id = new PersistentId("id");
Project project = Project.builder().name("userFacingName").build();
when(projectRepository.findById(projectId.toString())).thenReturn(Optional.of(project));
when(usersDAO.findById(id)).thenReturn(Optional.of(FURMSUser.builder().id(id).email("email").build()));
service.removeUser(communityId.toString(), projectId.toString(), id);
ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
Mockito.verify(auditLogRepository).create(argument.capture());
assertEquals(Operation.ROLE_ASSIGNMENT, argument.getValue().operationCategory);
assertEquals(Action.REVOKE, argument.getValue().action);
}
use of io.imunity.furms.domain.projects.Project in project furms by unity-idm.
the class ProjectAuditLogServiceIntegrationTest method shouldDetectProjectDeletion.
@Test
void shouldDetectProjectDeletion() {
// given
String id = "id";
String id2 = "id";
when(projectRepository.exists(id)).thenReturn(true);
List<FURMSUser> users = Collections.singletonList(FURMSUser.builder().id(new PersistentId("id")).email("email@test.com").build());
when(projectGroupsDAO.getAllUsers("id", "id")).thenReturn(users);
Project project = Project.builder().build();
when(projectRepository.findById("id")).thenReturn(Optional.of(project));
// when
service.delete(id, id2);
ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
Mockito.verify(auditLogRepository).create(argument.capture());
assertEquals(Operation.PROJECTS_MANAGEMENT, argument.getValue().operationCategory);
assertEquals(Action.DELETE, argument.getValue().action);
}
use of io.imunity.furms.domain.projects.Project in project furms by unity-idm.
the class ProjectAuditLogServiceIntegrationTest method shouldDetectUserAddition.
@Test
void shouldDetectUserAddition() {
UUID communityId = UUID.randomUUID();
UUID projectId = UUID.randomUUID();
PersistentId id = new PersistentId("id");
Project project = Project.builder().name("userFacingName").build();
when(projectRepository.findById(projectId.toString())).thenReturn(Optional.of(project));
when(usersDAO.findById(id)).thenReturn(Optional.of(FURMSUser.builder().id(id).email("email").build()));
service.addUser(communityId.toString(), projectId.toString(), id);
ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
Mockito.verify(auditLogRepository).create(argument.capture());
assertEquals(Operation.ROLE_ASSIGNMENT, argument.getValue().operationCategory);
assertEquals(Action.GRANT, argument.getValue().action);
}
use of io.imunity.furms.domain.projects.Project in project furms by unity-idm.
the class ProjectServiceImplTest method shouldAllowToCreateProject.
@Test
void shouldAllowToCreateProject() {
// given
String id = UUID.randomUUID().toString();
Project request = Project.builder().id(id).communityId("id").name("userFacingName").acronym("acronym").researchField("research field").utcStartTime(LocalDateTime.now()).utcEndTime(LocalDateTime.now().plusWeeks(1)).leaderId(new PersistentId(UUID.randomUUID().toString())).build();
ProjectGroup groupRequest = ProjectGroup.builder().id(id).communityId("id").name("userFacingName").build();
when(communityRepository.exists("id")).thenReturn(true);
when(projectRepository.isNamePresent(request.getCommunityId(), request.getName())).thenReturn(true);
when(projectRepository.findById(id)).thenReturn(Optional.of(request));
when(projectRepository.create(request)).thenReturn(id);
// when
service.create(request);
orderVerifier.verify(projectRepository).create(eq(request));
orderVerifier.verify(projectGroupsDAO).create(eq(groupRequest));
orderVerifier.verify(publisher).publishEvent(eq(new ProjectCreatedEvent(request)));
}
Aggregations