use of io.imunity.furms.domain.audit_log.AuditLog 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.audit_log.AuditLog 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.audit_log.AuditLog in project furms by unity-idm.
the class PolicyDocumentAuditLogServiceIntegrationTest method shouldDetectPolicyDocumentCreation.
@Test
void shouldDetectPolicyDocumentCreation() {
PolicyId policyId = new PolicyId(UUID.randomUUID());
PolicyDocument policyDocument = PolicyDocument.builder().id(policyId).build();
when(repository.create(policyDocument)).thenReturn(policyId);
when(repository.findById(policyId)).thenReturn(Optional.of(policyDocument));
service.create(policyDocument);
ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
Mockito.verify(auditLogRepository).create(argument.capture());
assertEquals(Operation.POLICY_DOCUMENTS_MANAGEMENT, argument.getValue().operationCategory);
assertEquals(Action.CREATE, argument.getValue().action);
}
use of io.imunity.furms.domain.audit_log.AuditLog in project furms by unity-idm.
the class PolicyDocumentAuditLogServiceIntegrationTest method shouldDetectPolicyDocumentUpdate.
@Test
void shouldDetectPolicyDocumentUpdate() {
PolicyId policyId = new PolicyId(UUID.randomUUID());
PolicyDocument policyDocument = PolicyDocument.builder().id(policyId).build();
when(repository.findById(policyId)).thenReturn(Optional.of(policyDocument));
when(repository.update(policyDocument, false)).thenReturn(policyId);
service.update(policyDocument);
ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
Mockito.verify(auditLogRepository).create(argument.capture());
assertEquals(Operation.POLICY_DOCUMENTS_MANAGEMENT, argument.getValue().operationCategory);
assertEquals(Action.UPDATE, argument.getValue().action);
}
use of io.imunity.furms.domain.audit_log.AuditLog in project furms by unity-idm.
the class PolicyDocumentAuditLogServiceIntegrationTest method shouldDetectPolicyDocumentAcceptation.
@Test
void shouldDetectPolicyDocumentAcceptation() {
FenixUserId userId = new FenixUserId("userId");
PolicyId policyId = new PolicyId(UUID.randomUUID());
PolicyDocument policyDocument = PolicyDocument.builder().id(policyId).revision(1).siteId("siteId").build();
PolicyAcceptance policyAcceptance = PolicyAcceptance.builder().policyDocumentId(policyId).policyDocumentRevision(1).build();
FURMSUser user = FURMSUser.builder().id(new PersistentId("id")).email("email").fenixUserId(userId).build();
when(usersDAO.findById(userId)).thenReturn(Optional.of(user));
when(repository.findById(policyId)).thenReturn(Optional.of(policyDocument));
service.addUserPolicyAcceptance("siteId", userId, policyAcceptance);
ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
Mockito.verify(auditLogRepository).create(argument.capture());
assertEquals(Operation.POLICY_ACCEPTANCE, argument.getValue().operationCategory);
assertEquals(Action.ACCEPT, argument.getValue().action);
}
Aggregations