Search in sources :

Example 6 with FindAuditLogResult

use of com.enonic.xp.audit.FindAuditLogResult 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());
}
Also used : FindAuditLogResult(com.enonic.xp.audit.FindAuditLogResult) AuditLog(com.enonic.xp.audit.AuditLog) Test(org.junit.jupiter.api.Test)

Example 7 with FindAuditLogResult

use of com.enonic.xp.audit.FindAuditLogResult 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());
}
Also used : LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) FindAuditLogResult(com.enonic.xp.audit.FindAuditLogResult) Test(org.junit.jupiter.api.Test)

Example 8 with FindAuditLogResult

use of com.enonic.xp.audit.FindAuditLogResult 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());
}
Also used : FindAuditLogResult(com.enonic.xp.audit.FindAuditLogResult) AuditLog(com.enonic.xp.audit.AuditLog) Test(org.junit.jupiter.api.Test)

Example 9 with FindAuditLogResult

use of com.enonic.xp.audit.FindAuditLogResult 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());
        });
    });
}
Also used : AuditLogContext(com.enonic.xp.core.impl.audit.AuditLogContext) Context(com.enonic.xp.context.Context) LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) FindAuditLogResult(com.enonic.xp.audit.FindAuditLogResult) AuditLog(com.enonic.xp.audit.AuditLog) Test(org.junit.jupiter.api.Test)

Example 10 with FindAuditLogResult

use of com.enonic.xp.audit.FindAuditLogResult 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());
}
Also used : FindAuditLogResult(com.enonic.xp.audit.FindAuditLogResult) AuditLog(com.enonic.xp.audit.AuditLog) Test(org.junit.jupiter.api.Test)

Aggregations

FindAuditLogResult (com.enonic.xp.audit.FindAuditLogResult)10 Test (org.junit.jupiter.api.Test)9 AuditLog (com.enonic.xp.audit.AuditLog)6 LogAuditLogParams (com.enonic.xp.audit.LogAuditLogParams)3 FindAuditLogParams (com.enonic.xp.audit.FindAuditLogParams)1 Context (com.enonic.xp.context.Context)1 AuditLogContext (com.enonic.xp.core.impl.audit.AuditLogContext)1 FindAuditLogResultMapper (com.enonic.xp.lib.audit.mapper.FindAuditLogResultMapper)1