SensorParserGroupServiceImpl implements SensorParserGroupService { @Override public SensorParserGroup findOne(String name) { return getAll().get(name); } @Autowired  SensorParserGroupServiceImpl(ConfigurationsCache cache, GlobalConfigService globalConfigService, SensorParserConfigService sensorParserConfigService); @Override SensorParserGroup save(SensorParserGroup sensorParserGroup); @Override SensorParserGroup findOne(String name); @Override Map<String, SensorParserGroup> getAll(); @Override boolean delete(String name);  }
@Test public void shouldFindSensorParserGroup() { ParserConfigurations parserConfigurations = mock(ParserConfigurations.class); SensorParserGroup group1 = new SensorParserGroup(); group1.setName("group1"); group1.setDescription("group1 description"); group1.setSensors(Collections.singleton("group1Sensor")); SensorParserGroup group2 = new SensorParserGroup(); group2.setName("group2"); group2.setDescription("group2 description"); group2.setSensors(Collections.singleton("group2Sensor")); when(parserConfigurations.getSensorParserGroups()).thenReturn(new HashMap<String, SensorParserGroup>() {{ put("group1", group1); put("group2", group2); }}); when(cache.get(ParserConfigurations.class)).thenReturn(parserConfigurations); assertEquals(group2, sensorParserGroupService.findOne("group2")); }