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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations