QuerySensorSchedulerAction implements ISchedulerAction { @Override public void init(final ISchedulerEntry entry, final IObject args) throws SchedulerActionInitializationException { try { Object queryExecutorDependency = args.getValue(queryExecutorFieldName); IQueryExecutor queryExecutor = IOC.resolve(IOC.resolve(IOC.getKeyForKeyStorage(), queryExecutorDependency)); queryExecutor.init(entry, args); entry.getState().setValue(queryExecutorFieldName, queryExecutorDependency); entry.getState().setValue(statisticsChainFieldName, args.getValue(statisticsChainFieldName)); } catch (ResolutionException | ReadValueException | ChangeValueException | InvalidArgumentException | QueryExecutorInitializationException e) { throw new SchedulerActionInitializationException("Error occurred initializing query sensor scheduler action.", e); } } QuerySensorSchedulerAction(); @Override void init(final ISchedulerEntry entry, final IObject args); @Override void execute(final ISchedulerEntry entry);  }
@Test public void Should_initializeEntryState() throws Exception { IObject args = IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.iobject.IObject"), ("{" + "'queryExecutor':'that query executor'," + "'statisticsChain':'the_statistics_chain'" + "}").replace('\'','"')); new QuerySensorSchedulerAction().init(schedulerEntryMock, args); verify(queryExecutorMock).init(same(schedulerEntryMock), same(args)); assertEquals("that query executor", schedulerEntryMock.getState() .getValue(IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "queryExecutor"))); assertEquals("the_statistics_chain", schedulerEntryMock.getState() .getValue(IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "statisticsChain"))); }