Search in sources :

Example 16 with IDockerImageInfo

use of org.eclipse.linuxtools.docker.core.IDockerImageInfo in project jbosstools-openshift by jbosstools.

the class DeployImageWizardModelTest method checkThatRemoveAnExistingServicePortIsEffective.

@Test
public void checkThatRemoveAnExistingServicePortIsEffective() {
    // assume Docker image is on local
    final IDockerImageInfo dockerImageInfo = Mockito.mock(IDockerImageInfo.class, Mockito.RETURNS_DEEP_STUBS);
    when(dockerConnection.hasImage(WILDFLY_IMAGE, LATEST_TAG)).thenReturn(true);
    when(dockerConnection.getImageInfo(WILDFLY_IMAGE_URI)).thenReturn(dockerImageInfo);
    when(dockerImageInfo.config().env()).thenReturn(Collections.emptyList());
    when(dockerImageInfo.config().exposedPorts()).thenReturn(new HashSet<>(Arrays.asList("8080/tcp", "9990/tcp")));
    when(dockerImageInfo.config().volumes()).thenReturn(Collections.emptySet());
    when(dockerImageInfo.containerConfig()).thenReturn(null);
    mockSingleImage(dockerConnection, WILDFLY_IMAGE, LATEST_TAG);
    // when
    model.setImageName(WILDFLY_IMAGE_URI);
    final boolean result = model.initializeContainerInfo();
    // then
    assertThat(result).isTrue();
    model.removeServicePort(model.getServicePorts().get(0));
    assertThat(model.getServicePorts()).hasSize(1);
    assertThat(model.getServicePorts()).isEqualTo(Collections.singletonList(new ServicePortAdapter(new PortSpecAdapter("9990-tcp", "TCP", 9990))));
}
Also used : ServicePortAdapter(org.jboss.tools.openshift.internal.ui.wizard.deployimage.ServicePortAdapter) PortSpecAdapter(org.jboss.tools.openshift.internal.core.models.PortSpecAdapter) IDockerImageInfo(org.eclipse.linuxtools.docker.core.IDockerImageInfo) Test(org.junit.Test)

Example 17 with IDockerImageInfo

use of org.eclipse.linuxtools.docker.core.IDockerImageInfo in project jbosstools-openshift by jbosstools.

the class DeployImageWizardModelTest method checkThatRemoveAnExistingEnvironmentVariableIsEffective.

@Test
public void checkThatRemoveAnExistingEnvironmentVariableIsEffective() {
    // assume Docker image is on local
    final IDockerImageInfo dockerImageInfo = Mockito.mock(IDockerImageInfo.class, Mockito.RETURNS_DEEP_STUBS);
    when(dockerConnection.hasImage(WILDFLY_IMAGE, LATEST_TAG)).thenReturn(true);
    when(dockerConnection.getImageInfo(WILDFLY_IMAGE_URI)).thenReturn(dockerImageInfo);
    mockSingleImage(dockerConnection, WILDFLY_IMAGE, LATEST_TAG);
    when(dockerImageInfo.config().env()).thenReturn(Arrays.asList("V1=value1", "V2=value2"));
    when(dockerImageInfo.config().exposedPorts()).thenReturn(Collections.emptySet());
    when(dockerImageInfo.config().volumes()).thenReturn(Collections.emptySet());
    when(dockerImageInfo.containerConfig()).thenReturn(null);
    // when
    model.setImageName(WILDFLY_IMAGE_URI);
    final boolean result = model.initializeContainerInfo();
    // then
    assertThat(result).isTrue();
    model.removeEnvironmentVariable(model.getEnvironmentVariable("V1"));
    assertThat(model.getEnvironmentVariables()).hasSize(2);
    // Deleted existing environment variable is marked as deleted, but remains in the table.
    assertThat(model.isEnvironmentVariableDeleted(model.getEnvironmentVariable("V1"))).isTrue();
    assertThat(model.getEnvironmentVariable("V2").getValue()).isEqualTo("value2");
}
Also used : IDockerImageInfo(org.eclipse.linuxtools.docker.core.IDockerImageInfo) Test(org.junit.Test)

Aggregations

IDockerImageInfo (org.eclipse.linuxtools.docker.core.IDockerImageInfo)17 Test (org.junit.Test)7 PortSpecAdapter (org.jboss.tools.openshift.internal.core.models.PortSpecAdapter)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 ArrayList (java.util.ArrayList)3 CoreException (org.eclipse.core.runtime.CoreException)3 IDockerImage (org.eclipse.linuxtools.docker.core.IDockerImage)3 EnvironmentVariable (org.jboss.tools.openshift.internal.ui.wizard.common.EnvironmentVariable)3 ServicePortAdapter (org.jboss.tools.openshift.internal.ui.wizard.deployimage.ServicePortAdapter)3 HashMap (java.util.HashMap)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)2 IDockerContainerConfig (org.eclipse.linuxtools.docker.core.IDockerContainerConfig)2 DockerContainerConfig (org.eclipse.linuxtools.internal.docker.core.DockerContainerConfig)2 FindImageInfoRunnable (org.eclipse.linuxtools.internal.docker.ui.jobs.FindImageInfoRunnable)2 DataVolumeModel (org.eclipse.linuxtools.internal.docker.ui.wizards.DataVolumeModel)2 ExposedPortModel (org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunSelectionModel.ExposedPortModel)2 DockerImageURI (com.openshift.restclient.images.DockerImageURI)1 IServicePort (com.openshift.restclient.model.IServicePort)1