### Question:
EnvironmentImpl implements Environment { @Override public Component getComponentWithName(String componentName) { return findFirstResult(groups, g -> g.findComponentWithName(componentName)) .orElseThrow(() -> new IllegalArgumentException(notFoundComponentMessage(componentName))); }  @Override List<ComponentGroup> findGroupsWithIp(String ip); @Override ComponentGroup getGroupWithName(String groupName); @Override Optional<ComponentGroup> findGroupWithComponent(String componentName); @Override Components getAllComponents(); @Override Component getComponentWithName(String componentName); @Override Components findComponentsFrom(List<String> groups, List<String> componentNames); @Override Component findComponentWithName(String componentName); @Override String toString();  }### Answer:
@Test void getComponentWithName() { when(group1.findComponentWithName("two")).thenReturn(of(two)); assertEquals(two, env.getComponentWithName("two")); assertThrows(IllegalArgumentException.class, () -> env.getComponentWithName("four")); }