Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Coulon2016-01-21 10:31:13 +0000
committerJeff Johnston2016-01-21 17:25:11 +0000
commit8076721edd21aac7c1cc30f2859b87bff62936a2 (patch)
tree5b4e014c6888ac91a495b2f60cb7c9e6e69cd5fd
parent411d6fb09923469b27943f58e990a6c029167751 (diff)
downloadorg.eclipse.linuxtools-8076721edd21aac7c1cc30f2859b87bff62936a2.tar.gz
org.eclipse.linuxtools-8076721edd21aac7c1cc30f2859b87bff62936a2.tar.xz
org.eclipse.linuxtools-8076721edd21aac7c1cc30f2859b87bff62936a2.zip
Bug 483679 - [docker image search] make tag selection optional
Allow for search wizard completion when an image is selected in the search result list, in which case the 'latest' tag is assumed. Added SWTBot tests Added a constant in DockerImage (not the API) to handle the 'latest' tag value Change-Id: I74c63f3ee6e533f55c9b875dff24df9d60f73380 Signed-off-by: Xavier Coulon <xcoulon@redhat.com> Reviewed-on: https://git.eclipse.org/r/63540 Tested-by: Hudson CI (cherry picked from commit d115f02832c62128e003bbac29f8f5365531741e) Reviewed-on: https://git.eclipse.org/r/64690 Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerImage.java2
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/CloseWizardRule.java5
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearchSWTBotTest.java62
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/docker/ui/wizards/ImageSearch.java8
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionModel.java7
5 files changed, 64 insertions, 20 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerImage.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerImage.java
index d83f964ed5..63e56522fe 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerImage.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerImage.java
@@ -58,6 +58,8 @@ public class DockerImage implements IDockerImage {
private final boolean intermediateImage;
private final boolean danglingImage;
+ /** the literal value for the 'latest' tag on Docker images. */
+ public static final String TAG_LATEST = "latest"; //$NON-NLS-1$
public DockerImage(final DockerConnection parent, @Deprecated final List<String> repoTags, final String repo, final List<String> tags,
final String id, final String parentId, final String created, final Long size,
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/CloseWizardRule.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/CloseWizardRule.java
index f765a53b51..719dca6cbf 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/CloseWizardRule.java
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/CloseWizardRule.java
@@ -11,6 +11,7 @@
package org.eclipse.linuxtools.internal.docker.ui.testutils.swt;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.junit.rules.ExternalResource;
@@ -24,8 +25,8 @@ public class CloseWizardRule extends ExternalResource {
protected void after() {
final SWTWorkbenchBot bot = new SWTWorkbenchBot();
try {
- while (bot.button("Cancel") != null) {
- bot.button("Cancel").click();
+ while (bot.button(IDialogConstants.CANCEL_LABEL) != null) {
+ bot.button(IDialogConstants.CANCEL_LABEL).click();
}
} catch (WidgetNotFoundException e) {
// ignoring
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearchSWTBotTest.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearchSWTBotTest.java
index becc4d2ccc..9f529b3eba 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearchSWTBotTest.java
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearchSWTBotTest.java
@@ -47,10 +47,10 @@ public class ImageSearchSWTBotTest {
@ClassRule
public static CloseWelcomePageRule closeWelcomePage = new CloseWelcomePageRule();
- @Rule
+ @Rule
public ClearConnectionManagerRule clearConnectionManager = new ClearConnectionManagerRule();
- @Rule
+ @Rule
public CloseWizardRule closeWizard = new CloseWizardRule();
@Before
@@ -64,48 +64,84 @@ public class ImageSearchSWTBotTest {
@Test
public void shouldTriggerSearchIfTermWasGiven() throws InterruptedException {
// given
- final DockerClient client = MockDockerClientFactory.onSearch("foo", MockImageSearchResultFactory.name("foo").build())
- .build();
+ final DockerClient client = MockDockerClientFactory
+ .onSearch("foo", MockImageSearchResultFactory.name("foo").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
// expand the 'Images' node
SWTUtils.syncExec(() -> dockerExplorerView.getCommonViewer().expandAll());
final SWTBotTreeItem imagesTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test", "Images");
-
+
// when opening the "Pull..." wizard
final SWTBotTree dockerExplorerViewTreeBot = dockerExplorerViewBot.bot().tree();
dockerExplorerViewTreeBot.select(imagesTreeItem);
dockerExplorerViewTreeBot.contextMenu("Pull...").click();
- // when specify a term
+ // when specifying a term
bot.textWithLabel(WizardMessages.getString("ImagePull.name.label")).setText("foo");
-
+
// when clicking on the "Search..." button
bot.button(WizardMessages.getString("ImagePull.search.label")).click();
- // then the search should have been triggered and results should be available
+ // then the search should have been triggered and results should be
+ // available
assertThat(bot.table().rowCount()).isEqualTo(1);
}
@Test
public void shouldNotTriggerSearchIfNoTermWasGiven() throws InterruptedException {
// given
- final DockerClient client = MockDockerClientFactory.onSearch("foo", MockImageSearchResultFactory.name("foo").build())
- .build();
+ final DockerClient client = MockDockerClientFactory
+ .onSearch("foo", MockImageSearchResultFactory.name("foo").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
// expand the 'Images' node
SWTUtils.syncExec(() -> dockerExplorerView.getCommonViewer().expandAll());
final SWTBotTreeItem imagesTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test", "Images");
-
+
// when opening the "Pull..." wizard
final SWTBotTree dockerExplorerViewTreeBot = dockerExplorerViewBot.bot().tree();
dockerExplorerViewTreeBot.select(imagesTreeItem);
dockerExplorerViewTreeBot.contextMenu("Pull...").click();
- // when clicking on the "Search..." button
+ // when clicking on the "Search..." button *without specifying a term before*
bot.button(WizardMessages.getString("ImagePull.search.label")).click();
- // then the search should have been triggered and results should be available
+ // then the search should have been triggered and results should be
+ // available
assertThat(bot.table().rowCount()).isEqualTo(0);
}
+ @Test
+ public void shouldAllowForDefaultLatestTag() throws InterruptedException {
+ // given
+ final DockerClient client = MockDockerClientFactory
+ .onSearch("foo", MockImageSearchResultFactory.name("foo").build()).build();
+ final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
+ // expand the 'Images' node
+ SWTUtils.syncExec(() -> dockerExplorerView.getCommonViewer().expandAll());
+ final SWTBotTreeItem imagesTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test", "Images");
+
+ // when opening the "Pull..." wizard
+ final SWTBotTree dockerExplorerViewTreeBot = dockerExplorerViewBot.bot().tree();
+ dockerExplorerViewTreeBot.select(imagesTreeItem);
+ dockerExplorerViewTreeBot.contextMenu("Pull...").click();
+
+ // when specifying a term
+ bot.textWithLabel(WizardMessages.getString("ImagePull.name.label")).setText("foo");
+
+ // when clicking on the "Search..." button
+ bot.button(WizardMessages.getString("ImagePull.search.label")).click();
+
+ // then the search should have been triggered and results should be
+ // available
+ assertThat(bot.table().rowCount()).isEqualTo(1);
+ assertThat(bot.button("Next >").isEnabled()).isTrue();
+ assertThat(bot.button("Finish").isEnabled()).isTrue();
+ bot.button("Finish").click();
+
+ // when back to Pull wizard, the Image name field should be filled
+ assertThat(bot.textWithLabel(WizardMessages.getString("ImagePull.name.label")).getText())
+ .isEqualTo("foo:latest");
+ }
+
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/docker/ui/wizards/ImageSearch.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/docker/ui/wizards/ImageSearch.java
index ef38f1d8bd..e85f65aec5 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/docker/ui/wizards/ImageSearch.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/docker/ui/wizards/ImageSearch.java
@@ -14,6 +14,7 @@ package org.eclipse.linuxtools.docker.ui.wizards;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.linuxtools.docker.core.IDockerConnection;
+import org.eclipse.linuxtools.internal.docker.core.DockerImage;
import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageSearchModel;
import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageSearchPage;
import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageTagSelectionPage;
@@ -62,7 +63,7 @@ public class ImageSearch extends Wizard {
@Override
public boolean canFinish() {
- return this.imageTagSelectionPage.isPageComplete();
+ return this.imageSearchPage.isPageComplete();
}
@Override
@@ -76,7 +77,10 @@ public class ImageSearch extends Wizard {
*/
public String getSelectedImage() {
return this.imageSearchPage.getSelectedImage().getName() + ":"
- + this.imageTagSelectionPage.getSelectedImageTag().getName();
+ + (this.imageTagSelectionPage.getSelectedImageTag() != null
+ ? this.imageTagSelectionPage.getSelectedImageTag()
+ .getName()
+ : DockerImage.TAG_LATEST);
}
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionModel.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionModel.java
index a2baec867d..7e9526a457 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionModel.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionModel.java
@@ -24,6 +24,7 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.linuxtools.docker.core.DockerConnectionManager;
import org.eclipse.linuxtools.docker.core.IDockerConnection;
import org.eclipse.linuxtools.docker.core.IDockerImage;
+import org.eclipse.linuxtools.internal.docker.core.DockerImage;
import org.eclipse.linuxtools.internal.docker.ui.databinding.BaseDatabindingModel;
/**
@@ -137,9 +138,9 @@ public class ImageRunSelectionModel extends BaseDatabindingModel {
public ImageRunSelectionModel(final IDockerImage selectedImage) {
this(selectedImage.getConnection());
- if (selectedImage.tags().contains("latest")) { //$NON-NLS-1$
- setSelectedImageName(ImageRunSelectionModel
- .getImageName(selectedImage.repo(), "latest")); //$NON-NLS-1$
+ if (selectedImage.tags().contains(DockerImage.TAG_LATEST)) {
+ setSelectedImageName(ImageRunSelectionModel.getImageName(
+ selectedImage.repo(), DockerImage.TAG_LATEST));
} else {
final String lastTag = selectedImage.tags()
.get(selectedImage.tags().size() - 1);

Back to the top