LinkFormatHelper { public static Link[] getBootstrapObjectDescription(LwM2mObjectEnabler objectEnabler) { List<Link> links = new ArrayList<>(); Map<String, String> rootAttributes = new HashMap<>(); rootAttributes.put("lwm2m", ObjectModel.DEFAULT_VERSION); links.add(new Link("/", rootAttributes)); links.addAll(getBootstrapObjectDescriptionWithoutRoot(objectEnabler)); return links.toArray(new Link[] {}); } private  LinkFormatHelper(); static Link[] getClientDescription(Collection<LwM2mObjectEnabler> objectEnablers, String rootPath); static Link[] getBootstrapClientDescription(Collection<LwM2mObjectEnabler> objectEnablers); static Link[] getObjectDescription(LwM2mObjectEnabler objectEnabler, String root); static Link[] getBootstrapObjectDescription(LwM2mObjectEnabler objectEnabler); static Link[] getInstanceDescription(LwM2mObjectEnabler objectEnabler, int instanceId, String root); static Link getResourceDescription(LwM2mObjectEnabler objectEnabler, int instanceId, int resourceId,
            String root);  }
@Test public void encode_bootstrap_object_with_version_and_no_instance() { Map<Integer, LwM2mInstanceEnabler> instancesMap = new HashMap<>(); ObjectEnabler objectEnabler = new ObjectEnabler(3, getVersionedObjectModel(3, "2.0"), instancesMap, null, ContentFormat.DEFAULT); Link[] links = LinkFormatHelper.getBootstrapObjectDescription(objectEnabler); String strLinks = Link.serialize(links); assertEquals("</>;lwm2m=1.0,</3>;ver=2.0", strLinks); }
@Test public void encode_bootstrap_object_with_version_and_instance() { Map<Integer, LwM2mInstanceEnabler> instancesMap = new HashMap<>(); instancesMap.put(0, new BaseInstanceEnabler()); ObjectEnabler objectEnabler = new ObjectEnabler(3, getVersionedObjectModel(3, "2.0"), instancesMap, null, ContentFormat.DEFAULT); Link[] links = LinkFormatHelper.getBootstrapObjectDescription(objectEnabler); String strLinks = Link.serialize(links); assertEquals("</>;lwm2m=1.0,</3>;ver=2.0,</3/0>", strLinks); }
@Test public void encode_bootstrap_server_object() { Map<Integer, LwM2mInstanceEnabler> instancesMap = new HashMap<>(); instancesMap.put(0, new Server(333, 120, BindingMode.UQ, false)); ObjectEnabler objectEnabler = new ObjectEnabler(1, getObjectModel(1), instancesMap, null, ContentFormat.DEFAULT); Link[] links = LinkFormatHelper.getBootstrapObjectDescription(objectEnabler); String strLinks = Link.serialize(links); assertEquals("</>;lwm2m=1.0,</1/0>;ssid=333", strLinks); }
@Test public void encode_bootstrap_server_object_with_version() { Map<Integer, LwM2mInstanceEnabler> instancesMap = new HashMap<>(); instancesMap.put(0, new Server(333, 120, BindingMode.UQ, false)); ObjectEnabler objectEnabler = new ObjectEnabler(1, getVersionedObjectModel(1, "2.0"), instancesMap, null, ContentFormat.DEFAULT); Link[] links = LinkFormatHelper.getBootstrapObjectDescription(objectEnabler); String strLinks = Link.serialize(links); assertEquals("</>;lwm2m=1.0,</1>;ver=2.0,</1/0>;ssid=333", strLinks); }
@Test public void encode_bootstrap_security_object() { Map<Integer, LwM2mInstanceEnabler> instancesMap = new HashMap<>(); instancesMap.put(0, Security.noSec("coap: instancesMap.put(1, Security.noSecBootstap("coap: instancesMap.put(2, Security.noSec("coap: instancesMap.put(3, Security.noSec("coap: ObjectEnabler objectEnabler = new ObjectEnabler(0, getObjectModel(0), instancesMap, null, ContentFormat.DEFAULT); Link[] links = LinkFormatHelper.getBootstrapObjectDescription(objectEnabler); String strLinks = Link.serialize(links); assertEquals("</>;lwm2m=1.0,</0/0>;ssid=111,</0/1>,</0/2>;ssid=222,</0/3>;ssid=333", strLinks); }
@Test public void encode_bootstrap_object() { Map<Integer, LwM2mInstanceEnabler> instancesMap = new HashMap<>(); instancesMap.put(0, new BaseInstanceEnabler()); ObjectEnabler objectEnabler = new ObjectEnabler(3, getObjectModel(3), instancesMap, null, ContentFormat.DEFAULT); Link[] links = LinkFormatHelper.getBootstrapObjectDescription(objectEnabler); String strLinks = Link.serialize(links); assertEquals("</>;lwm2m=1.0,</3/0>", strLinks); }