DeploymentHandler { public Deployment getDeployment(ResourceConfig config, List<ImageConfiguration> images) { Deployment deployment = new DeploymentBuilder() .withMetadata(createDeploymentMetaData(config)) .withSpec(createDeploymentSpec(config, images)) .build(); return deployment; } DeploymentHandler(PodTemplateHandler podTemplateHandler); Deployment getDeployment(ResourceConfig config,
                                    List<ImageConfiguration> images);  }
@Test public void deploymentTemplateHandlerTest() { ContainerHandler containerHandler = getContainerHandler(); PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler); DeploymentHandler deploymentHandler = new DeploymentHandler(podTemplateHandler); ResourceConfig config = new ResourceConfig.Builder() .imagePullPolicy("IfNotPresent") .controllerName("testing") .withServiceAccount("test-account") .withReplicas(5) .volumes(volumes1) .build(); Deployment deployment = deploymentHandler.getDeployment(config,images); assertNotNull(deployment.getSpec()); assertNotNull(deployment.getMetadata()); assertEquals(5,deployment.getSpec().getReplicas().intValue()); assertNotNull(deployment.getSpec().getTemplate()); assertEquals("testing",deployment.getMetadata().getName()); assertEquals("test-account",deployment.getSpec().getTemplate() .getSpec().getServiceAccountName()); assertFalse(deployment.getSpec().getTemplate().getSpec().getVolumes().isEmpty()); assertEquals("test",deployment.getSpec().getTemplate().getSpec(). getVolumes().get(0).getName()); assertEquals("/test/path",deployment.getSpec().getTemplate() .getSpec().getVolumes().get(0).getHostPath().getPath()); assertNotNull(deployment.getSpec().getTemplate().getSpec().getContainers()); }
@Test(expected = IllegalArgumentException.class) public void deploymentTemplateHandlerWithInvalidNameTest() { ContainerHandler containerHandler = getContainerHandler(); PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler); DeploymentHandler deploymentHandler = new DeploymentHandler(podTemplateHandler); ResourceConfig config = new ResourceConfig.Builder() .imagePullPolicy("IfNotPresent") .controllerName("TesTing") .withServiceAccount("test-account") .withReplicas(5) .volumes(volumes1) .build(); deploymentHandler.getDeployment(config, images); }
@Test(expected = IllegalArgumentException.class) public void deploymentTemplateHandlerWithoutControllerTest() { ContainerHandler containerHandler = getContainerHandler(); PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler); DeploymentHandler deploymentHandler = new DeploymentHandler(podTemplateHandler); ResourceConfig config = new ResourceConfig.Builder() .imagePullPolicy("IfNotPresent") .withServiceAccount("test-account") .withReplicas(5) .volumes(volumes1) .build(); deploymentHandler.getDeployment(config, images); }