@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)); }
@Override public boolean shouldIgnoreInteractionType(String interactionTypeNameOrId) { Optional<InteractTypeMapper> first = mappers .stream(). filter(x -> x.shouldIgnoreInteractionType(interactionTypeNameOrId)) .findFirst(); return first.isPresent(); }
InteractTypeMapperWithFallbackImpl implements InteractTypeMapper { @Override public boolean shouldIgnoreInteractionType(String interactionTypeNameOrId) { Optional<InteractTypeMapper> first = mappers .stream(). filter(x -> x.shouldIgnoreInteractionType(interactionTypeNameOrId)) .findFirst(); return first.isPresent(); } }
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); }
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); }
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);  }