### Question:
ConfigMapEnricher extends BaseEnricher { @Override public void create(PlatformMode platformMode, KubernetesListBuilder builder) { addAnnotations(builder); addConfigMapFromXmlConfigurations(builder); } ConfigMapEnricher(MavenEnricherContext enricherContext); @Override void create(PlatformMode platformMode, KubernetesListBuilder builder);  }### Answer:
@Test public void should_materialize_file_content_from_annotation() { new Expectations() { {{ context.getConfiguration(); result = new Configuration.Builder() .resource(new ResourceConfig()) .build(); }} }; final ConfigMapEnricher configMapEnricher = new ConfigMapEnricher(context); final KubernetesListBuilder builder = new KubernetesListBuilder(); builder.addToConfigMapItems(createBaseConfigMap()); configMapEnricher.create(PlatformMode.kubernetes, builder); final ConfigMap configMap = (ConfigMap) builder.buildFirstItem(); final Map<String, String> data = configMap.getData(); assertThat(data) .containsKey("test-application.properties"); final Map<String, String> annotations = configMap.getMetadata().getAnnotations(); assertThat(annotations) .isEmpty(); }
@Test public void should_materialize_file_content_from_annotation() throws Exception { new Expectations() { {{ context.resolvePath(file.toString()); result = file; }} }; final ConfigMap baseConfigMap = createAnnotationConfigMap("my-file", file); final KubernetesListBuilder builder = new KubernetesListBuilder() .addToConfigMapItems(baseConfigMap); new ConfigMapEnricher(context).create(PlatformMode.kubernetes, builder); final ConfigMap configMap = (ConfigMap) builder.buildFirstItem(); if (binary) { final Map<String, String> binaryData = configMap.getBinaryData(); assertThat(binaryData) .containsEntry("my-file", Base64.getEncoder().encodeToString(readFileContentAsBytes(file))); } else { final Map<String, String> data = configMap.getData(); assertThat(data) .containsEntry("my-file", readFileContentsAsString(file)); } final Map<String, String> annotations = configMap.getMetadata().getAnnotations(); assertThat(annotations) .isEmpty(); }
@Test public void should_materialize_file_content_from_xml() throws Exception { final io.fabric8.maven.core.config.ConfigMap baseConfigMap = createXmlConfigMap(file); final ResourceConfig config = new ResourceConfig.Builder() .withConfigMap(baseConfigMap) .build(); new Expectations() {{ context.getConfiguration(); result = new Configuration.Builder().resource(config).build(); context.resolvePath(file.toString()); result = file; }}; final KubernetesListBuilder builder = new KubernetesListBuilder(); new ConfigMapEnricher(context).create(PlatformMode.kubernetes, builder); final ConfigMap configMap = (ConfigMap) builder.buildFirstItem(); if (binary) { final Map<String, String> binaryData = configMap.getBinaryData(); assertThat(binaryData) .containsEntry(file.getFileName().toString(), Base64.getEncoder().encodeToString(readFileContentAsBytes(file))); } else { final Map<String, String> data = configMap.getData(); assertThat(data) .containsEntry(file.getFileName().toString(), readFileContentsAsString(file)); } }