From c520c83c5032b12f988935d1996c08972b4c05a3 Mon Sep 17 00:00:00 2001 From: Simon Bernard Date: Fri, 8 Dec 2023 16:50:33 +0100 Subject: [PATCH] Fix some WriteSingleValueTest about on object link --- .../tests/write/WriteSingleValueTest.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/write/WriteSingleValueTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/write/WriteSingleValueTest.java index cf5168f4c4..dbe7aabf06 100644 --- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/write/WriteSingleValueTest.java +++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/write/WriteSingleValueTest.java @@ -38,7 +38,6 @@ import org.eclipse.leshan.core.node.LwM2mPath; import org.eclipse.leshan.core.node.LwM2mResource; import org.eclipse.leshan.core.node.LwM2mResourceInstance; -import org.eclipse.leshan.core.node.LwM2mSingleResource; import org.eclipse.leshan.core.node.ObjectLink; import org.eclipse.leshan.core.node.codec.CodecException; import org.eclipse.leshan.core.request.ContentFormat; @@ -303,6 +302,26 @@ public void write_unsigned_integer_resource(ContentFormat contentFormat, Protoco assertThat(resource.getValue()).isEqualTo(expectedValue); } + @TestAllCases + public void write_objlnk_resource(ContentFormat contentFormat, Protocol givenProtocol, + String givenClientEndpointProvider, String givenServerEndpointProvider) throws InterruptedException { + // write resource + ObjectLink expectedValue = new ObjectLink(10245, 1); + WriteResponse response = server.send(currentRegistration, + new WriteRequest(contentFormat, TestLwM2mId.TEST_OBJECT, 0, TestLwM2mId.OBJLINK_VALUE, expectedValue)); + + // verify result + assertThat(response) // + .hasCode(CHANGED) // + .hasValidUnderlyingResponseFor(givenServerEndpointProvider); + + // read resource to check the value changed + ReadResponse readResponse = server.send(currentRegistration, + new ReadRequest(TestLwM2mId.TEST_OBJECT, 0, TestLwM2mId.OBJLINK_VALUE)); + LwM2mResource resource = (LwM2mResource) readResponse.getContent(); + assertThat(resource.getValue()).isEqualTo(expectedValue); + } + @TestAllCases public void can_write_single_instance_objlnk_resource(ContentFormat contentFormat, Protocol givenProtocol, String givenClientEndpointProvider, String givenServerEndpointProvider) throws InterruptedException { @@ -311,7 +330,7 @@ public void can_write_single_instance_objlnk_resource(ContentFormat contentForma // Write objlnk resource WriteResponse response = server.send(currentRegistration, new WriteRequest(contentFormat, - TestLwM2mId.TEST_OBJECT, 0, TestLwM2mId.MULTIPLE_OBJLINK_VALUE, expectedValue)); + TestLwM2mId.TEST_OBJECT, 0, TestLwM2mId.MULTIPLE_OBJLINK_VALUE, 0, expectedValue, Type.OBJLNK)); // Verify Write result assertThat(response) // @@ -320,8 +339,8 @@ public void can_write_single_instance_objlnk_resource(ContentFormat contentForma // Reading back the written OBJLNK value ReadResponse readResponse = server.send(currentRegistration, - new ReadRequest(TestLwM2mId.TEST_OBJECT, 0, TestLwM2mId.MULTIPLE_OBJLINK_VALUE)); - LwM2mSingleResource resource = (LwM2mSingleResource) readResponse.getContent(); + new ReadRequest(TestLwM2mId.TEST_OBJECT, 0, TestLwM2mId.MULTIPLE_OBJLINK_VALUE, 0)); + LwM2mResourceInstance resource = (LwM2mResourceInstance) readResponse.getContent(); assertThat(resource.getValue()).isEqualTo(expectedValue); }