@Test public void podBuildingWithoutAnnotations() { when(podNameFactory.newName(any())).thenReturn(TRUCK_PARK_NAME); when(configMapSupplier.get()).thenReturn(configMap); when(configMap.getData()).thenReturn(ImmutableMap .<String, String> builder() .put(DOCKER_IMAGE, DOCKER_IMAGE_NAME) .put(VERSION, IMAGE_VERSION) .put(CPU, "cpu1") .put(MEMORY, "mem1") .put(JVM_ARGS, "args1") .put(CLOUDWATCH_REGION, "region") .put(CLOUDWATCH_GROUP, "group") .build()); LanderConfiguration config = new LanderConfiguration(NAME, "topic", emptyMap(), "s3Prefix", false, PARTITION_COLUMN_VALUE, false); Pod pod = underTest.newInstance(config, singletonList(ARG)); ObjectMeta metadata = pod.getMetadata(); assertThat(metadata.getName(), is(TRUCK_PARK_NAME)); assertThat(metadata.getLabels(), is(ImmutableMap .<String, String> builder() .put(APP, TRUCK_PARK) .put(VERSION, IMAGE_VERSION) .put(ROAD, NAME) .build())); assertThat(metadata.getAnnotations(), is(Collections.emptyMap())); }
public Pod newInstance(LanderConfiguration config, List<String> args) { String truckParkName = podNameFactory.newName(config); log.info("Creating pod named: {}", truckParkName); Map<String, String> configMap = configMapSupplier.get().getData(); return new PodBuilder() .withMetadata(new ObjectMetaBuilder() .withName(truckParkName) .withLabels(labels(config.getRoadName(), configMap)) .withAnnotations(annotations(configMap)) .build()) .withSpec(new PodSpecBuilder() .withRestartPolicy(RESTART_POLICY_NEVER) .withContainers(container(config.getRoadName(), args, configMap, truckParkName)) .build()) .build(); }
LanderPodFactory { public Pod newInstance(LanderConfiguration config, List<String> args) { String truckParkName = podNameFactory.newName(config); log.info("Creating pod named: {}", truckParkName); Map<String, String> configMap = configMapSupplier.get().getData(); return new PodBuilder() .withMetadata(new ObjectMetaBuilder() .withName(truckParkName) .withLabels(labels(config.getRoadName(), configMap)) .withAnnotations(annotations(configMap)) .build()) .withSpec(new PodSpecBuilder() .withRestartPolicy(RESTART_POLICY_NEVER) .withContainers(container(config.getRoadName(), args, configMap, truckParkName)) .build()) .build(); } }
LanderPodFactory { public Pod newInstance(LanderConfiguration config, List<String> args) { String truckParkName = podNameFactory.newName(config); log.info("Creating pod named: {}", truckParkName); Map<String, String> configMap = configMapSupplier.get().getData(); return new PodBuilder() .withMetadata(new ObjectMetaBuilder() .withName(truckParkName) .withLabels(labels(config.getRoadName(), configMap)) .withAnnotations(annotations(configMap)) .build()) .withSpec(new PodSpecBuilder() .withRestartPolicy(RESTART_POLICY_NEVER) .withContainers(container(config.getRoadName(), args, configMap, truckParkName)) .build()) .build(); } @Autowired  LanderPodFactory(
      Supplier<ConfigMap> configMapSupplier,
      PodNameFactory podNameFactory,
      @Value("${ENVIRONMENT}") String environment); }
LanderPodFactory { public Pod newInstance(LanderConfiguration config, List<String> args) { String truckParkName = podNameFactory.newName(config); log.info("Creating pod named: {}", truckParkName); Map<String, String> configMap = configMapSupplier.get().getData(); return new PodBuilder() .withMetadata(new ObjectMetaBuilder() .withName(truckParkName) .withLabels(labels(config.getRoadName(), configMap)) .withAnnotations(annotations(configMap)) .build()) .withSpec(new PodSpecBuilder() .withRestartPolicy(RESTART_POLICY_NEVER) .withContainers(container(config.getRoadName(), args, configMap, truckParkName)) .build()) .build(); } @Autowired  LanderPodFactory(
      Supplier<ConfigMap> configMapSupplier,
      PodNameFactory podNameFactory,
      @Value("${ENVIRONMENT}") String environment); Pod newInstance(LanderConfiguration config, List<String> args); }
LanderPodFactory { public Pod newInstance(LanderConfiguration config, List<String> args) { String truckParkName = podNameFactory.newName(config); log.info("Creating pod named: {}", truckParkName); Map<String, String> configMap = configMapSupplier.get().getData(); return new PodBuilder() .withMetadata(new ObjectMetaBuilder() .withName(truckParkName) .withLabels(labels(config.getRoadName(), configMap)) .withAnnotations(annotations(configMap)) .build()) .withSpec(new PodSpecBuilder() .withRestartPolicy(RESTART_POLICY_NEVER) .withContainers(container(config.getRoadName(), args, configMap, truckParkName)) .build()) .build(); } @Autowired  LanderPodFactory(
      Supplier<ConfigMap> configMapSupplier,
      PodNameFactory podNameFactory,
      @Value("${ENVIRONMENT}") String environment); Pod newInstance(LanderConfiguration config, List<String> args); static final String DOCKER_IMAGE; }