Search in sources :

Example 31 with ActionImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl in project devspaces-images by redhat-developer.

the class CommandConverterTest method shouldConvertDevfileCommandToWorkspaceCommands.

@Test
public void shouldConvertDevfileCommandToWorkspaceCommands() throws Exception {
    // given
    CommandImpl devfileCommand = new CommandImpl();
    devfileCommand.setName("build");
    devfileCommand.setAttributes(ImmutableMap.of("attr", "value"));
    ActionImpl action = new ActionImpl();
    action.setComponent("dockerimageComponent");
    action.setType(EXEC_ACTION_TYPE);
    action.setWorkdir("/tmp");
    action.setCommand("mvn clean install");
    devfileCommand.getActions().add(action);
    // when
    org.eclipse.che.api.workspace.server.model.impl.CommandImpl workspaceCommand = commandConverter.toWorkspaceCommand(devfileCommand, null);
    // then
    assertEquals(workspaceCommand.getName(), "build");
    assertEquals(workspaceCommand.getType(), EXEC_ACTION_TYPE);
    assertEquals(workspaceCommand.getAttributes().size(), 3);
    assertEquals(workspaceCommand.getAttributes().get("attr"), "value");
    assertEquals(workspaceCommand.getAttributes().get(WORKING_DIRECTORY_ATTRIBUTE), "/tmp");
    assertEquals(workspaceCommand.getAttributes().get(COMPONENT_ALIAS_COMMAND_ATTRIBUTE), "dockerimageComponent");
    assertEquals(workspaceCommand.getCommandLine(), "mvn clean install");
}
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 32 with ActionImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl in project devspaces-images by redhat-developer.

the class CommandConverterTest method shouldAcceptActionWithReference.

@Test
public void shouldAcceptActionWithReference() throws Exception {
    // given
    CommandImpl devfileCommand = new CommandImpl();
    devfileCommand.setName("build");
    ActionImpl action = new ActionImpl();
    action.setType("exec");
    action.setReference("blah");
    devfileCommand.getActions().add(action);
    // when
    Command command = commandConverter.toWorkspaceCommand(devfileCommand, fileURL -> "content");
    // then
    assertNull(command.getCommandLine());
    assertEquals("blah", command.getAttributes().get(Command.COMMAND_ACTION_REFERENCE_ATTRIBUTE));
    assertEquals("content", command.getAttributes().get(Command.COMMAND_ACTION_REFERENCE_CONTENT_ATTRIBUTE));
}
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)

Example 33 with ActionImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl in project devspaces-images by redhat-developer.

the class DevfileIntegrityValidatorTest method shouldThrowExceptionOnUnexistingCommandActionComponent.

@Test(expectedExceptions = DevfileFormatException.class, expectedExceptionsMessageRegExp = "Command 'build' has action that refers to a component with unknown alias 'no_such_component'")
public void shouldThrowExceptionOnUnexistingCommandActionComponent() throws Exception {
    DevfileImpl broken = new DevfileImpl(initialDevfile);
    broken.getCommands().get(0).getActions().clear();
    ActionImpl action = new ActionImpl();
    action.setComponent("no_such_component");
    broken.getCommands().get(0).getActions().add(action);
    // when
    integrityValidator.validateDevfile(broken);
}
Also used : DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ActionImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl) Test(org.testng.annotations.Test)

Example 34 with ActionImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl in project devspaces-images by redhat-developer.

the class DevfileIntegrityValidatorTest method shouldThrowExceptionWhenCommandHasMultipleActions.

@Test(expectedExceptions = DevfileFormatException.class, expectedExceptionsMessageRegExp = "Multiple actions in command 'build' are not supported yet.")
public void shouldThrowExceptionWhenCommandHasMultipleActions() throws Exception {
    DevfileImpl broken = new DevfileImpl(initialDevfile);
    broken.getCommands().get(0).getActions().add(new ActionImpl());
    // when
    integrityValidator.validateDevfile(broken);
}
Also used : DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ActionImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl) Test(org.testng.annotations.Test)

Aggregations

ActionImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl)34 CommandImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl)26 Test (org.testng.annotations.Test)24 DevfileImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl)16 ComponentImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl)14 EndpointImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl)12 ProjectImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl)12 SourceImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl)12 EntrypointImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl)10 EnvImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl)10 MetadataImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.MetadataImpl)10 UserDevfileImpl (org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl)8 Command (org.eclipse.che.api.core.model.workspace.config.Command)6 CommandImpl (org.eclipse.che.api.workspace.server.model.impl.CommandImpl)4 VolumeImpl (org.eclipse.che.api.workspace.server.model.impl.VolumeImpl)4 AccountImpl (org.eclipse.che.account.spi.AccountImpl)2 WorkspaceExportException (org.eclipse.che.api.workspace.server.devfile.exception.WorkspaceExportException)2 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)2