Search in sources :

Example 6 with AuditLog

use of org.thingsboard.server.common.data.audit.AuditLog in project thingsboard by thingsboard.

the class BaseAuditLogControllerTest method testAuditLogs_byTenantIdAndEntityId.

@Test
public void testAuditLogs_byTenantIdAndEntityId() throws Exception {
    Device device = new Device();
    device.setName("Device name");
    device.setType("default");
    Device savedDevice = doPost("/api/device", device, Device.class);
    for (int i = 0; i < 178; i++) {
        savedDevice.setName("Device name" + i);
        doPost("/api/device", savedDevice, Device.class);
    }
    List<AuditLog> loadedAuditLogs = new ArrayList<>();
    TimePageLink pageLink = new TimePageLink(23);
    TimePageData<AuditLog> pageData;
    do {
        pageData = doGetTypedWithTimePageLink("/api/audit/logs/entity/DEVICE/" + savedDevice.getId().getId() + "?", new TypeReference<TimePageData<AuditLog>>() {
        }, pageLink);
        loadedAuditLogs.addAll(pageData.getData());
        if (pageData.hasNext()) {
            pageLink = pageData.getNextPageLink();
        }
    } while (pageData.hasNext());
    Assert.assertEquals(179, loadedAuditLogs.size());
}
Also used : Device(org.thingsboard.server.common.data.Device) ArrayList(java.util.ArrayList) TimePageLink(org.thingsboard.server.common.data.page.TimePageLink) TypeReference(com.fasterxml.jackson.core.type.TypeReference) AuditLog(org.thingsboard.server.common.data.audit.AuditLog) Test(org.junit.Test)

Aggregations

AuditLog (org.thingsboard.server.common.data.audit.AuditLog)6 TypeReference (com.fasterxml.jackson.core.type.TypeReference)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 Device (org.thingsboard.server.common.data.Device)2 TimePageLink (org.thingsboard.server.common.data.page.TimePageLink)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1