RunOperations { Pod convertRunConfigIntoPod() { RunConfig finalGeneratorConfig = runConfigBuilder.build(); return new PodBuilder() .withMetadata(RunConfigUtil.getObjectMetadataFromRunConfig(finalGeneratorConfig)) .withSpec(RunConfigUtil.getPodSpecFromRunConfig(finalGeneratorConfig)) .build(); } RunOperations(OkHttpClient client, Config config, String namespace, RunConfigBuilder runConfigBuilder); RunOperations inNamespace(String namespace); RunOperations withImage(String image); RunOperations withName(String name); RunOperations withRunConfig(RunConfig generatorRunConfig); Pod done();  }
@Test void testConvertRunConfigIntoPod() { Map<String, Quantity> limits = new HashMap<>(); limits.put("cpu", new Quantity("200m")); limits.put("memory", new Quantity("512Mi")); Map<String, Quantity> requests = new HashMap<>(); requests.put("memory", new Quantity("64Mi")); requests.put("cpu", new Quantity("150m")); Map<String, String> labels = new HashMap<>(); labels.put("first", "FIRST"); labels.put("second", "SECOND"); RunConfigBuilder generatorRunConfig = new RunConfigBuilder() .withName("test") .withImage("test:latest") .withLabels(labels) .withEnv(Collections.singletonMap("TEST_KEY", "TEST_VALUE")) .withImagePullPolicy("IfNotPresent") .withRestartPolicy("OnFailure") .withServiceAccount("ribbon") .withPort(5701) .withLimits(limits) .withRequests(requests); RunOperations deploymentGenerator = new RunOperations(mockClient, config, "ns1", generatorRunConfig); Pod pod = deploymentGenerator.convertRunConfigIntoPod(); assertNotNull(pod); assertEquals("test", pod.getMetadata().getName()); assertEquals("FIRST", pod.getMetadata().getLabels().get("first")); assertEquals("SECOND", pod.getMetadata().getLabels().get("second")); assertEquals("test", pod.getMetadata().getLabels().get("run")); assertNotNull(pod.getSpec()); assertEquals("OnFailure", pod.getSpec().getRestartPolicy()); assertEquals("ribbon", pod.getSpec().getServiceAccountName()); assertEquals("test", pod.getSpec().getContainers().get(0).getName()); assertEquals("IfNotPresent", pod.getSpec().getContainers().get(0).getImagePullPolicy()); assertEquals("test:latest", pod.getSpec().getContainers().get(0).getImage()); assertEquals(1, pod.getSpec().getContainers().get(0).getEnv().size()); assertEquals(1, pod.getSpec().getContainers().get(0).getPorts().size()); assertEquals(5701, pod.getSpec().getContainers().get(0).getPorts().get(0).getContainerPort()); assertEquals("TEST_KEY", pod.getSpec().getContainers().get(0).getEnv().get(0).getName()); assertEquals("TEST_VALUE", pod.getSpec().getContainers().get(0).getEnv().get(0).getValue()); assertEquals(new Quantity("200m"), pod.getSpec().getContainers().get(0).getResources().getLimits().get("cpu")); assertEquals(new Quantity("512Mi"), pod.getSpec().getContainers().get(0).getResources().getLimits().get("memory")); assertEquals(new Quantity("150m"), pod.getSpec().getContainers().get(0).getResources().getRequests().get("cpu")); assertEquals(new Quantity("64Mi"), pod.getSpec().getContainers().get(0).getResources().getRequests().get("memory")); }