### Question:
ComponentDefinition { public Component toComponent(ComponentFactory componentFactory, String environment) { return componentFactory.createComponent(name, originalName, environment); }  static ComponentDefinition withAlias(String alias, String originalName); static ComponentDefinition withName(String name); Component toComponent(ComponentFactory componentFactory, String environment);  }### Answer:
@Test void toComponent() { String env = "dev"; ComponentFactory factory = mock(ComponentFactory.class); Component expected = mock(Component.class); when(factory.createComponent(alias, name, env)).thenReturn(expected); assertSame(expected, withAlias(alias, name).toComponent(factory, env)); }