Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix unit tests using gcloud ADC #3722

Merged
merged 90 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
9991811
feat: initial removal of Credential argument in newApi() methods
diegomarquezp Feb 22, 2023
bafad26
chore: move account resolution to new class
diegomarquezp Feb 22, 2023
8418100
chore: cleanup of deploy classes
diegomarquezp Feb 23, 2023
fa88457
chore: cleanup of deploy UI classes
diegomarquezp Feb 23, 2023
e95eb0c
chore: cleanup of cloudsdk staging helper
diegomarquezp Feb 23, 2023
9ad0f16
chore: correct precond check, correct exception logging
diegomarquezp Feb 23, 2023
63adb79
feat: modify "Manage Google Accounts" button to rely on gcloud ADC
diegomarquezp Feb 24, 2023
25e14f8
fix: use `setBaseEnabled()` to correctly propagate login state
diegomarquezp Feb 24, 2023
675d3f7
chore: better UI, on-demand cred check
diegomarquezp Mar 2, 2023
f8e5cb2
chore: [wip] adapt single account to deploy dialog
diegomarquezp Mar 6, 2023
552c729
chore: display gcloud instruction messages
diegomarquezp Mar 14, 2023
57b86d8
fix: layout to wrap no ADC message
diegomarquezp Mar 16, 2023
7fedcf3
chore: disable deploy button when not logged in
diegomarquezp Mar 16, 2023
f874744
chore: do not throw exception when checking for credentials
diegomarquezp Mar 16, 2023
9fca091
fix: compilation errors
diegomarquezp Mar 16, 2023
29d0eee
fix: compilation errors in tests
diegomarquezp Mar 16, 2023
6e44d2e
Merge branch 'gcloud-cli-creds-cleanup' into gcloud-cli-creds-test-fixes
diegomarquezp Mar 16, 2023
0b62841
Merge branch 'gcloud-cli-creds-appengine-deploy' into gcloud-cli-cred…
diegomarquezp Mar 16, 2023
3151477
Merge branch 'gcloud-cli-creds-deploy-no-project' into gcloud-cli-cre…
diegomarquezp Mar 16, 2023
1373222
chore: initial compilation-enabling adjustments
diegomarquezp Mar 17, 2023
1f74161
chore: use `hasCredentialsSet()`
diegomarquezp Mar 20, 2023
8811a92
chore: add test account provider
diegomarquezp Mar 22, 2023
57caab7
chore: fix usagetracker and projectselector test
diegomarquezp Mar 22, 2023
fe2bdee
chore: expose `getCredential()`
diegomarquezp Mar 22, 2023
d251d6f
chore: fix projectselector tests
diegomarquezp Mar 22, 2023
a9c9715
chore: null check for `setPRoviderState()`
diegomarquezp Mar 22, 2023
a601d7d
chore: add avatar URL to test accounts
diegomarquezp Mar 22, 2023
4208f28
chore: fix login tests
diegomarquezp Mar 22, 2023
49eae09
chore: fix googleapis tests
diegomarquezp Mar 22, 2023
5c89517
chore: add convenience state+defaultprovider method
diegomarquezp Mar 22, 2023
79a6be8
chore: fix dataflow tests
diegomarquezp Mar 22, 2023
6e0fc57
chore: fix dataflow core tests
diegomarquezp Mar 22, 2023
5b4c232
chore: fix error-prone state check in localserver
diegomarquezp Mar 22, 2023
a6b950f
chore: correct static member initialization order in `TestAccountProv…
diegomarquezp Mar 22, 2023
68f1579
chore: initialize static account provider once
diegomarquezp Mar 23, 2023
7387366
chore: use mock methods instead of test acct provider in `MiniSelecto…
diegomarquezp Mar 23, 2023
275dd40
Merge branch 'gcloud-cli-creds' into gcloud-cli-creds-test-fixes
diegomarquezp Mar 23, 2023
fb425e8
chore: fixes after merging `gcloud-cli-creds`
diegomarquezp Mar 23, 2023
bcd858d
chore: use avatar urls in test accounts
diegomarquezp Mar 23, 2023
e64af26
chore: fix accounts panel tests
diegomarquezp Mar 23, 2023
f24ce4b
chore: fix dataflow preferences test
diegomarquezp Mar 23, 2023
35404ae
chore: fix login `Account` package
diegomarquezp Mar 23, 2023
17182c2
chore: fix usagetracker test ii
diegomarquezp Mar 23, 2023
d72792e
fix: project repository test
diegomarquezp Mar 23, 2023
9d59678
chore: fix googleapis proxy tests
diegomarquezp Mar 23, 2023
c9ddc7d
fix: dataflow preferences test
diegomarquezp Mar 23, 2023
20dfaec
chore: fix login tests, remove unused elements (pending cleanup)
diegomarquezp Mar 24, 2023
92bd48e
chore: fix app engine deploy tests
diegomarquezp Mar 24, 2023
2baf89b
chore: remove unnecessary test in `GcpProjectQueryJobTest`
diegomarquezp Mar 24, 2023
1f3fdba
chore: fix localserver tests iii
diegomarquezp Mar 24, 2023
2f922c5
chore: more dataflow ui test fixes
diegomarquezp Mar 26, 2023
0858bcc
chore: fix project repository test
diegomarquezp Mar 26, 2023
df2f533
chore: accounts panel test to assert correct number of children
diegomarquezp Mar 27, 2023
855db03
chore: run tests on any pr
diegomarquezp Mar 27, 2023
d227577
chore: fix update accounts logic in `GoogleLoginService`
diegomarquezp Mar 27, 2023
bba6286
chore: remove initialization of static members in constructors
diegomarquezp Mar 27, 2023
f71b56b
chore: fire listeners in `AccountSelector`
diegomarquezp Mar 28, 2023
d68707e
chore: fix `GoogleApiFactory` initalization in `GcpLocalRunTabTest`
diegomarquezp Mar 28, 2023
59b97d0
chore: fix cache check in `AccountSelector`
diegomarquezp Mar 28, 2023
5ff7a3f
chore: fix `CloudSdkProcessWrapperTest`
diegomarquezp Mar 28, 2023
ffb6aa2
chore: correct stubbing in `DefaultedPipelineOptionsComponentTest`
diegomarquezp Mar 28, 2023
b7e54f4
chore: remove unused imports in `CloudSdkProcessWrapper`
diegomarquezp Mar 28, 2023
f40809e
chore: remove unused import in `AccountPanelsTest`
diegomarquezp Mar 28, 2023
fd1d42e
chore: trigger update on `GcpLocalRunTabTest`
diegomarquezp Mar 28, 2023
9c68243
chore: fix `fireSelectionListeners` after setting change tracker vari…
diegomarquezp Mar 28, 2023
a18bf6d
chore: fix `GcpLocalRUnTabTest`
diegomarquezp Mar 28, 2023
b1426ac
chore: refactor force `AccountSelector` check to a better named method
diegomarquezp Mar 28, 2023
41de20a
chore: return validation states in `RunOptionsDefaultsComponent`
diegomarquezp Mar 28, 2023
bdac2ed
chore: add status checks to other test in `RODCTest`
diegomarquezp Mar 28, 2023
9dcdcc5
chore: make `forceCheck()` public in `AccountSelector`
diegomarquezp Mar 29, 2023
a53f488
chore: remove unused thrown exception from delcaration in `GcpLocalRu…
diegomarquezp Mar 29, 2023
99b0e97
chore: set flag to enable `forceAccountCheck`
diegomarquezp Mar 29, 2023
1a2580d
chore: have dataflow Command RunOptionsDefaultScomponent not found to…
diegomarquezp Mar 29, 2023
2db054f
chore: fix login service test
diegomarquezp Mar 29, 2023
9c4978d
chore: fix assertions, verify projects loaded in `RunOptionsDefaultCO…
diegomarquezp Mar 29, 2023
3c78d87
chore: update project lists on account change in `RunOptionsDefaultsC…
diegomarquezp Mar 29, 2023
4364ac4
chore: lock `login` `com.google.api` versions to `1.25.0`
diegomarquezp Mar 29, 2023
9b34c42
chore: remove unthrown exception declaration in `GcpLocalRunTabTest`
diegomarquezp Mar 29, 2023
055cbf9
chore: fix tests in `RunOptionsDefaultsCOmponentTest`
diegomarquezp Mar 29, 2023
89617b3
chore: correct versions in login MANIFEST.MF
diegomarquezp Mar 29, 2023
dfc3e42
chore: fix Command setUpServiceKeyCreation not found in Command GcpLo…
diegomarquezp Mar 29, 2023
d4ed22d
chore: make account selector to return update result
diegomarquezp Mar 29, 2023
a224d05
chore: fix non-existent version of `com.google.api.services.oauth2`
diegomarquezp Mar 29, 2023
70eba60
chore: fix logic check in `forceAccountCHeck` for `AccountSelector`
diegomarquezp Mar 29, 2023
8606143
chore: exclude `oauth2` package in manifest check
diegomarquezp Mar 30, 2023
a644598
chore: fix comments in default pipeline options test
diegomarquezp Apr 11, 2023
f1786ba
chore: fixes in dataflow tests
diegomarquezp Apr 11, 2023
861577d
chore: remove TODO comment
diegomarquezp Apr 11, 2023
456716b
chore: using `EnumMap` in `TestAccountProvider`
diegomarquezp Apr 11, 2023
6986f65
chore: handle `GoogleApiFactory` credential-related methods internall…
diegomarquezp Apr 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/eclipse-2018-09-java8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab

jobs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@
package com.google.cloud.tools.eclipse.appengine.deploy.util;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import com.google.cloud.tools.appengine.operations.AppEngineWebXmlProjectStaging;
import com.google.cloud.tools.appengine.operations.Deployment;
import com.google.cloud.tools.appengine.operations.cloudsdk.CloudSdkNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import com.google.cloud.tools.eclipse.test.util.TestAccountProvider;
import com.google.cloud.tools.eclipse.test.util.TestAccountProvider.State;
import org.eclipse.core.runtime.Status;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
Expand All @@ -39,34 +38,25 @@ public class CloudSdkProcessWrapperTest {

private final CloudSdkProcessWrapper wrapper = new CloudSdkProcessWrapper();

@Before
public void setUp() {
TestAccountProvider.setAsDefaultProvider(State.NOT_LOGGED_IN);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as a test suite does not instantiate a client (e.g. apiFactory.newXXXClient()), this account provider must be setup to prevent actual calls or credential checks

}

@Test
public void testGetAppEngineDeployment_nullCredentialFile() throws CloudSdkNotFoundException {
try {
wrapper.getAppEngineDeployment(null, null);
wrapper.getAppEngineDeployment(null);
fail();
} catch (NullPointerException ex) {
} catch (IllegalStateException ex) {
assertEquals(ex.getMessage(), "credential required for deploying");
}
}

@Test
public void testGetAppEngineDeployment_nonExistingCredentialFile()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Providing credentials does not apply anymore.

throws CloudSdkNotFoundException {
Path credential = tempFolder.getRoot().toPath().resolve("non-existing-file");
assertFalse(Files.exists(credential));

try {
wrapper.getAppEngineDeployment(credential, null);
fail();
} catch (IllegalArgumentException ex) {
assertEquals(ex.getMessage(), "non-existing credential file");
}
}

@Test
public void testGetAppEngineDeployment() throws IOException, CloudSdkNotFoundException {
Path credential = tempFolder.newFile().toPath();
Deployment deployment = wrapper.getAppEngineDeployment(credential, null);
public void testGetAppEngineDeployment() throws CloudSdkNotFoundException {
TestAccountProvider.setProviderState(State.LOGGED_IN);
Deployment deployment = wrapper.getAppEngineDeployment(null);
assertNotNull(deployment);
}

Expand All @@ -78,11 +68,11 @@ public void testGetAppEngineStandardStaging() throws CloudSdkNotFoundException {

@Test
public void testGetAppEngineDeployment_cannotSetUpTwice()
throws IOException, CloudSdkNotFoundException {
Path credential = tempFolder.newFile().toPath();
wrapper.getAppEngineDeployment(credential, null);
throws CloudSdkNotFoundException {
TestAccountProvider.setProviderState(State.LOGGED_IN);
wrapper.getAppEngineDeployment(null);
try {
wrapper.getAppEngineDeployment(credential, null);
wrapper.getAppEngineDeployment(null);
fail();
} catch (IllegalStateException ex) {
assertEquals(ex.getMessage(), "process wrapper already set up");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.doReturn;

import com.google.cloud.tools.eclipse.googleapis.IGoogleApiFactory;
import com.google.cloud.tools.eclipse.login.IGoogleLoginService;
import com.google.cloud.tools.eclipse.test.util.TestAccountProvider;
import com.google.cloud.tools.eclipse.test.util.ui.CompositeUtil;
import com.google.cloud.tools.eclipse.test.util.ui.ShellTestResource;
import java.util.Optional;
import org.eclipse.core.resources.IProject;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.forms.widgets.SharedScrolledComposite;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -45,6 +49,12 @@ public abstract class DeployPropertyPageTest<P extends DeployPreferencesPanel> {
@Mock
private IGoogleApiFactory googleApiFactory;

@Before
public void setup() {
doReturn(Optional.of(TestAccountProvider.ACCOUNT_1)).when(googleApiFactory).getAccount();
doReturn(Optional.of(TestAccountProvider.CREDENTIAL_ACCOUNT_1)).when(googleApiFactory).getCredential();
}

@Test
public void testCorrectPanelIsShownForFacetedProject() {
DeployPropertyPage page = new DeployPropertyPage(loginService, googleApiFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ public void tearDown() {
assertEquals(Job.NONE, queryJob.getState());
}

@Test(expected = NullPointerException.class)
public void testNullCredential() {
new GcpProjectQueryJob(projectRepository, projectSelector,
dataBindingContext, isLatestQueryJob);
}

@Test
public void testRun_setsProjects() throws InterruptedException, ProjectRepositoryException {
queryJob.schedule();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
package com.google.cloud.tools.eclipse.appengine.deploy.ui.flexible;

import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import com.google.cloud.tools.eclipse.googleapis.IGoogleApiFactory;
import com.google.cloud.tools.eclipse.test.util.TestAccountProvider;
import com.google.cloud.tools.eclipse.test.util.ui.CompositeUtil;
import com.google.cloud.tools.eclipse.test.util.ui.ShellTestResource;
import java.util.Optional;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Path;
import org.eclipse.swt.widgets.Composite;
Expand All @@ -38,17 +41,23 @@ public class FlexDeployPreferencesDialogTest {
+ "flexible environment. Visit <a href=\"https://cloud.google.com/appengine/pricing\">"
+ "GCP Pricing</a> for pricing information.";

@Rule public ShellTestResource shellResource = new ShellTestResource();
@Rule
public ShellTestResource shellResource = new ShellTestResource();

private FlexDeployPreferencesDialog dialog;

private IGoogleApiFactory googleApiFactory;

@Before
public void setUp() {
googleApiFactory = mock(IGoogleApiFactory.class);
doReturn(Optional.of(TestAccountProvider.ACCOUNT_1)).when(googleApiFactory).getAccount();
doReturn(Optional.of(TestAccountProvider.CREDENTIAL_ACCOUNT_1)).when(googleApiFactory)
.getCredential();
IProject project = mock(IProject.class);
when(project.getName()).thenReturn("");
when(project.getLocation()).thenReturn(new Path("/"));
dialog = new FlexDeployPreferencesDialog(null, "title", project,
mock(IGoogleApiFactory.class));
dialog = new FlexDeployPreferencesDialog(null, "title", project, googleApiFactory);
}

@Test
Expand All @@ -61,8 +70,7 @@ public void testFlexPricingLabel() {
}

private static Control findGcpPricingLink(Composite dialogArea) {
return CompositeUtil.findControl(dialogArea,
control -> control instanceof Link && GCP_PRICING_MESSAGE.equals(((Link) control).getText())
);
return CompositeUtil.findControl(dialogArea, control -> control instanceof Link
&& GCP_PRICING_MESSAGE.equals(((Link) control).getText()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;

import com.google.cloud.tools.eclipse.appengine.deploy.ui.internal.AppYamlValidator;
import com.google.cloud.tools.eclipse.appengine.facets.AppEngineFlexWarFacet;
import com.google.cloud.tools.eclipse.googleapis.IGoogleApiFactory;
import com.google.cloud.tools.eclipse.projectselector.ProjectRepository;
import com.google.cloud.tools.eclipse.test.util.TestAccountProvider;
import com.google.cloud.tools.eclipse.test.util.project.TestProjectCreator;
import com.google.cloud.tools.eclipse.test.util.ui.CompositeUtil;
import com.google.cloud.tools.eclipse.test.util.ui.ShellTestResource;
import java.util.Optional;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.resources.IProject;
Expand Down Expand Up @@ -61,6 +64,9 @@ public class FlexDeployPreferencesPanelTest {

@Before
public void setUp() {
doReturn(Optional.of(TestAccountProvider.ACCOUNT_1)).when(apiFactory).getAccount();
doReturn(Optional.of(TestAccountProvider.CREDENTIAL_ACCOUNT_1)).when(apiFactory)
.getCredential();
project = projectCreator.getProject();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,23 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.doReturn;

import com.google.cloud.tools.eclipse.appengine.deploy.ui.AppEngineDeployPreferencesPanel;
import com.google.cloud.tools.eclipse.appengine.deploy.ui.internal.DeployArtifactValidator;
import com.google.cloud.tools.eclipse.googleapis.IGoogleApiFactory;
import com.google.cloud.tools.eclipse.projectselector.ProjectRepository;
import com.google.cloud.tools.eclipse.test.util.TestAccountProvider;
import com.google.cloud.tools.eclipse.test.util.ui.CompositeUtil;
import com.google.cloud.tools.eclipse.test.util.ui.ShellTestResource;
import java.util.Optional;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -49,6 +53,13 @@ public class FlexExistingArtifactDeployPreferencesPanelTest {

@Rule public ShellTestResource shellResource = new ShellTestResource();

@Before
public void setup() {
doReturn(Optional.of(TestAccountProvider.ACCOUNT_1)).when(apiFactory).getAccount();
doReturn(Optional.of(TestAccountProvider.CREDENTIAL_ACCOUNT_1)).when(apiFactory)
.getCredential();
}

@Test
public void testDeployArtifactPathField() {
AppEngineDeployPreferencesPanel panel = createPanel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public class DeployPropertyPageForStandardProjectTest
extends DeployPropertyPageTest<AppEngineDeployPreferencesPanel> {

@Rule
public TestProjectCreator standardProjectCreator = new TestProjectCreator().withFacets(
JavaFacet.VERSION_1_8, WebFacetUtils.WEB_31,
AppEngineStandardFacetChangeListener.APP_ENGINE_STANDARD_JRE8);
public TestProjectCreator standardProjectCreator =
new TestProjectCreator().withFacets(JavaFacet.VERSION_1_8, WebFacetUtils.WEB_31,
AppEngineStandardFacetChangeListener.APP_ENGINE_STANDARD_JRE8);

@Override
protected IProject getProject() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
package com.google.cloud.tools.eclipse.appengine.deploy.ui.standard;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import com.google.cloud.tools.eclipse.googleapis.IGoogleApiFactory;
import com.google.cloud.tools.eclipse.projectselector.ProjectRepository;
import com.google.cloud.tools.eclipse.test.util.TestAccountProvider;
import com.google.cloud.tools.eclipse.test.util.ui.ShellTestResource;
import java.util.Optional;
import org.eclipse.core.resources.IProject;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -33,10 +36,14 @@ public class StandardDeployPreferencesPanelTest {

@Test
public void testGetHelpContextId() {
IGoogleApiFactory apiFactory = mock(IGoogleApiFactory.class);
doReturn(Optional.of(TestAccountProvider.ACCOUNT_1)).when(apiFactory).getAccount();
doReturn(Optional.of(TestAccountProvider.CREDENTIAL_ACCOUNT_1)).when(apiFactory)
.getCredential();
IProject project = mock(IProject.class);
when(project.getName()).thenReturn("");
StandardDeployPreferencesPanel panel = new StandardDeployPreferencesPanel(
shellResource.getShell(), project, mock(IGoogleApiFactory.class), mock(Runnable.class),
shellResource.getShell(), project, apiFactory, mock(Runnable.class),
false, mock(ProjectRepository.class));

assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ private void createProjectIdSection(IGoogleApiFactory apiFactory) {

Composite linkComposite = new Composite(this, SWT.NONE);
Link createNewProject = new Link(linkComposite, SWT.WRAP);
if (apiFactory.hasCredentialsSet()) {
if (apiFactory.getCredential().isPresent()) {
createNewProject.setText(Messages.getString("projectselector.createproject",
CREATE_GCP_PROJECT_URL));
createNewProject.setToolTipText(Messages.getString("projectselector.createproject.tooltip"));
Expand Down Expand Up @@ -510,7 +510,7 @@ private void refreshProjectsForSelectedCredential(IGoogleApiFactory apiFactory)
projectSelector.setProjects(Collections.<GcpProject>emptyList());
latestGcpProjectQueryJob = null;

if (apiFactory.hasCredentialsSet()) {
if (apiFactory.getCredential().isPresent()) {
Predicate<Job> isLatestQueryJob = job -> job == latestGcpProjectQueryJob;
latestGcpProjectQueryJob = new GcpProjectQueryJob(projectRepository,
projectSelector, bindingContext, isLatestQueryJob);
Expand Down Expand Up @@ -598,7 +598,7 @@ protected IStatus validate() {
// this access is recorded and ensures that changes are tracked, don't move it inside the if
Object selectedProject = projectSelection.getValue();

if (!apiFactory.hasCredentialsSet()) {
if (!apiFactory.getCredential().isPresent()) {
return ValidationStatus.ok();
}
if (projects.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected Control createDialogArea(Composite parent) {
@Override
public int getMessageType(ValidationStatusProvider statusProvider) {
int type = super.getMessageType(statusProvider);
setValid(type != IMessageProvider.ERROR && apiFactory.hasCredentialsSet());
setValid(type != IMessageProvider.ERROR && apiFactory.getCredential().isPresent());
return type;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
import com.google.cloud.tools.appengine.configuration.AppYamlProjectStageConfiguration;
import com.google.cloud.tools.appengine.operations.AppEngineWebXmlProjectStaging;
import com.google.cloud.tools.appengine.operations.AppYamlProjectStaging;
import com.google.cloud.tools.appengine.operations.CloudSdk;
import com.google.cloud.tools.eclipse.appengine.deploy.util.CloudSdkProcessWrapper;
import java.nio.file.Path;
import java.util.logging.Level;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.google.cloud.tools.eclipse.appengine.deploy.util;

import com.google.cloud.tools.appengine.operations.Deployment;
import com.google.api.client.auth.oauth2.Credential;
import com.google.cloud.tools.appengine.operations.AppCfg;
import com.google.cloud.tools.appengine.operations.AppEngineWebXmlProjectStaging;
import com.google.cloud.tools.appengine.operations.CloudSdk;
Expand Down Expand Up @@ -72,15 +71,7 @@ public class CloudSdkProcessWrapper {
*/
public Deployment getAppEngineDeployment(MessageConsoleStream normalOutputStream)
throws CloudSdkNotFoundException {
Credential credential = null;
try {
credential = new GoogleApiFactory().getAccount().getOAuth2Credential();
}
catch (IOException ex) {
// will be handled in preconditions check;
}
Preconditions.checkNotNull(credential, "credentials not set");

Preconditions.checkState(new GoogleApiFactory().getCredential().isPresent(), "credential required for deploying");
Preconditions.checkState(!initialized, "process wrapper already set up");
initialized = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Bundle-Vendor: %providerName
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Localization: plugin
Require-Bundle: com.google.cloud.tools.eclipse.test.dependencies
Import-Package: com.google.cloud.tools.eclipse.swtbot,
Import-Package: com.google.cloud.tools.eclipse.googleapis.internal,
com.google.cloud.tools.eclipse.swtbot,
com.google.cloud.tools.eclipse.test.util,
com.google.cloud.tools.eclipse.test.util.project,
com.google.cloud.tools.eclipse.test.util.ui,
Expand Down
Loading