use of org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager 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());
}
use of org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager in project linuxtools by eclipse.
the class DockerExplorerView method createDockerConnectionUnix.
/**
* Creates a docker connection connected with IDockerConnection.
* (used with mockito)
*
* @param connections
* IDockerConnections
*/
public void createDockerConnectionUnix(final IDockerConnection... connections) {
final IDockerConnectionStorageManager connectionStorageManager = MockDockerConnectionStorageManagerFactory.providing(connections);
DockerConnectionManager.getInstance().setConnectionStorageManager(connectionStorageManager);
}
use of org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager in project linuxtools by eclipse.
the class MockDockerConnectionStorageManagerFactory method providing.
public static IDockerConnectionStorageManager providing(final IDockerConnection... mockedConnections) {
final IDockerConnectionStorageManager connectionStorageManager = Mockito.mock(IDockerConnectionStorageManager.class);
Mockito.when(connectionStorageManager.loadConnections()).thenReturn(Stream.of(mockedConnections).collect(Collectors.toList()));
return connectionStorageManager;
}
use of org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager in project linuxtools by eclipse.
the class MockDockerConnectionStorageManagerFactory method loadNone.
public static IDockerConnectionStorageManager loadNone() {
final IDockerConnectionStorageManager connectionStorageManager = Mockito.mock(IDockerConnectionStorageManager.class);
Mockito.when(connectionStorageManager.loadConnections()).thenReturn(Collections.emptyList());
return connectionStorageManager;
}
use of org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager in project linuxtools by eclipse.
the class MockDockerConnectionManager method configureConnectionManager.
/**
* Configures the {@link DockerConnectionManager} with the given array of
* {@link IDockerConnection} (can be mocked) and refreshes the associated
* {@link DockerExplorerView}.
*
* @param connections
* the connection to configure in the
* {@link DockerConnectionManager} via a mocked
* {@link IDockerConnectionStorageManager}
*/
public static void configureConnectionManager(final IDockerConnection... connections) {
final IDockerConnectionStorageManager connectionStorageManager = MockDockerConnectionStorageManagerFactory.providing(connections);
configureConnectionManager(connectionStorageManager);
}
Aggregations