use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class CommandUtilsSWTBotTest method shouldRetrieveConnectionFromSelectedContainerPortsCategory.
@Test
public void shouldRetrieveConnectionFromSelectedContainerPortsCategory() {
// given
final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("foo_bar").build(), MockContainerInfoFactory.port("8080/tcp", "0.0.0.0", "8080").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
final SWTBotTreeItem ports = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Containers", "foo_bar", "Ports");
// when selecting the port
ports.select();
// then current connection should be found
Assertions.assertThat(CommandUtils.getCurrentConnection(dockerExplorerView)).isEqualTo(dockerConnection);
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class CommandUtilsSWTBotTest method shouldRetrieveConnectionFromSelectedContainer.
@Test
public void shouldRetrieveConnectionFromSelectedContainer() {
// given
final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("foo_bar").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
final SWTBotTreeItem container = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Containers", "foo_bar");
// when selecting the container
container.select();
// then current connection should be found
Assertions.assertThat(CommandUtils.getCurrentConnection(dockerExplorerView)).isEqualTo(dockerConnection);
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class CommandUtilsSWTBotTest method shouldRetrieveConnectionFromSelectedImagesCategory.
@Test
public void shouldRetrieveConnectionFromSelectedImagesCategory() {
// given
final DockerClient client = MockDockerClientFactory.image(MockImageFactory.name("foo").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
final SWTBotTreeItem images = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Images");
// when selecting the images category
images.select();
// then current connection should be found
Assertions.assertThat(CommandUtils.getCurrentConnection(dockerExplorerView)).isEqualTo(dockerConnection);
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class DockerComposeSWTBotTest method getRunAsDockerComposeContextMenu.
/**
* @return the {@link SWTBotMenu} for the "Run as > Docker Image Build"
* shortcut
*/
private SWTBotMenu getRunAsDockerComposeContextMenu(final String projectName, final String dockerComposeFileName) {
final SWTBotView projectExplorerBotView = this.projectExplorerViewRule.getProjectExplorerBotView();
// make sure the project explorer view is visible, in case it was hidden
// by another view.
projectExplorerBotView.setFocus();
final SWTBotTreeItem fooProjectTreeItem = SWTUtils.getTreeItem(projectExplorerBotView, projectName);
assertThat(fooProjectTreeItem).isNotNull();
SWTUtils.syncExec(() -> fooProjectTreeItem.expand());
final SWTBotTreeItem dockerfileTreeItem = SWTUtils.getTreeItem(fooProjectTreeItem, dockerComposeFileName);
assertThat(dockerfileTreeItem).isNotNull();
SWTUtils.select(dockerfileTreeItem);
final SWTBotMenu runAsDockerComposeMenu = SWTUtils.getContextMenu(projectExplorerBotView.bot().tree(), "Run As", "1 Docker Compose");
return runAsDockerComposeMenu;
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem 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();
}
Aggregations