QuerySensorCreationStrategy implements IResolveDependencyStrategy { @Override public <T> T resolve(final Object... args) throws ResolveDependencyStrategyException { Object statisticsChainId = args[CHAIN_ID_STRATEGY_ARGUMENT_INDEX]; IObject conf = (IObject) args[CONFIG_STRATEGY_ARGUMENT_INDEX]; try { conf.setValue(statisticsChainFieldName, statisticsChainId); conf.setValue(actionFieldName, ACTION_DEPENDENCY); ISchedulerEntry entry = IOC.resolve( Keys.getOrAdd("new scheduler entry"), conf, IOC.resolve(Keys.getOrAdd("query sensors scheduler storage")) ); return (T) new QuerySensorHandle(entry); } catch (ChangeValueException | InvalidArgumentException | ResolutionException e) { throw new ResolveDependencyStrategyException(e); } } QuerySensorCreationStrategy(); @Override T resolve(final Object... args);  }
@Test public void Should_createSchedulerEntryAndSensorHandle() throws Exception { IObject conf = IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.iobject.IObject")); when(newEntryStrategyMock.resolve(same(conf), same(entryStorage))).thenAnswer(invocation -> { assertEquals("stat_chain", conf.getValue(IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "statisticsChain"))); assertEquals("query sensor scheduler action", conf.getValue(IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "action"))); return entryMock; }); ISensorHandle handle = new QuerySensorCreationStrategy().resolve( "stat_chain", conf ); assertNotNull(handle); }