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");
}
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));
}
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);
}
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);
}
Aggregations