use of org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl in project che by eclipse.
the class TestObjectsFactory method createEnv.
public static EnvironmentImpl createEnv() {
final EnvironmentRecipeImpl newRecipe = new EnvironmentRecipeImpl();
newRecipe.setLocation("new-location");
newRecipe.setType("new-type");
newRecipe.setContentType("new-content-type");
newRecipe.setContent("new-content");
final ExtendedMachineImpl newMachine = new ExtendedMachineImpl();
final ServerConf2Impl serverConf1 = new ServerConf2Impl("2265", "http", ImmutableMap.of("prop1", "val"));
final ServerConf2Impl serverConf2 = new ServerConf2Impl("2266", "ftp", ImmutableMap.of("prop1", "val"));
newMachine.setServers(ImmutableMap.of("ref1", serverConf1, "ref2", serverConf2));
newMachine.setAgents(ImmutableList.of("agent5", "agent4"));
newMachine.setAttributes(singletonMap("att1", "val"));
final EnvironmentImpl newEnv = new EnvironmentImpl();
newEnv.setMachines(ImmutableMap.of("new-machine", newMachine));
newEnv.setRecipe(newRecipe);
return newEnv;
}
use of org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl 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.EnvironmentRecipeImpl in project che by eclipse.
the class CheEnvironmentValidatorTest method createEnv.
private static EnvironmentDto createEnv() {
// singletonMap, asList are wrapped into modifiable collections to ease env modifying by tests
EnvironmentImpl env = new EnvironmentImpl();
Map<String, ExtendedMachineImpl> machines = new HashMap<>();
Map<String, ServerConf2Impl> servers = new HashMap<>();
servers.put("ref1", new ServerConf2Impl("8080/tcp", "proto1", singletonMap("prop1", "propValue")));
servers.put("ref2", new ServerConf2Impl("8080/udp", "proto1", null));
servers.put("ref3", new ServerConf2Impl("9090", "proto1", null));
machines.put("dev-machine", new ExtendedMachineImpl(asList("org.eclipse.che.ws-agent", "someAgent"), servers, singletonMap("memoryLimitBytes", "10000")));
machines.put("machine2", new ExtendedMachineImpl(asList("someAgent2", "someAgent3"), null, singletonMap("memoryLimitBytes", "10000")));
env.setRecipe(new EnvironmentRecipeImpl("compose", "application/x-yaml", "content", null));
env.setMachines(machines);
return DtoConverter.asDto(env);
}
use of org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl in project che by eclipse.
the class EnvironmentParserTest method shouldOverrideMemoryLimitFromExtendedMachineInComposeEnv.
@Test
public void shouldOverrideMemoryLimitFromExtendedMachineInComposeEnv() throws Exception {
// given
HashMap<String, ExtendedMachineImpl> machines = new HashMap<>();
machines.put("machine1", new ExtendedMachineImpl(emptyList(), emptyMap(), singletonMap("memoryLimitBytes", "101010")));
machines.put("machine2", new ExtendedMachineImpl(emptyList(), emptyMap(), emptyMap()));
EnvironmentImpl environment = new EnvironmentImpl(new EnvironmentRecipeImpl("compose", "application/x-yaml", "content", null), machines);
CheServicesEnvironmentImpl cheEnv = new CheServicesEnvironmentImpl();
cheEnv.getServices().put("machine1", new CheServiceImpl());
cheEnv.getServices().put("machine2", new CheServiceImpl());
when(envParser.parse(environment)).thenReturn(cheEnv);
// when
CheServicesEnvironmentImpl cheServicesEnvironment = parser.parse(environment);
// then
assertEquals(cheServicesEnvironment, cheEnv);
assertEquals(cheServicesEnvironment.getServices().get("machine1").getMemLimit().longValue(), 101010L);
assertEquals(cheServicesEnvironment.getServices().get("machine2").getMemLimit(), null);
}
use of org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl in project che by eclipse.
the class EnvironmentParserTest method shouldThrowExceptionInCaseFailedParseMemoryLimit.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Value of attribute 'memoryLimitBytes' of machine 'machine1' is illegal")
public void shouldThrowExceptionInCaseFailedParseMemoryLimit() throws ServerException {
HashMap<String, ExtendedMachineImpl> machines = new HashMap<>();
machines.put("machine1", new ExtendedMachineImpl(emptyList(), emptyMap(), singletonMap("memoryLimitBytes", "here should be memory size number")));
EnvironmentImpl environment = new EnvironmentImpl(new EnvironmentRecipeImpl("compose", "application/x-yaml", "content", null), machines);
CheServicesEnvironmentImpl cheEnv = new CheServicesEnvironmentImpl();
cheEnv.getServices().put("machine1", new CheServiceImpl());
when(envParser.parse(environment)).thenReturn(cheEnv);
// when
parser.parse(environment);
}
Aggregations