Search in sources :

Example 1 with ServicePortAdapter

use of org.jboss.tools.openshift.internal.ui.wizard.deployimage.ServicePortAdapter in project jbosstools-openshift by jbosstools.

the class DeployImageWizardModelTest method checkThatServicePortsAreReset.

@Test
public void checkThatServicePortsAreReset() {
    // 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))));
    model.resetServicePorts();
    assertThat(model.getServicePorts()).hasSize(2);
    ServicePortAdapter first = new ServicePortAdapter(new PortSpecAdapter("8080-tcp", "TCP", 8080));
    first.setRoutePort(true);
    assertThat(model.getServicePorts()).isEqualTo(Arrays.asList(first, 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 2 with ServicePortAdapter

use of org.jboss.tools.openshift.internal.ui.wizard.deployimage.ServicePortAdapter in project jbosstools-openshift by jbosstools.

the class DeployImageWizardModelTest method checkThatRemoveANonExistingServicePortIsNotEffective.

@Test
public void checkThatRemoveANonExistingServicePortIsNotEffective() {
    // 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();
    IServicePort port = new ServicePortAdapter();
    port.setName("9000-tcp");
    port.setProtocol("TCP");
    port.setPort(9000);
    port.setTargetPort(9000);
    model.removeServicePort(port);
    assertThat(model.getServicePorts()).hasSize(2);
    ServicePortAdapter first = new ServicePortAdapter(new PortSpecAdapter("8080-tcp", "TCP", 8080));
    first.setRoutePort(true);
    assertThat(model.getServicePorts()).isEqualTo(Arrays.asList(first, new ServicePortAdapter(new PortSpecAdapter("9990-tcp", "TCP", 9990))));
}
Also used : ServicePortAdapter(org.jboss.tools.openshift.internal.ui.wizard.deployimage.ServicePortAdapter) IServicePort(com.openshift.restclient.model.IServicePort) PortSpecAdapter(org.jboss.tools.openshift.internal.core.models.PortSpecAdapter) IDockerImageInfo(org.eclipse.linuxtools.docker.core.IDockerImageInfo) Test(org.junit.Test)

Example 3 with ServicePortAdapter

use of org.jboss.tools.openshift.internal.ui.wizard.deployimage.ServicePortAdapter 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)

Aggregations

IDockerImageInfo (org.eclipse.linuxtools.docker.core.IDockerImageInfo)3 PortSpecAdapter (org.jboss.tools.openshift.internal.core.models.PortSpecAdapter)3 ServicePortAdapter (org.jboss.tools.openshift.internal.ui.wizard.deployimage.ServicePortAdapter)3 Test (org.junit.Test)3 IServicePort (com.openshift.restclient.model.IServicePort)1