use of com.google.api.services.clouddebugger.v2.model.Breakpoint in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudDebugProcessStateController method pruneBreakpointCache.
private void pruneBreakpointCache(List<Breakpoint> currentList) {
// Clear out the obsolete breakpoint cache for old items.
HashSet<String> toRemoveSet = new HashSet<>();
toRemoveSet.addAll(fullFinalBreakpoints.keySet());
if (!toRemoveSet.isEmpty() && currentList != null) {
for (Breakpoint bp : currentList) {
toRemoveSet.remove(bp.getId());
}
}
for (String idToRemove : toRemoveSet) {
fullFinalBreakpoints.remove(idToRemove);
}
}
use of com.google.api.services.clouddebugger.v2.model.Breakpoint in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudDebugProcessStateController method queryServerForBreakpoints.
private List<Breakpoint> queryServerForBreakpoints(CloudDebugProcessState state, Debugger client, String tokenToSend) throws IOException {
List<Breakpoint> currentList = null;
String responseWaitToken = tokenToSend;
while (tokenToSend == null || tokenToSend.equals(responseWaitToken)) {
if (tokenToSend != null && !isBackgroundListening()) {
return null;
}
ListBreakpointsResponse response = client.debuggees().breakpoints().list(state.getDebuggeeId()).setIncludeInactive(Boolean.TRUE).setActionValue("CAPTURE").setStripResults(Boolean.TRUE).setWaitToken(CloudDebugConfigType.useWaitToken() ? tokenToSend : null).setClientVersion(ServiceManager.getService(PluginInfoService.class).getClientVersionForCloudDebugger()).execute();
// up the background watcher.
if (tokenToSend != null && !isBackgroundListening()) {
return null;
}
currentList = response.getBreakpoints();
responseWaitToken = response.getNextWaitToken();
if (tokenToSend == null) {
break;
}
if (!CloudDebugConfigType.useWaitToken() && tokenToSend.equals(responseWaitToken)) {
try {
// our fallback polling mode has a 1 second loop.
Thread.currentThread().sleep(1000);
} catch (InterruptedException ex) {
return null;
}
}
}
state.setWaitToken(responseWaitToken);
if (currentList != null) {
Collections.sort(currentList, BreakpointComparer.getDefaultInstance());
}
state.setCurrentServerBreakpointList(currentList != null ? ContainerUtil.immutableList(currentList) : ContainerUtil.immutableList(new ArrayList<>()));
return currentList;
}
use of com.google.api.services.clouddebugger.v2.model.Breakpoint in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudBreakpointHandlerTest method testUnregisterBreakpoint_shouldSetAddedOnServerToFalseAfterHitOnBackend.
@SuppressWarnings("unchecked")
public void testUnregisterBreakpoint_shouldSetAddedOnServerToFalseAfterHitOnBackend() throws Exception {
XLineBreakpointImpl breakpoint = registerMockBreakpoint(NO_WATCHES, NO_CONDITION, 13, "fileName", "packageName", false, "12abc");
handler.setStateToDisabled(new Breakpoint().setId("12abc"));
assertNotNull(breakpoint.getProperties());
assertTrue(((CloudLineBreakpointProperties) breakpoint.getProperties()).isAddedOnServer());
handler.unregisterBreakpoint(breakpoint, false);
assertFalse(((CloudLineBreakpointProperties) breakpoint.getProperties()).isAddedOnServer());
verify(stateController, never()).deleteBreakpointAsync("12abc");
}
use of com.google.api.services.clouddebugger.v2.model.Breakpoint 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.google.api.services.clouddebugger.v2.model.Breakpoint in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudBreakpointHandlerTest method testCreateIdeRepresentationsIfNecessaryVerifiesNonFinalIdeBreakpoint.
public void testCreateIdeRepresentationsIfNecessaryVerifiesNonFinalIdeBreakpoint() throws Exception {
XLineBreakpointImpl breakpoint = registerMockBreakpoint(NO_WATCHES, NO_CONDITION, 13, "fileName", "packageName", false, "12abc");
CloudLineBreakpoint cloudLineBreakpoint = (CloudLineBreakpoint) breakpoint.getUserData(com.intellij.debugger.ui.breakpoints.Breakpoint.DATA_KEY);
assertNotNull(cloudLineBreakpoint);
Assert.assertFalse(cloudLineBreakpoint.isVerified());
handler.createIdeRepresentationsIfNecessary(Lists.newArrayList(new Breakpoint().setId("12abc")));
assertThat(cloudLineBreakpoint.getErrorMessage(), nullValue());
Assert.assertTrue(cloudLineBreakpoint.isVerified());
}
Aggregations