use of com.enonic.xp.audit.AuditLog in project xp by enonic.
the class AuditLogServiceImplTest_find method find_type.
@Test
public void find_type() {
AuditLog log1 = logAsAdmin(LogAuditLogParams.create().type("type1").build());
AuditLog log2 = logAsAdmin(LogAuditLogParams.create().type("type2").build());
FindAuditLogResult result = findAsAdmin(FindAuditLogParams.create().type("type1").build());
assertEquals(1L, result.getCount());
assertEquals(log1, result.getHits().first());
result = findAsAdmin(FindAuditLogParams.create().type("type2").build());
assertEquals(1L, result.getCount());
assertEquals(log2, result.getHits().first());
}
use of com.enonic.xp.audit.AuditLog in project xp by enonic.
the class AuditLogServiceImplTest_find method find_to.
@Test
public void find_to() {
AuditLog log = logAsAdmin(LogAuditLogParams.create().type("test").time(Instant.now()).build());
FindAuditLogResult result = findAsAdmin(FindAuditLogParams.create().to(Instant.now().minus(30, ChronoUnit.DAYS)).build());
assertEquals(0L, result.getCount());
result = findAsAdmin(FindAuditLogParams.create().to(Instant.now()).build());
assertEquals(1L, result.getCount());
assertEquals(log, result.getHits().first());
}
use of com.enonic.xp.audit.AuditLog 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.AuditLog in project xp by enonic.
the class AuditLogServiceImplTest_find method find_source.
@Test
public void find_source() {
AuditLog log1 = logAsAdmin(LogAuditLogParams.create().type("test").source("source1").build());
AuditLog log2 = logAsAdmin(LogAuditLogParams.create().type("test").source("source2").build());
FindAuditLogResult result = findAsAdmin(FindAuditLogParams.create().source("source1").build());
assertEquals(1L, result.getCount());
assertEquals(log1, result.getHits().first());
result = findAsAdmin(FindAuditLogParams.create().source("source2").build());
assertEquals(1L, result.getCount());
assertEquals(log2, result.getHits().first());
}
use of com.enonic.xp.audit.AuditLog in project xp by enonic.
the class AuditLogServiceImplTest_log method get.
@Test
public void get() {
final LogAuditLogParams params = LogAuditLogParams.create().type("test").build();
final AuditLog log1 = AuditLogContext.createAdminContext().callWith(() -> auditLogService.log(params));
final AuditLog log2 = AuditLogContext.createAdminContext().callWith(() -> auditLogService.get(log1.getId()));
assertEquals(log1, log2);
}
Aggregations