@Test public void testParsePodList() throws Exception { KubernetesList podList = assertParseExampleFile("pod-list.json", KubernetesList.class); List<HasMetadata> items = podList.getItems(); assertNotEmpty("items", items); Pod pod = (Pod) items.get(0); assertNotNull("pod1", pod); assertEquals("pod1.name", "my-pod-1", KubernetesHelper.getName(pod)); PodSpec podSpec = pod.getSpec(); assertNotNull("pod1.podSpec", podSpec); List<Container> containers = podSpec.getContainers(); assertNotEmpty("pod1.podSpec.containers", containers); Container container = containers.get(0); assertNotNull("pod1.podSpec.container[0]", container); assertEquals("pod1.podSpec.container[0].name", "nginx", container.getName()); assertEquals("pod1.podSpec.container[0].image", "dockerfile/nginx", container.getImage()); LOG.info("pod1 container1 " + container); String json = KubernetesHelper.toJson(podList); LOG.info("Got JSON: " + json); }
private void assertContainers(List<Container> containers) { for (Container container : containers) { assertNotNull(container.getId()); assertNotNull(container.getImage()); } }