private BatchExtensionDictionnary newSelector(Object... extensions) { ComponentContainer iocContainer = new ComponentContainer(); for (Object extension : extensions) { iocContainer.addSingleton(extension); } return new BatchExtensionDictionnary( iocContainer, mock(DefaultSensorContext.class), mock(SensorOptimizer.class)); }
@Test public void shouldSearchInParentContainers() { Sensor a = new FakeSensor(); Sensor b = new FakeSensor(); Sensor c = new FakeSensor(); ComponentContainer grandParent = new ComponentContainer(); grandParent.addSingleton(a); ComponentContainer parent = grandParent.createChild(); parent.addSingleton(b); ComponentContainer child = parent.createChild(); child.addSingleton(c); BatchExtensionDictionnary dictionnary = new BatchExtensionDictionnary( child, mock(DefaultSensorContext.class), mock(SensorOptimizer.class)); assertThat(dictionnary.select(Sensor.class, null, true, null)).containsOnly(a, b, c); }