Search in sources :

Example 51 with SWTBotTreeItem

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);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Test(org.junit.Test)

Example 52 with SWTBotTreeItem

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)");
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Test(org.junit.Test)

Example 53 with SWTBotTreeItem

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");
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Test(org.junit.Test)

Example 54 with SWTBotTreeItem

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();
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Test(org.junit.Test)

Example 55 with SWTBotTreeItem

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);
}
Also used : SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)

Aggregations

SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)63 Test (org.junit.Test)38 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)20 DockerClient (com.spotify.docker.client.DockerClient)19 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)9 Path (org.eclipse.core.runtime.Path)7 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)7 IDockerConnectionStorageManager (org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager)6 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)5 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)5 IEditorReference (org.eclipse.ui.IEditorReference)5 Ignore (org.junit.Ignore)5 IResource (org.eclipse.core.resources.IResource)4 File (java.io.File)3 IFile (org.eclipse.core.resources.IFile)3 ProjectExplorerTreeItemAppearsCondition (org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorerTreeItemAppearsCondition)3 TCPConnectionSettings (org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings)3 UnixSocketConnectionSettings (org.eclipse.linuxtools.internal.docker.core.UnixSocketConnectionSettings)2