use of com.openshift.restclient.model.IServicePort in project jbosstools-openshift by jbosstools.
the class DeployImageWizardModel method setServicePortsFromPorts.
private void setServicePortsFromPorts(List<IPort> portSpecs) {
this.imagePorts = new ArrayList<>(portSpecs.size());
List<IServicePort> servicePorts = new ArrayList<>(portSpecs.size());
for (IPort port : portSpecs) {
servicePorts.add(new ServicePortAdapter(port));
imagePorts.add(new ServicePortAdapter(port));
}
setServicePorts(servicePorts);
}
use of com.openshift.restclient.model.IServicePort 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))));
}
Aggregations