use of org.eclipse.che.plugin.docker.compose.ComposeEnvironment in project che by eclipse.
the class EnvironmentDeserializerTest method testCorrectContentParsing.
@Test(dataProvider = "correctContentTestData")
public void testCorrectContentParsing(String content, Map<String, String> expected) throws ServerException {
ComposeEnvironment cheServicesEnvironment = parser.parse(content, "application/x-yaml");
// then
assertEquals(cheServicesEnvironment.getServices().get("dev-machine").getEnvironment(), expected);
}
use of org.eclipse.che.plugin.docker.compose.ComposeEnvironment in project che by eclipse.
the class ComposeEnvironmentParser method parse.
/**
* Parses compose file from {@link Environment} into {@link CheServicesEnvironmentImpl}.
*
* @param environment
* environment with {@link EnvironmentRecipe} to parse.
* {@link EnvironmentRecipe} contains {@link CheServicesEnvironmentImpl} definition.
* @throws IllegalArgumentException
* when environment or environment recipe is invalid
* @throws ServerException
* when environment recipe can not be retrieved
*/
@Override
public CheServicesEnvironmentImpl parse(Environment environment) throws ServerException {
requireNonNull(environment, "Environment should not be null");
EnvironmentRecipe recipe = environment.getRecipe();
requireNonNull(environment.getRecipe(), "Environment recipe should not be null");
String content = getContentOfRecipe(recipe);
ComposeEnvironment composeEnvironment = parse(content, recipe.getContentType());
return asCheEnvironment(composeEnvironment);
}
use of org.eclipse.che.plugin.docker.compose.ComposeEnvironment in project che by eclipse.
the class BuildContextTest method shouldNotParseBuildArgsWhenNotProvided.
@Test
public void shouldNotParseBuildArgsWhenNotProvided() throws ServerException {
// given
String recipeContent = "services:\n" + " dev-machine:\n" + " build:\n" + " context: .\n";
// when
ComposeEnvironment composeEnvironment = parser.parse(recipeContent, "application/x-yaml");
// then
assertEquals(Collections.emptyMap(), composeEnvironment.getServices().get("dev-machine").getBuild().getArgs());
}
use of org.eclipse.che.plugin.docker.compose.ComposeEnvironment in project che by eclipse.
the class BuildContextTest method shouldParseBuildArgsWhenProvided.
@Test
public void shouldParseBuildArgsWhenProvided() throws ServerException {
// given
String recipeContent = "services:\n" + " dev-machine:\n" + " build:\n" + " context: .\n" + " args:\n" + " buildno: 1\n" + " password: secret\n";
Map<String, String> expected = new HashMap<String, String>() {
{
put("buildno", "1");
put("password", "secret");
}
};
// when
ComposeEnvironment composeEnvironment = parser.parse(recipeContent, "application/x-yaml");
// then
assertEquals(composeEnvironment.getServices().get("dev-machine").getBuild().getArgs(), expected);
}
use of org.eclipse.che.plugin.docker.compose.ComposeEnvironment in project che by eclipse.
the class CommandDeserializerTest method composeServiceCommandShouldBeParsedSuccessfully.
@Test(dataProvider = "validCommand")
public void composeServiceCommandShouldBeParsedSuccessfully(String command, List<String> commandWords, int commandNumberOfWords) throws Exception {
String content = format(RECIPE_WITHOUT_COMMAND_VALUE, command);
ComposeEnvironment composeEnvironment = composeEnvironmentParser.parse(content, "application/x-yaml");
assertEquals(composeEnvironment.getServices().size(), 1);
ComposeServiceImpl service = composeEnvironment.getServices().get("machine1");
assertEquals(service.getImage(), "codenvy/mysql");
assertEquals(service.getMemLimit().longValue(), 2147483648L);
Map<String, String> environment = service.getEnvironment();
assertEquals(environment.size(), 2);
assertEquals(environment.get("MYSQL_USER"), "petclinic");
assertEquals(environment.get("MYSQL_PASSWORD"), "password");
assertTrue(service.getExpose().containsAll(asList("4403", "5502")));
assertTrue(service.getCommand().containsAll(commandWords));
assertEquals(service.getCommand().size(), commandNumberOfWords);
}
Aggregations