diff --git a/application/src/test/java/org/thingsboard/server/controller/EntityViewControllerTest.java b/application/src/test/java/org/thingsboard/server/controller/EntityViewControllerTest.java index decea27abb..48c508f43f 100644 --- a/application/src/test/java/org/thingsboard/server/controller/EntityViewControllerTest.java +++ b/application/src/test/java/org/thingsboard/server/controller/EntityViewControllerTest.java @@ -371,15 +371,15 @@ public class EntityViewControllerTest extends AbstractControllerTest { @Test public void testUpdateEntityViewByCustomerUserToEntityNotAssignedToCustomer() throws Exception { EntityView savedView = getNewSavedEntityView("Customer entity view"); - doPost("/api/customer/" + customerId.getId() + "/entityView/" + savedView.getId().getId(), EntityView.class); - doPost("/api/customer/" + customerId.getId() + "/device/" + testDevice.getId().getId(), Device.class); + doPost("/api/owner/CUSTOMER/" + customerId.getId() + "/ENTITY_VIEW/" + savedView.getId().getId()).andExpect(status().isOk()); + doPost("/api/owner/CUSTOMER/" + customerId.getId() + "/DEVICE/" + testDevice.getId().getId()).andExpect(status().isOk()); Device otherDevice = new Device(); otherDevice.setName("Device not assigned to customer"); otherDevice.setType("default"); otherDevice = doPost("/api/device", otherDevice, Device.class); - loginCustomerUser(); + loginCustomerAdminUser(); EntityView customerView = doGet("/api/entityView/" + savedView.getId().getId(), EntityView.class); customerView.setEntityId(otherDevice.getId()); @@ -393,9 +393,9 @@ public class EntityViewControllerTest extends AbstractControllerTest { @Test public void testUpdateEntityViewByCustomerUserKeepingEntity() throws Exception { EntityView savedView = getNewSavedEntityView("Customer entity view"); - doPost("/api/customer/" + customerId.getId() + "/entityView/" + savedView.getId().getId(), EntityView.class); + doPost("/api/owner/CUSTOMER/" + customerId.getId() + "/ENTITY_VIEW/" + savedView.getId().getId()).andExpect(status().isOk()); - loginCustomerUser(); + loginCustomerAdminUser(); EntityView customerView = doGet("/api/entityView/" + savedView.getId().getId(), EntityView.class); customerView.setName("Customer entity view renamed"); @@ -408,9 +408,9 @@ public class EntityViewControllerTest extends AbstractControllerTest { @Test public void testUpdateEntityViewKeysByCustomerUserWithEntityNotAssignedToCustomer() throws Exception { EntityView savedView = getNewSavedEntityView("Customer entity view"); - doPost("/api/customer/" + customerId.getId() + "/entityView/" + savedView.getId().getId(), EntityView.class); + doPost("/api/owner/CUSTOMER/" + customerId.getId() + "/ENTITY_VIEW/" + savedView.getId().getId()).andExpect(status().isOk()); - loginCustomerUser(); + loginCustomerAdminUser(); EntityView customerView = doGet("/api/entityView/" + savedView.getId().getId(), EntityView.class); customerView.setKeys(new TelemetryEntityView(List.of("tsKey1"), new AttributesEntityView())); diff --git a/application/src/test/java/org/thingsboard/server/edge/EntityViewEdgeTest.java b/application/src/test/java/org/thingsboard/server/edge/EntityViewEdgeTest.java index ffa3ae3d58..e725fccffd 100644 --- a/application/src/test/java/org/thingsboard/server/edge/EntityViewEdgeTest.java +++ b/application/src/test/java/org/thingsboard/server/edge/EntityViewEdgeTest.java @@ -248,6 +248,8 @@ public class EntityViewEdgeTest extends AbstractEdgeTest { Assert.assertEquals(differentTenantId, storedView.getTenantId()); Assert.assertEquals("Other tenant EntityView", storedView.getName()); Assert.assertEquals(otherTenantDevice.getId(), storedView.getEntityId()); + Assert.assertEquals(otherTenantView.getCustomerId(), storedView.getCustomerId()); + Assert.assertEquals(otherTenantView.getOwnerId(), storedView.getOwnerId()); loginTenantAdmin(); } diff --git a/application/src/test/java/org/thingsboard/server/service/entitiy/EntityServiceTest.java b/application/src/test/java/org/thingsboard/server/service/entitiy/EntityServiceTest.java index 2cde516aad..e509d2666d 100644 --- a/application/src/test/java/org/thingsboard/server/service/entitiy/EntityServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/entitiy/EntityServiceTest.java @@ -2105,6 +2105,7 @@ public class EntityServiceTest extends AbstractControllerTest { entityView.setCustomerId(customerId); entityView.setName("test"); entityView.setType("default"); + entityView.setEntityId(deviceId); customerEntityIds.add(entityViewService.saveEntityView(entityView).getId()); EntityGroup entityGroup = new EntityGroup(); @@ -3876,12 +3877,18 @@ public class EntityServiceTest extends AbstractControllerTest { @Test public void testEntityViewEntityMapping() { + Device device = new Device(); + device.setTenantId(tenantId); + device.setName("Device for entity view"); + device.setType("default"); + device = deviceService.saveDevice(device); + EntityView entityView = new EntityView(); entityView.setTenantId(tenantId); entityView.setCustomerId(customerId); entityView.setName("test"); entityView.setType("default"); - entityView.setEntityId(new DeviceId(UUID.randomUUID())); + entityView.setEntityId(device.getId()); entityView.setKeys(new TelemetryEntityView(List.of("test"), null)); entityView.setStartTimeMs(124); entityView.setEndTimeMs(256);