use of org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl in project devspaces-images by redhat-developer.
the class CommandConverterTest method shouldConvertWorkspaceCommandToDevfileCommand.
@Test
public void shouldConvertWorkspaceCommandToDevfileCommand() throws Exception {
// given
org.eclipse.che.api.workspace.server.model.impl.CommandImpl workspaceCommand = new org.eclipse.che.api.workspace.server.model.impl.CommandImpl("build", "mvn clean install", "custom");
workspaceCommand.getAttributes().put(COMPONENT_ALIAS_COMMAND_ATTRIBUTE, "dockerimageComponent");
workspaceCommand.getAttributes().put(WORKING_DIRECTORY_ATTRIBUTE, "/tmp");
workspaceCommand.getAttributes().put("anotherAttribute", "value");
// when
CommandImpl devfileCommand = commandConverter.toDevfileCommand(workspaceCommand);
// then
assertEquals(devfileCommand.getName(), "build");
assertEquals(devfileCommand.getActions().size(), 1);
assertEquals(devfileCommand.getAttributes().size(), 1);
assertEquals(devfileCommand.getAttributes().get("anotherAttribute"), "value");
ActionImpl action = devfileCommand.getActions().get(0);
assertEquals(action.getComponent(), "dockerimageComponent");
assertEquals(action.getWorkdir(), "/tmp");
assertEquals(action.getCommand(), "mvn clean install");
assertEquals(action.getType(), EXEC_ACTION_TYPE);
}
use of org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl in project devspaces-images by redhat-developer.
the class CommandConverterTest method shouldAcceptActionWithReferenceContent.
@Test
public void shouldAcceptActionWithReferenceContent() throws Exception {
// given
CommandImpl devfileCommand = new CommandImpl();
devfileCommand.setName("build");
ActionImpl action = new ActionImpl();
action.setType("exec");
action.setReference("blah");
action.setReferenceContent("content");
devfileCommand.getActions().add(action);
// when
Command command = commandConverter.toWorkspaceCommand(devfileCommand, null);
// 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.CommandImpl 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.CommandImpl 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.CommandImpl in project devspaces-images by redhat-developer.
the class DevfileIntegrityValidatorTest method shouldThrowExceptionOnDuplicateCommandName.
@Test(expectedExceptions = DevfileFormatException.class, expectedExceptionsMessageRegExp = "Duplicate command name found:'build'")
public void shouldThrowExceptionOnDuplicateCommandName() throws Exception {
DevfileImpl broken = new DevfileImpl(initialDevfile);
CommandImpl command = new CommandImpl();
command.setName(initialDevfile.getCommands().get(0).getName());
broken.getCommands().add(command);
// when
integrityValidator.validateDevfile(broken);
}
Aggregations