EmbeddedSensorObservationPeriod implements IEmbeddedSensorObservationPeriod { @Override public IObject createMessage() throws ResolutionException, ChangeValueException, InvalidArgumentException, EmbeddedSensorStrategyException { IObject message = IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.iobject.IObject")); message.setValue(periodStartFieldName, periodStart); message.setValue(periodEndFieldName, periodEnd); message.setValue(dataFieldName, extractData()); return message; } EmbeddedSensorObservationPeriod(final long start, final long end, final long nItems, final IEmbeddedSensorStrategy<TState> strategy); @Override EmbeddedSensorObservationPeriod<TState> nextPeriod(final long inclTime); @Override boolean isTimeCompleted(final long time); @Override boolean recordProcessor(final IMessageProcessor mp, final long time); @Override IObject createMessage();  }
@Test public void Should_createMessage() throws Exception { IEmbeddedSensorObservationPeriod esop = new EmbeddedSensorObservationPeriod<>(100, 200, 4, strategyMock); Collection res = mock(Collection.class); when(strategyMock.extractPeriod(same(states[0]))).thenReturn(res); IObject msg = esop.createMessage(); assertEquals(100L, ((Long) msg.getValue(IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "periodStart"))).longValue()); assertEquals(200L, ((Long) msg.getValue(IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "periodEnd"))).longValue()); assertSame(res, msg.getValue(IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "data"))); }