### Question:
InteractTypeMapperWithFallbackImpl implements InteractTypeMapper { @Override public boolean shouldIgnoreInteractionType(String interactionTypeNameOrId) { Optional<InteractTypeMapper> first = mappers .stream(). filter(x -> x.shouldIgnoreInteractionType(interactionTypeNameOrId)) .findFirst(); return first.isPresent(); } InteractTypeMapperWithFallbackImpl(InteractTypeMapper... mappers); @Override boolean shouldIgnoreInteractionType(String interactionTypeNameOrId); @Override InteractType getInteractType(String interactionTypeNameOrId);  }### Answer:
@Test public void firstMapperToIgnore() { InteractTypeMapper mapper1 = Mockito.mock(InteractTypeMapper.class); when(mapper1.shouldIgnoreInteractionType("eats")).thenReturn(true); InteractTypeMapper mapper2 = Mockito.mock(InteractTypeMapper.class); when(mapper2.shouldIgnoreInteractionType("eats")).thenReturn(false); InteractTypeMapper interactTypeMapperWithFallback = new InteractTypeMapperWithFallbackImpl(mapper1, mapper2); assertThat(interactTypeMapperWithFallback.shouldIgnoreInteractionType("eats"), is(true)); }
@Test public void secondMapperToIgnore() { InteractTypeMapper mapper1 = Mockito.mock(InteractTypeMapper.class); when(mapper1.shouldIgnoreInteractionType("eats")).thenReturn(false); InteractTypeMapper mapper2 = Mockito.mock(InteractTypeMapper.class); when(mapper2.shouldIgnoreInteractionType("eats")).thenReturn(true); InteractTypeMapper interactTypeMapperWithFallback = new InteractTypeMapperWithFallbackImpl(mapper1, mapper2); assertThat(interactTypeMapperWithFallback.shouldIgnoreInteractionType("eats"), is(true)); }
@Test public void noMapperToIgnore() { InteractTypeMapper mapper1 = Mockito.mock(InteractTypeMapper.class); when(mapper1.shouldIgnoreInteractionType("eats")).thenReturn(false); InteractTypeMapper mapper2 = Mockito.mock(InteractTypeMapper.class); when(mapper2.shouldIgnoreInteractionType("eats")).thenReturn(false); InteractTypeMapper interactTypeMapperWithFallback = new InteractTypeMapperWithFallbackImpl(mapper1, mapper2); assertThat(interactTypeMapperWithFallback.shouldIgnoreInteractionType("eats"), is(false)); }