Search in sources :

Example 1 with EntityViewInfo

use of org.thingsboard.server.common.data.EntityViewInfo in project thingsboard by thingsboard.

the class BaseEntityViewControllerTest method testGetTenantEntityViews.

@Test
public void testGetTenantEntityViews() throws Exception {
    List<EntityViewInfo> views = new ArrayList<>();
    for (int i = 0; i < 178; i++) {
        views.add(new EntityViewInfo(getNewSavedEntityView("Test entity view" + i), null, false));
    }
    List<EntityViewInfo> loadedViews = loadListOfInfo(new PageLink(23), "/api/tenant/entityViewInfos?");
    Collections.sort(views, idComparator);
    Collections.sort(loadedViews, idComparator);
    assertEquals(views, loadedViews);
}
Also used : ArrayList(java.util.ArrayList) PageLink(org.thingsboard.server.common.data.page.PageLink) EntityViewInfo(org.thingsboard.server.common.data.EntityViewInfo) Test(org.junit.Test)

Example 2 with EntityViewInfo

use of org.thingsboard.server.common.data.EntityViewInfo in project thingsboard by thingsboard.

the class BaseEntityViewControllerTest method testGetCustomerEntityViews.

@Test
public void testGetCustomerEntityViews() throws Exception {
    Customer customer = doPost("/api/customer", getNewCustomer("Test customer"), Customer.class);
    CustomerId customerId = customer.getId();
    String urlTemplate = "/api/customer/" + customerId.getId().toString() + "/entityViewInfos?";
    List<EntityViewInfo> views = new ArrayList<>();
    for (int i = 0; i < 128; i++) {
        views.add(new EntityViewInfo(doPost("/api/customer/" + customerId.getId().toString() + "/entityView/" + getNewSavedEntityView("Test entity view " + i).getId().getId().toString(), EntityView.class), customer.getTitle(), customer.isPublic()));
    }
    List<EntityViewInfo> loadedViews = loadListOfInfo(new PageLink(23), urlTemplate);
    Collections.sort(views, idComparator);
    Collections.sort(loadedViews, idComparator);
    assertEquals(views, loadedViews);
}
Also used : Customer(org.thingsboard.server.common.data.Customer) ArrayList(java.util.ArrayList) PageLink(org.thingsboard.server.common.data.page.PageLink) EntityViewInfo(org.thingsboard.server.common.data.EntityViewInfo) CustomerId(org.thingsboard.server.common.data.id.CustomerId) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 3 with EntityViewInfo

use of org.thingsboard.server.common.data.EntityViewInfo in project thingsboard by thingsboard.

the class BaseController method checkEntityViewInfoId.

EntityViewInfo checkEntityViewInfoId(EntityViewId entityViewId, Operation operation) throws ThingsboardException {
    try {
        validateId(entityViewId, "Incorrect entityViewId " + entityViewId);
        EntityViewInfo entityView = entityViewService.findEntityViewInfoById(getCurrentUser().getTenantId(), entityViewId);
        checkNotNull(entityView, "Entity view with id [" + entityViewId + "] is not found");
        accessControlService.checkPermission(getCurrentUser(), Resource.ENTITY_VIEW, operation, entityViewId, entityView);
        return entityView;
    } catch (Exception e) {
        throw handleException(e, false);
    }
}
Also used : EntityViewInfo(org.thingsboard.server.common.data.EntityViewInfo) DataValidationException(org.thingsboard.server.dao.exception.DataValidationException) MessagingException(javax.mail.MessagingException) IncorrectParameterException(org.thingsboard.server.dao.exception.IncorrectParameterException) ThingsboardException(org.thingsboard.server.common.data.exception.ThingsboardException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

EntityViewInfo (org.thingsboard.server.common.data.EntityViewInfo)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 PageLink (org.thingsboard.server.common.data.page.PageLink)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 MessagingException (javax.mail.MessagingException)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Customer (org.thingsboard.server.common.data.Customer)1 ThingsboardException (org.thingsboard.server.common.data.exception.ThingsboardException)1 CustomerId (org.thingsboard.server.common.data.id.CustomerId)1 DataValidationException (org.thingsboard.server.dao.exception.DataValidationException)1 IncorrectParameterException (org.thingsboard.server.dao.exception.IncorrectParameterException)1