use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class DockerExplorerViewSWTBotTest method shouldProvideEnabledUnpauseCommandOnMultipleContainersAtOnce.
@Test
public void shouldProvideEnabledUnpauseCommandOnMultipleContainersAtOnce() {
// given
final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("gentle_foo").status("Up (Paused)").build()).container(MockContainerFactory.name("angry_bar").status("Up (Paused)").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
// open the context menu on one of the containers
selectContainersInTreeView("Test", "gentle_foo", "angry_bar");
final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Unpause");
// then
MenuAssertion.assertThat(menuCommand).isVisible().isEnabled();
}
use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class DockerExplorerViewSWTBotTest method shouldDisableConnectionWhenUnreachable.
@Test
public void shouldDisableConnectionWhenUnreachable() throws DockerException, InterruptedException {
// given
final DockerClient client = MockDockerClientFactory.build();
Mockito.when(client.ping()).thenThrow(new DockerException("failed by mock"));
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
// when
final SWTBotTreeItem connectionTreeItem = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test");
// then
assertThat(connectionTreeItem.getItems()).isEmpty();
}
use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class DockerExplorerViewSWTBotTest method shouldProvideEnabledStartCommandOnMultipleContainersAtOnce.
@Test
public void shouldProvideEnabledStartCommandOnMultipleContainersAtOnce() {
// given
final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("gentle_foo").status("Stopped").build()).container(MockContainerFactory.name("angry_bar").status("Stopped").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
// open the context menu on one of the containers
selectContainersInTreeView("Test", "gentle_foo", "angry_bar");
final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Start");
// then
MenuAssertion.assertThat(menuCommand).isVisible().isEnabled();
}
use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class DockerExplorerViewSWTBotTest method shouldProvideDisabledPauseCommandOnMultipleContainersAtOnce.
@Test
public void shouldProvideDisabledPauseCommandOnMultipleContainersAtOnce() {
// given
final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("gentle_foo").status("Up (Paused)").build()).container(MockContainerFactory.name("angry_bar").status("Running").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
// open the context menu on one of the containers
selectContainersInTreeView("Test", "gentle_foo", "angry_bar");
final SWTBotMenu menuCommand = SWTUtils.getContextMenu(dockerExplorerViewBot.bot().tree(), "Pause");
// then
MenuAssertion.assertThat(menuCommand).isVisible().isNotEnabled();
}
use of org.eclipse.linuxtools.internal.docker.core.DockerConnection 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);
}
Aggregations