### Question:
ComponentGroupImpl implements ComponentGroup { @Override public Optional<Component> findComponentWithName(String componentName) { return components.asList() .stream() .filter(c -> c.getName().equals(componentName)) .findFirst(); }  @Override Optional<String> getIp(); @Override Optional<Component> findComponentWithName(String componentName); @Override String toString();  }### Answer:
@Test void findComponentByName() { when(one.getName()).thenReturn("one"); when(two.getName()).thenReturn("two"); when(components.asList()).thenReturn(asList(one, two)); ComponentGroup group = new ComponentGroupImpl("group", null, components); assertEquals(of(two), group.findComponentWithName("two")); assertEquals(empty(), group.findComponentWithName("missing")); }