// Previously failed because immutable-map builder threw exception if put same key multiple times, // and the NamedActionWithUrl did not have equals/hashCode @Test public void testSensorWithMultipleOpenUrlActionsRegistered() throws IOException { AttributeSensor<String> sensor = Sensors.newStringSensor("sensor1"); entity.setAttribute(sensor, "http://myval"); RendererHints.register(sensor, RendererHints.namedActionWithUrl()); RendererHints.register(sensor, RendererHints.namedActionWithUrl()); SensorSummary summary = SensorTransformer.sensorSummary(entity, sensor); assertEquals(summary.getLinks().get("action:open"), URI.create("http://myval")); }
@Test public void testEscapesUriForSensorName() throws IOException { Sensor<String> sensor = Sensors.newStringSensor("name with space"); SensorSummary summary = SensorTransformer.sensorSummary(entity, sensor); URI selfUri = summary.getLinks().get("self"); String expectedUri = "/v1/applications/" + entity.getApplicationId() + "/entities/" + entity.getId() + "/sensors/" + "name%20with%20space"; assertEquals(selfUri, URI.create(expectedUri)); }