use of org.eclipse.che.api.core.model.workspace.config.Environment in project devspaces-images by redhat-developer.
the class InternalEnvironmentFactoryTest method testApplyContainerSourceAttributeToTheMachineSpecifiedInEnv.
@Test
public void testApplyContainerSourceAttributeToTheMachineSpecifiedInEnv() throws Exception {
// given
final Environment sourceEnv = mock(Environment.class);
MachineConfigImpl machineConfig = mock(MachineConfigImpl.class);
final Map<String, MachineConfigImpl> machineConfigMap = ImmutableMap.of("envMachine", machineConfig);
doReturn(machineConfigMap).when(sourceEnv).getMachines();
when(environmentFactory.doCreate(any(), any(), any())).thenAnswer(invocation -> {
Map<String, InternalMachineConfig> envMachines = invocation.getArgument(1);
final InternalEnvironment internalEnv = mock(InternalEnvironment.class);
when(internalEnv.getMachines()).thenReturn(envMachines);
return internalEnv;
});
// when
InternalEnvironment resultEnv = environmentFactory.create(sourceEnv);
// then
assertEquals(resultEnv.getMachines().get("envMachine").getAttributes().get(CONTAINER_SOURCE_ATTRIBUTE), RECIPE_CONTAINER_SOURCE);
}
Aggregations