use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl in project che by eclipse.
the class EnvironmentParserTest method shouldBeAbleToParseEnvironment.
@Test
public void shouldBeAbleToParseEnvironment() throws Exception {
// given
when(envParser.parse(environment)).thenReturn(cheEnv);
// when
CheServicesEnvironmentImpl cheServicesEnvironment = parser.parse(environment);
// then
assertEquals(cheServicesEnvironment, cheEnv);
verify(envParser).parse(environment);
}
use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl 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);
}
use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl in project che by eclipse.
the class DefaultServicesStartStrategyTest method shouldOrderServicesWithVolumesFrom.
@Test
public void shouldOrderServicesWithVolumesFrom() throws Exception {
// given
CheServicesEnvironmentImpl composeEnvironment = new CheServicesEnvironmentImpl();
composeEnvironment.getServices().put("second", new CheServiceImpl().withVolumesFrom(singletonList("first")));
composeEnvironment.getServices().put("third", new CheServiceImpl().withVolumesFrom(asList("first", "second")));
composeEnvironment.getServices().put("first", new CheServiceImpl().withVolumesFrom(emptyList()));
composeEnvironment.getServices().put("forth", new CheServiceImpl().withVolumesFrom(singletonList("third")));
composeEnvironment.getServices().put("fifth", new CheServiceImpl().withVolumesFrom(asList("forth", "first")));
List<String> expected = asList("first", "second", "third", "forth", "fifth");
// when
List<String> actual = strategy.order(composeEnvironment);
// then
assertEquals(actual, expected);
}
use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl in project che by eclipse.
the class DefaultServicesStartStrategyTest method testOrderingOfServicesWithoutDependencies.
@Test
public void testOrderingOfServicesWithoutDependencies() throws Exception {
// given
CheServicesEnvironmentImpl composeEnvironment = new CheServicesEnvironmentImpl();
composeEnvironment.getServices().put("second", new CheServiceImpl());
composeEnvironment.getServices().put("third", new CheServiceImpl());
composeEnvironment.getServices().put("first", new CheServiceImpl());
String[] expected = new String[] { "first", "second", "third" };
// when
String[] actual = strategy.order(composeEnvironment).toArray(new String[composeEnvironment.getServices().size()]);
// then
assertEqualsNoOrder(actual, expected);
}
use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl in project che by eclipse.
the class DefaultServicesStartStrategyTest method shouldFailIfDependsOnFieldContainsNonExistingService.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Dependency 'fifth' in machine 'second' points to unknown machine.")
public void shouldFailIfDependsOnFieldContainsNonExistingService() throws Exception {
// given
CheServicesEnvironmentImpl composeEnvironment = new CheServicesEnvironmentImpl();
composeEnvironment.getServices().put("second", new CheServiceImpl().withDependsOn(singletonList("fifth")));
composeEnvironment.getServices().put("third", new CheServiceImpl());
composeEnvironment.getServices().put("first", new CheServiceImpl());
// when
strategy.order(composeEnvironment);
}
Aggregations