use of com.spotify.docker.client.DockerClient in project linuxtools by eclipse.
the class DockerExplorerViewSWTBotTest method shouldShowContainerVolumes.
@Test
public void shouldShowContainerVolumes() {
// given
final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("foo_bar").build(), MockContainerInfoFactory.volume("/path/to/container").volume("/path/to/host:/path/to/container").volume("/path/to/host:/path/to/container:Z,ro").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
SWTUtils.asyncExec(() -> dockerExplorerView.getCommonViewer().expandAll());
// when
final SWTBotTreeItem volumesTreeItem = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Containers", "foo_bar", "Volumes");
// then
SWTBotTreeItemAssertions.assertThat(volumesTreeItem).isExpanded().hasChildItems(3);
SWTBotTreeItemAssertions.assertThat(volumesTreeItem.getNode(0)).hasText("/path/to/container");
SWTBotTreeItemAssertions.assertThat(volumesTreeItem.getNode(1)).hasText("/path/to/host -> /path/to/container");
SWTBotTreeItemAssertions.assertThat(volumesTreeItem.getNode(2)).hasText("/path/to/host -> /path/to/container (Z,ro)");
}
use of com.spotify.docker.client.DockerClient in project linuxtools by eclipse.
the class DockerImageHierarchyViewSWTBotTest method setupData.
@Before
public void setupData() {
// data is built as follows:
// root_image
// |- foo_image1
// _|- foo_container1 (Up)
// _|- foo_image2
// __|- foo_container21 (Exited)
// __|- foo_container22 (Paused)
// |- bar_image11
// _|- bar_container1
final Image rootImage = MockImageFactory.id("sha256:root_image").name("root_image").build();
final Image fooImage1 = MockImageFactory.id("sha256:foo_image1").name("foo_image1").parentId("sha256:root_image").build();
final Image fooImage2 = MockImageFactory.id("sha256:foo_image2").name("foo_image2", "foo_image2_alias").parentId("sha256:foo_image1").build();
final Container fooContainer1 = MockContainerFactory.id("sha256:foo_container1").name("foo_container1").imageName("foo_image1").status("Up").build();
final Container fooContainer21 = MockContainerFactory.id("sha256:foo_container21").name("foo_container21").imageName("foo_image2").status("Exited").build();
final Container fooContainer22 = MockContainerFactory.id("sha256:foo_container22").name("foo_container22").imageName("foo_image2_alias").status("Up (Paused)").build();
final Image barImage1 = MockImageFactory.id("sha256:bar_image1").name("bar_image1").parentId("sha256:root_image").build();
final Container barContainer1 = MockContainerFactory.id("sha256:bar_container1").name("bar_container1").imageName("bar_image1").build();
final DockerClient client = MockDockerClientFactory.image(rootImage).image(fooImage1).container(fooContainer1).image(fooImage2).container(fooContainer21).container(fooContainer22).image(barImage1).container(barContainer1).build();
this.connection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
this.connection.getImages(true);
this.connection.getContainers(true);
DockerConnectionManagerUtils.configureConnectionManager(connection);
}
use of com.spotify.docker.client.DockerClient in project linuxtools by eclipse.
the class DockerImagesViewSWTBotTest method shouldRemoveListenersWhenClosingView.
@Test
public void shouldRemoveListenersWhenClosingView() {
// given
final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("angry_bar").status("Stopped").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
SWTUtils.getTreeItem(dockerExplorerBotView, "Test").select();
// remove the DockerContainerRefreshManager
dockerConnection.removeContainerListener(DockerContainerRefreshManager.getInstance());
// DockerExplorerView inner classes
assertThat(dockerConnection.getImageListeners()).hasSize(2);
// close the Docker Images View
dockerImagesBotView.close();
// there should be one listener left: DockerExplorerView
assertThat(dockerConnection.getImageListeners()).hasSize(1);
}
use of com.spotify.docker.client.DockerClient in project linuxtools by eclipse.
the class DockerImagesViewSWTBotTest method verifyBuildAndPullActionEnablement.
@Test
public void verifyBuildAndPullActionEnablement() {
// given
final DockerClient client = MockDockerClientFactory.image(MockImageFactory.name("angry_bar").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
SWTUtils.syncExec(() -> SWTUtils.getView(bot, "org.eclipse.ui.views.PropertySheet", true));
this.dockerImagesView.setFocus();
// select the container in the table
selectImageInTable("angry_bar");
List<SWTBotToolbarButton> buttons = this.dockerImagesBotView.getToolbarButtons();
for (SWTBotToolbarButton button : buttons) {
if (button.getText().equals("Build Image")) {
assertThat(button.isEnabled());
} else if (button.getText().equals("Pull...")) {
assertThat(button.isEnabled());
}
}
unselectImages();
buttons = this.dockerImagesBotView.getToolbarButtons();
for (SWTBotToolbarButton button : buttons) {
if (button.getText().equals("Build Image")) {
assertThat(button.isEnabled());
} else if (button.getText().equals("Pull...")) {
assertThat(button.isEnabled());
}
}
unselectConnections();
buttons = this.dockerImagesBotView.getToolbarButtons();
for (SWTBotToolbarButton button : buttons) {
if (button.getText().equals("Build Image")) {
assertThat(!button.isEnabled());
} else if (button.getText().equals("Pull...")) {
assertThat(!button.isEnabled());
}
}
}
use of com.spotify.docker.client.DockerClient in project linuxtools by eclipse.
the class DockerImagesViewSWTBotTest method setup.
@Before
public void setup() {
this.bot = new SWTWorkbenchBot();
final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("angry_bar").status("Stopped").build()).image(MockImageFactory.id("987654321abcde").name("default:1").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Default", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
SWTUtils.asyncExec(() -> {
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(DockerExplorerView.VIEW_ID);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(DockerImagesView.VIEW_ID);
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Failed to open Docker Images view: " + e.getMessage());
}
});
this.dockerImagesBotView = bot.viewById("org.eclipse.linuxtools.docker.ui.dockerImagesView");
this.dockerImagesView = (DockerImagesView) (dockerImagesBotView.getViewReference().getView(true));
this.dockerExplorerBotView = bot.viewById(DockerExplorerView.VIEW_ID);
}
Aggregations