Search in sources :

Example 1 with ObjectEnabler

use of org.eclipse.leshan.client.resource.ObjectEnabler in project leshan by eclipse.

the class LinkFormatHelperTest method encode_client_description_with_version_2_0_no_instances.

@Test
public void encode_client_description_with_version_2_0_no_instances() {
    List<LwM2mObjectEnabler> objectEnablers = new ArrayList<>();
    Map<Integer, LwM2mInstanceEnabler> instancesMap = new HashMap<>();
    objectEnablers.add(new ObjectEnabler(6, getVersionedObjectModel(6, "2.0"), instancesMap, null));
    Link[] links = LinkFormatHelper.getClientDescription(objectEnablers, null);
    String strLinks = Link.serialize(links);
    assertEquals("</>;rt=\"oma.lwm2m\", </6>;ver=\"2.0\"", strLinks);
}
Also used : LwM2mInstanceEnabler(org.eclipse.leshan.client.resource.LwM2mInstanceEnabler) LwM2mObjectEnabler(org.eclipse.leshan.client.resource.LwM2mObjectEnabler) LwM2mObjectEnabler(org.eclipse.leshan.client.resource.LwM2mObjectEnabler) ObjectEnabler(org.eclipse.leshan.client.resource.ObjectEnabler) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Link(org.eclipse.leshan.Link) Test(org.junit.Test)

Example 2 with ObjectEnabler

use of org.eclipse.leshan.client.resource.ObjectEnabler in project leshan by eclipse.

the class LinkFormatHelperTest method encode_client_description_with_version_1_0.

@Test
public void encode_client_description_with_version_1_0() {
    List<LwM2mObjectEnabler> objectEnablers = new ArrayList<>();
    Map<Integer, LwM2mInstanceEnabler> instancesMap = new HashMap<>();
    instancesMap.put(0, new BaseInstanceEnabler());
    objectEnablers.add(new ObjectEnabler(6, getObjectModel(6), instancesMap, null));
    Link[] links = LinkFormatHelper.getClientDescription(objectEnablers, null);
    String strLinks = Link.serialize(links);
    assertEquals("</>;rt=\"oma.lwm2m\", </6/0>", strLinks);
}
Also used : LwM2mInstanceEnabler(org.eclipse.leshan.client.resource.LwM2mInstanceEnabler) LwM2mObjectEnabler(org.eclipse.leshan.client.resource.LwM2mObjectEnabler) LwM2mObjectEnabler(org.eclipse.leshan.client.resource.LwM2mObjectEnabler) ObjectEnabler(org.eclipse.leshan.client.resource.ObjectEnabler) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BaseInstanceEnabler(org.eclipse.leshan.client.resource.BaseInstanceEnabler) Link(org.eclipse.leshan.Link) Test(org.junit.Test)

Example 3 with ObjectEnabler

use of org.eclipse.leshan.client.resource.ObjectEnabler in project leshan by eclipse.

the class RegistrationTest method fail_to_create_client_with_same_object_twice.

// TODO not really a registration test
@Test(expected = IllegalArgumentException.class)
public void fail_to_create_client_with_same_object_twice() {
    ObjectEnabler objectEnabler = new ObjectEnabler(1, null, new HashMap<Integer, LwM2mInstanceEnabler>(), null);
    ObjectEnabler objectEnabler2 = new ObjectEnabler(1, null, new HashMap<Integer, LwM2mInstanceEnabler>(), null);
    ArrayList<LwM2mObjectEnabler> objects = new ArrayList<>();
    objects.add(objectEnabler);
    objects.add(objectEnabler2);
    helper.client = new LeshanClientBuilder("test").setObjects(objects).build();
}
Also used : LwM2mInstanceEnabler(org.eclipse.leshan.client.resource.LwM2mInstanceEnabler) LwM2mObjectEnabler(org.eclipse.leshan.client.resource.LwM2mObjectEnabler) LwM2mObjectEnabler(org.eclipse.leshan.client.resource.LwM2mObjectEnabler) ObjectEnabler(org.eclipse.leshan.client.resource.ObjectEnabler) LeshanClientBuilder(org.eclipse.leshan.client.californium.LeshanClientBuilder) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 4 with ObjectEnabler

use of org.eclipse.leshan.client.resource.ObjectEnabler in project leshan by eclipse.

the class LinkFormatHelperTest method encode_client_description_with_version_2_0.

@Test
public void encode_client_description_with_version_2_0() {
    List<LwM2mObjectEnabler> objectEnablers = new ArrayList<>();
    Map<Integer, LwM2mInstanceEnabler> instancesMap = new HashMap<>();
    instancesMap.put(0, new BaseInstanceEnabler());
    instancesMap.put(1, new BaseInstanceEnabler());
    objectEnablers.add(new ObjectEnabler(6, getVersionedObjectModel(6, "2.0"), instancesMap, null));
    Link[] links = LinkFormatHelper.getClientDescription(objectEnablers, null);
    String strLinks = Link.serialize(links);
    assertEquals("</>;rt=\"oma.lwm2m\", </6>;ver=\"2.0\", </6/0>, </6/1>", strLinks);
}
Also used : LwM2mInstanceEnabler(org.eclipse.leshan.client.resource.LwM2mInstanceEnabler) LwM2mObjectEnabler(org.eclipse.leshan.client.resource.LwM2mObjectEnabler) LwM2mObjectEnabler(org.eclipse.leshan.client.resource.LwM2mObjectEnabler) ObjectEnabler(org.eclipse.leshan.client.resource.ObjectEnabler) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BaseInstanceEnabler(org.eclipse.leshan.client.resource.BaseInstanceEnabler) Link(org.eclipse.leshan.Link) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)4 LwM2mInstanceEnabler (org.eclipse.leshan.client.resource.LwM2mInstanceEnabler)4 LwM2mObjectEnabler (org.eclipse.leshan.client.resource.LwM2mObjectEnabler)4 ObjectEnabler (org.eclipse.leshan.client.resource.ObjectEnabler)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 Link (org.eclipse.leshan.Link)3 BaseInstanceEnabler (org.eclipse.leshan.client.resource.BaseInstanceEnabler)2 LeshanClientBuilder (org.eclipse.leshan.client.californium.LeshanClientBuilder)1