use of org.eclipse.che.ide.api.command.CommandImpl in project che by eclipse.
the class TestServiceClientTest method runTestsDirectlyBecauseNoDevMachine.
@Test
public void runTestsDirectlyBecauseNoDevMachine() {
Promise<CommandImpl> compileCommandPromise = createCommandPromise(new CommandImpl("test-compile", "mvn test-compile -f ${current.project.path}", "mvn"));
when(devMachine.getDescriptor()).thenReturn(null);
testServiceClient.runTestsAfterCompilation(projectPath, testFramework, parameters, statusNotification, compileCommandPromise);
verify(statusNotification).setContent("Executing the tests without preliminary compilation.");
verify(execAgentCommandManager, never()).startProcess(anyString(), Matchers.<Command>any());
verify(testServiceClient).sendTests(projectPath, testFramework, parameters);
}
use of org.eclipse.che.ide.api.command.CommandImpl in project che by eclipse.
the class ProcessesPanelPresenter method restoreState.
private void restoreState(final MachineEntity machine) {
execAgentCommandManager.getProcesses(machine.getId(), false).then(new Operation<List<GetProcessesResponseDto>>() {
@Override
public void apply(List<GetProcessesResponseDto> processes) throws OperationException {
for (GetProcessesResponseDto process : processes) {
final int pid = process.getPid();
final String type = process.getType();
/*
* Do not show the process if the command line has prefix #hidden
*/
if (!isNullOrEmpty(process.getCommandLine()) && process.getCommandLine().startsWith("#hidden")) {
continue;
}
/*
* Hide the processes which are launched by command of unknown type
*/
if (isProcessLaunchedByCommandOfKnownType(type)) {
final String processName = process.getName();
final CommandImpl commandByName = getWorkspaceCommandByName(processName);
if (commandByName == null) {
final String commandLine = process.getCommandLine();
final CommandImpl command = new CommandImpl(processName, commandLine, type);
final CommandOutputConsole console = commandConsoleFactory.create(command, machine);
getAndPrintProcessLogs(console, pid);
subscribeToProcess(console, pid);
addCommandOutput(machine.getId(), console);
} else {
macroProcessor.expandMacros(commandByName.getCommandLine()).then(new Operation<String>() {
@Override
public void apply(String expandedCommandLine) throws OperationException {
final CommandImpl command = new CommandImpl(commandByName.getName(), expandedCommandLine, commandByName.getType(), commandByName.getAttributes());
final CommandOutputConsole console = commandConsoleFactory.create(command, machine);
getAndPrintProcessLogs(console, pid);
subscribeToProcess(console, pid);
addCommandOutput(machine.getId(), console);
}
});
}
}
}
}
private void getAndPrintProcessLogs(final CommandOutputConsole console, final int pid) {
String from = null;
String till = null;
int limit = 50;
int skip = 0;
execAgentCommandManager.getProcessLogs(machine.getId(), pid, from, till, limit, skip).then(new Operation<List<GetProcessLogsResponseDto>>() {
@Override
public void apply(List<GetProcessLogsResponseDto> logs) throws OperationException {
for (GetProcessLogsResponseDto log : logs) {
String text = log.getText();
console.printOutput(text);
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
String error = "Error trying to get process log with pid: " + pid + ". " + arg.getMessage();
Log.error(getClass(), error);
}
});
}
private void subscribeToProcess(CommandOutputConsole console, int pid) {
String stderr = "stderr";
String stdout = "stdout";
String processStatus = "process_status";
String after = null;
execAgentCommandManager.subscribe(machine.getId(), pid, asList(stderr, stdout, processStatus), after).thenIfProcessStartedEvent(console.getProcessStartedOperation()).thenIfProcessDiedEvent(console.getProcessDiedOperation()).thenIfProcessStdOutEvent(console.getStdOutOperation()).thenIfProcessStdErrEvent(console.getStdErrOperation()).then(console.getProcessSubscribeOperation());
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
notificationManager.notify(localizationConstant.failedToGetProcesses(machine.getId()));
}
});
}
use of org.eclipse.che.ide.api.command.CommandImpl in project che by eclipse.
the class EditCommandsPresenterTest method setUp.
@Before
public void setUp() {
presenter.editedCommandNameInitial = COMMAND_NAME;
when(commandManager.update(anyString(), anyObject())).thenReturn(commandPromise);
CommandType commandType = mock(CommandType.class);
when(commandType.getId()).thenReturn(COMMAND_TYPE);
List<CommandType> commandTypes = new ArrayList<>(1);
commandTypes.add(commandType);
when(commandTypeRegistry.getCommandTypes()).thenReturn(commandTypes);
when(command.getType()).thenReturn(COMMAND_TYPE);
when(command.getName()).thenReturn(COMMAND_NAME);
List<CommandImpl> commands = new ArrayList<>(1);
commands.add(command);
when(commandManager.getCommands()).thenReturn(commands);
}
Aggregations