Search in sources :

Example 6 with IDockerConnectionStorageManager

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());
}
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)

Example 7 with IDockerConnectionStorageManager

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);
}
Also used : IDockerConnectionStorageManager(org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager)

Example 8 with IDockerConnectionStorageManager

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;
}
Also used : IDockerConnectionStorageManager(org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager)

Example 9 with IDockerConnectionStorageManager

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;
}
Also used : IDockerConnectionStorageManager(org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager)

Example 10 with IDockerConnectionStorageManager

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);
}
Also used : IDockerConnectionStorageManager(org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager)

Aggregations

IDockerConnectionStorageManager (org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager)11 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)6 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)6 Test (org.junit.Test)6 TCPConnectionSettings (org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings)3 File (java.io.File)2 UnixSocketConnectionSettings (org.eclipse.linuxtools.internal.docker.core.UnixSocketConnectionSettings)2