use of io.imunity.furms.domain.policy_documents.PolicyDocument 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.policy_documents.PolicyDocument 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.policy_documents.PolicyDocument 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);
}
use of io.imunity.furms.domain.policy_documents.PolicyDocument in project furms by unity-idm.
the class PolicyDocumentAuditLogServiceIntegrationTest method shouldDetectPolicyDocumentDeletion.
@Test
void shouldDetectPolicyDocumentDeletion() {
PolicyId policyId = new PolicyId(UUID.randomUUID());
PolicyDocument policyDocument = PolicyDocument.builder().id(policyId).build();
when(repository.findById(policyId)).thenReturn(Optional.of(policyDocument));
service.delete("siteId", policyId);
ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
Mockito.verify(auditLogRepository).create(argument.capture());
assertEquals(Operation.POLICY_DOCUMENTS_MANAGEMENT, argument.getValue().operationCategory);
assertEquals(Action.DELETE, argument.getValue().action);
}
use of io.imunity.furms.domain.policy_documents.PolicyDocument in project furms by unity-idm.
the class PolicyDocumentServiceImplTest method shouldUpdate.
@Test
void shouldUpdate() {
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);
orderVerifier.verify(validator).validateUpdate(policyDocument);
orderVerifier.verify(repository).update(policyDocument, false);
orderVerifier.verify(publisher).publishEvent(new PolicyDocumentUpdatedEvent(policyDocument, policyDocument));
}
Aggregations