SensorParserConfigServiceImpl implements SensorParserConfigService { @Override public Map<String, SensorParserConfig> getAll() throws RestException { Map<String, SensorParserConfig> sensorParserConfigs = new HashMap<>(); List<String> sensorNames = getAllTypes(); for (String name : sensorNames) { SensorParserConfig config = findOne(name); if(config != null) { sensorParserConfigs.put(name, config); } } return sensorParserConfigs; } @Autowired  SensorParserConfigServiceImpl(ObjectMapper objectMapper, CuratorFramework client,
      GrokService grokService, ConfigurationsCache cache); @Override SensorParserConfig save(String name, SensorParserConfig sensorParserConfig); @Override SensorParserConfig findOne(String name); @Override Map<String, SensorParserConfig> getAll(); @Override boolean delete(String name); @Override List<String> getAllTypes(); @Override Map<String, String> getAvailableParsers(); @Override Map<String, String> reloadAvailableParsers(); @Override JSONObject parseMessage(ParseMessageRequest parseMessageRequest);  }
@Test public void getAllShouldProperlyReturnSensorParserConfigs() throws Exception { final SensorParserConfig broSensorParserConfig = getTestBroSensorParserConfig(); final SensorParserConfig squidSensorParserConfig = getTestSquidSensorParserConfig(); ParserConfigurations configs = new ParserConfigurations(){ @Override public Map<String, Object> getConfigurations() { return ImmutableMap.of(ParserConfigurations.getKey("bro"), broSensorParserConfig ,ParserConfigurations.getKey("squid"), squidSensorParserConfig ); } }; when(cache.get( eq(ParserConfigurations.class))) .thenReturn(configs); assertEquals(new HashMap<String, Object>() {{ put("bro", getTestBroSensorParserConfig()); put("squid", getTestSquidSensorParserConfig()); }}, sensorParserConfigService.getAll()); }