DaemonSetHandler { public DaemonSet getDaemonSet(ResourceConfig config, List<ImageConfiguration> images) { return new DaemonSetBuilder() .withMetadata(createDaemonSetMetaData(config)) .withSpec(createDaemonSetSpec(config, images)) .build(); } DaemonSetHandler(PodTemplateHandler podTemplateHandler); DaemonSet getDaemonSet(ResourceConfig config,
                                  List<ImageConfiguration> images);  }
@Test public void daemonTemplateHandlerTest() { ContainerHandler containerHandler = getContainerHandler(); PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler); DaemonSetHandler daemonSetHandler = new DaemonSetHandler(podTemplateHandler); ResourceConfig config = new ResourceConfig.Builder() .imagePullPolicy("IfNotPresent") .controllerName("testing") .withServiceAccount("test-account") .volumes(volumes1) .build(); DaemonSet daemonSet = daemonSetHandler.getDaemonSet(config,images); assertNotNull(daemonSet.getSpec()); assertNotNull(daemonSet.getMetadata()); assertNotNull(daemonSet.getSpec().getTemplate()); assertEquals("testing",daemonSet.getMetadata().getName()); assertEquals("test-account",daemonSet.getSpec().getTemplate() .getSpec().getServiceAccountName()); assertFalse(daemonSet.getSpec().getTemplate().getSpec().getVolumes().isEmpty()); assertEquals("test",daemonSet.getSpec().getTemplate().getSpec(). getVolumes().get(0).getName()); assertEquals("/test/path",daemonSet.getSpec().getTemplate() .getSpec().getVolumes().get(0).getHostPath().getPath()); assertNotNull(daemonSet.getSpec().getTemplate().getSpec().getContainers()); }
@Test(expected = IllegalArgumentException.class) public void daemonTemplateHandlerWithInvalidNameTest() { ContainerHandler containerHandler = getContainerHandler(); PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler); DaemonSetHandler daemonSetHandler = new DaemonSetHandler(podTemplateHandler); ResourceConfig config = new ResourceConfig.Builder() .imagePullPolicy("IfNotPresent") .controllerName("TesTing") .withServiceAccount("test-account") .volumes(volumes1) .build(); daemonSetHandler.getDaemonSet(config, images); }
@Test(expected = IllegalArgumentException.class) public void daemonTemplateHandlerWithoutControllerTest() { ContainerHandler containerHandler = getContainerHandler(); PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler); DaemonSetHandler daemonSetHandler = new DaemonSetHandler(podTemplateHandler); ResourceConfig config = new ResourceConfig.Builder() .imagePullPolicy("IfNotPresent") .withServiceAccount("test-account") .volumes(volumes1) .build(); daemonSetHandler.getDaemonSet(config, images); }