StatusCache implements DeployerCommandListener, DeployerSensorListener { public Map<Integer, String> queryStatus(Set<Integer> sensorIDs) { if (sensorIDs == null || sensorIDs.size() == 0) { return null; } log.trace("Query status for sensor IDs : {0}", sensorIDs); Map<Integer, String> statuses = new HashMap<Integer, String>(); for (Integer sensorId : sensorIDs) { statuses.put(sensorId, queryStatus(sensorId)); } log.trace("Returning sensor status map (ID, Value) : {0}", statuses); return statuses; } StatusCache();  StatusCache(ChangedStatusTable cst, EventProcessorChain epc); @Override void onCommandsDeployed(Set<Command> commands); @Override void onSensorsDeployed(Set<Sensor> sensors); void start(); synchronized void registerSensor(Sensor sensor); Sensor getSensor(int id); synchronized void shutdown(); synchronized void update(Event event); Map<Integer, String> queryStatus(Set<Integer> sensorIDs); String queryStatus(Integer sensorID); Event queryStatus(String name); Iterator<Event> getStateSnapshot(); void initializeEventContext(Set<Command> commands); Integer sensorIDFromName(String sensorName);  }
@Test public void testQueryStatus() { StatusCache cache = new StatusCache(); Switch switchEvent = new Switch(1, "test", "foo", Switch.State.ON); cache.update(switchEvent); Assert.assertTrue(cache.queryStatus(1).equals("foo")); }
@Test public void testQueryStatusNonExistingStatus() { StatusCache cache = new StatusCache(); Assert.assertTrue(Sensor.isUnknownSensorValue(cache.queryStatus(0))); }