CheckpointFibonacciRepeatStrategy extends CheckpointRepeatStrategy { @Override public void init(final ISchedulerEntry entry, final IObject args) throws SchedulingStrategyExecutionException { try { Duration interval = Duration.parse((String) args.getValue(baseIntervalFieldName)); entry.getState().setValue(baseIntervalFieldName, interval.toString()); entry.getState().setValue(number1FieldName, 0); entry.getState().setValue(number2FieldName, 1); } catch (ReadValueException | ChangeValueException | InvalidArgumentException e) { throw new SchedulingStrategyExecutionException("Error occurred initializing scheduling strategy.", e); } super.init(entry, args); } CheckpointFibonacciRepeatStrategy(); @Override void init(final ISchedulerEntry entry, final IObject args);  }
@Test public void Should_initializeEntryState() throws Exception { ISchedulingStrategy strategy = new CheckpointFibonacciRepeatStrategy(); makeEntry("{}"); strategy.init(entryMock, makeArgs("{" + "'times':2," + "'baseInterval':'PT3H'" + "}")); verify(entryMock).save(); verify(entryMock).scheduleNext(anyLong()); assertEquals("PT3H", entryState.getValue(IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "baseInterval"))); assertEquals("PT3H", entryState.getValue(IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "postRestoreDelay"))); assertEquals("PT3H", entryState.getValue(IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "postCompletionDelay"))); assertEquals(2, entryState.getValue(IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "times"))); assertEquals(1, entryState.getValue(IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "remainingTimes"))); assertEquals(1, entryState.getValue(IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "number1"))); assertEquals(1, entryState.getValue(IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "number2"))); }