lwm2m: added to lwm2mClient a new field: deviceIdStr and removed the deviceId global variable
This commit is contained in:
		
							parent
							
								
									39b17072ca
								
							
						
					
					
						commit
						12d27e2a33
					
				@ -30,6 +30,7 @@ import org.junit.Before;
 | 
			
		||||
import org.mockito.Mockito;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.boot.test.mock.mockito.SpyBean;
 | 
			
		||||
import org.springframework.http.HttpStatus;
 | 
			
		||||
import org.springframework.test.context.TestPropertySource;
 | 
			
		||||
import org.thingsboard.common.util.JacksonUtil;
 | 
			
		||||
import org.thingsboard.common.util.ThingsBoardThreadFactory;
 | 
			
		||||
@ -188,7 +189,7 @@ public abstract class AbstractLwM2MIntegrationTest extends AbstractTransportInte
 | 
			
		||||
 | 
			
		||||
    @After
 | 
			
		||||
    public void after() throws Exception {
 | 
			
		||||
        clientDestroy();
 | 
			
		||||
        this.clientDestroy(true);
 | 
			
		||||
        if (executor != null && !executor.isShutdown()) {
 | 
			
		||||
            executor.shutdownNow();
 | 
			
		||||
        }
 | 
			
		||||
@ -231,9 +232,8 @@ public abstract class AbstractLwM2MIntegrationTest extends AbstractTransportInte
 | 
			
		||||
        getWsClient().waitForReply();
 | 
			
		||||
 | 
			
		||||
        getWsClient().registerWaitForUpdate();
 | 
			
		||||
        createNewClient(security, null, false, endpoint, null, queueMode);
 | 
			
		||||
        deviceId = device.getId().getId().toString();
 | 
			
		||||
        awaitObserveReadAll(0, deviceId);
 | 
			
		||||
        this.createNewClient(security, null, false, endpoint, null, queueMode, device.getId().getId().toString());
 | 
			
		||||
        awaitObserveReadAll(0, lwM2MTestClient.getDeviceIdStr());
 | 
			
		||||
        String msg = getWsClient().waitForUpdate();
 | 
			
		||||
 | 
			
		||||
        EntityDataUpdate update = JacksonUtil.fromString(msg, EntityDataUpdate.class);
 | 
			
		||||
@ -301,18 +301,18 @@ public abstract class AbstractLwM2MIntegrationTest extends AbstractTransportInte
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void createNewClient(Security security, Security securityBs, boolean isRpc,
 | 
			
		||||
                                String endpoint) throws Exception {
 | 
			
		||||
        this.createNewClient(security, securityBs, isRpc, endpoint, null, false);
 | 
			
		||||
                                String endpoint, String deviceIdStr) throws Exception {
 | 
			
		||||
        this.createNewClient(security, securityBs, isRpc, endpoint, null, false, deviceIdStr);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void createNewClient(Security security, Security securityBs, boolean isRpc,
 | 
			
		||||
                                String endpoint, Integer clientDtlsCidLength) throws Exception {
 | 
			
		||||
        this.createNewClient(security, securityBs, isRpc, endpoint, clientDtlsCidLength, false);
 | 
			
		||||
                                String endpoint, Integer clientDtlsCidLength, String deviceIdStr) throws Exception {
 | 
			
		||||
        this.createNewClient(security, securityBs, isRpc, endpoint, clientDtlsCidLength, false, deviceIdStr);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void createNewClient(Security security, Security securityBs, boolean isRpc,
 | 
			
		||||
                                String endpoint, Integer clientDtlsCidLength, boolean queueMode) throws Exception {
 | 
			
		||||
        this.clientDestroy();
 | 
			
		||||
                                String endpoint, Integer clientDtlsCidLength, boolean queueMode, String deviceIdStr) throws Exception {
 | 
			
		||||
        this.clientDestroy(false);
 | 
			
		||||
        lwM2MTestClient = new LwM2MTestClient(this.executor, endpoint);
 | 
			
		||||
 | 
			
		||||
        try (ServerSocket socket = new ServerSocket(0)) {
 | 
			
		||||
@ -321,13 +321,17 @@ public abstract class AbstractLwM2MIntegrationTest extends AbstractTransportInte
 | 
			
		||||
                    this.defaultLwM2mUplinkMsgHandlerTest, this.clientContextTest,
 | 
			
		||||
                    clientDtlsCidLength, queueMode, supportFormatOnly_SenMLJSON_SenMLCBOR);
 | 
			
		||||
        }
 | 
			
		||||
        lwM2MTestClient.setDeviceIdStr(deviceIdStr);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void clientDestroy() {
 | 
			
		||||
    private void clientDestroy(boolean isAfter) {
 | 
			
		||||
        try {
 | 
			
		||||
            if (lwM2MTestClient != null) {
 | 
			
		||||
                if (isAfter) {
 | 
			
		||||
                    sendObserveCancelAllWithAwait(lwM2MTestClient.getDeviceIdStr());
 | 
			
		||||
                    awaitDeleteDevice(lwM2MTestClient.getDeviceIdStr());
 | 
			
		||||
                }
 | 
			
		||||
                lwM2MTestClient.destroy();
 | 
			
		||||
                awaitClientDestroy(lwM2MTestClient.getLeshanClient());
 | 
			
		||||
            }
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            log.error("Failed client Destroy", e);
 | 
			
		||||
@ -395,6 +399,15 @@ public abstract class AbstractLwM2MIntegrationTest extends AbstractTransportInte
 | 
			
		||||
                .atMost(40, TimeUnit.SECONDS)
 | 
			
		||||
                .until(() -> cntObserve == getCntObserveAll(deviceIdStr));
 | 
			
		||||
    }
 | 
			
		||||
    protected  void awaitDeleteDevice(String deviceIdStr) throws Exception {
 | 
			
		||||
        await("Delete device with id:  " + deviceIdStr)
 | 
			
		||||
                .atMost(40, TimeUnit.SECONDS)
 | 
			
		||||
                .until(() -> {
 | 
			
		||||
                    doDelete("/api/device/" + deviceIdStr)
 | 
			
		||||
                            .andExpect(status().isOk());
 | 
			
		||||
                   return HttpStatus.NOT_FOUND.value() == doGet("/api/device/" + deviceIdStr).andReturn().getResponse().getStatus();
 | 
			
		||||
                });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected Integer getCntObserveAll(String deviceIdStr) throws Exception {
 | 
			
		||||
        String actualResult = sendObserveOK("ObserveReadAll", null, deviceIdStr);
 | 
			
		||||
@ -408,7 +421,7 @@ public abstract class AbstractLwM2MIntegrationTest extends AbstractTransportInte
 | 
			
		||||
        String actualResultCancelAll = sendObserveOK("ObserveCancelAll", null, deviceIdStr);
 | 
			
		||||
        ObjectNode rpcActualResultCancelAll = JacksonUtil.fromString(actualResultCancelAll, ObjectNode.class);
 | 
			
		||||
        assertEquals(ResponseCode.CONTENT.getName(), rpcActualResultCancelAll.get("result").asText());
 | 
			
		||||
        awaitObserveReadAll(0, deviceId);
 | 
			
		||||
        awaitObserveReadAll(0, lwM2MTestClient.getDeviceIdStr());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected String sendRpcObserveOkWithResultValue(String method, String params) throws Exception {
 | 
			
		||||
@ -418,7 +431,7 @@ public abstract class AbstractLwM2MIntegrationTest extends AbstractTransportInte
 | 
			
		||||
        return rpcActualResult.get("value").asText();
 | 
			
		||||
    }
 | 
			
		||||
    protected String sendRpcObserveOk(String method, String params) throws Exception {
 | 
			
		||||
        return sendObserveOK(method, params, deviceId);
 | 
			
		||||
        return sendObserveOK(method, params, lwM2MTestClient.getDeviceIdStr());
 | 
			
		||||
    }
 | 
			
		||||
    protected String sendObserveOK(String method, String params, String deviceIdStr) throws Exception {
 | 
			
		||||
        String sendRpcRequest;
 | 
			
		||||
 | 
			
		||||
@ -138,6 +138,7 @@ public class LwM2MTestClient {
 | 
			
		||||
    private LwM2mUplinkMsgHandler defaultLwM2mUplinkMsgHandlerTest;
 | 
			
		||||
    private LwM2mClientContext clientContext;
 | 
			
		||||
    private LwM2mTemperatureSensor lwM2mTemperatureSensor12;
 | 
			
		||||
    private String deviceIdStr;
 | 
			
		||||
 | 
			
		||||
    public void init(Security security, Security securityBs, int port, boolean isRpc,
 | 
			
		||||
                     LwM2mUplinkMsgHandler defaultLwM2mUplinkMsgHandler,
 | 
			
		||||
 | 
			
		||||
@ -55,7 +55,7 @@ public class Ota5LwM2MIntegrationTest extends AbstractOtaLwM2MIntegrationTest {
 | 
			
		||||
        DeviceProfile deviceProfile = createLwm2mDeviceProfile("profileFor" + this.CLIENT_ENDPOINT_WITHOUT_FW_INFO, transportConfiguration);
 | 
			
		||||
        LwM2MDeviceCredentials deviceCredentials = getDeviceCredentialsNoSec(createNoSecClientCredentials(this.CLIENT_ENDPOINT_WITHOUT_FW_INFO));
 | 
			
		||||
        final Device device = createLwm2mDevice(deviceCredentials, this.CLIENT_ENDPOINT_WITHOUT_FW_INFO, deviceProfile.getId());
 | 
			
		||||
        createNewClient(SECURITY_NO_SEC, null, false, this.CLIENT_ENDPOINT_WITHOUT_FW_INFO);
 | 
			
		||||
        createNewClient(SECURITY_NO_SEC, null, false, this.CLIENT_ENDPOINT_WITHOUT_FW_INFO, device.getId().getId().toString());
 | 
			
		||||
        awaitObserveReadAll(0, device.getId().getId().toString());
 | 
			
		||||
 | 
			
		||||
        device.setFirmwareId(createFirmware("5.1", deviceProfile.getId()).getId());
 | 
			
		||||
@ -90,7 +90,7 @@ public class Ota5LwM2MIntegrationTest extends AbstractOtaLwM2MIntegrationTest {
 | 
			
		||||
        DeviceProfile deviceProfile =  createLwm2mDeviceProfile("profileFor" + this.CLIENT_ENDPOINT_OTA5, transportConfiguration);
 | 
			
		||||
        LwM2MDeviceCredentials deviceCredentials = getDeviceCredentialsNoSec(createNoSecClientCredentials(this.CLIENT_ENDPOINT_OTA5));
 | 
			
		||||
        final Device device = createLwm2mDevice(deviceCredentials, this.CLIENT_ENDPOINT_OTA5, deviceProfile.getId());
 | 
			
		||||
        createNewClient(SECURITY_NO_SEC, null, false, this.CLIENT_ENDPOINT_OTA5);
 | 
			
		||||
        createNewClient(SECURITY_NO_SEC, null, false, this.CLIENT_ENDPOINT_OTA5, device.getId().getId().toString());
 | 
			
		||||
        awaitObserveReadAll(5, device.getId().getId().toString());
 | 
			
		||||
 | 
			
		||||
        device.setFirmwareId(createFirmware("fw.v.1.5.0-update", deviceProfile.getId()).getId());
 | 
			
		||||
 | 
			
		||||
@ -54,7 +54,7 @@ public class Ota9LwM2MIntegrationTest extends AbstractOtaLwM2MIntegrationTest {
 | 
			
		||||
        DeviceProfile deviceProfile = createLwm2mDeviceProfile("profileFor" + this.CLIENT_ENDPOINT_OTA9, transportConfiguration);
 | 
			
		||||
        LwM2MDeviceCredentials deviceCredentials = getDeviceCredentialsNoSec(createNoSecClientCredentials(this.CLIENT_ENDPOINT_OTA9));
 | 
			
		||||
        final Device device = createLwm2mDevice(deviceCredentials, this.CLIENT_ENDPOINT_OTA9, deviceProfile.getId());
 | 
			
		||||
        createNewClient(SECURITY_NO_SEC, null, false, this.CLIENT_ENDPOINT_OTA9);
 | 
			
		||||
        createNewClient(SECURITY_NO_SEC, null, false, this.CLIENT_ENDPOINT_OTA9, device.getId().getId().toString());
 | 
			
		||||
        awaitObserveReadAll(4, device.getId().getId().toString());
 | 
			
		||||
 | 
			
		||||
        device.setSoftwareId(createSoftware(deviceProfile.getId()).getId());
 | 
			
		||||
 | 
			
		||||
@ -121,7 +121,7 @@ public abstract class AbstractRpcLwM2MIntegrationTest extends AbstractLwM2MInteg
 | 
			
		||||
 | 
			
		||||
    protected void initRpc(int typeConfigProfile) throws Exception {
 | 
			
		||||
        String endpoint = DEVICE_ENDPOINT_RPC_PREF + endpointSequence.incrementAndGet();
 | 
			
		||||
        createNewClient(SECURITY_NO_SEC, null, true, endpoint);
 | 
			
		||||
        createNewClient(SECURITY_NO_SEC, null, true, endpoint, null);
 | 
			
		||||
        expectedObjects = ConcurrentHashMap.newKeySet();
 | 
			
		||||
        expectedObjectIdVers = ConcurrentHashMap.newKeySet();
 | 
			
		||||
        expectedInstances = ConcurrentHashMap.newKeySet();
 | 
			
		||||
@ -232,8 +232,7 @@ public abstract class AbstractRpcLwM2MIntegrationTest extends AbstractLwM2MInteg
 | 
			
		||||
 | 
			
		||||
        LwM2MDeviceCredentials deviceCredentials = getDeviceCredentialsNoSec(createNoSecClientCredentials(endpoint));
 | 
			
		||||
        final Device device = createLwm2mDevice(deviceCredentials, endpoint, deviceProfile.getId());
 | 
			
		||||
        deviceId = device.getId().getId().toString();
 | 
			
		||||
 | 
			
		||||
        lwM2MTestClient.setDeviceIdStr(device.getId().getId().toString());
 | 
			
		||||
        lwM2MTestClient.start(true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -315,7 +315,7 @@ public class RpcLwm2MIntegrationObserveCompositeTest extends AbstractRpcLwM2MInt
 | 
			
		||||
        assertEquals(ResponseCode.CONTENT.getName(), rpcActualResult.get("result").asText());
 | 
			
		||||
        assertEquals("1", rpcActualResult.get("value").asText());
 | 
			
		||||
 | 
			
		||||
        assertEquals(0, (Object) getCntObserveAll(deviceId));
 | 
			
		||||
        assertEquals(0, (Object) getCntObserveAll(lwM2MTestClient.getDeviceIdStr()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@ -335,7 +335,7 @@ public class RpcLwm2MIntegrationObserveCompositeTest extends AbstractRpcLwM2MInt
 | 
			
		||||
        String actualResult = sendCompositeRPCByIds("ObserveComposite", expectedIds);
 | 
			
		||||
        ObjectNode rpcActualResult = JacksonUtil.fromString(actualResult, ObjectNode.class);
 | 
			
		||||
        assertEquals(ResponseCode.CONTENT.getName(), rpcActualResult.get("result").asText());
 | 
			
		||||
        awaitObserveReadAll(1, deviceId);
 | 
			
		||||
        awaitObserveReadAll(1, lwM2MTestClient.getDeviceIdStr());
 | 
			
		||||
 | 
			
		||||
        // ObserveCompositeCancel two
 | 
			
		||||
        expectedIds = "[\"" + objectInstanceIdVer_5 + "\", \"" + expectedIdVer19_1_0_0 + "\"]";
 | 
			
		||||
@ -418,7 +418,7 @@ public class RpcLwm2MIntegrationObserveCompositeTest extends AbstractRpcLwM2MInt
 | 
			
		||||
        updateAttrTelemetryResourceAtLeastOnceAfterAction(initAttrTelemetryAtCount_19_0_2, idVer_19_0_2);
 | 
			
		||||
 | 
			
		||||
        // 2 - "ObserveReadAll": No update of all resources we are observing - after "ObserveReadCancelAll"
 | 
			
		||||
        sendObserveCancelAllWithAwait(deviceId);
 | 
			
		||||
        sendObserveCancelAllWithAwait(lwM2MTestClient.getDeviceIdStr());
 | 
			
		||||
        updateRegAtLeastOnceAfterAction();
 | 
			
		||||
        actualResultReadAll = sendCompositeRPCByKeys("ObserveReadAll", null);
 | 
			
		||||
        rpcActualResultReadAll = JacksonUtil.fromString(actualResultReadAll, ObjectNode.class);
 | 
			
		||||
@ -479,17 +479,17 @@ public class RpcLwm2MIntegrationObserveCompositeTest extends AbstractRpcLwM2MInt
 | 
			
		||||
        } else {
 | 
			
		||||
            sendRpcRequest = "{\"method\": \"" + method + "\", \"params\": {\"id\": \"" + params + "\"}}";
 | 
			
		||||
        }
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, sendRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), sendRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String sendCompositeRPCByIds(String method, String paths) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"" + method + "\", \"params\": {\"ids\":" + paths + "}}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String sendCompositeRPCByKeys(String method, String keys) throws Exception {
 | 
			
		||||
        String sendRpcRequest = "{\"method\": \"" + method + "\", \"params\": {\"keys\":" + keys + "}}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, sendRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), sendRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void updateAttrTelemetryAllAtLeastOnceAfterAction(long initialInvocationCount) {
 | 
			
		||||
 | 
			
		||||
@ -127,7 +127,7 @@ public class RpcLwm2mIntegrationCreateTest extends AbstractRpcLwM2MIntegrationTe
 | 
			
		||||
 | 
			
		||||
    private String sendRPCreateById(String path, String value) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"Create\", \"params\": {\"id\": \"" + path + "\", \"value\": " + value + " }}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -90,7 +90,7 @@ public class RpcLwm2mIntegrationDeleteTest extends AbstractRpcLwM2MIntegrationTe
 | 
			
		||||
 | 
			
		||||
    private String sendRPCDeleteById(String path) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"Delete\", \"params\": {\"id\": \"" + path  + "\"}}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -61,7 +61,7 @@ public class RpcLwm2mIntegrationDiscoverTest extends AbstractRpcLwM2MIntegration
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testDiscoverAll_Return_CONTENT_LinksAllObjectsAllInstancesOfClient() throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\":\"DiscoverAll\"}";
 | 
			
		||||
        String actualResult = doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        String actualResult = doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        ObjectNode rpcActualResult = JacksonUtil.fromString(actualResult, ObjectNode.class);
 | 
			
		||||
        assertEquals(ResponseCode.CONTENT.getName(), rpcActualResult.get("result").asText());
 | 
			
		||||
        JsonNode rpcActualValue = JacksonUtil.toJsonNode(rpcActualResult.get("value").asText());
 | 
			
		||||
@ -194,7 +194,7 @@ public class RpcLwm2mIntegrationDiscoverTest extends AbstractRpcLwM2MIntegration
 | 
			
		||||
 | 
			
		||||
    private String sendDiscover(String path) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"Discover\", \"params\": {\"id\": \"" + path + "\"}}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private  String convertObjectIdToVerId(String path, String ver) {
 | 
			
		||||
 | 
			
		||||
@ -164,11 +164,11 @@ public class RpcLwm2mIntegrationDiscoverWriteAttributesTest extends AbstractRpcL
 | 
			
		||||
 | 
			
		||||
    private String sendRPCExecuteWithValueById(String path, String value) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"WriteAttributes\", \"params\": {\"id\": \"" + path + "\", \"attributes\": " + value + " }}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String sendDiscover(String path) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"Discover\", \"params\": {\"id\": \"" + path + "\"}}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -174,12 +174,12 @@ public class RpcLwm2mIntegrationExecuteTest extends AbstractRpcLwM2MIntegrationT
 | 
			
		||||
 | 
			
		||||
    private String sendRPCExecuteById(String path) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"Execute\", \"params\": {\"id\": \"" + path + "\"}}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String sendRPCExecuteWithValueById(String path, Object value) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"Execute\", \"params\": {\"id\": \"" + path + "\", \"value\": " + value + " }}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -45,13 +45,13 @@ public class RpcLwm2mIntegrationObserveTest extends AbstractRpcLwM2MIntegrationO
 | 
			
		||||
 | 
			
		||||
    @Before
 | 
			
		||||
    public void setupObserveTest() throws Exception {
 | 
			
		||||
        awaitObserveReadAll(4, deviceId);
 | 
			
		||||
        awaitObserveReadAll(4,lwM2MTestClient.getDeviceIdStr());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testObserveReadAll_Count_4_CancelAll_Count_0_Ok() throws Exception {
 | 
			
		||||
        sendObserveCancelAllWithAwait(deviceId);
 | 
			
		||||
        sendObserveCancelAllWithAwait(lwM2MTestClient.getDeviceIdStr());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@ -61,7 +61,7 @@ public class RpcLwm2mIntegrationObserveTest extends AbstractRpcLwM2MIntegrationO
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testObserveOneResource_Result_CONTENT_Value_Count_3_After_Cancel_Count_2() throws Exception {
 | 
			
		||||
        long initSendTelemetryAtCount = countSendParametersOnThingsboardTelemetryResource(RESOURCE_ID_NAME_3_9);
 | 
			
		||||
        sendObserveCancelAllWithAwait(deviceId);
 | 
			
		||||
        sendObserveCancelAllWithAwait(lwM2MTestClient.getDeviceIdStr());
 | 
			
		||||
        sendRpcObserveWithContainsLwM2mSingleResource(idVer_3_0_9);
 | 
			
		||||
        updateRegAtLeastOnceAfterAction();
 | 
			
		||||
        long lastSendTelemetryAtCount = countSendParametersOnThingsboardTelemetryResource(RESOURCE_ID_NAME_3_9);
 | 
			
		||||
@ -74,7 +74,7 @@ public class RpcLwm2mIntegrationObserveTest extends AbstractRpcLwM2MIntegrationO
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testObserveOneObjectInstance_Result_CONTENT_Value_Count_3_After_Cancel_Count_2() throws Exception {
 | 
			
		||||
        sendObserveCancelAllWithAwait(deviceId);
 | 
			
		||||
        sendObserveCancelAllWithAwait(lwM2MTestClient.getDeviceIdStr());
 | 
			
		||||
        String idVer_3_0 = objectInstanceIdVer_3;
 | 
			
		||||
        sendRpcObserveWithContainsLwM2mSingleResource(idVer_3_0);
 | 
			
		||||
 | 
			
		||||
@ -89,7 +89,7 @@ public class RpcLwm2mIntegrationObserveTest extends AbstractRpcLwM2MIntegrationO
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testObserveOneObject_Result_CONTENT_Value_Count_3_After_Cancel_Count_2() throws Exception {
 | 
			
		||||
        sendObserveCancelAllWithAwait(deviceId);
 | 
			
		||||
        sendObserveCancelAllWithAwait(lwM2MTestClient.getDeviceIdStr());
 | 
			
		||||
        String idVer_3_0 = objectInstanceIdVer_3;
 | 
			
		||||
        sendRpcObserveWithContainsLwM2mSingleResource(idVer_3_0);
 | 
			
		||||
 | 
			
		||||
@ -199,7 +199,7 @@ public class RpcLwm2mIntegrationObserveTest extends AbstractRpcLwM2MIntegrationO
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testObserves_OverlappedPaths_FirstResource_SecondObjectOrInstance() throws Exception {
 | 
			
		||||
        sendObserveCancelAllWithAwait(deviceId);
 | 
			
		||||
        sendObserveCancelAllWithAwait(lwM2MTestClient.getDeviceIdStr());
 | 
			
		||||
        // "19/0/0"
 | 
			
		||||
        sendRpcObserveOkWithResultValue("Observe", idVer_19_0_0);
 | 
			
		||||
        // PreviousObservation "19/0/0" change to CurrentObservation "19" - object
 | 
			
		||||
@ -247,7 +247,7 @@ public class RpcLwm2mIntegrationObserveTest extends AbstractRpcLwM2MIntegrationO
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testObserveResource_ObserveCancelResource_Result_CONTENT_Count_1() throws Exception {
 | 
			
		||||
        sendObserveCancelAllWithAwait(deviceId);
 | 
			
		||||
        sendObserveCancelAllWithAwait(lwM2MTestClient.getDeviceIdStr());
 | 
			
		||||
 | 
			
		||||
        String actualValuesReadAll = sendRpcObserveReadAllWithResult(idVer_3_0_9);
 | 
			
		||||
        assertEquals(1, actualValuesReadAll.split(",").length);
 | 
			
		||||
@ -265,7 +265,7 @@ public class RpcLwm2mIntegrationObserveTest extends AbstractRpcLwM2MIntegrationO
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testObserveObject_ObserveCancelOneResource_Result_INTERNAL_SERVER_ERROR_Than_Cancel_ObserveObject_Result_CONTENT_Count_1() throws Exception {
 | 
			
		||||
        sendObserveCancelAllWithAwait(deviceId);
 | 
			
		||||
        sendObserveCancelAllWithAwait(lwM2MTestClient.getDeviceIdStr());
 | 
			
		||||
 | 
			
		||||
        String actualValuesReadAll = sendRpcObserveReadAllWithResult(objectIdVer_3);
 | 
			
		||||
        assertEquals(1, actualValuesReadAll.split(",").length);
 | 
			
		||||
@ -292,7 +292,7 @@ public class RpcLwm2mIntegrationObserveTest extends AbstractRpcLwM2MIntegrationO
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testObserveResource_ObserveCancelObject_Result_CONTENT_Count_1() throws Exception {
 | 
			
		||||
        sendObserveCancelAllWithAwait(deviceId);
 | 
			
		||||
        sendObserveCancelAllWithAwait(lwM2MTestClient.getDeviceIdStr());
 | 
			
		||||
        sendRpcObserveWithWithTwoResource(idVer_3_0_0, idVer_3_0_9);
 | 
			
		||||
        String rpcActualResul = sendRpcObserveOkWithResultValue("ObserveReadAll", null);
 | 
			
		||||
        assertEquals(2, rpcActualResul.split(",").length);
 | 
			
		||||
@ -320,7 +320,7 @@ public class RpcLwm2mIntegrationObserveTest extends AbstractRpcLwM2MIntegrationO
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testObserveResource_Update_AfterUpdateRegistration() throws Exception {
 | 
			
		||||
        sendObserveCancelAllWithAwait(deviceId);
 | 
			
		||||
        sendObserveCancelAllWithAwait(lwM2MTestClient.getDeviceIdStr());
 | 
			
		||||
 | 
			
		||||
        int cntUpdate = 3;
 | 
			
		||||
        verify(defaultUplinkMsgHandlerTest, timeout(50000).atLeast(cntUpdate))
 | 
			
		||||
 | 
			
		||||
@ -62,7 +62,7 @@ public class RpcLwm2mIntegrationReadCollectedValueTest extends AbstractRpcLwM2MI
 | 
			
		||||
        AtomicReference<ObjectNode> actualValues = new AtomicReference<>();
 | 
			
		||||
        await().atMost(40, SECONDS).until(() -> {
 | 
			
		||||
            actualValues.set(doGetAsync(
 | 
			
		||||
                    "/api/plugins/telemetry/DEVICE/" + deviceId + "/values/timeseries?keys="
 | 
			
		||||
                    "/api/plugins/telemetry/DEVICE/" + lwM2MTestClient.getDeviceIdStr() + "/values/timeseries?keys="
 | 
			
		||||
                            + RESOURCE_ID_NAME_3303_12_5700
 | 
			
		||||
                            + "&startTs=" + (RESOURCE_ID_3303_12_5700_TS_0 - RESOURCE_ID_VALUE_3303_12_5700_DELTA_TS)
 | 
			
		||||
                            + "&endTs=" + (RESOURCE_ID_3303_12_5700_TS_1 + RESOURCE_ID_VALUE_3303_12_5700_DELTA_TS)
 | 
			
		||||
@ -93,6 +93,6 @@ public class RpcLwm2mIntegrationReadCollectedValueTest extends AbstractRpcLwM2MI
 | 
			
		||||
 | 
			
		||||
    private String sendRPCById(String path) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"Read\", \"params\": {\"id\": \"" + path + "\"}}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -232,21 +232,21 @@ public class RpcLwm2mIntegrationReadTest extends AbstractRpcLwM2MIntegrationTest
 | 
			
		||||
 | 
			
		||||
    private String sendRPCById(String path) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"Read\", \"params\": {\"id\": \"" + path + "\"}}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String sendRPCByKey(String key) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"Read\", \"params\": {\"key\": \"" + key + "\"}}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String sendCompositeRPCByIds(String paths) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"ReadComposite\", \"params\": {\"ids\":" + paths + "}}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String sendCompositeRPCByKeys(String keys) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"ReadComposite\", \"params\": {\"keys\":" + keys + "}}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -88,11 +88,11 @@ public class RpcLwm2mIntegrationWriteCborTest extends AbstractRpcLwM2MIntegratio
 | 
			
		||||
 | 
			
		||||
    private String sendRPCWriteObjectById(String method, String path, Object value) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"" + method + "\", \"params\": {\"id\": \"" + path + "\", \"value\": " + value + " }}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String sendRPCReadById(String id) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"Read\", \"params\": {\"id\": \"" + id + "\"}}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -346,31 +346,31 @@ public class RpcLwm2mIntegrationWriteTest extends AbstractRpcLwM2MIntegrationTes
 | 
			
		||||
 | 
			
		||||
    private String sendRPCWriteStringById(String method, String path, String value) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"" + method + "\", \"params\": {\"id\": \"" + path + "\", \"value\": \"" + value + "\" }}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String sendRPCWriteObjectById(String method, String path, Object value) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"" + method + "\", \"params\": {\"id\": \"" + path + "\", \"value\": " + value + " }}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String sendRPCReadById(String id) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"Read\", \"params\": {\"id\": \"" + id + "\"}}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String sendRPCWriteByKey(String method, String key, String value) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"" + method + "\", \"params\": {\"key\": \"" + key + "\", \"value\": \"" + value + "\" }}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String sendRPCReadByKey(String key) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"Read\", \"params\": {\"key\": \"" + key + "\"}}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String sendCompositeRPC(String nodes) throws Exception {
 | 
			
		||||
        String setRpcRequest = "{\"method\": \"WriteComposite\", \"params\": {\"nodes\":" + nodes + "}}";
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + deviceId, setRpcRequest, String.class, status().isOk());
 | 
			
		||||
        return doPostAsync("/api/plugins/rpc/twoway/" + lwM2MTestClient.getDeviceIdStr(), setRpcRequest, String.class, status().isOk());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -207,7 +207,7 @@ public abstract class AbstractSecurityLwM2MIntegrationTest extends AbstractLwM2M
 | 
			
		||||
                                       boolean isStartLw) throws Exception {
 | 
			
		||||
        DeviceProfile deviceProfile = createLwm2mDeviceProfile("profileFor" + endpoint, transportConfiguration);
 | 
			
		||||
        final Device device = createLwm2mDevice(deviceCredentials, endpoint, deviceProfile.getId());
 | 
			
		||||
        createNewClient(security, securityBs, true, endpoint);
 | 
			
		||||
        createNewClient(security, securityBs, true, endpoint, device.getId().getId().toString());
 | 
			
		||||
        lwM2MTestClient.start(isStartLw);
 | 
			
		||||
        if (isAwaitObserveReadAll) {
 | 
			
		||||
            awaitObserveReadAll(0, device.getId().getId().toString());
 | 
			
		||||
@ -253,7 +253,7 @@ public abstract class AbstractSecurityLwM2MIntegrationTest extends AbstractLwM2M
 | 
			
		||||
        DeviceProfile deviceProfile = createLwm2mDeviceProfile("profileFor" + endpoint, transportConfiguration);
 | 
			
		||||
        final Device device = createLwm2mDevice(deviceCredentials, endpoint, deviceProfile.getId());
 | 
			
		||||
        String deviceIdStr = device.getId().getId().toString();
 | 
			
		||||
        createNewClient(security, securityBs, true, endpoint);
 | 
			
		||||
        createNewClient(security, securityBs, true, endpoint, deviceIdStr);
 | 
			
		||||
        lwM2MTestClient.start(true);
 | 
			
		||||
        awaitObserveReadAll(0, deviceIdStr);
 | 
			
		||||
        await(awaitAlias)
 | 
			
		||||
 | 
			
		||||
@ -20,6 +20,7 @@ import org.eclipse.californium.elements.config.Configuration;
 | 
			
		||||
import org.eclipse.leshan.client.californium.endpoint.CaliforniumClientEndpoint;
 | 
			
		||||
import org.eclipse.leshan.client.californium.endpoint.CaliforniumClientEndpointsProvider;
 | 
			
		||||
import org.junit.Assert;
 | 
			
		||||
import org.thingsboard.server.common.data.Device;
 | 
			
		||||
import org.thingsboard.server.common.data.DeviceProfile;
 | 
			
		||||
import org.thingsboard.server.dao.service.DaoSqlTest;
 | 
			
		||||
import org.thingsboard.server.transport.lwm2m.security.AbstractSecurityLwM2MIntegrationTest;
 | 
			
		||||
@ -50,8 +51,8 @@ public abstract class AbstractSecurityLwM2MIntegrationDtlsCidLengthTest extends
 | 
			
		||||
    protected void basicTestConnectionDtlsCidLength(Integer clientDtlsCidLength,
 | 
			
		||||
                                                    Integer serverDtlsCidLength) throws Exception {
 | 
			
		||||
        DeviceProfile deviceProfile = createLwm2mDeviceProfile("profileFor" + clientEndpoint, transportConfiguration);
 | 
			
		||||
        createLwm2mDevice(deviceCredentials, clientEndpoint, deviceProfile.getId());
 | 
			
		||||
        createNewClient(security, null, true, clientEndpoint, clientDtlsCidLength);
 | 
			
		||||
        final Device device = createLwm2mDevice(deviceCredentials, clientEndpoint, deviceProfile.getId());
 | 
			
		||||
        createNewClient(security, null, true, clientEndpoint, clientDtlsCidLength, device.getId().getId().toString());
 | 
			
		||||
        lwM2MTestClient.start(true);
 | 
			
		||||
        await(awaitAlias)
 | 
			
		||||
                .atMost(40, TimeUnit.SECONDS)
 | 
			
		||||
 | 
			
		||||
@ -23,6 +23,7 @@ import org.eclipse.leshan.server.registration.RegistrationStore;
 | 
			
		||||
import org.eclipse.leshan.server.registration.RegistrationUpdate;
 | 
			
		||||
import org.junit.Assert;
 | 
			
		||||
import org.springframework.boot.test.mock.mockito.SpyBean;
 | 
			
		||||
import org.thingsboard.server.common.data.Device;
 | 
			
		||||
import org.thingsboard.server.common.data.DeviceProfile;
 | 
			
		||||
import org.thingsboard.server.common.data.device.profile.Lwm2mDeviceProfileTransportConfiguration;
 | 
			
		||||
import org.thingsboard.server.dao.service.DaoSqlTest;
 | 
			
		||||
@ -61,8 +62,8 @@ public abstract class AbstractLwM2MIntegrationDiffPortTest extends AbstractSecur
 | 
			
		||||
        }).when(registrationStoreTest).updateRegistration(any(RegistrationUpdate.class));
 | 
			
		||||
 | 
			
		||||
        DeviceProfile deviceProfile = createLwm2mDeviceProfile("profileFor" + clientEndpoint, transportConfiguration);
 | 
			
		||||
        createLwm2mDevice(deviceCredentials, clientEndpoint, deviceProfile.getId());
 | 
			
		||||
        createNewClient(security, null, true, clientEndpoint);
 | 
			
		||||
        final Device device = createLwm2mDevice(deviceCredentials, clientEndpoint, deviceProfile.getId());
 | 
			
		||||
        createNewClient(security, null, true, clientEndpoint, device.getId().getId().toString());
 | 
			
		||||
        lwM2MTestClient.start(true);
 | 
			
		||||
        await(awaitAlias)
 | 
			
		||||
                .atMost(40, TimeUnit.SECONDS)
 | 
			
		||||
 | 
			
		||||
@ -45,6 +45,7 @@ import org.thingsboard.server.common.data.ResourceType;
 | 
			
		||||
import org.thingsboard.server.common.data.StringUtils;
 | 
			
		||||
import org.thingsboard.server.common.data.Tenant;
 | 
			
		||||
import org.thingsboard.server.common.data.device.data.PowerMode;
 | 
			
		||||
import org.thingsboard.server.common.data.exception.TenantNotFoundException;
 | 
			
		||||
import org.thingsboard.server.common.data.id.CustomerId;
 | 
			
		||||
import org.thingsboard.server.common.data.id.DeviceId;
 | 
			
		||||
import org.thingsboard.server.common.data.id.DeviceProfileId;
 | 
			
		||||
@ -1100,16 +1101,21 @@ public class DefaultTransportService extends TransportActivityManager implements
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void sendToCore(TenantId tenantId, EntityId entityId, ToCoreMsg msg, UUID routingKey, TransportServiceCallback<Void> callback) {
 | 
			
		||||
        TopicPartitionInfo tpi = partitionService.resolve(ServiceType.TB_CORE, tenantId, entityId);
 | 
			
		||||
        if (log.isTraceEnabled()) {
 | 
			
		||||
        // TODO remove before PR
 | 
			
		||||
        try {
 | 
			
		||||
            TopicPartitionInfo tpi = partitionService.resolve(ServiceType.TB_CORE, tenantId, entityId);
 | 
			
		||||
            log.trace("[{}][{}] Pushing to topic {} message {}", tenantId, entityId, tpi.getFullTopicName(), msg);
 | 
			
		||||
            if (log.isTraceEnabled()) {
 | 
			
		||||
                log.trace("[{}][{}] Pushing to topic {} message {}", tenantId, entityId, tpi.getFullTopicName(), msg);
 | 
			
		||||
            }
 | 
			
		||||
            TransportTbQueueCallback transportTbQueueCallback = callback != null ?
 | 
			
		||||
                    new TransportTbQueueCallback(callback) : null;
 | 
			
		||||
            tbCoreProducerStats.incrementTotal();
 | 
			
		||||
            StatsCallback wrappedCallback = new StatsCallback(transportTbQueueCallback, tbCoreProducerStats);
 | 
			
		||||
            tbCoreMsgProducer.send(tpi, new TbProtoQueueMsg<>(routingKey, msg), wrappedCallback);
 | 
			
		||||
        } catch (TenantNotFoundException e) {
 | 
			
		||||
            log.trace("Failed to send message to core. Tenant with ID [{}] not found in the database. Message delivery aborted.", tenantId, e);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        TransportTbQueueCallback transportTbQueueCallback = callback != null ?
 | 
			
		||||
                new TransportTbQueueCallback(callback) : null;
 | 
			
		||||
        tbCoreProducerStats.incrementTotal();
 | 
			
		||||
        StatsCallback wrappedCallback = new StatsCallback(transportTbQueueCallback, tbCoreProducerStats);
 | 
			
		||||
        tbCoreMsgProducer.send(tpi, new TbProtoQueueMsg<>(routingKey, msg), wrappedCallback);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void sendToRuleEngine(TenantId tenantId, DeviceId deviceId, CustomerId customerId, TransportProtos.SessionInfoProto sessionInfo, JsonObject json,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user