use of nl.teslanet.mule.connectors.coap.api.DiscoveredResource in project mule-coap-connector by teslanet-nl.
the class DiscoveryTest method testWellKnownCore.
@Test
public void testWellKnownCore() throws Exception {
String flowName = "discover";
Event result = flowRunner(flowName).withPayload("nothing_important").run();
Message response = result.getMessage();
@SuppressWarnings("unchecked") HashMap<String, DiscoveredResource> links = linkMap((Set<DiscoveredResource>) response.getPayload().getValue());
assertEquals("wrong number of weblinks", 8, links.size());
DiscoveredResource link = links.get("/.well-known/core");
assertNotNull("/.well-known/core is missing", link);
}
use of nl.teslanet.mule.connectors.coap.api.DiscoveredResource in project mule-coap-connector by teslanet-nl.
the class DiscoveryTest method testObs.
@Test
public void testObs() throws Exception {
String flowName = "discover";
Event result = flowRunner(flowName).withPayload("nothing_important").run();
Message response = result.getMessage();
@SuppressWarnings("unchecked") HashMap<String, DiscoveredResource> links = linkMap((Set<DiscoveredResource>) response.getPayload().getValue());
DiscoveredResource link = links.get("/service/resource_with_obs");
assertNotNull("/service/resource_with_obs is missing", link);
assertTrue("obs not true", link.isObs());
// check other attributes are not there
assertEquals("ct length unexpected", 0, link.getCt().size());
assertEquals("if length unexpected", 0, link.getIf().size());
assertEquals("rt length unexpected", 0, link.getRt().size());
assertEquals("sz unexpected", "", link.getSz());
assertNull("title unexpected", link.getTitle());
}
use of nl.teslanet.mule.connectors.coap.api.DiscoveredResource in project mule-coap-connector by teslanet-nl.
the class DiscoveryTest method testIf.
@Test
public void testIf() throws Exception {
String flowName = "discover";
Event result = flowRunner(flowName).withPayload("nothing_important").run();
Message response = result.getMessage();
@SuppressWarnings("unchecked") HashMap<String, DiscoveredResource> links = linkMap((Set<DiscoveredResource>) response.getPayload().getValue());
DiscoveredResource link = links.get("/service/resource_with_if");
assertNotNull("/service/resource_with_if is missing", link);
assertEquals("wrong number of ifdesc", 2, link.getIf().size());
assertEquals("ifdesc does not contain 0", "if1", link.getIf().get(0));
assertEquals("ifdesc does not contain 41", "if2", link.getIf().get(1));
// check other attributes are not there
assertEquals("ct length unexpected", 0, link.getCt().size());
assertFalse("obs unexpected", link.isObs());
assertEquals("rt length unexpected", 0, link.getRt().size());
assertEquals("sz unexpected", "", link.getSz());
assertNull("title unexpected", link.getTitle());
}
use of nl.teslanet.mule.connectors.coap.api.DiscoveredResource in project mule-coap-connector by teslanet-nl.
the class DiscoveryTest method testRt.
@Test
public void testRt() throws Exception {
String flowName = "discover";
Event result = flowRunner(flowName).withPayload("nothing_important").run();
Message response = result.getMessage();
@SuppressWarnings("unchecked") HashMap<String, DiscoveredResource> links = linkMap((Set<DiscoveredResource>) response.getPayload().getValue());
DiscoveredResource link = links.get("/service/resource_with_rt");
assertNotNull("/service/resource_with_rt is missing", link);
assertEquals("wrong number of rt", 2, link.getRt().size());
assertEquals("rt does not contain rt1", "rt1", link.getRt().get(0));
assertEquals("rt does not contain rt2", "rt2", link.getRt().get(1));
// check other attributes are not there
assertEquals("ct length unexpected", 0, link.getCt().size());
assertEquals("if length unexpected", 0, link.getIf().size());
assertFalse("obs unexpected", link.isObs());
assertEquals("sz unexpected", "", link.getSz());
assertNull("title unexpected", link.getTitle());
}
use of nl.teslanet.mule.connectors.coap.api.DiscoveredResource in project mule-coap-connector by teslanet-nl.
the class DiscoveryTest method testSz.
@Test
public void testSz() throws Exception {
String flowName = "discover";
Event result = flowRunner(flowName).withPayload("nothing_important").run();
Message response = result.getMessage();
@SuppressWarnings("unchecked") HashMap<String, DiscoveredResource> links = linkMap((Set<DiscoveredResource>) response.getPayload().getValue());
DiscoveredResource link = links.get("/service/resource_with_sz");
assertNotNull("/service/resource_with_sz is missing", link);
assertEquals("sz has wrong value", "123456", link.getSz());
// check other attributes are not there
assertEquals("ct length unexpected", 0, link.getCt().size());
assertEquals("if length unexpected", 0, link.getIf().size());
assertFalse("obs unexpected", link.isObs());
assertEquals("rt length unexpected", 0, link.getRt().size());
assertNull("title unexpected", link.getTitle());
}
Aggregations