use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class DockerContainersViewSWTBotTest method shouldOpenImageHierarchyView.
@Test
public void shouldOpenImageHierarchyView() {
// 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);
// make sure the hierarchy view is closed.
SWTUtils.closeView(this.bot, DockerImageHierarchyView.VIEW_ID);
// open the context menu on one of the containers
selectContainerInTable("angry_bar");
SWTUtils.getContextMenu(dockerContainersViewBot.bot().table(), "Open Image Hierarchy").click();
// wait 1sec
SWTUtils.wait(1, TimeUnit.SECONDS);
DockerImageHierarchyViewAssertions.assertThat(SWTUtils.getView(bot, DockerImageHierarchyView.VIEW_ID)).isNotNull();
}
use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class DockerContainersViewSWTBotTest method setup.
@Before
public void setup() {
this.bot = new SWTWorkbenchBot();
final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("defaultcon").status("Running").build()).image(MockImageFactory.id("987654321abcde").name("default:1").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Default", client).withDefaultTCPConnectionSettings();
dockerConnection.removeContainerListener(DockerContainerRefreshManager.getInstance());
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
SWTUtils.asyncExec(() -> {
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(DockerContainersView.VIEW_ID);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(DockerExplorerView.VIEW_ID);
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Failed to open Docker Explorer view: " + e.getMessage());
}
});
this.dockerContainersViewBot = bot.viewById(DockerContainersView.VIEW_ID);
this.dockerContainersView = (DockerContainersView) (dockerContainersViewBot.getViewReference().getView(true));
this.dockerExplorerBotView = bot.viewById(DockerExplorerView.VIEW_ID);
}
use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class DockerContainersViewSWTBotTest method shouldNotRemoveListenersWhenNoSelectedConnectionBeforeClosingView.
@Test
public void shouldNotRemoveListenersWhenNoSelectedConnectionBeforeClosingView() {
// given
dockerExplorerBotView.close();
final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("angry_bar").status("Stopped").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
// remove the DockerContainerRefreshManager
dockerConnection.removeContainerListener(DockerContainerRefreshManager.getInstance());
assertThat(dockerConnection.getContainerListeners()).hasSize(0);
// close the Docker Containers View
dockerContainersViewBot.close();
// there should be one listener left: DockerExplorerView
assertThat(dockerConnection.getContainerListeners()).hasSize(0);
}
use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class DockerContainersViewSWTBotTest method shouldProvideEnabledRestartOnMultipleContainers.
@Test
public void shouldProvideEnabledRestartOnMultipleContainers() {
// given
final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("gentle_foo").status("Running").build()).container(MockContainerFactory.name("bold_eagle").status("Stopped").build()).container(MockContainerFactory.name("angry_bar").status("Running").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
// make sure the hierarchy view is closed.
SWTUtils.closeView(this.bot, DockerImageHierarchyView.VIEW_ID);
// open the context menu on one of the containers
selectContainersInTable("gentle_foo", "bold_eagle", "angry_bar");
final SWTBotMenu menuCommand = dockerContainersViewBot.bot().table().contextMenu("Restart");
// then
MenuAssertion.assertThat(menuCommand).isVisible().isEnabled();
}
use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class DockerContainersViewSWTBotTest method shouldShowSelectedContainerInPropertiesView.
@Test
public void shouldShowSelectedContainerInPropertiesView() {
// given
final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("angry_bar").status("Stopped").build(), MockContainerInfoFactory.networkMode("host").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
final PropertySheet propertySheet = SWTUtils.syncExec(() -> SWTUtils.getView(bot, "org.eclipse.ui.views.PropertySheet", true));
this.dockerContainersView.setFocus();
// select the container in the table
selectContainerInTable("angry_bar");
// then the properties view should have a selected tab with container
// info
assertThat(propertySheet.getCurrentPage()).isInstanceOf(TabbedPropertySheetPage.class);
final TabbedPropertySheetPage currentPage = (TabbedPropertySheetPage) propertySheet.getCurrentPage();
TabDescriptorAssertions.assertThat(currentPage.getSelectedTab()).isNotNull().hasId("org.eclipse.linuxtools.docker.ui.properties.container.info");
}
Aggregations