use of com.intellij.xdebugger.XDebuggerManager in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudBreakpointHandlerTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
fixture = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getTestName(true)).getFixture();
fixture.setUp();
project = new MockProjectEx(getTestRootDisposable());
psiManager = mock(PsiManager.class);
project.registerService(PsiManager.class, psiManager);
XDebugSession session = mock(XDebugSession.class);
when(session.getProject()).thenReturn(project);
process = mock(CloudDebugProcess.class);
when(process.getXDebugSession()).thenReturn(session);
CloudDebugProcessState processState = mock(CloudDebugProcessState.class);
existingBreakpoints = new ArrayList<Breakpoint>();
when(processState.getCurrentServerBreakpointList()).thenReturn(ContainerUtil.immutableList(existingBreakpoints));
when(process.getProcessState()).thenReturn(processState);
stateController = mock(CloudDebugProcessStateController.class);
when(process.getStateController()).thenReturn(stateController);
registrationShouldSucceed = true;
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
addedBp.set((Breakpoint) invocation.getArguments()[0]);
SetBreakpointHandler handler = (SetBreakpointHandler) invocation.getArguments()[1];
if (registrationShouldSucceed) {
handler.onSuccess(desiredResultId);
} else {
handler.onError("Registration failed");
}
return null;
}
}).when(stateController).setBreakpointAsync(any(Breakpoint.class), any(SetBreakpointHandler.class));
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
removedBp.set((String) invocation.getArguments()[0]);
return null;
}
}).when(stateController).deleteBreakpointAsync(anyString());
fileResolver = mock(ServerToIdeFileResolver.class);
handler = new CloudBreakpointHandler(process, fileResolver);
XDebuggerManager debuggerManager = mock(XDebuggerManager.class);
project.addComponent(XDebuggerManager.class, debuggerManager);
breakpointManager = mock(XBreakpointManager.class);
when(debuggerManager.getBreakpointManager()).thenReturn(breakpointManager);
}
use of com.intellij.xdebugger.XDebuggerManager in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudDebugProcessStateCollectorTest method createMockXDebuggerManager.
void createMockXDebuggerManager(Project project, XDebugSession[] value) {
XDebuggerManager debuggerManager = mock(XDebuggerManager.class);
when(debuggerManager.getDebugSessions()).thenReturn(value);
when(project.getComponent(XDebuggerManager.class)).thenReturn(debuggerManager);
}
use of com.intellij.xdebugger.XDebuggerManager in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudDebugProcessTest method testOnBreakpointListChangedSetsErrorMessageAndUpdatesBreakpointPresentation.
public void testOnBreakpointListChangedSetsErrorMessageAndUpdatesBreakpointPresentation() throws Exception {
// override the default XBreakpointManager implementation with mock to use Mockito.verify()
XBreakpointManager breakpointManager = mock(XBreakpointManager.class);
XDebuggerManager debuggerManager = mock(XDebuggerManager.class);
when(debuggerManager.getBreakpointManager()).thenReturn(breakpointManager);
((ProjectImpl) getProject()).registerComponentInstance(XDebuggerManager.class, debuggerManager);
ArrayList<Breakpoint> breakpoints = new ArrayList<Breakpoint>();
Breakpoint breakpoint = new Breakpoint();
breakpoint.setId("breakpointId").setIsFinalState(Boolean.TRUE).setStatus(new StatusMessage().setIsError(Boolean.TRUE));
breakpoints.add(breakpoint);
CloudDebugProcessState processState = mock(CloudDebugProcessState.class);
when(processState.getCurrentServerBreakpointList()).thenReturn(ContainerUtil.immutableList(breakpoints));
XLineBreakpointImpl xLineBreakpointImpl = mock(XLineBreakpointImpl.class);
CloudLineBreakpoint cloudLineBreakpoint = mockCloudLineBreakpoint("mock error message", xLineBreakpointImpl);
when(xLineBreakpointImpl.getUserData(com.intellij.debugger.ui.breakpoints.Breakpoint.DATA_KEY)).thenReturn(cloudLineBreakpoint);
CloudBreakpointHandler breakpointHandler = mock(CloudBreakpointHandler.class);
when(breakpointHandler.getEnabledXBreakpoint(breakpoint)).thenReturn(xLineBreakpointImpl);
process.setBreakpointHandler(breakpointHandler);
process.initialize(processState);
process.onBreakpointListChanged(mock(CloudDebugProcessState.class));
verify(cloudLineBreakpoint).setErrorMessage(eq("General error"));
verify(cloudLineBreakpoint).getXBreakpoint();
verify(cloudLineBreakpoint).getSetIcon(Matchers.anyBoolean());
verify(cloudLineBreakpoint).getErrorMessage();
verify(breakpointManager).updateBreakpointPresentation(same(xLineBreakpointImpl), any(Icon.class), eq("General error"));
process.getStateController().stopBackgroundListening();
}
use of com.intellij.xdebugger.XDebuggerManager in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudDebugProcessTest method mockCloudDebugProcess.
@NotNull
private CloudDebugProcess mockCloudDebugProcess(XBreakpointManager breakpointManager, XDebugSession debugSession) {
Project project = mock(Project.class);
when(debugSession.getProject()).thenReturn(project);
XDebuggerManager debuggerManager = mock(XDebuggerManager.class);
when(project.getComponent(XDebuggerManager.class)).thenReturn(debuggerManager);
when(debuggerManager.getBreakpointManager()).thenReturn(breakpointManager);
return new CloudDebugProcess(debugSession);
}
Aggregations