@Test
public void Should_work()
        throws Exception {

    when(timeMock.currentTimeMillis()).thenReturn(1000L);
    IObject args = IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.iobject.IObject"),
            ("{" +
                    "'period':'PT1M'," +
                    "'strategy':'the sensor strategy'," +
                    "'statisticsChain':'theStatisticsChain'," +
                    "'limit':100" +
                    "}").replace('\'','"'));
    EmbeddedSensorReceiver r = new EmbeddedSensorReceiver(args);
    verify(periodStrategyMock).resolve(eq(1000L), eq(61000L), eq(100L), same(sensorStrategyMock));
    when(timeMock.currentTimeMillis()).thenReturn(2000L);
    r.receive(processors[0]);
    verify(periods[0]).recordProcessor(same(processors[0]), eq(2000L));
    verify(periods[0]).isTimeCompleted(2000L);
    verifyNoMoreInteractions(periods[0]);
    reset(periods[0]);
    when(timeMock.currentTimeMillis()).thenReturn(62000L);
    when(periods[0].isTimeCompleted(62000L)).thenReturn(true);
    when(periods[0].nextPeriod(62000L)).thenReturn(periods[1]);
    r.receive(processors[1]);
    verify(periods[1]).recordProcessor(processors[1], 62000L);
    verify(timerMock).schedule(taskCaptor.capture(), eq(62000L + 1000L));
    verify(messageBusHandlerMock, times(0)).handle(any(), any());
    when(periods[0].createMessage()).thenReturn(mock(IObject.class));
    taskCaptor.getValue().execute();
    verify(messageBusHandlerMock).handle(same(periods[0].createMessage()), eq("theStatisticsChain__0"));
}