use of com.enonic.xp.audit.LogAuditLogParams in project xp by enonic.
the class AuditLogServiceImplTest_find method find.
@Test
public void find() {
LogAuditLogParams params = LogAuditLogParams.create().type("test").build();
AuditLog log = logAsAdmin(params);
FindAuditLogResult result = findAsAdmin(FindAuditLogParams.create().ids(AuditLogIds.from(log.getId())).build());
assertEquals(1L, result.getCount());
assertEquals(log, result.getHits().first());
}
use of com.enonic.xp.audit.LogAuditLogParams in project xp by enonic.
the class AuditLogServiceImplTest_find method find_anonymous.
@Test
public void find_anonymous() {
final Context context = ContextBuilder.create().repositoryId(AuditLogConstants.AUDIT_LOG_REPO_ID).branch(AuditLogConstants.AUDIT_LOG_BRANCH).authInfo(AuthenticationInfo.create().principals(PrincipalKey.ofAnonymous()).user(User.ANONYMOUS).build()).build();
AuditLogContext.createAdminContext().runWith(() -> {
LogAuditLogParams params = LogAuditLogParams.create().type("test").build();
AuditLog log = auditLogService.log(params);
context.runWith(() -> {
FindAuditLogResult result = auditLogService.find(FindAuditLogParams.create().ids(AuditLogIds.from(log.getId())).build());
assertEquals(0L, result.getCount());
});
});
}
use of com.enonic.xp.audit.LogAuditLogParams in project xp by enonic.
the class AuditLogServiceImplTest_find method find_none.
@Test
public void find_none() {
LogAuditLogParams params = LogAuditLogParams.create().type("test").build();
logAsAdmin(params);
FindAuditLogResult result = findAsAdmin(FindAuditLogParams.create().build());
assertEquals(1L, result.getCount());
}
use of com.enonic.xp.audit.LogAuditLogParams in project xp by enonic.
the class ContentServiceImplTest_applyPermissions method audit_data.
@Test
public void audit_data() throws Exception {
final ArgumentCaptor<LogAuditLogParams> captor = ArgumentCaptor.forClass(LogAuditLogParams.class);
final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
final Content content = this.contentService.create(createContentParams);
final ApplyContentPermissionsParams applyParams = ApplyContentPermissionsParams.create().contentId(content.getId()).applyContentPermissionsListener(Mockito.mock(ApplyPermissionsListener.class)).build();
final ApplyContentPermissionsResult result = this.contentService.applyPermissions(applyParams);
Mockito.verify(auditLogService, Mockito.timeout(5000).times(2)).log(captor.capture());
final PropertySet logResultSet = captor.getValue().getData().getSet("result");
assertEquals(content.getPath().toString(), logResultSet.getStrings("succeedContents").iterator().next());
}
use of com.enonic.xp.audit.LogAuditLogParams in project xp by enonic.
the class ContentServiceImplTest_duplicate method audit_data.
@Test
public void audit_data() throws Exception {
final ArgumentCaptor<LogAuditLogParams> captor = ArgumentCaptor.forClass(LogAuditLogParams.class);
final Content rootContent = createContent(ContentPath.ROOT);
final Content childContent = createContent(rootContent.getPath());
final Content duplicatedContent = doDuplicateContent(rootContent);
Mockito.verify(auditLogService, Mockito.timeout(5000).times(3)).log(captor.capture());
final PropertySet logResultSet = captor.getValue().getData().getSet("result");
final Iterable<String> ids = logResultSet.getStrings("duplicatedContents");
assertEquals(2, StreamSupport.stream(ids.spliterator(), false).count());
assertTrue(StreamSupport.stream(ids.spliterator(), false).anyMatch(id -> id.equals(duplicatedContent.getId().toString())));
}
Aggregations