Search in sources :

Example 11 with CommandImpl

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));
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl) MetadataImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.MetadataImpl) UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ProjectImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl) SourceImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl) UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) ActionImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) Test(org.testng.annotations.Test)

Example 12 with CommandImpl

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);
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl) FileContentProvider(org.eclipse.che.api.workspace.server.devfile.FileContentProvider) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) Test(org.testng.annotations.Test)

Example 13 with CommandImpl

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));
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl) ActionImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl) Test(org.testng.annotations.Test)

Example 14 with CommandImpl

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);
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl) ActionImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl) Test(org.testng.annotations.Test)

Example 15 with CommandImpl

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");
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl) Command(org.eclipse.che.api.core.model.workspace.config.Command) ActionImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl) Test(org.testng.annotations.Test)

Aggregations

CommandImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl)30 ActionImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl)26 Test (org.testng.annotations.Test)22 DevfileImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl)14 ComponentImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl)10 UserDevfileImpl (org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl)8 EndpointImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl)8 MetadataImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.MetadataImpl)8 ProjectImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl)8 SourceImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl)8 Command (org.eclipse.che.api.core.model.workspace.config.Command)6 EntrypointImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl)6 EnvImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl)6 FileContentProvider (org.eclipse.che.api.workspace.server.devfile.FileContentProvider)2 WorkspaceExportException (org.eclipse.che.api.workspace.server.devfile.exception.WorkspaceExportException)2 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)2