@Test
public void Should_recoverSequenceFromDumpRestoringDumpedChains()
        throws Exception {

    IReceiverChain chainA = mock(IReceiverChain.class), chainB = mock(IReceiverChain.class);
    IObject seqDump = IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.iobject.IObject"),
            ("{" +
                    "'maxDepth':3," +
                    "'chainsStack':['a','b','a']," +
                    "'stepsStack':[1,4,2]," +
                    "'chainsDump':{" +
                    "   'a': {'this-is':'chain-a dump'}" +
                    "}" +
                    "}").replace('\'','"'));
    when(chainStorageMock.resolve("b")).thenReturn(chainB);
    when(chainStorageMock.resolve("a")).thenThrow(ChainNotFoundException.class);
    when(chainResolutionStrategyMock.resolve(
            eq("a"),
            same(((IObject) seqDump
                    .getValue(IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "chainsDump")))
                    .getValue(IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "a"))),
            any(),
            same(routerMock)
    )).thenReturn(chainA);
    when(chainA.get(0)).thenReturn(mock(IMessageReceiver.class));
    when(chainA.get(1)).thenReturn(mock(IMessageReceiver.class));
    when(chainA.get(2)).thenReturn(mock(IMessageReceiver.class));
    when(chainA.get(3)).thenReturn(mock(IMessageReceiver.class));
    IMessageProcessingSequence sequence = new MessageProcessingSequenceRecoveryStrategy().resolve(seqDump);
    assertNotNull(sequence);
    assertEquals(2, sequence.getCurrentLevel());
    assertEquals(3, sequence.getStepAtLevel(2));
    assertEquals(4, sequence.getStepAtLevel(1));
    assertEquals(1, sequence.getStepAtLevel(0));
    try {
        sequence.callChain(chainA);
        fail();
    } catch (NestedChainStackOverflowException ok) {}
}