Search in sources :

Example 1 with ExposedPort

use of org.eclipse.che.plugin.docker.client.json.ExposedPort in project che by eclipse.

the class KubernetesServiceTest method shouldReturnServicePortListFromImageExposedPortList.

@Test
public void shouldReturnServicePortListFromImageExposedPortList() {
    // Given
    Map<String, ExposedPort> imageExposedPorts = new HashMap<>();
    imageExposedPorts.put("8080/TCP", new ExposedPort());
    // When
    List<ServicePort> servicePorts = KubernetesService.getServicePortsFrom(imageExposedPorts.keySet());
    // Then
    List<String> portsAndProtocols = servicePorts.stream().map(p -> Integer.toString(p.getPort()) + "/" + p.getProtocol()).collect(Collectors.toList());
    assertTrue(imageExposedPorts.keySet().stream().anyMatch(portsAndProtocols::contains));
}
Also used : ExposedPort(org.eclipse.che.plugin.docker.client.json.ExposedPort) HashSet(java.util.HashSet) List(java.util.List) Map(java.util.Map) BeforeClass(org.testng.annotations.BeforeClass) Assert.assertTrue(org.testng.Assert.assertTrue) Set(java.util.Set) ServicePort(io.fabric8.kubernetes.api.model.ServicePort) HashMap(java.util.HashMap) Test(org.testng.annotations.Test) Collectors(java.util.stream.Collectors) ExposedPort(org.eclipse.che.plugin.docker.client.json.ExposedPort) ServicePort(io.fabric8.kubernetes.api.model.ServicePort) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Example 2 with ExposedPort

use of org.eclipse.che.plugin.docker.client.json.ExposedPort in project che by eclipse.

the class KubernetesContainerTest method shouldReturnContainerPortListFromImageExposedPortList.

@Test
public void shouldReturnContainerPortListFromImageExposedPortList() {
    // Given
    Map<String, ExposedPort> imageExposedPorts = new HashMap<>();
    imageExposedPorts.put("8080/tcp", new ExposedPort());
    // When
    List<ContainerPort> containerPorts = KubernetesContainer.getContainerPortsFrom(imageExposedPorts.keySet());
    // Then
    List<String> portsAndProtocols = containerPorts.stream().map(p -> Integer.toString(p.getContainerPort()) + "/" + p.getProtocol().toLowerCase()).collect(Collectors.toList());
    assertTrue(imageExposedPorts.keySet().stream().anyMatch(portsAndProtocols::contains));
}
Also used : ExposedPort(org.eclipse.che.plugin.docker.client.json.ExposedPort) HashSet(java.util.HashSet) ContainerPort(io.fabric8.kubernetes.api.model.ContainerPort) List(java.util.List) Map(java.util.Map) BeforeClass(org.testng.annotations.BeforeClass) Assert.assertTrue(org.testng.Assert.assertTrue) Set(java.util.Set) HashMap(java.util.HashMap) Test(org.testng.annotations.Test) Collectors(java.util.stream.Collectors) ExposedPort(org.eclipse.che.plugin.docker.client.json.ExposedPort) HashMap(java.util.HashMap) ContainerPort(io.fabric8.kubernetes.api.model.ContainerPort) Test(org.testng.annotations.Test)

Aggregations

HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 ExposedPort (org.eclipse.che.plugin.docker.client.json.ExposedPort)2 Assert.assertTrue (org.testng.Assert.assertTrue)2 BeforeClass (org.testng.annotations.BeforeClass)2 Test (org.testng.annotations.Test)2 ContainerPort (io.fabric8.kubernetes.api.model.ContainerPort)1 ServicePort (io.fabric8.kubernetes.api.model.ServicePort)1