ImmutableReceiverChain implements IReceiverChain, IDumpable { @Override public Collection<IReceiverChain> getExceptionalChains() { return allExceptionalChains; } ImmutableReceiverChain(final String name, final IObject chainDescription, final IMessageReceiver[] receivers, final IObject[] arguments,
                                  final Map<Class<? extends Throwable>, IObject> exceptionalChainsAndEnv); @Override IMessageReceiver get(final int index); @Override IObject getArguments(final int index); @Override String getName(); @Override IObject getExceptionalChainAndEnvironments(final Throwable exception); @Override IObject getChainDescription(); @Override Collection<IReceiverChain> getExceptionalChains(); @Override IObject dump(final IObject options);  }
@Test public void Should_provideCollectionOfUniqueExceptionalChains() throws Exception { IReceiverChain exceptional1 = mock(IReceiverChain.class), exceptional2 = mock(IReceiverChain.class); IFieldName chainFN = IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "chain"); IObject eobj1 = mock(IObject.class), eobj2 = mock(IObject.class), eobj3 = mock(IObject.class); when(eobj1.getValue(eq(chainFN))).thenReturn(exceptional1); when(eobj2.getValue(eq(chainFN))).thenReturn(exceptional2); when(eobj3.getValue(eq(chainFN))).thenReturn(exceptional1); Map<Class<? extends Throwable>, IObject> eMap = new HashMap<>(); eMap.put(Exception.class, eobj1); eMap.put(NullPointerException.class, eobj2); eMap.put(RuntimeException.class, eobj3); IReceiverChain chain = new ImmutableReceiverChain("theChain", mock(IObject.class), new IMessageReceiver[0], new IObject[0], eMap); Collection<IReceiverChain> eColl = chain.getExceptionalChains(); assertEquals(new HashSet<>(Arrays.asList(exceptional1, exceptional2)), eColl); }