EnricherManager { public void enrich(PlatformMode platformMode, KubernetesListBuilder builder) { enrich(platformMode, defaultEnricherConfig, builder); } EnricherManager(ResourceConfig resourceConfig, EnricherContext enricherContext, Optional<List<String>> extraClasspathElements); void createDefaultResources(PlatformMode platformMode, final KubernetesListBuilder builder); void createDefaultResources(PlatformMode platformMode, ProcessorConfig enricherConfig, final KubernetesListBuilder builder); void enrich(PlatformMode platformMode, KubernetesListBuilder builder); void enrich(PlatformMode platformMode, final ProcessorConfig enricherConfig, final KubernetesListBuilder builder);  }
@Test public void enrichEmpty() { new Expectations() {{ context.getConfiguration(); result = new Configuration.Builder() .processorConfig(ProcessorConfig.EMPTY) .build(); }}; EnricherManager manager = new EnricherManager(null, context, Optional.empty()); KubernetesListBuilder builder = new KubernetesListBuilder(); manager.enrich(PlatformMode.kubernetes, builder); assertEquals(0,builder.build().getItems().size(),1); }
@Test public void enrichSimple() { new Expectations() {{ context.getConfiguration(); result = new Configuration.Builder() .processorConfig(new ProcessorConfig(Arrays.asList("fmp-metadata", "fmp-project-label"),null,new HashMap<>())) .build(); }}; EnricherManager manager = new EnricherManager(null, context, Optional.empty()); KubernetesListBuilder builder = new KubernetesListBuilder(); builder.addToItems(new ReplicaSetBuilder() .withNewSpec() .withNewTemplate() .withNewSpec() .addNewContainer() .withName("test") .withImage("busybox") .endContainer() .endSpec() .endTemplate() .endSpec() .build()); manager.enrich(PlatformMode.kubernetes, builder); KubernetesList list = builder.build(); assertEquals(1, list.getItems().size()); ReplicaSet pod = (ReplicaSet) list.getItems().get(0); ObjectMeta metadata = pod.getMetadata(); assertNotNull(metadata); Map<String, String> labels = metadata.getLabels(); assertNotNull(labels); assertEquals("fabric8", labels.get("provider")); }