use of org.eclipse.leshan.core.node.ObjectLink in project leshan by eclipse.
the class WriteTest method can_write_single_instance_objlnk_resource_in_tlv.
@Test
public void can_write_single_instance_objlnk_resource_in_tlv() throws InterruptedException {
ObjectLink data = new ObjectLink(10245, 1);
// Write objlnk resource in TLV format
WriteResponse response = helper.server.send(helper.getCurrentRegistration(), new WriteRequest(ContentFormat.TLV, IntegrationTestHelper.TEST_OBJECT_ID, 0, IntegrationTestHelper.OBJLNK_SINGLE_INSTANCE_RESOURCE_ID, data));
// Verify Write result
assertEquals(ResponseCode.CHANGED, response.getCode());
assertNotNull(response.getCoapResponse());
assertThat(response.getCoapResponse(), is(instanceOf(Response.class)));
// Reading back the written OBJLNK value
ReadResponse readResponse = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(IntegrationTestHelper.TEST_OBJECT_ID, 0, IntegrationTestHelper.OBJLNK_SINGLE_INSTANCE_RESOURCE_ID));
LwM2mSingleResource resource = (LwM2mSingleResource) readResponse.getContent();
// verify read value
assertEquals(((ObjectLink) resource.getValue()).getObjectId(), 10245);
assertEquals(((ObjectLink) resource.getValue()).getObjectInstanceId(), 1);
}
use of org.eclipse.leshan.core.node.ObjectLink in project leshan by eclipse.
the class LwM2mNodeDecoderTest method assertObj66Instance.
private void assertObj66Instance(LwM2mObject oObject) {
assertEquals(66, oObject.getId());
assertEquals(2, oObject.getInstances().size());
// instance 1
LwM2mObjectInstance oInstance0 = oObject.getInstance(0);
assertEquals("myService 1", oInstance0.getResource(0).getValue());
assertEquals("Internet.15.234", oInstance0.getResource(1).getValue());
assertEquals(new ObjectLink(67, 0), oInstance0.getResource(2).getValue());
// instance 2
LwM2mObjectInstance oInstance2 = oObject.getInstance(1);
assertEquals("myService 2", oInstance2.getResource(0).getValue());
}
use of org.eclipse.leshan.core.node.ObjectLink in project leshan by eclipse.
the class LwM2mNodeDecoderTest method assertObj65Instance.
private void assertObj65Instance(LwM2mObjectInstance instance) {
assertEquals(0, instance.getId());
// instance 1
assertEquals(2, instance.getResource(0).getValues().size());
assertEquals(new ObjectLink(66, 0), instance.getResource(0).getValue(0));
assertEquals(new ObjectLink(66, 1), instance.getResource(0).getValue(1));
assertEquals("8613800755500", instance.getResource(1).getValue());
assertEquals(305419896L, instance.getResource(2).getValue());
}
Aggregations