use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldResetConnectionStateWhenTCPConnectionSettingsChanged.
@Test
public void shouldResetConnectionStateWhenTCPConnectionSettingsChanged() {
// given
dockerContainers.close();
dockerImages.close();
final IDockerConnection connection = configureTCPConnection("Test");
final IDockerConnectionStorageManager connectionStorageManager = MockDockerConnectionStorageManagerFactory.providing(connection);
DockerConnectionManagerUtils.configureConnectionManager(connectionStorageManager);
final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(connectionTreeItem).isNotNull();
// when
openConnectionEditionWizard("Test");
bot.text(2).setText("https://foo.bar:1234");
getFinishButton().click();
// then
final IDockerConnection foundConnection = DockerConnectionManager.getInstance().findConnection("Test");
assertThat(foundConnection).isNotNull();
assertThat(foundConnection.getSettings()).isNotNull().isEqualTo(new TCPConnectionSettings("https://foo.bar:1234", PATH_TO_CERTS));
assertThat(foundConnection.getState()).isEqualTo(EnumDockerConnectionState.UNKNOWN);
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldSaveConnectionWhenNameChanged.
@SuppressWarnings("unchecked")
@Test
public void shouldSaveConnectionWhenNameChanged() {
// given
final IDockerConnection connection = configureTCPConnection("Test");
final IDockerConnectionStorageManager connectionStorageManager = MockDockerConnectionStorageManagerFactory.providing(connection);
DockerConnectionManagerUtils.configureConnectionManager(connectionStorageManager);
final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(connectionTreeItem).isNotNull();
// 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(0).setText("foo");
getFinishButton().click();
// then
final IDockerConnection foundConnection = DockerConnectionManager.getInstance().findConnection("foo");
assertThat(foundConnection).isNotNull();
Mockito.verify(connectionStorageManager).saveConnections(Matchers.anyList());
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldResetConnectionStateWhenUnixConnectionSettingsChanged.
@Test
public void shouldResetConnectionStateWhenUnixConnectionSettingsChanged() throws IOException {
// given
dockerContainers.close();
dockerImages.close();
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");
assertThat(connection.getState()).isEqualTo(EnumDockerConnectionState.UNKNOWN);
// 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()));
assertThat(foundConnection.getState()).isEqualTo(EnumDockerConnectionState.UNKNOWN);
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldSaveConnectionWhenTCPConnectionSettingsChanged.
@SuppressWarnings("unchecked")
@Test
public void shouldSaveConnectionWhenTCPConnectionSettingsChanged() {
// given
final IDockerConnection connection = configureTCPConnection("Test");
final IDockerConnectionStorageManager connectionStorageManager = MockDockerConnectionStorageManagerFactory.providing(connection);
DockerConnectionManagerUtils.configureConnectionManager(connectionStorageManager);
final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(connectionTreeItem).isNotNull();
// 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(2).setText("https://foo.bar:1234");
getFinishButton().click();
// then
final IDockerConnection foundConnection = DockerConnectionManager.getInstance().findConnection("Test");
assertThat(foundConnection).isNotNull();
assertThat(foundConnection.getSettings()).isNotNull().isEqualTo(new TCPConnectionSettings("https://foo.bar:1234", PATH_TO_CERTS));
Mockito.verify(connectionStorageManager).saveConnections(Matchers.anyList());
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldRefreshDockerExplorerViewWhenUnixSockerConnectionSettingsChanged.
@Test
public void shouldRefreshDockerExplorerViewWhenUnixSockerConnectionSettingsChanged() throws IOException {
// given
dockerContainers.close();
dockerImages.close();
final IDockerConnection connection = configureUnixSocketConnection("Test");
final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(connectionTreeItem).isNotNull();
final File tmpDockerSocketFile = folder.newFile("docker.sock");
// when
openConnectionEditionWizard("Test");
bot.text(1).setText(tmpDockerSocketFile.getAbsolutePath());
getFinishButton().click();
SWTUtils.wait(2, TimeUnit.SECONDS);
// then
final SWTBotTreeItem updatedConnectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(updatedConnectionTreeItem).isNotNull();
assertThat(updatedConnectionTreeItem.getText()).contains(tmpDockerSocketFile.getAbsolutePath());
// list of containers and images should have been refreshed
Mockito.verify(connection, Mockito.times(0)).getContainers(true);
Mockito.verify(connection, Mockito.times(0)).getImages(true);
}
Aggregations