Fix Equals And HashCode issue for Device/Asset/EntityView Info
This commit is contained in:
parent
7a385e34d1
commit
89efe12c45
@ -689,6 +689,10 @@ public class DeviceController extends BaseController {
|
||||
@RequestParam int page,
|
||||
@ApiParam(value = DEVICE_TYPE_DESCRIPTION)
|
||||
@RequestParam(required = false) String type,
|
||||
@ApiParam(value = DEVICE_PROFILE_ID_PARAM_DESCRIPTION)
|
||||
@RequestParam(required = false) String deviceProfileId,
|
||||
@ApiParam(value = DEVICE_ACTIVE_PARAM_DESCRIPTION)
|
||||
@RequestParam(required = false) Boolean active,
|
||||
@ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION)
|
||||
@RequestParam(required = false) String textSearch,
|
||||
@ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = DEVICE_SORT_PROPERTY_ALLOWABLE_VALUES)
|
||||
@ -707,8 +711,11 @@ public class DeviceController extends BaseController {
|
||||
DeviceInfoFilter.DeviceInfoFilterBuilder filter = DeviceInfoFilter.builder();
|
||||
filter.tenantId(tenantId);
|
||||
filter.edgeId(edgeId);
|
||||
filter.active(active);
|
||||
if (type != null && type.trim().length() > 0) {
|
||||
filter.type(type);
|
||||
} else if (deviceProfileId != null && deviceProfileId.length() > 0) {
|
||||
filter.deviceProfileId(new DeviceProfileId(toUUID(deviceProfileId)));
|
||||
}
|
||||
return checkNotNull(deviceService.findDeviceInfosByFilter(filter.build(), pageLink));
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@ import org.thingsboard.server.common.data.Customer;
|
||||
import org.thingsboard.server.common.data.Dashboard;
|
||||
import org.thingsboard.server.common.data.DataConstants;
|
||||
import org.thingsboard.server.common.data.Device;
|
||||
import org.thingsboard.server.common.data.DeviceInfo;
|
||||
import org.thingsboard.server.common.data.DeviceProfile;
|
||||
import org.thingsboard.server.common.data.OtaPackageInfo;
|
||||
import org.thingsboard.server.common.data.SaveOtaPackageInfoRequest;
|
||||
@ -322,9 +323,9 @@ abstract public class AbstractEdgeTest extends AbstractControllerTest {
|
||||
UUID deviceUUID = new UUID(deviceUpdateMsg.getIdMSB(), deviceUpdateMsg.getIdLSB());
|
||||
Device device = doGet("/api/device/" + deviceUUID, Device.class);
|
||||
Assert.assertNotNull(device);
|
||||
List<Device> edgeDevices = doGetTypedWithPageLink("/api/edge/" + edge.getUuidId() + "/devices?",
|
||||
new TypeReference<PageData<Device>>() {}, new PageLink(100)).getData();
|
||||
Assert.assertTrue(edgeDevices.contains(device));
|
||||
List<DeviceInfo> edgeDevices = doGetTypedWithPageLink("/api/edge/" + edge.getUuidId() + "/devices?",
|
||||
new TypeReference<PageData<DeviceInfo>>() {}, new PageLink(100)).getData();
|
||||
Assert.assertTrue(edgeDevices.stream().map(DeviceInfo::getId).anyMatch(id -> id.equals(device.getId())));
|
||||
|
||||
testAutoGeneratedCodeByProtobuf(deviceUpdateMsg);
|
||||
}
|
||||
@ -487,10 +488,10 @@ abstract public class AbstractEdgeTest extends AbstractControllerTest {
|
||||
}
|
||||
|
||||
protected Device findDeviceByName(String deviceName) throws Exception {
|
||||
List<Device> edgeDevices = doGetTypedWithPageLink("/api/edge/" + edge.getUuidId() + "/devices?",
|
||||
new TypeReference<PageData<Device>>() {
|
||||
List<DeviceInfo> edgeDevices = doGetTypedWithPageLink("/api/edge/" + edge.getUuidId() + "/devices?",
|
||||
new TypeReference<PageData<DeviceInfo>>() {
|
||||
}, new PageLink(100)).getData();
|
||||
Optional<Device> foundDevice = edgeDevices.stream().filter(d -> d.getName().equals(deviceName)).findAny();
|
||||
Optional<DeviceInfo> foundDevice = edgeDevices.stream().filter(d -> d.getName().equals(deviceName)).findAny();
|
||||
Assert.assertTrue(foundDevice.isPresent());
|
||||
Device device = foundDevice.get();
|
||||
Assert.assertEquals(deviceName, device.getName());
|
||||
|
||||
@ -25,11 +25,13 @@ import io.netty.handler.codec.mqtt.MqttQoS;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.thingsboard.common.util.JacksonUtil;
|
||||
import org.thingsboard.server.common.data.Customer;
|
||||
import org.thingsboard.server.common.data.DataConstants;
|
||||
import org.thingsboard.server.common.data.Device;
|
||||
import org.thingsboard.server.common.data.DeviceInfo;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.OtaPackageInfo;
|
||||
import org.thingsboard.server.common.data.StringUtils;
|
||||
@ -46,11 +48,14 @@ import org.thingsboard.server.common.data.id.EntityId;
|
||||
import org.thingsboard.server.common.data.ota.OtaPackageType;
|
||||
import org.thingsboard.server.common.data.page.PageData;
|
||||
import org.thingsboard.server.common.data.page.PageLink;
|
||||
import org.thingsboard.server.common.data.relation.EntityRelation;
|
||||
import org.thingsboard.server.common.data.relation.RelationTypeGroup;
|
||||
import org.thingsboard.server.common.data.security.DeviceCredentials;
|
||||
import org.thingsboard.server.common.data.security.DeviceCredentialsType;
|
||||
import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration;
|
||||
import org.thingsboard.server.common.msg.session.FeatureType;
|
||||
import org.thingsboard.server.common.transport.adaptor.JsonConverter;
|
||||
import org.thingsboard.server.dao.relation.RelationService;
|
||||
import org.thingsboard.server.gen.edge.v1.AttributesRequestMsg;
|
||||
import org.thingsboard.server.gen.edge.v1.DeviceCredentialsRequestMsg;
|
||||
import org.thingsboard.server.gen.edge.v1.DeviceCredentialsUpdateMsg;
|
||||
@ -378,18 +383,18 @@ abstract public class BaseDeviceEdgeTest extends AbstractEdgeTest {
|
||||
sendAttributesRequestAndVerify(device, DataConstants.SHARED_SCOPE, "{\"key2\":\"value2\"}",
|
||||
"key2", "value2");
|
||||
|
||||
doDelete("/api/plugins/telemetry/DEVICE/" + device.getUuidId() + "/" + DataConstants.SERVER_SCOPE, "keys","key1, inactivityTimeout");
|
||||
doDelete("/api/plugins/telemetry/DEVICE/" + device.getUuidId() + "/" + DataConstants.SERVER_SCOPE, "keys", "key1, inactivityTimeout");
|
||||
doDelete("/api/plugins/telemetry/DEVICE/" + device.getUuidId() + "/" + DataConstants.SHARED_SCOPE, "keys", "key2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendDeleteDeviceOnEdgeToCloud() throws Exception {
|
||||
Device device = saveDeviceOnCloudAndVerifyDeliveryToEdge();
|
||||
Device savedDevice = saveDeviceOnCloudAndVerifyDeliveryToEdge();
|
||||
UplinkMsg.Builder upLinkMsgBuilder = UplinkMsg.newBuilder();
|
||||
DeviceUpdateMsg.Builder deviceDeleteMsgBuilder = DeviceUpdateMsg.newBuilder();
|
||||
deviceDeleteMsgBuilder.setMsgType(UpdateMsgType.ENTITY_DELETED_RPC_MESSAGE);
|
||||
deviceDeleteMsgBuilder.setIdMSB(device.getId().getId().getMostSignificantBits());
|
||||
deviceDeleteMsgBuilder.setIdLSB(device.getId().getId().getLeastSignificantBits());
|
||||
deviceDeleteMsgBuilder.setIdMSB(savedDevice.getId().getId().getMostSignificantBits());
|
||||
deviceDeleteMsgBuilder.setIdLSB(savedDevice.getId().getId().getLeastSignificantBits());
|
||||
testAutoGeneratedCodeByProtobuf(deviceDeleteMsgBuilder);
|
||||
|
||||
upLinkMsgBuilder.addDeviceUpdateMsg(deviceDeleteMsgBuilder.build());
|
||||
@ -398,12 +403,12 @@ abstract public class BaseDeviceEdgeTest extends AbstractEdgeTest {
|
||||
edgeImitator.expectResponsesAmount(1);
|
||||
edgeImitator.sendUplinkMsg(upLinkMsgBuilder.build());
|
||||
Assert.assertTrue(edgeImitator.waitForResponses());
|
||||
device = doGet("/api/device/" + device.getUuidId(), Device.class);
|
||||
Assert.assertNotNull(device);
|
||||
List<Device> edgeDevices = doGetTypedWithPageLink("/api/edge/" + edge.getUuidId() + "/devices?",
|
||||
new TypeReference<PageData<Device>>() {
|
||||
DeviceInfo deviceInfo = doGet("/api/device/info/" + savedDevice.getUuidId(), DeviceInfo.class);
|
||||
Assert.assertNotNull(deviceInfo);
|
||||
List<DeviceInfo> edgeDevices = doGetTypedWithPageLink("/api/edge/" + edge.getUuidId() + "/devices?",
|
||||
new TypeReference<PageData<DeviceInfo>>() {
|
||||
}, new PageLink(100)).getData();
|
||||
Assert.assertFalse(edgeDevices.contains(device));
|
||||
Assert.assertFalse(edgeDevices.contains(deviceInfo));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -455,7 +460,8 @@ abstract public class BaseDeviceEdgeTest extends AbstractEdgeTest {
|
||||
Assert.assertEquals(timeseriesValue, timeseries.get(timeseriesKey).get(0).get("value"));
|
||||
|
||||
String attributeValuesUrl = "/api/plugins/telemetry/DEVICE/" + device.getId() + "/values/attributes/" + DataConstants.SERVER_SCOPE;
|
||||
List<Map<String, String>> attributes = doGetAsyncTyped(attributeValuesUrl, new TypeReference<>() {});
|
||||
List<Map<String, String>> attributes = doGetAsyncTyped(attributeValuesUrl, new TypeReference<>() {
|
||||
});
|
||||
|
||||
Assert.assertEquals(3, attributes.size());
|
||||
|
||||
@ -599,7 +605,8 @@ abstract public class BaseDeviceEdgeTest extends AbstractEdgeTest {
|
||||
.atMost(10, TimeUnit.SECONDS)
|
||||
.until(() -> {
|
||||
String urlTemplate = "/api/plugins/telemetry/DEVICE/" + device.getId() + "/keys/attributes/" + scope;
|
||||
List<String> actualKeys = doGetAsyncTyped(urlTemplate, new TypeReference<>() {});
|
||||
List<String> actualKeys = doGetAsyncTyped(urlTemplate, new TypeReference<>() {
|
||||
});
|
||||
return actualKeys != null && !actualKeys.isEmpty() && actualKeys.contains(expectedKey);
|
||||
});
|
||||
|
||||
@ -656,7 +663,8 @@ abstract public class BaseDeviceEdgeTest extends AbstractEdgeTest {
|
||||
|
||||
private Map<String, List<Map<String, String>>> loadDeviceTimeseries(Device device, String timeseriesKey) throws Exception {
|
||||
return doGetAsyncTyped("/api/plugins/telemetry/DEVICE/" + device.getUuidId() + "/values/timeseries?keys=" + timeseriesKey,
|
||||
new TypeReference<>() {});
|
||||
new TypeReference<>() {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -713,7 +721,8 @@ abstract public class BaseDeviceEdgeTest extends AbstractEdgeTest {
|
||||
.atMost(10, TimeUnit.SECONDS)
|
||||
.until(() -> {
|
||||
String urlTemplate = "/api/plugins/telemetry/DEVICE/" + device.getId() + "/keys/timeseries";
|
||||
List<String> actualKeys = doGetAsyncTyped(urlTemplate, new TypeReference<>() {});
|
||||
List<String> actualKeys = doGetAsyncTyped(urlTemplate, new TypeReference<>() {
|
||||
});
|
||||
return actualKeys != null && !actualKeys.isEmpty() && actualKeys.contains("temperature");
|
||||
});
|
||||
|
||||
|
||||
@ -18,12 +18,16 @@ package org.thingsboard.server.common.data;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.thingsboard.server.common.data.id.DeviceId;
|
||||
|
||||
@ApiModel
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DeviceInfo extends Device {
|
||||
|
||||
private static final long serialVersionUID = -3004579925090663691L;
|
||||
|
||||
@ApiModelProperty(position = 13, value = "Title of the Customer that owns the device.", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
|
||||
private String customerTitle;
|
||||
@ApiModelProperty(position = 14, value = "Indicates special 'Public' Customer that is auto-generated to use the devices on public dashboards.", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
|
||||
|
||||
@ -17,9 +17,11 @@ package org.thingsboard.server.common.data;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.thingsboard.server.common.data.id.EntityViewId;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class EntityViewInfo extends EntityView {
|
||||
|
||||
@ApiModelProperty(position = 12, value = "Title of the Customer that owns the entity view.", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
|
||||
|
||||
@ -18,12 +18,16 @@ package org.thingsboard.server.common.data.asset;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.thingsboard.server.common.data.id.AssetId;
|
||||
|
||||
@ApiModel
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class AssetInfo extends Asset {
|
||||
|
||||
private static final long serialVersionUID = -4094528227011066194L;
|
||||
|
||||
@ApiModelProperty(position = 10, value = "Title of the Customer that owns the asset.", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
|
||||
private String customerTitle;
|
||||
@ApiModelProperty(position = 11, value = "Indicates special 'Public' Customer that is auto-generated to use the assets on public dashboards.", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user