Search in sources :

Example 6 with EnvironmentRecipeImpl

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;
}
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 7 with EnvironmentRecipeImpl

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);
}
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 8 with EnvironmentRecipeImpl

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);
}
Also used : ServerConf2Impl(org.eclipse.che.api.workspace.server.model.impl.ServerConf2Impl) HashMap(java.util.HashMap) 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) EnvironmentRecipeImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl)

Example 9 with EnvironmentRecipeImpl

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);
}
Also used : HashMap(java.util.HashMap) CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) 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) EnvironmentRecipeImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl) Test(org.testng.annotations.Test)

Example 10 with EnvironmentRecipeImpl

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);
}
Also used : HashMap(java.util.HashMap) CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) 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) EnvironmentRecipeImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl) Test(org.testng.annotations.Test)

Aggregations

EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)10 EnvironmentRecipeImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl)10 ExtendedMachineImpl (org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl)10 ServerConf2Impl (org.eclipse.che.api.workspace.server.model.impl.ServerConf2Impl)7 HashMap (java.util.HashMap)6 CheServicesEnvironmentImpl (org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl)5 ArrayList (java.util.ArrayList)3 CommandImpl (org.eclipse.che.api.machine.server.model.impl.CommandImpl)3 ProjectConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl)3 SourceStorageImpl (org.eclipse.che.api.workspace.server.model.impl.SourceStorageImpl)3 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)3 CheServiceImpl (org.eclipse.che.api.environment.server.model.CheServiceImpl)2 Test (org.testng.annotations.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 Collections.singletonList (java.util.Collections.singletonList)1 Collections.singletonMap (java.util.Collections.singletonMap)1 HashSet (java.util.HashSet)1