Search in sources :

Example 26 with SWTBotTreeItem

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.

the class EditDockerConnectionSWTBotTest method shouldRefreshDockerContainersViewWhenConnectionNameChanges.

@Test
public void shouldRefreshDockerContainersViewWhenConnectionNameChanges() {
    // given
    configureTCPConnection("Test");
    final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
    assertThat(connectionTreeItem).isNotNull();
    // when
    openConnectionEditionWizard("Test");
    bot.text(0).setText("foo");
    getFinishButton().click();
    SWTUtils.wait(2, TimeUnit.SECONDS);
    // then
    final DockerContainersView dockerContainersView = dockerContainers.view();
    final String formTitle = SWTUtils.syncExec(() -> dockerContainersView.getFormTitle());
    assertThat(formTitle).contains("foo");
}
Also used : SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) DockerContainersView(org.eclipse.linuxtools.internal.docker.ui.views.DockerContainersView) Test(org.junit.Test)

Example 27 with SWTBotTreeItem

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.

the class EditDockerConnectionSWTBotTest method shouldRefreshDockerExplorerViewWhenNameChangedTwice.

@Test
public void shouldRefreshDockerExplorerViewWhenNameChangedTwice() {
    // given
    configureTCPConnection("Test");
    final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
    assertThat(connectionTreeItem).isNotNull();
    // name change #1
    openConnectionEditionWizard("Test");
    bot.text(0).setText("foo");
    getFinishButton().click();
    SWTUtils.wait(2, TimeUnit.SECONDS);
    // name change #2
    openConnectionEditionWizard("foo");
    bot.text(0).setText("bar");
    getFinishButton().click();
    SWTUtils.wait(2, TimeUnit.SECONDS);
    // then
    final SWTBotTreeItem updatedConnectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "bar");
    assertThat(updatedConnectionTreeItem).isNotNull();
}
Also used : SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Test(org.junit.Test)

Example 28 with SWTBotTreeItem

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.

the class EditDockerConnectionSWTBotTest method shouldRefreshDockerImagesViewWhenConnectionNameChanges.

@Test
public void shouldRefreshDockerImagesViewWhenConnectionNameChanges() {
    // given
    configureTCPConnection("Test");
    final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
    assertThat(connectionTreeItem).isNotNull();
    // when
    openConnectionEditionWizard("Test");
    bot.text(0).setText("foo");
    getFinishButton().click();
    SWTUtils.wait(2, TimeUnit.SECONDS);
    // then
    final DockerImagesView dockerImagesView = dockerImages.view();
    final String formTitle = SWTUtils.syncExec(() -> dockerImagesView.getFormTitle());
    assertThat(formTitle).contains("foo");
}
Also used : SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) DockerImagesView(org.eclipse.linuxtools.internal.docker.ui.views.DockerImagesView) Test(org.junit.Test)

Example 29 with SWTBotTreeItem

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.

the class EditDockerConnectionSWTBotTest method shouldRefreshDockerExplorerViewWhenConnectionNameChanged.

@Test
public void shouldRefreshDockerExplorerViewWhenConnectionNameChanged() {
    // given
    final IDockerConnection connection = configureTCPConnection("Test");
    final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
    assertThat(connectionTreeItem).isNotNull();
    // when
    openConnectionEditionWizard("Test");
    bot.text(0).setText("foo");
    getFinishButton().click();
    SWTUtils.wait(2, TimeUnit.SECONDS);
    // then
    final SWTBotTreeItem updatedConnectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "foo");
    assertThat(updatedConnectionTreeItem).isNotNull();
}
Also used : SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) Test(org.junit.Test)

Example 30 with SWTBotTreeItem

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.

the class EditDockerConnectionSWTBotTest method shouldSaveConnectionWhenUnixSocketConnectionSettingsChanged.

@SuppressWarnings("unchecked")
@Test
public void shouldSaveConnectionWhenUnixSocketConnectionSettingsChanged() throws IOException {
    // given
    final IDockerConnection connection = configureUnixSocketConnection("Test");
    final IDockerConnectionStorageManager connectionStorageManager = MockDockerConnectionStorageManagerFactory.providing(connection);
    DockerConnectionManagerUtils.configureConnectionManager(connectionStorageManager);
    final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
    assertThat(connectionTreeItem).isNotNull();
    final File tmpDockerSocketFile = folder.newFile("docker.sock");
    // let's ignore the connection savings that may have occurred when
    // adding elements from the extension points
    Mockito.reset(connectionStorageManager);
    // when
    openConnectionEditionWizard("Test");
    bot.text(1).setText(tmpDockerSocketFile.getAbsolutePath());
    getFinishButton().click();
    // then
    final IDockerConnection foundConnection = DockerConnectionManager.getInstance().findConnection("Test");
    assertThat(foundConnection).isNotNull();
    assertThat(foundConnection.getSettings()).isNotNull().isEqualTo(new UnixSocketConnectionSettings(tmpDockerSocketFile.getAbsolutePath()));
    Mockito.verify(connectionStorageManager).saveConnections(Matchers.anyList());
}
Also used : IDockerConnectionStorageManager(org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager) UnixSocketConnectionSettings(org.eclipse.linuxtools.internal.docker.core.UnixSocketConnectionSettings) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) File(java.io.File) Test(org.junit.Test)

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