Registration implements Serializable { public Map<Integer, String> getSupportedObject() { Map<Integer, String> objects = supportedObjects.get(); if (objects != null) return objects; supportedObjects.compareAndSet(null, Collections.unmodifiableMap(getSupportedObject(rootPath, objectLinks))); return supportedObjects.get(); } protected  Registration(String id, String endpoint, Identity identity, String lwM2mVersion, Long lifetimeInSec,
            String smsNumber, BindingMode bindingMode, Link[] objectLinks, Date registrationDate, Date lastUpdate,
            Map<String, String> additionalRegistrationAttributes, Map<Integer, String> supportedObjects); String getId(); Date getRegistrationDate(); Identity getIdentity(); InetSocketAddress getSocketAddress(); InetAddress getAddress(); int getPort(); Link[] getObjectLinks(); Link[] getSortedObjectLinks(); Long getLifeTimeInSec(); String getSmsNumber(); String getLwM2mVersion(); BindingMode getBindingMode(); String getRootPath(); String getEndpoint(); Date getLastUpdate(); long getExpirationTimeStamp(); long getExpirationTimeStamp(long gracePeriodInSec); boolean canInitiateConnection(); boolean isAlive(); boolean isAlive(long gracePeriodInSec); Map<String, String> getAdditionalRegistrationAttributes(); boolean usesQueueMode(); String getSupportedVersion(Integer objectid); Map<Integer, String> getSupportedObject(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static Map<Integer, String> getSupportedObject(String rootPath, Link[] objectLinks);  }
@Test public void test_supported_object_given_an_object_link_without_version() { Registration reg = given_a_registration_with_object_link_like("</1/0>,</3/0>"); Map<Integer, String> supportedObject = reg.getSupportedObject(); assertEquals(2, supportedObject.size()); assertEquals(ObjectModel.DEFAULT_VERSION, supportedObject.get(1)); assertEquals(ObjectModel.DEFAULT_VERSION, supportedObject.get(3)); }
@Test public void test_supported_object_given_an_object_link_with_rootpath() { Registration reg = given_a_registration_with_object_link_like("</root>;rt=\"oma.lwm2m\", </root/1/0>,</3/0>"); Map<Integer, String> supportedObject = reg.getSupportedObject(); assertEquals(1, supportedObject.size()); assertEquals(ObjectModel.DEFAULT_VERSION, supportedObject.get(1)); assertNull(supportedObject.get(3)); }
@Test public void test_supported_object_given_an_object_link_with_unquoted_rootpath() { Registration reg = given_a_registration_with_object_link_like("</root>;rt=oma.lwm2m, </root/1/0>,</3/0>"); Map<Integer, String> supportedObject = reg.getSupportedObject(); assertEquals(1, supportedObject.size()); assertEquals(ObjectModel.DEFAULT_VERSION, supportedObject.get(1)); assertNull(supportedObject.get(3)); }
@Test public void test_supported_object_given_an_object_link_with_regexp_rootpath() { Registration reg = given_a_registration_with_object_link_like( "</r(\\d+)oot>;rt=\"oma.lwm2m\", </r(\\d+)oot/1/0>,</3/0>"); Map<Integer, String> supportedObject = reg.getSupportedObject(); assertEquals(1, supportedObject.size()); assertEquals(ObjectModel.DEFAULT_VERSION, supportedObject.get(1)); assertNull(supportedObject.get(3)); }
@Test public void test_supported_object_given_an_object_link_with_version() { Registration reg = given_a_registration_with_object_link_like("</1/0>,</3>;ver=\"1.1\",</3/0>"); Map<Integer, String> supportedObject = reg.getSupportedObject(); assertEquals(2, supportedObject.size()); assertEquals(ObjectModel.DEFAULT_VERSION, supportedObject.get(1)); assertEquals("1.1", supportedObject.get(3)); }
@Test public void test_supported_object_given_an_object_link_with_not_lwm2m_url() { Registration reg = given_a_registration_with_object_link_like( "<text>,</1/text/0/in/path>,empty,</2/O/test/in/path>,</3/0>;ver=\"1.1\",<4/0/0/>"); Map<Integer, String> supportedObject = reg.getSupportedObject(); assertEquals(1, supportedObject.size()); assertEquals("1.1", supportedObject.get(3)); }