CycloneDXGenerator extends AbstractGenerator { @Override public Map<String, IAttachable> produce(Collection<Artifact> artifacts) throws ExecutionException { LOG.debug("Created a cyclone-dx bill-of-material for {} artifacts", artifacts.size()); List<Component> components = toComponents(artifacts); Bom bom = new Bom(); bom.setComponents(components); BomGenerator gen = BomGeneratorFactory.create(CycloneDxSchema.Version.VERSION_11, bom); File targetFile = createTargetFile(); doGenerate(gen, targetFile); LOG.debug("Bill-of-material created in {}", targetFile); return Collections.singletonMap("cyclonedx-bom", new Attachable("xml", "cyclonedx-bom", targetFile)); }  @Override Map<String, IAttachable> produce(Collection<Artifact> artifacts);  }
@Test void simpleReport() throws Exception { List<Artifact> artifacts = readIQDataToArtifacts("ReportWithTwoComponents.json"); Map<String, IAttachable> map = generator.produce(artifacts); assertThat(map).hasSize(1); IAttachable attachable = map.get("cyclonedx-bom"); assertThat(attachable.getClassifier()).isEqualTo("cyclonedx-bom"); assertThat(attachable.getType()).isEqualTo("xml"); File bomFile = attachable.getFile(); Bom bom = new BomParser().parse(bomFile); assertThat(bom.getComponents()).hasSize(2); }
@Test void reportWithMavenAndFiles() throws Exception { List<Artifact> artifacts = readIQDataToArtifacts("ReportWithMavenAndFiles.json"); Map<String, IAttachable> map = generator.produce(artifacts); IAttachable attachable = map.get("cyclonedx-bom"); File bomFile = attachable.getFile(); Bom bom = new BomParser().parse(bomFile); assertThat(bom.getComponents()).hasSize(30); }