SensorResource extends AbstractBrooklynRestResource implements SensorApi { protected Object get(boolean preferJson, String application, String entityToken, String sensorName, Boolean raw) { final Entity entity = brooklyn().getEntity(application, entityToken); AttributeSensor<?> sensor = findSensor(entity, sensorName); if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.SEE_ENTITY, entity)) { throw WebResourceUtils.forbidden("User '%s' is not authorized to see entity '%s'", Entitlements.getEntitlementContext().user(), entity); } if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.SEE_SENSOR, new EntityAndItem<String>(entity, sensor.getName()))) { throw WebResourceUtils.forbidden("User '%s' is not authorized to see entity '%s' sensor '%s'", Entitlements.getEntitlementContext().user(), entity, sensor.getName()); } Object value = entity.getAttribute(sensor); return resolving(value).preferJson(preferJson).asJerseyOutermostReturnValue(true).raw(raw).context(entity).immediately(true).renderAs(sensor).resolve(); }  @Override List<SensorSummary> list(final String application, final String entityToken); @Override Map<String, Object> batchSensorRead(final String application, final String entityToken, final Boolean raw); @Override String getPlain(String application, String entityToken, String sensorName, final Boolean raw); @Override Object get(final String application, final String entityToken, String sensorName, final Boolean raw); @SuppressWarnings({ "rawtypes", "unchecked" }) @Override void setFromMap(String application, String entityToken, Map newValues); @SuppressWarnings({ "rawtypes", "unchecked" }) @Override void set(String application, String entityToken, String sensorName, Object newValue); @Override void delete(String application, String entityToken, String sensorName);  }
@Test(dependsOnMethods = "testBatchSensorRead") public void testBatchSensorReadRaw() throws Exception { Response response = client().path(SENSORS_ENDPOINT + "/current-state") .query("raw", "true") .accept(MediaType.APPLICATION_JSON) .get(); Map<String, ?> currentState = response.readEntity(new GenericType<Map<String,?>>(Map.class) {}); for (String sensor : currentState.keySet()) { if (sensor.equals(SENSOR_NAME)) { assertEquals(currentState.get(sensor), Integer.valueOf(12345)); } } }