@Nullable protected Debugger getCloudDebuggerClient() { if (cloudDebuggerClient == null) { cloudDebuggerClient = CloudDebuggerClient.getLongTimeoutClient(processState); } return cloudDebuggerClient; }
public static Debugger getLongTimeoutClient(final @Nullable String userEmail) { return getClient(userEmail, LONG_CONNECTION_TIMEOUT_MS); }
@Test public void testGetShortTimeoutClient_fromNullUserEmail() { Assert.assertNull(CloudDebuggerClient.getShortTimeoutClient((String) null)); } }
private void setupCloudDebuggerBackendMockWithException(String userEmail, IOException e) throws IOException { Breakpoints breakpoints = mock(Breakpoints.class); when(breakpoints.list(anyString())).thenThrow(e); Debuggees debuggees = mock(Debuggees.class); when(debuggees.breakpoints()).thenReturn(breakpoints); Debugger debugger = mock(Debugger.class); when(debugger.debuggees()).thenReturn(debuggees); CloudDebuggerClient.setClient( userEmail + CloudDebuggerClient.SHORT_CONNECTION_TIMEOUT_MS, debugger); }
@Test public void testGetShortTimeoutClient_fromUserEmail() { Debugger client = CloudDebuggerClient.getShortTimeoutClient("foo@example.com"); Assert.assertNotNull(client.debuggees().breakpoints()); }
assertEquals(USER, state.getUserEmail()); CloudDebuggerClient.setClient(state.getUserEmail() + 120000, client);
@Nullable private Debugger getCloudDebuggerClient() { CloudProject cloudProject = projectSelector.getSelectedProject(); CredentialedUser credentialedUser = cloudProject == null ? null : Services.getLoginService() .getLoggedInUser(cloudProject.googleUsername()) .orElse(null); if (this.credentialedUser == credentialedUser) { return cloudDebuggerClient; } this.credentialedUser = credentialedUser; cloudDebuggerClient = this.credentialedUser != null ? CloudDebuggerClient.getLongTimeoutClient(this.credentialedUser.getEmail()) : null; return cloudDebuggerClient; }
final Debugger client = CloudDebuggerClient.getShortTimeoutClient(state); if (client == null) { if (state.isListenInBackground()) {
public static Debugger getShortTimeoutClient(final @Nullable String userEmail) { return getClient(userEmail, SHORT_CONNECTION_TIMEOUT_MS); }
assertEquals(USER, state.getUserEmail()); CloudDebuggerClient.setClient(state.getUserEmail() + 120000, client);
@Test public void testGetLongTimeoutClient_fromNullUserEmail() { Assert.assertNull(CloudDebuggerClient.getLongTimeoutClient((String) null)); }
/** * Returns a cloud debugger connection given {@link CloudDebugProcessState} to indicate the * credentials to use. The function may return null if the user is not logged in. TODO: Create a * better experience attaching when not logged in TODO: Handle cases where the user logs out in * the middle of a debug session. */ @Nullable public static Debugger getLongTimeoutClient(final @NotNull CloudDebugProcessState state) { return getClient(state.getUserEmail(), LONG_CONNECTION_TIMEOUT_MS); }
@Test public void testUserAgent() throws IOException { when(mockInfoService.getUserAgent()).thenReturn("userAgent"); Debugger client = CloudDebuggerClient.getLongTimeoutClient("foo@example.com"); HttpRequest httpRequest = client.debuggees().list().buildHttpRequestUsingHead(); HttpHeaders headers = httpRequest.getHeaders(); String userAgent = headers.getUserAgent(); Assert.assertTrue(userAgent.startsWith("userAgent")); Assert.assertTrue(userAgent.endsWith("Google-API-Java-Client")); }
public static Debugger getShortTimeoutClient(final @NotNull CloudDebugProcessState state) { return getClient(state.getUserEmail(), SHORT_CONNECTION_TIMEOUT_MS); }
throw new IllegalStateException(); final Debugger client = CloudDebuggerClient.getLongTimeoutClient(state); if (client == null) { LOG.warn("no client available attempting to setBreakpoint");
return; final Debugger client = CloudDebuggerClient.getLongTimeoutClient(state); if (client == null) { LOG.warn("no client available attempting to resolveBreakpointAsync");
return; final Debugger client = CloudDebuggerClient.getLongTimeoutClient(state); if (client == null) { LOG.warn("no client available attempting to setBreakpoint");
return; final Debugger client = CloudDebuggerClient.getLongTimeoutClient(state); if (client == null) { LOG.info("no client available attempting to checkForChanges");