### Question:
ConfigConditionalContext implements
        ComponentConditionalContext<ComponentDescriptor<T>>,
        Predicate<GettableComponent<T>> { @Override public boolean isEnable(final ComponentFactory factory, final ComponentDescriptor<T> descriptor) { Objects.requireNonNull(factory, "factory must not be null"); Objects.requireNonNull(descriptor, "descriptor must not be null"); final Optional<Condition> optional = descriptor.condition(); return optional .map(condition -> condition.matches(buildConditionContent(factory, descriptor))) .orElse(true); } ConfigConditionalContext(final Conf config); static ConfigConditionalContext<T> of(final Conf config); @Override boolean test(final GettableComponent<T> component); @Override boolean isEnable(final ComponentFactory factory,
                            final ComponentDescriptor<T> descriptor);  }### Answer:
@Test public void shouldReturnFalseGivenNotMatchingConditionalContent() { ComponentDescriptor<Object> descriptor = ComponentDescriptorBuilder .create() .type(Object.class) .supplier(() -> null) .condition(context -> false) .build(); Assertions.assertFalse(context.isEnable(Mockito.mock(ComponentFactory.class), descriptor)); }
@Test public void shouldReturnTrueGivenMatchingConditionalContent() { ComponentDescriptor<Object> descriptor = ComponentDescriptorBuilder .create() .type(Object.class) .supplier(() -> null) .condition(context -> true) .build(); Assertions.assertTrue(context.isEnable(Mockito.mock(ComponentFactory.class), descriptor)); }
@Test public void shouldReturnTrueWhenMatchingNonConditionalComponent() { ComponentDescriptor<Object> descriptor = ComponentDescriptorBuilder .create() .type(Object.class) .supplier(() -> null) .build(); Assertions.assertTrue(context.isEnable(Mockito.mock(ComponentFactory.class), descriptor)); }