use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class DockerExplorerViewSWTBotTest method shouldRefreshImagesAndShowChanges.
@Test
public void shouldRefreshImagesAndShowChanges() {
// given
final DockerClient client = MockDockerClientFactory.build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
// one connection
final SWTBotTreeItem connection = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test");
// "containers" and "images" items
Assertions.assertThat(connection.getItems()).hasSize(2);
final SWTBotTreeItem imagesTreeItem = SWTUtils.expand(connection, "Images");
Assertions.assertThat(imagesTreeItem.getItems().length).isEqualTo(0);
// update the client
final DockerClient updatedClient = MockDockerClientFactory.image(MockImageFactory.name("foo/bar").build()).build();
dockerConnection.setClient(updatedClient);
// when locating the 'Images' node and hit refresh
dockerExplorerViewBot.bot().tree().select(imagesTreeItem);
dockerExplorerViewBot.bot().tree().contextMenu("Refresh").click();
SWTUtils.wait(2, TimeUnit.SECONDS);
imagesTreeItem.expand();
Conditions.waitForJobs(DockerExplorerView.class, "Docker Explorer View jobs");
// then check that there are images now
Assertions.assertThat(imagesTreeItem.isExpanded()).isTrue();
Assertions.assertThat(imagesTreeItem.getItems().length).isEqualTo(1);
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class DockerExplorerViewSWTBotTest method shouldShowContainerPortMapping.
@Test
public void shouldShowContainerPortMapping() {
// given
final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("foo_bar").build(), MockContainerInfoFactory.port("8080/tcp", "0.0.0.0", "8080").port("8787/tcp", "0.0.0.0", "8787").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
// when
final SWTBotTreeItem containerPorts = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Containers", "foo_bar", "Ports");
// then
SWTBotTreeItemAssertions.assertThat(containerPorts).isExpanded().hasChildItems(2);
SWTBotTreeItemAssertions.assertThat(containerPorts.getNode(0)).hasText("0.0.0.0:8080 -> 8080 (tcp)");
SWTBotTreeItemAssertions.assertThat(containerPorts.getNode(1)).hasText("0.0.0.0:8787 -> 8787 (tcp)");
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class DockerExplorerViewSWTBotTest method shouldShowAllImageVariants.
@Test
public void shouldShowAllImageVariants() {
// given
final DockerClient client = MockDockerClientFactory.image(MockImageFactory.id("1a2b3c4d5e6f7g").name("foo:1.0", "foo:latest", "bar:1.0", "bar:latest").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
SWTUtils.asyncExec(() -> dockerExplorerView.getCommonViewer().expandAll());
final SWTBotTreeItem imagesTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test", "Images");
// when
SWTUtils.asyncExec(() -> imagesTreeItem.expand());
// then 2 images should be displayed
final SWTBotTreeItem[] images = imagesTreeItem.getItems();
assertThat(images).hasSize(2);
assertThat(images[0].getText()).startsWith("bar:1.0, latest");
assertThat(images[1].getText()).startsWith("foo:1.0, latest");
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class DockerExplorerViewSWTBotTest method shouldRemainExpandedAfterRefreshOnContainersCategory.
@Test
public void shouldRemainExpandedAfterRefreshOnContainersCategory() {
// given
final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("foo_bar").build(), MockContainerInfoFactory.volume("/path/to/container").port("8080/tcp", "0.0.0.0", "8080").link("/foo:/bar/foo").volume("/path/to/host:/path/to/container:Z,ro").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
final SWTBotTreeItem containers = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Containers");
final SWTBotTreeItem containerLinks = SWTUtils.expand(containers, "foo_bar", "Links");
final SWTBotTreeItem containerPorts = SWTUtils.expand(containers, "foo_bar", "Ports");
final SWTBotTreeItem containerVolumes = SWTUtils.expand(containers, "foo_bar", "Volumes");
// ensure items are actually expanded before calling the 'refresh'
// command
SWTBotTreeItemAssertions.assertThat(containerLinks).isExpanded();
SWTBotTreeItemAssertions.assertThat(containerPorts).isExpanded();
SWTBotTreeItemAssertions.assertThat(containerVolumes).isExpanded();
// when refreshing the container
dockerExplorerViewBot.bot().tree().select(containers);
dockerExplorerViewBot.bot().tree().contextMenu("Refresh").click();
SWTUtils.asyncExec(() -> containers.expand());
// then all items should remain expanded (after they were reloaded)
SWTBotTreeItemAssertions.assertThat(SWTUtils.getTreeItem(containers, "foo_bar", "Links")).isExpanded();
SWTBotTreeItemAssertions.assertThat(SWTUtils.getTreeItem(containers, "foo_bar", "Ports")).isExpanded();
SWTBotTreeItemAssertions.assertThat(SWTUtils.getTreeItem(containers, "foo_bar", "Volumes")).isExpanded();
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class DockerExplorerViewSWTBotTest method selectImagesInTreeView.
private void selectImagesInTreeView(final String connectionName, final String... imageNames) {
SWTUtils.asyncExec(() -> dockerExplorerView.getCommonViewer().expandAll());
// when a second call to expand the container is done (because the first
// expandAll stopped with a "Loading..." job that retrieved the
// containers)
final SWTBotTreeItem imagesTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, connectionName, "Images");
SWTUtils.asyncExec(() -> imagesTreeItem.expand());
// select both images
SWTUtils.select(imagesTreeItem, imageNames);
}
Aggregations