use of org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl in project devspaces-images by redhat-developer.
the class UserDevfileDaoTest method shouldUpdateUserDevfile.
@Test
public void shouldUpdateUserDevfile() throws Exception {
// given
DevfileImpl newDevfile = TestObjectGenerator.createDevfile("newUpdate");
newDevfile.setApiVersion("V15.0");
newDevfile.setProjects(ImmutableList.of(new ProjectImpl("projectUp2", new SourceImpl("typeUp2", "http://location", "branch2", "point2", "tag2", "commit2", "sparseCheckoutDir2"), "path2")));
newDevfile.setComponents(ImmutableList.of(new ComponentImpl("type3", "id54")));
newDevfile.setCommands(ImmutableList.of(new CommandImpl(new CommandImpl("cmd1", Collections.singletonList(new ActionImpl("exe44", "compo2nent2", "run.sh", "/home/user/2", null, null)), Collections.singletonMap("attr1", "value1"), null))));
newDevfile.setAttributes(ImmutableMap.of("key2", "val34"));
newDevfile.setMetadata(new MetadataImpl("myNewName"));
final UserDevfileImpl update = devfiles[0];
update.setDevfile(newDevfile);
// when
userDevfileDaoDao.update(update);
// then
assertEquals(userDevfileDaoDao.getById(update.getId()), Optional.of(update));
}
use of org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl in project devspaces-images by redhat-developer.
the class DevfileConverterTest method shouldConvertCommandsDuringConvertingDevfileToWorkspaceConfig.
@Test
public void shouldConvertCommandsDuringConvertingDevfileToWorkspaceConfig() throws Exception {
// given
FileContentProvider fileContentProvider = mock(FileContentProvider.class);
DevfileImpl devfile = newDevfile("petclinic");
CommandImpl devfileCommand = mock(CommandImpl.class);
devfile.getCommands().add(devfileCommand);
org.eclipse.che.api.workspace.server.model.impl.CommandImpl workspaceCommand = mock(org.eclipse.che.api.workspace.server.model.impl.CommandImpl.class);
when(commandConverter.toWorkspaceCommand(any(), any())).thenReturn(workspaceCommand);
// when
WorkspaceConfigImpl workspaceConfig = devfileConverter.devFileToWorkspaceConfig(devfile, fileContentProvider);
// then
assertEquals(workspaceConfig.getCommands().size(), 1);
assertSame(workspaceConfig.getCommands().get(0), workspaceCommand);
}
use of org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl in project devspaces-images by redhat-developer.
the class CommandConverterTest method shouldNotSetWorkingDirAttributeIfItIsMissingInDevfileCommandDuringConvertingDevfileCommandToWorkspaceCommands.
@Test
public void shouldNotSetWorkingDirAttributeIfItIsMissingInDevfileCommandDuringConvertingDevfileCommandToWorkspaceCommands() throws Exception {
// given
CommandImpl devfileCommand = new CommandImpl();
ActionImpl action = new ActionImpl();
action.setWorkdir(null);
devfileCommand.getActions().add(action);
devfileCommand.setAttributes(new HashMap<>());
// when
org.eclipse.che.api.workspace.server.model.impl.CommandImpl workspaceCommand = commandConverter.toWorkspaceCommand(devfileCommand, null);
// then
assertFalse(workspaceCommand.getAttributes().containsKey(WORKING_DIRECTORY_ATTRIBUTE));
}
use of org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl in project devspaces-images by redhat-developer.
the class CommandConverterTest method shouldThrowAnExceptionIfDevfileCommandHasMultipleActions.
@Test(expectedExceptions = DevfileFormatException.class, expectedExceptionsMessageRegExp = "Command `build` MUST has one and only one action")
public void shouldThrowAnExceptionIfDevfileCommandHasMultipleActions() throws Exception {
// given
CommandImpl devfileCommand = new CommandImpl();
devfileCommand.setName("build");
devfileCommand.setAttributes(ImmutableMap.of("attr", "value"));
devfileCommand.getActions().add(new ActionImpl());
devfileCommand.getActions().add(new ActionImpl());
// when
commandConverter.toWorkspaceCommand(devfileCommand, null);
}
use of org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl in project devspaces-images by redhat-developer.
the class CommandConverterTest method shouldAcceptActionWithCommand.
@Test
public void shouldAcceptActionWithCommand() throws Exception {
// given
CommandImpl devfileCommand = new CommandImpl();
devfileCommand.setName("build");
ActionImpl action = new ActionImpl();
action.setType("exec");
action.setCommand("blah");
devfileCommand.getActions().add(action);
// when
Command command = commandConverter.toWorkspaceCommand(devfileCommand, null);
// then
assertEquals(command.getCommandLine(), "blah");
}
Aggregations