Search in sources :

Example 1 with VariableDto

use of org.eclipse.che.api.debug.shared.dto.VariableDto in project che by eclipse.

the class AbstractDebugger method asDto.

private VariableDto asDto(Variable variable) {
    VariableDto dto = dtoFactory.createDto(VariableDto.class);
    dto.withValue(variable.getValue());
    dto.withVariablePath(asDto(variable.getVariablePath()));
    dto.withPrimitive(variable.isPrimitive());
    dto.withType(variable.getType());
    dto.withName(variable.getName());
    dto.withExistInformation(variable.isExistInformation());
    dto.withVariables(asDto(variable.getVariables()));
    return dto;
}
Also used : VariableDto(org.eclipse.che.api.debug.shared.dto.VariableDto)

Example 2 with VariableDto

use of org.eclipse.che.api.debug.shared.dto.VariableDto in project che by eclipse.

the class DebuggerTest method testGetValue.

@Test
public void testGetValue() throws Exception {
    final VariableDto variableDto = mock(VariableDto.class);
    final Variable variable = mock(Variable.class);
    final Promise<SimpleValueDto> promiseValue = mock(Promise.class);
    doReturn(variableDto).when(dtoFactory).createDto(VariableDto.class);
    doReturn(mock(VariablePathDto.class)).when(dtoFactory).createDto(VariablePathDto.class);
    doReturn(mock(VariablePathDto.class)).when(variable).getVariablePath();
    doReturn(Collections.emptyList()).when(variable).getVariables();
    doReturn(promiseValue).when(service).getValue(SESSION_ID, variableDto);
    doReturn(promiseValue).when(promiseValue).then((Function<SimpleValueDto, Object>) any());
    doReturn(promiseValue).when(promiseValue).catchError((Operation<PromiseError>) any());
    Promise<SimpleValue> result = debugger.getValue(variable);
    assertEquals(promiseValue, result);
}
Also used : Variable(org.eclipse.che.api.debug.shared.model.Variable) VariablePathDto(org.eclipse.che.api.debug.shared.dto.VariablePathDto) PromiseError(org.eclipse.che.api.promises.client.PromiseError) VariableDto(org.eclipse.che.api.debug.shared.dto.VariableDto) SimpleValueDto(org.eclipse.che.api.debug.shared.dto.SimpleValueDto) SimpleValue(org.eclipse.che.api.debug.shared.model.SimpleValue) BaseTest(org.eclipse.che.plugin.debugger.ide.BaseTest) Test(org.junit.Test)

Example 3 with VariableDto

use of org.eclipse.che.api.debug.shared.dto.VariableDto in project che by eclipse.

the class DebuggerTest method testChangeVariableValue.

@Test
public void testChangeVariableValue() throws Exception {
    final List<String> path = mock(List.class);
    final String newValue = "new-value";
    VariablePath variablePath = mock(VariablePathDto.class);
    doReturn(path).when(variablePath).getPath();
    VariableDto variableDto = mock(VariableDto.class);
    doReturn(variableDto).when(dtoFactory).createDto(VariableDto.class);
    Variable variable = mock(Variable.class);
    doReturn(mock(VariablePathDto.class)).when(dtoFactory).createDto(VariablePathDto.class);
    doReturn(variablePath).when(variable).getVariablePath();
    doReturn(newValue).when(variable).getValue();
    doReturn(Collections.emptyList()).when(variable).getVariables();
    doReturn(promiseVoid).when(service).setValue(SESSION_ID, variableDto);
    doReturn(promiseVoid).when(promiseVoid).then((Operation<Void>) any());
    debugger.setValue(variable);
    verify(promiseVoid).then(operationVoidCaptor.capture());
    operationVoidCaptor.getValue().apply(null);
    verify(observer).onValueChanged(path, newValue);
    verify(promiseVoid).catchError(operationPromiseErrorCaptor.capture());
    operationPromiseErrorCaptor.getValue().apply(promiseError);
    verify(promiseError).getMessage();
}
Also used : VariablePath(org.eclipse.che.api.debug.shared.model.VariablePath) Variable(org.eclipse.che.api.debug.shared.model.Variable) VariablePathDto(org.eclipse.che.api.debug.shared.dto.VariablePathDto) VariableDto(org.eclipse.che.api.debug.shared.dto.VariableDto) Matchers.anyString(org.mockito.Matchers.anyString) BaseTest(org.eclipse.che.plugin.debugger.ide.BaseTest) Test(org.junit.Test)

Aggregations

VariableDto (org.eclipse.che.api.debug.shared.dto.VariableDto)3 VariablePathDto (org.eclipse.che.api.debug.shared.dto.VariablePathDto)2 Variable (org.eclipse.che.api.debug.shared.model.Variable)2 BaseTest (org.eclipse.che.plugin.debugger.ide.BaseTest)2 Test (org.junit.Test)2 SimpleValueDto (org.eclipse.che.api.debug.shared.dto.SimpleValueDto)1 SimpleValue (org.eclipse.che.api.debug.shared.model.SimpleValue)1 VariablePath (org.eclipse.che.api.debug.shared.model.VariablePath)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1 Matchers.anyString (org.mockito.Matchers.anyString)1