lwm2m: conflict resolution
This commit is contained in:
parent
32e3d9050b
commit
221629fb29
@ -24,6 +24,7 @@ import org.thingsboard.server.transport.lwm2m.rpc.AbstractRpcLwM2MIntegrationTes
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.RESOURCE_ID_14;
|
||||||
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.RESOURCE_ID_6;
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.RESOURCE_ID_6;
|
||||||
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.RESOURCE_ID_7;
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.RESOURCE_ID_7;
|
||||||
|
|
||||||
@ -134,6 +135,28 @@ public class RpcLwm2mIntegrationDiscoverWriteAttributesTest extends AbstractRpcL
|
|||||||
assertTrue(rpcActualResult.get("value").asText().contains(expected));
|
assertTrue(rpcActualResult.get("value").asText().contains(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WriteAttributes {"id":"/3/0/14","attributes":{"pmax":100, "pmin":10}}
|
||||||
|
* if not implemented:
|
||||||
|
* {"result":"INTERNAL_SERVER_ERROR","error":"not implemented"}
|
||||||
|
* if implemented:
|
||||||
|
* {"result":"CHANGED"}
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testWriteAttributesResourceWithParametersById_Result_CHANGED() throws Exception {
|
||||||
|
String expectedPath = objectInstanceIdVer_3 + "/" + RESOURCE_ID_14;
|
||||||
|
String expectedValue = "{\"pmax\":100, \"pmin\":10}";
|
||||||
|
String actualResult = sendRPCExecuteWithValueById(expectedPath, expectedValue);
|
||||||
|
ObjectNode rpcActualResult = JacksonUtil.fromString(actualResult, ObjectNode.class);
|
||||||
|
assertEquals(ResponseCode.CHANGED.getName(), rpcActualResult.get("result").asText());
|
||||||
|
// result changed
|
||||||
|
actualResult = sendDiscover(expectedPath);
|
||||||
|
rpcActualResult = JacksonUtil.fromString(actualResult, ObjectNode.class);
|
||||||
|
assertEquals(ResponseCode.CONTENT.getName(), rpcActualResult.get("result").asText());
|
||||||
|
String expected = "</3/0/14>;pmax=100;pmin=10";
|
||||||
|
assertTrue(rpcActualResult.get("value").asText().contains(expected));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <NOTIFICATION> Class Attributes
|
* <NOTIFICATION> Class Attributes
|
||||||
* Minimum/Maximum Period pmin/pmax
|
* Minimum/Maximum Period pmin/pmax
|
||||||
|
|||||||
@ -1,56 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright © 2016-2024 The Thingsboard Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.thingsboard.server.transport.lwm2m.rpc.sql;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
||||||
import org.eclipse.leshan.core.ResponseCode;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.thingsboard.common.util.JacksonUtil;
|
|
||||||
import org.thingsboard.server.transport.lwm2m.rpc.AbstractRpcLwM2MIntegrationTest;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
|
||||||
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.RESOURCE_ID_14;
|
|
||||||
|
|
||||||
|
|
||||||
public class RpcLwm2mIntegrationWriteAttributesTest extends AbstractRpcLwM2MIntegrationTest {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* WriteAttributes {"id":"/3/0/14","attributes":{"pmax":100, "pmin":10}}
|
|
||||||
* if not implemented:
|
|
||||||
* {"result":"INTERNAL_SERVER_ERROR","error":"not implemented"}
|
|
||||||
* if implemented:
|
|
||||||
* {"result":"CHANGED"}
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testWriteAttributesResourceWithParametersById_Result_INTERNAL_SERVER_ERROR() throws Exception {
|
|
||||||
String expectedPath = objectInstanceIdVer_3 + "/" + RESOURCE_ID_14;
|
|
||||||
String expectedValue = "{\"pmax\":100, \"pmin\":10}";
|
|
||||||
String actualResult = sendRPCExecuteWithValueById(expectedPath, expectedValue);
|
|
||||||
ObjectNode rpcActualResult = JacksonUtil.fromString(actualResult, ObjectNode.class);
|
|
||||||
assertEquals(ResponseCode.INTERNAL_SERVER_ERROR.getName(), rpcActualResult.get("result").asText());
|
|
||||||
String expected = "not implemented";
|
|
||||||
String actual = rpcActualResult.get("error").asText();
|
|
||||||
assertTrue(actual.equals(expected));
|
|
||||||
}
|
|
||||||
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user