use of com.enonic.xp.audit.AuditLog in project xp by enonic.
the class CreateAuditLogHandlerTest method mockCreateLog.
public void mockCreateLog() {
PropertyTree data = new PropertyTree();
data.setString("custom", "string");
data.addDouble("somevalue", 2.5);
AuditLog mocklog1 = auditLogBuilder(LogAuditLogParams.create().type("testlog").build()).source("testbundle").build();
AuditLog mocklog2 = auditLogBuilder(LogAuditLogParams.create().type("testlog").source("testbundle").user(PrincipalKey.ofAnonymous()).objectUris(AuditLogUris.from("some:resource:uri")).data(data).build()).build();
Mockito.when(this.auditLogService.log(Mockito.any(LogAuditLogParams.class))).thenReturn(mocklog1).thenReturn(mocklog2);
}
use of com.enonic.xp.audit.AuditLog in project xp by enonic.
the class FindAuditLogCommand method runQuery.
private FindAuditLogResult runQuery() {
final NodeQuery query = createQuery();
if (query == null) {
return FindAuditLogResult.empty();
}
FindNodesByQueryResult result = nodeService.findByQuery(query);
List<AuditLog> logs = result.getNodeIds().stream().map(nodeService::getById).map(AuditLogSerializer::fromNode).collect(Collectors.toList());
return FindAuditLogResult.create().total(result.getTotalHits()).hits(AuditLogs.from(logs)).build();
}
use of com.enonic.xp.audit.AuditLog in project xp by enonic.
the class AuditLogServiceImplTest method get_by_id.
@Test
public void get_by_id() {
AuditLog log = auditLogService.get(new AuditLogId());
assertLog(log);
}
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.
@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());
}
Aggregations