Search in sources :

Example 26 with EnvironmentImpl

use of org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl in project che by eclipse.

the class DockerImageEnvironmentParserTest method shouldBeAbleToParseDockerImageEnvironment.

@Test
public void shouldBeAbleToParseDockerImageEnvironment() throws Exception {
    // given
    EnvironmentImpl environment = createDockerimageEnvConfig(DEFAULT_DOCKER_IMAGE, DEFAULT_MACHINE_NAME);
    CheServicesEnvironmentImpl expected = new CheServicesEnvironmentImpl();
    expected.getServices().put(DEFAULT_MACHINE_NAME, new CheServiceImpl().withImage(DEFAULT_DOCKER_IMAGE));
    // when
    CheServicesEnvironmentImpl cheServicesEnvironment = parser.parse(environment);
    // then
    assertEquals(cheServicesEnvironment, expected);
}
Also used : CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) Test(org.testng.annotations.Test)

Example 27 with EnvironmentImpl

use of org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl in project che by eclipse.

the class DockerfileEnvironmentParserTest method shouldThrowExceptionOnParseOfDockerfileEnvWithSeveralExtendedMachines.

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Environment of type '.*' doesn't support multiple machines, but contains machines: .*")
public void shouldThrowExceptionOnParseOfDockerfileEnvWithSeveralExtendedMachines() throws Exception {
    // given
    EnvironmentImpl environment = createDockerfileEnvConfig();
    environment.getMachines().put("anotherMachine", new ExtendedMachineImpl(emptyList(), emptyMap(), emptyMap()));
    // when
    parser.parse(environment);
}
Also used : ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) Test(org.testng.annotations.Test)

Example 28 with EnvironmentImpl

use of org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl in project che by eclipse.

the class DockerfileEnvironmentParserTest method shouldThrowExceptionInCaseEnvironmentContainsNotSupportedRecipeType.

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Dockerfile environment parser doesn't support recipe type 'dockerImage'")
public void shouldThrowExceptionInCaseEnvironmentContainsNotSupportedRecipeType() throws ServerException {
    // given
    EnvironmentImpl environment = createDockerfileEnvConfig();
    environment.getRecipe().setType("dockerImage");
    // when
    parser.parse(environment);
}
Also used : EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) Test(org.testng.annotations.Test)

Example 29 with EnvironmentImpl

use of org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl in project che by eclipse.

the class FactoryServiceTest method createEnvDto.

private static EnvironmentDto createEnvDto() {
    final EnvironmentRecipeImpl environmentRecipe = new EnvironmentRecipeImpl();
    environmentRecipe.setType("type");
    environmentRecipe.setContent("content");
    environmentRecipe.setContentType("compose");
    environmentRecipe.setLocation("location");
    final EnvironmentImpl env = new EnvironmentImpl();
    final ExtendedMachineImpl extendedMachine = new ExtendedMachineImpl();
    extendedMachine.setAgents(singletonList("agent"));
    extendedMachine.setAttributes(singletonMap("att1", "value"));
    extendedMachine.setServers(singletonMap("agent", new ServerConf2Impl("5555", "https", singletonMap("prop1", "value1"))));
    env.setRecipe(environmentRecipe);
    env.setMachines(singletonMap("machine1", extendedMachine));
    return org.eclipse.che.api.workspace.server.DtoConverter.asDto(env);
}
Also used : ServerConf2Impl(org.eclipse.che.api.workspace.server.model.impl.ServerConf2Impl) ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) EnvironmentRecipeImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl)

Example 30 with EnvironmentImpl

use of org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl in project che by eclipse.

the class CheEnvironmentEngineTest method shouldSetDockerfileContentInsteadOfUrlIfUrlPointsToCheApiOnEnvironmentStart.

@Test
public void shouldSetDockerfileContentInsteadOfUrlIfUrlPointsToCheApiOnEnvironmentStart() throws Exception {
    // given
    EnvironmentImpl env = createEnv();
    String machineName = "machineWithDockerfileFromApi";
    String dockerfileContent = "this is dockerfile content";
    when(recipeDownloader.getRecipe(anyString())).thenReturn(dockerfileContent);
    //prepare CheServicesEnvironmentImpl which should return compose parser
    CheServicesEnvironmentImpl cheServicesEnvironment = createCheServicesEnvByName(machineName);
    cheServicesEnvironment.getServices().get(machineName).withBuild(new CheServiceBuildContextImpl().withContext(API_ENDPOINT + "/recipe/12345"));
    // when
    startEnv(env, cheServicesEnvironment);
    // then
    ArgumentCaptor<CheServiceImpl> captor = ArgumentCaptor.forClass(CheServiceImpl.class);
    verify(machineProvider).startService(anyString(), anyString(), anyString(), eq(machineName), eq(false), anyString(), captor.capture(), any(LineConsumer.class));
    CheServiceImpl actualService = captor.getValue();
    assertNull(actualService.getBuild().getContext());
    assertNull(actualService.getBuild().getDockerfilePath());
    assertEquals(actualService.getBuild().getDockerfileContent(), dockerfileContent);
}
Also used : LineConsumer(org.eclipse.che.api.core.util.LineConsumer) CheServiceBuildContextImpl(org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl) CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Aggregations

EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)40 CheServicesEnvironmentImpl (org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl)27 Test (org.testng.annotations.Test)23 ExtendedMachineImpl (org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl)17 CheServiceImpl (org.eclipse.che.api.environment.server.model.CheServiceImpl)15 Matchers.anyString (org.mockito.Matchers.anyString)14 EnvironmentRecipeImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl)10 LineConsumer (org.eclipse.che.api.core.util.LineConsumer)9 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)7 ServerConf2Impl (org.eclipse.che.api.workspace.server.model.impl.ServerConf2Impl)7 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)6 Instance (org.eclipse.che.api.machine.server.spi.Instance)5 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)5 CheServiceBuildContextImpl (org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl)4 CommandImpl (org.eclipse.che.api.machine.server.model.impl.CommandImpl)4 NotFoundException (org.eclipse.che.api.core.NotFoundException)3 ServerException (org.eclipse.che.api.core.ServerException)3 Machine (org.eclipse.che.api.core.model.machine.Machine)3 ExtendedMachine (org.eclipse.che.api.core.model.workspace.ExtendedMachine)3