use of com.google.cloud.tools.intellij.login.IntegratedGoogleLoginService in project google-cloud-intellij by GoogleCloudPlatform.
the class ProjectSelector method updateCloudProjectSelection.
private void updateCloudProjectSelection(CloudProject selection) {
projectNameLabel.setHyperlinkText(selection.projectName());
projectAccountSeparatorLabel.setVisible(true);
// first just show account email, then expand with name/picture if this account is signed in.
// if not signed in, hide icon and account name completely and prompt to sign in.
accountInfoLabel.setHyperlinkText(selection.googleUsername());
IntegratedGoogleLoginService loginService = Services.getLoginService();
Optional<CredentialedUser> loggedInUser = loginService.getLoggedInUser(selection.googleUsername());
if (!loggedInUser.isPresent()) {
accountInfoLabel.setHyperlinkText(GoogleCloudCoreMessageBundle.message("cloud.project.selector.not.signed.in", selection.googleUsername()));
} else if (loggedInUser.isPresent()) {
accountInfoLabel.setHyperlinkText(String.format("%s (%s)", Strings.nullToEmpty(loggedInUser.get().getName()), loggedInUser.get().getEmail()));
}
accountInfoLabel.setIcon(loginService.isLoggedIn() ? GoogleLoginIcons.getScaledUserIcon(ACCOUNT_ICON_SIZE, loggedInUser.orElse(null)) : null);
}
use of com.google.cloud.tools.intellij.login.IntegratedGoogleLoginService in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudAttachDialogTest method mockCredentials.
private void mockCredentials() throws Exception {
IntegratedGoogleLoginService mockLoginService = TestUtils.installMockService(IntegratedGoogleLoginService.class);
GoogleLoginState googleLoginState = mock(GoogleLoginState.class);
Credential credential = mock(Credential.class);
this.user = mock(CredentialedUser.class);
LinkedHashMap<String, CredentialedUser> allusers = new LinkedHashMap<String, CredentialedUser>();
when(this.user.getCredential()).thenReturn(credential);
when(this.user.getEmail()).thenReturn(USER);
when(this.user.getGoogleLoginState()).thenReturn(googleLoginState);
when(googleLoginState.fetchAccessToken()).thenReturn(PASSWORD);
when(mockLoginService.getAllUsers()).thenReturn(allusers);
allusers.put(USER, this.user);
}
use of com.google.cloud.tools.intellij.login.IntegratedGoogleLoginService in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudDebugProcessTest method testRemoveConsolePane.
public void testRemoveConsolePane() {
// if this was a JUnit4 test case, we could set the LoggedErrorProcessor to a mock that does
// not fail the test if an error is logged using @BeforeClass. Since this is a JUnit3 test
// case, we need to elaborately initialize a user in GoogleLogin
CloudDebugProcessState state = // Mockito.mock(CloudDebugProcessState.class);
new CloudDebugProcessState();
state.setUserEmail("mockUser@foo.com");
CredentialedUser credentialedUser = mock(CredentialedUser.class);
when(credentialedUser.getGoogleLoginState()).thenReturn(mock(GoogleLoginState.class));
LinkedHashMap<String, CredentialedUser> users = new LinkedHashMap<String, CredentialedUser>();
users.put(state.getUserEmail(), credentialedUser);
IntegratedGoogleLoginService mockGoogleLoginService = TestUtils.installMockService(IntegratedGoogleLoginService.class);
when(mockGoogleLoginService.getAllUsers()).thenReturn(users);
process.initialize(state);
XDebugTabLayouter layouter = process.createTabLayouter();
RunnerLayoutUi ui = mock(RunnerLayoutUi.class);
Content console = mock(Content.class);
when(ui.findContent(DebuggerContentInfo.CONSOLE_CONTENT)).thenReturn(console);
ui.removeContent(console, false);
LayoutStateDefaults defaults = mock(LayoutStateDefaults.class);
when(ui.getDefaults()).thenReturn(defaults);
layouter.registerAdditionalContent(ui);
verify(ui, Mockito.atLeast(1)).removeContent(console, false);
process.getStateController().stopBackgroundListening();
UIUtil.dispatchAllInvocationEvents();
}
use of com.google.cloud.tools.intellij.login.IntegratedGoogleLoginService in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudDebugProcessStateTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
fixture = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getTestName(true)).getFixture();
fixture.setUp();
project = new MockProjectEx(getTestRootDisposable());
PsiManager psiManager = Mockito.mock(PsiManager.class);
project.registerService(PsiManager.class, psiManager);
IntegratedGoogleLoginService mockLoginService = TestUtils.installMockService(IntegratedGoogleLoginService.class);
GoogleLoginState googleLoginState = Mockito.mock(GoogleLoginState.class);
CredentialedUser user = Mockito.mock(CredentialedUser.class);
LinkedHashMap<String, CredentialedUser> allusers = new LinkedHashMap<String, CredentialedUser>();
when(user.getEmail()).thenReturn(USER);
when(user.getGoogleLoginState()).thenReturn(googleLoginState);
when(googleLoginState.fetchAccessToken()).thenReturn(PASSWORD);
when(mockLoginService.getAllUsers()).thenReturn(allusers);
allusers.put(USER, user);
}
use of com.google.cloud.tools.intellij.login.IntegratedGoogleLoginService in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudDebuggerClientTest method setUp.
@Before
public void setUp() {
IntegratedGoogleLoginService mockLogin = Mockito.mock(IntegratedGoogleLoginService.class);
registerService(IntegratedGoogleLoginService.class, mockLogin);
registerService(PluginInfoService.class, mockInfoService);
LinkedHashMap<String, CredentialedUser> allUsers = new LinkedHashMap<String, CredentialedUser>();
CredentialedUser user = Mockito.mock(CredentialedUser.class);
allUsers.put("foo@example.com", user);
when(mockLogin.getAllUsers()).thenReturn(allUsers);
Credential credential = Mockito.mock(Credential.class);
when(user.getCredential()).thenReturn(credential);
GoogleLoginState loginState = Mockito.mock(GoogleLoginState.class);
when(user.getGoogleLoginState()).thenReturn(loginState);
}
Aggregations