From 514cf8aada7387811303b4198251e5affce93c90 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Thu, 5 Jan 2017 15:35:21 -0500 Subject: [PATCH] Remove .appengine.facets dependency from ui.util (#1183) * Remove .appengine.facets dependency from ui.util * Make getProject static method * Don't call empty super method * Remove Preconditions * Throw NullPointerException --- .../deploy/FacetedProjectHelperTest.java | 11 +-- .../StandardDeployCommandHandlerTest.java | 61 ------------ .../StandardDeployCommandHandler.java | 93 +++++++++---------- .../facets/StandardFacetInstallationTest.java | 4 +- .../appengine/DeployPropertyPageTest.java | 3 +- ...wMavenBasedAppEngineProjectWizardTest.java | 3 +- ...NewNativeAppEngineStandardProjectTest.java | 3 +- .../META-INF/MANIFEST.MF | 3 +- .../ui/util/ProjectFromSelectionHelper.java | 23 +---- .../eclipse/util/FacetedProjectHelper.java | 23 ++--- 10 files changed, 62 insertions(+), 165 deletions(-) delete mode 100644 plugins/com.google.cloud.tools.eclipse.appengine.deploy.ui.test/src/com/google/cloud/tools/eclipse/appengine/deploy/ui/standard/StandardDeployCommandHandlerTest.java diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.deploy.test/src/com/google/cloud/tools/eclipse/appengine/deploy/FacetedProjectHelperTest.java b/plugins/com.google.cloud.tools.eclipse.appengine.deploy.test/src/com/google/cloud/tools/eclipse/appengine/deploy/FacetedProjectHelperTest.java index c26782791b..70a6c5497b 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.deploy.test/src/com/google/cloud/tools/eclipse/appengine/deploy/FacetedProjectHelperTest.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.deploy.test/src/com/google/cloud/tools/eclipse/appengine/deploy/FacetedProjectHelperTest.java @@ -18,19 +18,12 @@ import static org.mockito.Mockito.mock; -import org.eclipse.core.runtime.CoreException; +import com.google.cloud.tools.eclipse.util.FacetedProjectHelper; import org.eclipse.wst.common.project.facet.core.IFacetedProject; import org.junit.Test; -import com.google.cloud.tools.eclipse.util.FacetedProjectHelper; - public class FacetedProjectHelperTest { - @Test(expected = NullPointerException.class) - public void testGetFacetedProject_nullArgument() throws CoreException { - new FacetedProjectHelper().getFacetedProject(null); - } - @Test(expected = NullPointerException.class) public void testProjectHasFacet_projectNull() { new FacetedProjectHelper().projectHasFacet(null, null); @@ -40,7 +33,7 @@ public void testProjectHasFacet_projectNull() { public void testProjectHasFacet_facetIdNull() { new FacetedProjectHelper().projectHasFacet(mock(IFacetedProject.class), null); } - + @Test(expected = IllegalArgumentException.class) public void testProjectHasFacet_facetIdEmpty() { new FacetedProjectHelper().projectHasFacet(mock(IFacetedProject.class), ""); diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.deploy.ui.test/src/com/google/cloud/tools/eclipse/appengine/deploy/ui/standard/StandardDeployCommandHandlerTest.java b/plugins/com.google.cloud.tools.eclipse.appengine.deploy.ui.test/src/com/google/cloud/tools/eclipse/appengine/deploy/ui/standard/StandardDeployCommandHandlerTest.java deleted file mode 100644 index d77527a834..0000000000 --- a/plugins/com.google.cloud.tools.eclipse.appengine.deploy.ui.test/src/com/google/cloud/tools/eclipse/appengine/deploy/ui/standard/StandardDeployCommandHandlerTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2016 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.cloud.tools.eclipse.appengine.deploy.ui.standard; - -import static org.mockito.Matchers.isA; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.cloud.tools.eclipse.test.util.ui.ExecutionEventBuilder; -import com.google.cloud.tools.eclipse.util.FacetedProjectHelper; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.swt.widgets.Shell; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - -@RunWith(MockitoJUnitRunner.class) -public class StandardDeployCommandHandlerTest { - - @Mock private FacetedProjectHelper facetedProjectHelper; - - @Test(expected = ExecutionException.class) - public void testExecute_facetedProjectCreationThrowsException() throws ExecutionException, CoreException { - StandardDeployCommandHandler handler = new StandardDeployCommandHandler(facetedProjectHelper); - - when(facetedProjectHelper.getFacetedProject(isA(IProject.class))).thenThrow(getFakeCoreException()); - ExecutionEvent event = new ExecutionEventBuilder().withCurrentSelection(mock(IProject.class)) - .withActiveShell(mock(Shell.class)).build(); - - handler.execute(event); - } - - private CoreException getFakeCoreException() { - return new CoreException(getFakeErrorStatus()); - } - - private Status getFakeErrorStatus() { - return new Status(IStatus.ERROR, "fakePluginId", "test exception"); - } - -} diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.deploy.ui/src/com/google/cloud/tools/eclipse/appengine/deploy/ui/standard/StandardDeployCommandHandler.java b/plugins/com.google.cloud.tools.eclipse.appengine.deploy.ui/src/com/google/cloud/tools/eclipse/appengine/deploy/ui/standard/StandardDeployCommandHandler.java index 9668a5e6ce..c67678ecbd 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.deploy.ui/src/com/google/cloud/tools/eclipse/appengine/deploy/ui/standard/StandardDeployCommandHandler.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.deploy.ui/src/com/google/cloud/tools/eclipse/appengine/deploy/ui/standard/StandardDeployCommandHandler.java @@ -16,13 +16,29 @@ package com.google.cloud.tools.eclipse.appengine.deploy.ui.standard; +import com.google.api.client.auth.oauth2.Credential; +import com.google.cloud.tools.appengine.api.deploy.DefaultDeployConfiguration; +import com.google.cloud.tools.eclipse.appengine.deploy.CleanupOldDeploysJob; +import com.google.cloud.tools.eclipse.appengine.deploy.standard.StandardDeployJob; +import com.google.cloud.tools.eclipse.appengine.deploy.standard.StandardDeployJobConfig; +import com.google.cloud.tools.eclipse.appengine.deploy.standard.StandardDeployPreferences; +import com.google.cloud.tools.eclipse.appengine.deploy.standard.StandardDeployPreferencesConverter; +import com.google.cloud.tools.eclipse.appengine.deploy.ui.DeployConsole; +import com.google.cloud.tools.eclipse.appengine.deploy.ui.DeployPreferencesDialog; +import com.google.cloud.tools.eclipse.appengine.deploy.ui.Messages; +import com.google.cloud.tools.eclipse.appengine.login.IGoogleLoginService; +import com.google.cloud.tools.eclipse.sdk.ui.MessageConsoleWriterOutputLineListener; +import com.google.cloud.tools.eclipse.ui.util.MessageConsoleUtilities; +import com.google.cloud.tools.eclipse.ui.util.ProjectFromSelectionHelper; +import com.google.cloud.tools.eclipse.ui.util.ServiceUtils; +import com.google.cloud.tools.eclipse.usagetracker.AnalyticsEvents; +import com.google.cloud.tools.eclipse.usagetracker.AnalyticsPingManager; import java.io.IOException; import java.nio.file.Files; import java.text.DateFormat; import java.text.MessageFormat; import java.util.Date; import java.util.Locale; - import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; @@ -40,26 +56,8 @@ import org.eclipse.ui.console.IConsoleManager; import org.eclipse.ui.console.MessageConsoleStream; import org.eclipse.ui.handlers.HandlerUtil; - -import com.google.api.client.auth.oauth2.Credential; -import com.google.cloud.tools.appengine.api.deploy.DefaultDeployConfiguration; -import com.google.cloud.tools.eclipse.appengine.deploy.CleanupOldDeploysJob; -import com.google.cloud.tools.eclipse.appengine.deploy.standard.StandardDeployJob; -import com.google.cloud.tools.eclipse.appengine.deploy.standard.StandardDeployJobConfig; -import com.google.cloud.tools.eclipse.appengine.deploy.standard.StandardDeployPreferences; -import com.google.cloud.tools.eclipse.appengine.deploy.standard.StandardDeployPreferencesConverter; -import com.google.cloud.tools.eclipse.appengine.deploy.ui.DeployConsole; -import com.google.cloud.tools.eclipse.appengine.deploy.ui.DeployPreferencesDialog; -import com.google.cloud.tools.eclipse.appengine.deploy.ui.Messages; -import com.google.cloud.tools.eclipse.appengine.login.IGoogleLoginService; -import com.google.cloud.tools.eclipse.sdk.ui.MessageConsoleWriterOutputLineListener; -import com.google.cloud.tools.eclipse.ui.util.MessageConsoleUtilities; -import com.google.cloud.tools.eclipse.ui.util.ProjectFromSelectionHelper; -import com.google.cloud.tools.eclipse.ui.util.ServiceUtils; -import com.google.cloud.tools.eclipse.usagetracker.AnalyticsEvents; -import com.google.cloud.tools.eclipse.usagetracker.AnalyticsPingManager; -import com.google.cloud.tools.eclipse.util.FacetedProjectHelper; -import com.google.common.annotations.VisibleForTesting; +import org.eclipse.wst.common.project.facet.core.IFacetedProject; +import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; /** * Command handler to deploy a web application project to App Engine Standard. @@ -71,40 +69,36 @@ public class StandardDeployCommandHandler extends AbstractHandler { private static final String CONSOLE_NAME = "App Engine Deploy"; - private ProjectFromSelectionHelper helper; - - public StandardDeployCommandHandler() { - this(new FacetedProjectHelper()); - } - - @VisibleForTesting - StandardDeployCommandHandler(FacetedProjectHelper facetedProjectHelper) { - this.helper = new ProjectFromSelectionHelper(facetedProjectHelper); - } - @Override public Object execute(ExecutionEvent event) throws ExecutionException { try { - IProject project = helper.getAppEngineStandardProject(event); - if (project != null) { - if (!checkProjectErrors(project)) { - MessageDialog.openInformation(HandlerUtil.getActiveShell(event), - Messages.getString("build.error.dialog.title"), - Messages.getString("build.error.dialog.message")); - return null; - } - - IGoogleLoginService loginService = ServiceUtils.getService(event, IGoogleLoginService.class); - DeployPreferencesDialog dialog = - new DeployPreferencesDialog(HandlerUtil.getActiveShell(event), project, loginService); - if (dialog.open() == Window.OK) { - launchDeployJob(project, dialog.getCredential()); - } + IProject project = ProjectFromSelectionHelper.getProject(event); + if (project == null) { + throw new NullPointerException("Deploy menu enabled for non-project resources"); + } + IFacetedProject facetedProject = ProjectFacetsManager.create(project); + if (facetedProject == null) { + throw new NullPointerException("Deploy menu enabled for non-faceted projects"); + } + + if (!checkProjectErrors(project)) { + MessageDialog.openInformation(HandlerUtil.getActiveShell(event), + Messages.getString("build.error.dialog.title"), + Messages.getString("build.error.dialog.message")); + return null; + } + + IGoogleLoginService loginService = ServiceUtils.getService(event, IGoogleLoginService.class); + DeployPreferencesDialog dialog = + new DeployPreferencesDialog(HandlerUtil.getActiveShell(event), project, loginService); + if (dialog.open() == Window.OK) { + launchDeployJob(project, dialog.getCredential()); } // return value must be null, reserved for future use return null; } catch (CoreException | IOException exception) { - throw new ExecutionException(Messages.getString("deploy.failed.error.message"), exception); //$NON-NLS-1$ + throw new ExecutionException( + Messages.getString("deploy.failed.error.message"), exception); //$NON-NLS-1$ } } @@ -137,14 +131,13 @@ private void launchDeployJob(IProject project, Credential credential) @Override public void done(IJobChangeEvent event) { - super.done(event); AnalyticsPingManager.getInstance().sendPing(AnalyticsEvents.APP_ENGINE_DEPLOY_SUCCESS, AnalyticsEvents.APP_ENGINE_DEPLOY_STANDARD, null); launchCleanupJob(); } }); deploy.schedule(); - + IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager(); consoleManager.showConsoleView(messageConsole); } diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.facets.test/src/com/google/cloud/tools/eclipse/appengine/facets/StandardFacetInstallationTest.java b/plugins/com.google.cloud.tools.eclipse.appengine.facets.test/src/com/google/cloud/tools/eclipse/appengine/facets/StandardFacetInstallationTest.java index 91ef00e860..3136bfe690 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.facets.test/src/com/google/cloud/tools/eclipse/appengine/facets/StandardFacetInstallationTest.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.facets.test/src/com/google/cloud/tools/eclipse/appengine/facets/StandardFacetInstallationTest.java @@ -21,7 +21,6 @@ import static org.junit.Assert.assertTrue; import com.google.cloud.tools.eclipse.test.util.project.ProjectUtils; -import com.google.cloud.tools.eclipse.util.FacetedProjectHelper; import java.io.IOException; import java.util.List; import org.eclipse.core.resources.IFile; @@ -29,6 +28,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Path; import org.eclipse.wst.common.project.facet.core.IFacetedProject; +import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; import org.junit.After; import org.junit.Test; @@ -54,7 +54,7 @@ public void testStandardFacetInstallation() throws IOException, CoreException { ProjectUtils.importProjects(getClass(), "projects/test-dynamic-web-project.zip", null); assertEquals(1, projects.size()); IProject project = projects.get(0); - IFacetedProject facetedProject = new FacetedProjectHelper().getFacetedProject(project); + IFacetedProject facetedProject = ProjectFacetsManager.create(project); // verify that the appengine-web.xml is installed in the dynamic web root folder AppEngineStandardFacet.installAppEngineFacet(facetedProject, true, null); IFile correctAppEngineWebXml = project.getFile(new Path("war/WEB-INF/appengine-web.xml")); diff --git a/plugins/com.google.cloud.tools.eclipse.integration.appengine/src/com/google/cloud/tools/eclipse/integration/appengine/DeployPropertyPageTest.java b/plugins/com.google.cloud.tools.eclipse.integration.appengine/src/com/google/cloud/tools/eclipse/integration/appengine/DeployPropertyPageTest.java index 34e06c41b9..d429442281 100644 --- a/plugins/com.google.cloud.tools.eclipse.integration.appengine/src/com/google/cloud/tools/eclipse/integration/appengine/DeployPropertyPageTest.java +++ b/plugins/com.google.cloud.tools.eclipse.integration.appengine/src/com/google/cloud/tools/eclipse/integration/appengine/DeployPropertyPageTest.java @@ -25,6 +25,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.wst.common.project.facet.core.IFacetedProject; +import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; import org.junit.Test; public class DeployPropertyPageTest extends AbstractProjectTests { @@ -32,7 +33,7 @@ public class DeployPropertyPageTest extends AbstractProjectTests { public void testPropertyPageTitle_standardProject() throws CoreException { String projectName = "foo"; project = SwtBotAppEngineActions.createNativeWebAppProject(bot, projectName, null, null); - IFacetedProject facetedProject = new FacetedProjectHelper().getFacetedProject(project); + IFacetedProject facetedProject = ProjectFacetsManager.create(project); assertNotNull("Native App Engine projects should be faceted", facetedProject); assertTrue( new FacetedProjectHelper().projectHasFacet(facetedProject, AppEngineStandardFacet.ID)); diff --git a/plugins/com.google.cloud.tools.eclipse.integration.appengine/src/com/google/cloud/tools/eclipse/integration/appengine/NewMavenBasedAppEngineProjectWizardTest.java b/plugins/com.google.cloud.tools.eclipse.integration.appengine/src/com/google/cloud/tools/eclipse/integration/appengine/NewMavenBasedAppEngineProjectWizardTest.java index cec709a6c0..8c008c5e51 100644 --- a/plugins/com.google.cloud.tools.eclipse.integration.appengine/src/com/google/cloud/tools/eclipse/integration/appengine/NewMavenBasedAppEngineProjectWizardTest.java +++ b/plugins/com.google.cloud.tools.eclipse.integration.appengine/src/com/google/cloud/tools/eclipse/integration/appengine/NewMavenBasedAppEngineProjectWizardTest.java @@ -31,6 +31,7 @@ import org.eclipse.core.runtime.Path; import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.eclipse.wst.common.project.facet.core.IFacetedProject; +import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; import org.junit.Test; import org.junit.runner.RunWith; @@ -96,7 +97,7 @@ private void createAndCheck(String artifactId, String location, project.getLocation().toFile().getParentFile().getCanonicalPath()); } - IFacetedProject facetedProject = new FacetedProjectHelper().getFacetedProject(project); + IFacetedProject facetedProject = ProjectFacetsManager.create(project); assertNotNull("m2e-wtp should create a faceted project", facetedProject); assertTrue("Project does not have standard facet", new FacetedProjectHelper().projectHasFacet(facetedProject, AppEngineStandardFacet.ID)); diff --git a/plugins/com.google.cloud.tools.eclipse.integration.appengine/src/com/google/cloud/tools/eclipse/integration/appengine/NewNativeAppEngineStandardProjectTest.java b/plugins/com.google.cloud.tools.eclipse.integration.appengine/src/com/google/cloud/tools/eclipse/integration/appengine/NewNativeAppEngineStandardProjectTest.java index a2f6fe02d4..e17b4326d1 100644 --- a/plugins/com.google.cloud.tools.eclipse.integration.appengine/src/com/google/cloud/tools/eclipse/integration/appengine/NewNativeAppEngineStandardProjectTest.java +++ b/plugins/com.google.cloud.tools.eclipse.integration.appengine/src/com/google/cloud/tools/eclipse/integration/appengine/NewNativeAppEngineStandardProjectTest.java @@ -28,6 +28,7 @@ import org.eclipse.core.runtime.Path; import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.eclipse.wst.common.project.facet.core.IFacetedProject; +import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; import org.junit.Test; import org.junit.runner.RunWith; @@ -61,7 +62,7 @@ private void createAndCheck(String projectName, String packageName, String[] pro packageName); assertTrue(project.exists()); - IFacetedProject facetedProject = new FacetedProjectHelper().getFacetedProject(project); + IFacetedProject facetedProject = ProjectFacetsManager.create(project); assertNotNull("Native App Engine projects should be faceted", facetedProject); assertTrue("Project does not have standard facet", new FacetedProjectHelper().projectHasFacet(facetedProject, AppEngineStandardFacet.ID)); diff --git a/plugins/com.google.cloud.tools.eclipse.ui.util/META-INF/MANIFEST.MF b/plugins/com.google.cloud.tools.eclipse.ui.util/META-INF/MANIFEST.MF index d8b82e0f34..b4f77eee38 100644 --- a/plugins/com.google.cloud.tools.eclipse.ui.util/META-INF/MANIFEST.MF +++ b/plugins/com.google.cloud.tools.eclipse.ui.util/META-INF/MANIFEST.MF @@ -8,8 +8,7 @@ Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy Require-Bundle: org.eclipse.ui.workbench -Import-Package: com.google.cloud.tools.eclipse.appengine.facets, - com.google.cloud.tools.eclipse.ui.util, +Import-Package: com.google.cloud.tools.eclipse.ui.util, com.google.cloud.tools.eclipse.util, com.google.cloud.tools.eclipse.util.status, com.google.cloud.tools.project;version="0.1.9", diff --git a/plugins/com.google.cloud.tools.eclipse.ui.util/src/com/google/cloud/tools/eclipse/ui/util/ProjectFromSelectionHelper.java b/plugins/com.google.cloud.tools.eclipse.ui.util/src/com/google/cloud/tools/eclipse/ui/util/ProjectFromSelectionHelper.java index 063bbe306a..2f9cd1548d 100644 --- a/plugins/com.google.cloud.tools.eclipse.ui.util/src/com/google/cloud/tools/eclipse/ui/util/ProjectFromSelectionHelper.java +++ b/plugins/com.google.cloud.tools.eclipse.ui.util/src/com/google/cloud/tools/eclipse/ui/util/ProjectFromSelectionHelper.java @@ -16,41 +16,22 @@ package com.google.cloud.tools.eclipse.ui.util; -import com.google.cloud.tools.eclipse.appengine.facets.AppEngineStandardFacet; import com.google.cloud.tools.eclipse.util.AdapterUtil; -import com.google.cloud.tools.eclipse.util.FacetedProjectHelper; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.handlers.HandlerUtil; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; public class ProjectFromSelectionHelper { - private FacetedProjectHelper facetedProjectHelper; - - public ProjectFromSelectionHelper(FacetedProjectHelper facetedProjectHelper) { - this.facetedProjectHelper = facetedProjectHelper; - } - - public IProject getAppEngineStandardProject(ExecutionEvent event) - throws CoreException, ExecutionException { + public static IProject getProject(ExecutionEvent event) throws ExecutionException { ISelection selection = HandlerUtil.getCurrentSelectionChecked(event); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; if (structuredSelection.size() == 1) { - IProject project = AdapterUtil.adapt(structuredSelection.getFirstElement(), IProject.class); - if (project == null) { - return null; - } - - IFacetedProject facetedProject = facetedProjectHelper.getFacetedProject(project); - if (AppEngineStandardFacet.hasAppEngineFacet(facetedProject)) { - return project; - } + return AdapterUtil.adapt(structuredSelection.getFirstElement(), IProject.class); } } return null; diff --git a/plugins/com.google.cloud.tools.eclipse.util/src/com/google/cloud/tools/eclipse/util/FacetedProjectHelper.java b/plugins/com.google.cloud.tools.eclipse.util/src/com/google/cloud/tools/eclipse/util/FacetedProjectHelper.java index 0ad8b489be..f1fef87e4f 100644 --- a/plugins/com.google.cloud.tools.eclipse.util/src/com/google/cloud/tools/eclipse/util/FacetedProjectHelper.java +++ b/plugins/com.google.cloud.tools.eclipse.util/src/com/google/cloud/tools/eclipse/util/FacetedProjectHelper.java @@ -16,37 +16,26 @@ package com.google.cloud.tools.eclipse.util; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; +import com.google.common.base.Preconditions; import org.eclipse.wst.common.project.facet.core.IFacetedProject; import org.eclipse.wst.common.project.facet.core.IProjectFacet; import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import com.google.common.base.Preconditions; - /** - * Wraps certain {@link org.eclipse.wst.common.project.facet.core.ProjectFacetsManager} static methods to allow - * unit testing of classes that use those methods. + * Wraps certain {@link ProjectFacetsManager} static methods to allow unit testing of classes that + * use those methods. */ public class FacetedProjectHelper { /** - * Wraps {@link org.eclipse.wst.common.project.facet.core.ProjectFacetsManager#create(IProject)} - */ - public IFacetedProject getFacetedProject(IProject project) throws CoreException { - Preconditions.checkNotNull(project, "project is null"); - return ProjectFacetsManager.create(project); - } - - /** - * Wraps {@link org.eclipse.wst.common.project.facet.core.ProjectFacetsManager#getProjectFacet(String)} and - * {@link org.eclipse.wst.common.project.facet.core.IFacetedProjectBase#hasProjectFacet(IProjectFacet)}. + * Wraps {@link ProjectFacetsManager#getProjectFacet()} and + * {@link org.eclipse.wst.common.project.facet.core.IFacetedProjectBase#hasProjectFacet()}. */ public boolean projectHasFacet(IFacetedProject facetedProject, String facetId) { Preconditions.checkNotNull(facetedProject, "facetedProject is null"); Preconditions.checkNotNull(facetId, "facetId is null"); Preconditions.checkArgument(!facetId.isEmpty(), "facetId is empty string"); - + IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet(facetId); return facetedProject.hasProjectFacet(projectFacet); }