use of com.google.api.services.clouddebugger.v2.model.ListBreakpointsResponse in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudDebugGlobalPoller method queryServerForBreakpoints.
private void queryServerForBreakpoints(CloudDebugProcessState state, Debugger client) throws IOException {
if (state.getDebuggeeId() == null) {
throw new IllegalStateException("CloudDebugProcessState.getDebuggeeId() was null");
}
Debuggees debuggees = client.debuggees();
Breakpoints breakpoints = debuggees.breakpoints();
Breakpoints.List listRequest = breakpoints.list(state.getDebuggeeId()).setIncludeInactive(Boolean.TRUE).setActionValue("CAPTURE").setStripResults(Boolean.TRUE).setWaitToken(state.getWaitToken());
ListBreakpointsResponse response = listRequest.setClientVersion(ServiceManager.getService(PluginInfoService.class).getClientVersionForCloudDebugger()).execute();
List<Breakpoint> currentList = response.getBreakpoints();
String responseWaitToken = response.getNextWaitToken();
state.setWaitToken(responseWaitToken);
if (currentList != null) {
Collections.sort(currentList, BreakpointComparer.getDefaultInstance());
}
state.setCurrentServerBreakpointList(currentList != null ? ContainerUtil.immutableList(currentList) : ContainerUtil.immutableList(new ArrayList<Breakpoint>()));
}
use of com.google.api.services.clouddebugger.v2.model.ListBreakpointsResponse 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.ListBreakpointsResponse in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudDebugProcessStateTest method createMockClient.
private Debugger createMockClient(final List<Breakpoint> returnedBreakpoints) throws IOException {
Debugger client = Mockito.mock(Debugger.class);
Debugger.Debuggees debuggees = Mockito.mock(Debugger.Debuggees.class);
Debugger.Debuggees.Breakpoints breakpoints = Mockito.mock(Debugger.Debuggees.Breakpoints.class);
Debugger.Debuggees.Breakpoints.List list = Mockito.mock(Debugger.Debuggees.Breakpoints.List.class);
when(client.debuggees()).thenReturn(debuggees);
when(debuggees.breakpoints()).thenReturn(breakpoints);
when(breakpoints.list(DEBUGEE_ID)).thenReturn(list);
when(list.setIncludeInactive(Boolean.TRUE)).thenReturn(list);
when(list.setActionValue("CAPTURE")).thenReturn(list);
when(list.setStripResults(Boolean.TRUE)).thenReturn(list);
when(list.setWaitToken(null)).thenReturn(list);
when(list.setClientVersion(ServiceManager.getService(PluginInfoService.class).getClientVersionForCloudDebugger())).thenReturn(list);
when(list.execute()).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
ListBreakpointsResponse response = new ListBreakpointsResponse();
List<Breakpoint> copy = new ArrayList<Breakpoint>(returnedBreakpoints);
response.setBreakpoints(copy);
return response;
}
});
return client;
}
Aggregations