Search in sources :

Example 16 with Environment

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);
}
Also used : MachineConfigImpl(org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl) Environment(org.eclipse.che.api.core.model.workspace.config.Environment) Test(org.testng.annotations.Test)

Aggregations

Environment (org.eclipse.che.api.core.model.workspace.config.Environment)16 VisibleForTesting (com.google.common.annotations.VisibleForTesting)6 Test (org.testng.annotations.Test)6 NotFoundException (org.eclipse.che.api.core.NotFoundException)4 ServerException (org.eclipse.che.api.core.ServerException)4 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)4 InfrastructureException (org.eclipse.che.api.workspace.server.spi.InfrastructureException)4 InternalInfrastructureException (org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException)4 InternalEnvironment (org.eclipse.che.api.workspace.server.spi.environment.InternalEnvironment)4 ImmutableMap (com.google.common.collect.ImmutableMap)2 Map (java.util.Map)2 ConflictException (org.eclipse.che.api.core.ConflictException)2 ValidationException (org.eclipse.che.api.core.ValidationException)2 WorkspaceStatus (org.eclipse.che.api.core.model.workspace.WorkspaceStatus)2 Recipe (org.eclipse.che.api.core.model.workspace.config.Recipe)2 MachineConfigImpl (org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl)2 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)2 InternalRuntime (org.eclipse.che.api.workspace.server.spi.InternalRuntime)2 Unlocker (org.eclipse.che.commons.lang.concurrent.Unlocker)2 NoEnoughResourcesException (org.eclipse.che.multiuser.resource.api.exception.NoEnoughResourcesException)2