Skip to content

Commit 49f1019

Browse files
authored
Various fixes accumulated so far (#2229)
* Various fixes accumulated so far * Revert SnakeYAML version change in feature.xml * Resolve merge conflict due to parallel edit
1 parent 7d139f5 commit 49f1019

20 files changed

Lines changed: 76 additions & 258 deletions

File tree

plugins/com.google.cloud.tools.eclipse.appengine.deploy.ui.test/src/com/google/cloud/tools/eclipse/appengine/deploy/ui/GcpProjectQueryJobTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.google.cloud.tools.eclipse.projectselector.ProjectSelector;
3030
import com.google.cloud.tools.eclipse.projectselector.model.GcpProject;
3131
import com.google.common.base.Predicate;
32+
import com.google.common.base.Predicates;
3233
import java.util.List;
3334
import org.eclipse.core.databinding.DataBindingContext;
3435
import org.eclipse.core.runtime.jobs.Job;
@@ -121,13 +122,11 @@ public void testRun_abandonStaleJob() throws InterruptedException, ProjectReposi
121122
ProjectRepository projectRepository2 = mock(ProjectRepository.class);
122123
when(projectRepository2.getProjects(staleCredential)).thenReturn(anotherProjectList);
123124

124-
Predicate<Job> notLatest = mock(Predicate.class);
125+
// This second job is stale, i.e., it was fired, but user has selected another credential.
126+
Predicate<Job> notLatest = Predicates.alwaysFalse();
125127
Job staleJob = new GcpProjectQueryJob(staleCredential, projectRepository2,
126128
projectSelector, dataBindingContext, notLatest);
127129

128-
// This second job is stale, i.e., it was fired, but user has selected another credential.
129-
when(notLatest.apply(staleJob)).thenReturn(false);
130-
131130
queryJob.schedule();
132131
queryJob.join();
133132
// Make the stale job complete even after "queryJob" finishes.

plugins/com.google.cloud.tools.eclipse.appengine.deploy.ui.test/src/com/google/cloud/tools/eclipse/appengine/deploy/ui/internal/AppEngineApplicationQueryJobTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.google.cloud.tools.eclipse.projectselector.model.AppEngine;
3434
import com.google.cloud.tools.eclipse.projectselector.model.GcpProject;
3535
import com.google.common.base.Predicate;
36+
import com.google.common.base.Predicates;
3637
import org.eclipse.core.runtime.jobs.Job;
3738
import org.eclipse.jface.viewers.IStructuredSelection;
3839
import org.eclipse.swt.widgets.Display;
@@ -186,13 +187,11 @@ public void testRun_abandonStaleJob() throws InterruptedException, ProjectReposi
186187
when(projectRepository2.getAppEngineApplication(staleCredential, "staleProjectId"))
187188
.thenThrow(new ProjectRepositoryException("testException"));
188189

189-
Predicate<Job> notLatest = mock(Predicate.class);
190+
// This second job is stale, i.e., it was fired, but user has selected another credential.
191+
Predicate<Job> notLatest = Predicates.alwaysFalse();
190192
Job staleJob = new AppEngineApplicationQueryJob(staleProject, staleCredential,
191193
projectRepository2, projectSelector, EXPECTED_LINK, notLatest);
192194

193-
// This second job is stale, i.e., it was fired, but user has selected another credential.
194-
when(notLatest.apply(staleJob)).thenReturn(false);
195-
196195
queryJob.schedule();
197196
queryJob.join();
198197
// Make the stale job complete even after "queryJob" finishes.

plugins/com.google.cloud.tools.eclipse.appengine.deploy.ui/src/com/google/cloud/tools/eclipse/appengine/deploy/ui/flexible/FlexDeployPreferencesPanel.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
import org.eclipse.core.resources.IProject;
2929
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
3030
import org.eclipse.jface.databinding.swt.WidgetProperties;
31+
import org.eclipse.jface.layout.GridDataFactory;
3132
import org.eclipse.jface.layout.GridLayoutFactory;
3233
import org.eclipse.swt.SWT;
33-
import org.eclipse.swt.layout.GridData;
3434
import org.eclipse.swt.widgets.Button;
3535
import org.eclipse.swt.widgets.Composite;
3636
import org.eclipse.swt.widgets.Label;
@@ -72,10 +72,8 @@ private void createAppYamlSection() {
7272
browse.setText(Messages.getString("deploy.preferences.dialog.browse"));
7373
browse.addSelectionListener(new RelativeFileFieldSetter(appYamlField, project.getLocation()));
7474

75-
GridLayoutFactory.fillDefaults().numColumns(2).applyTo(secondColumn);
76-
GridData fillGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
77-
secondColumn.setLayoutData(fillGridData);
78-
appYamlField.setLayoutData(fillGridData);
75+
GridLayoutFactory.fillDefaults().numColumns(2).generateLayout(secondColumn);
76+
GridDataFactory.fillDefaults().applyTo(secondColumn);
7977

8078
// Part 2. set up data binding
8179
ISWTObservableValue fieldValue = WidgetProperties.text(SWT.Modify).observe(appYamlField);

plugins/com.google.cloud.tools.eclipse.appengine.libraries.test/src/com/google/cloud/tools/eclipse/appengine/libraries/LibraryClasspathContainerTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public void setUp() {
4545
mockClasspathEntry);
4646
}
4747

48+
@Test
4849
public void testConstructor_nullPath() {
4950
try {
5051
new LibraryClasspathContainer(null, "description", mockClasspathEntry);
@@ -54,6 +55,7 @@ public void testConstructor_nullPath() {
5455
}
5556
}
5657

58+
@Test
5759
public void testConstructor_nullDescription() {
5860
try {
5961
new LibraryClasspathContainer(new Path("container/path"), null, mockClasspathEntry);
@@ -63,15 +65,17 @@ public void testConstructor_nullDescription() {
6365
}
6466
}
6567

68+
@Test
6669
public void testConstructor_emptyDescription() {
6770
try {
6871
new LibraryClasspathContainer(new Path("container/path"), "", mockClasspathEntry);
69-
fail("Expected NullPointerException");
70-
} catch (NullPointerException ex) {
72+
fail("Expected IllegalArgumentException");
73+
} catch (IllegalArgumentException ex) {
7174
assertNotNull(ex.getMessage());
7275
}
7376
}
7477

78+
@Test
7579
public void testConstructor_nullClasspathEntries() {
7680
try {
7781
new LibraryClasspathContainer(new Path("container/path"), "description", null);
@@ -92,7 +96,7 @@ public void testGetDescription() {
9296
}
9397

9498
@Test
95-
public void testGetKind_returnsApplication() throws Exception {
99+
public void testGetKind_returnsApplication() {
96100
assertThat(classpathContainer.getKind(), is(IClasspathContainer.K_APPLICATION));
97101
}
98102

plugins/com.google.cloud.tools.eclipse.appengine.libraries.test/src/com/google/cloud/tools/eclipse/appengine/libraries/model/LibraryFactoryTest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
import org.eclipse.core.runtime.IConfigurationElement;
2020
import org.junit.Assert;
2121
import org.junit.Test;
22-
import org.junit.runner.RunWith;
2322
import org.mockito.Mockito;
2423

2524
public class LibraryFactoryTest {
26-
25+
2726
private LibraryFactory factory = new LibraryFactory();
28-
27+
2928
@Test
3029
public void testCreate() throws LibraryFactoryException {
3130
IConfigurationElement configuration = Mockito.mock(IConfigurationElement.class);
@@ -43,16 +42,16 @@ public void testCreate() throws LibraryFactoryException {
4342
Library library = factory.create(configuration);
4443
Assert.assertEquals("com.google.guava", library.getGroup());
4544
}
46-
45+
4746
@Test
4847
public void testCreate_null() throws LibraryFactoryException {
4948
try {
5049
factory.create(null);
5150
Assert.fail();
5251
} catch (NullPointerException ex) {
53-
}
52+
}
5453
}
55-
54+
5655
@Test
5756
public void testCreate_nonLibrary() {
5857
IConfigurationElement configuration = Mockito.mock(IConfigurationElement.class);
@@ -61,7 +60,7 @@ public void testCreate_nonLibrary() {
6160
Assert.fail();
6261
} catch (LibraryFactoryException ex) {
6362
Assert.assertNotNull(ex.getMessage());
64-
}
63+
}
6564
}
66-
65+
6766
}

plugins/com.google.cloud.tools.eclipse.appengine.libraries.test/src/com/google/cloud/tools/eclipse/appengine/libraries/persistence/LibraryClasspathContainerSerializerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public class LibraryClasspathContainerSerializerTest {
9090
private LibraryClasspathContainer container;
9191

9292
@Before
93-
public void setUp() throws Exception {
93+
public void setUp() {
9494
List<IClasspathEntry> classpathEntries = Arrays.asList(
9595
newClasspathEntry(IClasspathEntry.CPE_LIBRARY, "/test/path/to/jar",
9696
"/test/path/to/src", new IClasspathAttribute[] {newAttribute("attrName", "attrValue")},

plugins/com.google.cloud.tools.eclipse.appengine.libraries.ui.test/src/com/google/cloud/tools/eclipse/appengine/libraries/ui/AppEngineLibrariesSelectorGroupTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class AppEngineLibrariesSelectorGroupTest {
5252
private SWTBotCheckBox objectifyButton;
5353

5454
@Before
55-
public void setUp() throws Exception {
55+
public void setUp() {
5656
shell = shellTestResource.getShell();
5757
shell.setLayout(new FillLayout());
5858
librariesSelector = new LibrarySelectorGroup(shell, CloudLibraries.APP_ENGINE_GROUP);

plugins/com.google.cloud.tools.eclipse.appengine.localserver.test/src/com/google/cloud/tools/eclipse/appengine/localserver/server/LocalAppEngineServerLaunchConfigurationDelegateTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class LocalAppEngineServerLaunchConfigurationDelegateTest {
6161
private LocalAppEngineServerBehaviour serverBehavior;
6262

6363
@Before
64-
public void setUp() throws CoreException {
64+
public void setUp() {
6565
when(server.loadAdapter(any(Class.class), any(IProgressMonitor.class)))
6666
.thenReturn(serverBehavior);
6767
}

plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/server/LocalAppEngineServerLaunchConfigurationDelegate.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,10 @@ private static IProject[] getReferencedProjects(ILaunchConfiguration configurati
590590
* </ul>
591591
*/
592592
private class CloudSdkDebugTarget extends DebugElement implements IDebugTarget {
593-
private ILaunch launch;
594-
private LocalAppEngineServerBehaviour serverBehaviour;
595-
private IServer server;
596-
private IOConsole console;
593+
private final ILaunch launch;
594+
private final LocalAppEngineServerBehaviour serverBehaviour;
595+
private final IServer server;
596+
private final IOConsole console;
597597

598598
// Fire a {@link DebugEvent#TERMINATED} event when the server is stopped
599599
private IServerListener serverEventsListener = new IServerListener() {
@@ -655,7 +655,7 @@ public void launchesRemoved(ILaunch[] launches) {
655655
}
656656
};
657657

658-
CloudSdkDebugTarget(ILaunch launch, LocalAppEngineServerBehaviour serverBehaviour,
658+
private CloudSdkDebugTarget(ILaunch launch, LocalAppEngineServerBehaviour serverBehaviour,
659659
IOConsole console) {
660660
super(null);
661661
this.launch = launch;
@@ -664,14 +664,13 @@ public void launchesRemoved(ILaunch[] launches) {
664664
this.console = console;
665665
}
666666

667-
protected void removeConsole() {
667+
private void removeConsole() {
668668
ConsolePlugin plugin = ConsolePlugin.getDefault();
669669
IConsoleManager manager = plugin.getConsoleManager();
670670
manager.removeConsoles(new IConsole[] {console});
671671
console.destroy();
672672
}
673673

674-
675674
/** Add required listeners */
676675
private void engage() {
677676
getLaunchManager().addLaunchListener(launchesListener);

plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ui/LocalAppEngineConsole.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
* A console that displays information for a run/debug session of the App Engine runtime
3434
*/
3535
public class LocalAppEngineConsole extends MessageConsole {
36-
private LocalAppEngineServerBehaviour serverBehaviour;
37-
private String unprefixedName;
38-
private IServerListener serverStateListener = new IServerListener() {
36+
private final LocalAppEngineServerBehaviour serverBehaviour;
37+
private final String unprefixedName;
38+
private final IServerListener serverStateListener = new IServerListener() {
3939
@Override
4040
public void serverChanged(ServerEvent event) {
4141
if ((event.getKind() & ServerEvent.SERVER_CHANGE) != 0) {
@@ -50,7 +50,7 @@ private LocalAppEngineConsole(String name, LocalAppEngineServerBehaviour serverB
5050
this.serverBehaviour = serverBehaviour;
5151
}
5252

53-
protected void update(int serverState) {
53+
private void update(int serverState) {
5454
if (serverState == IServer.STATE_STOPPED) {
5555
disengage(); // we should no longer update
5656
}
@@ -60,17 +60,14 @@ protected void update(int serverState) {
6060
/**
6161
* Update the shown name with the server stop/stopping state.
6262
*/
63-
protected void updateName(int serverState) {
63+
private void updateName(int serverState) {
6464
final String computedName;
6565
if (serverState == IServer.STATE_STARTING) {
66-
computedName =
67-
Messages.getString("SERVER_STARTING_TEMPLATE", unprefixedName);
66+
computedName = Messages.getString("SERVER_STARTING_TEMPLATE", unprefixedName);
6867
} else if (serverState == IServer.STATE_STOPPING) {
69-
computedName =
70-
Messages.getString("SERVER_STOPPING_TEMPLATE", unprefixedName);
68+
computedName = Messages.getString("SERVER_STOPPING_TEMPLATE", unprefixedName);
7169
} else if (serverState == IServer.STATE_STOPPED) {
72-
computedName =
73-
Messages.getString("SERVER_STOPPED_TEMPLATE", unprefixedName);
70+
computedName = Messages.getString("SERVER_STOPPED_TEMPLATE", unprefixedName);
7471
} else {
7572
computedName = unprefixedName;
7673
}
@@ -110,7 +107,7 @@ private void disengage() {
110107

111108
public static class Factory implements ConsoleFactory<LocalAppEngineConsole> {
112109

113-
private LocalAppEngineServerBehaviour serverBehaviour;
110+
private final LocalAppEngineServerBehaviour serverBehaviour;
114111

115112
public Factory(LocalAppEngineServerBehaviour serverBehaviour) {
116113
this.serverBehaviour = serverBehaviour;

0 commit comments

Comments
 (0)