@Test void licenseInformationIsAdded() { Artifact myArtifact = new ArtifactTestHarness.Builder() .setNPM("@angular/isTrue", "23_0_3") .setDeclared("MIT") .build(); Component component = toComponent(myArtifact); assertThat(component.getPurl()).isEqualTo("pkg:npm/%40angular%2Fistrue@23_0_3"); assertThat(component.getName()).isEqualTo("@angular/istrue"); assertThat(component.getVersion()).isEqualTo("23_0_3"); assertThat(component.getLicenseChoice().getLicenses()) .hasSize(1) .extracting("id").containsExactly("MIT"); }
public static Component toComponent(Artifact artifact) { if (artifact == null) { throw new IllegalArgumentException("Artifact must not be null"); } Component c = new Component(); c.setType(Component.Type.LIBRARY); setCoordinatesForComponent(artifact, c); LicenseInformation licenses = ArtifactLicenseUtils.getFinalLicenses(artifact); addLicensesToComponent(licenses.getLicenses(), c); addHashesToComponent(artifact, c); if (c.getPurl() == null) { createGenericPurl(c, artifact); } return c; }
ArtifactToComponentConverter { public static Component toComponent(Artifact artifact) { if (artifact == null) { throw new IllegalArgumentException("Artifact must not be null"); } Component c = new Component(); c.setType(Component.Type.LIBRARY); setCoordinatesForComponent(artifact, c); LicenseInformation licenses = ArtifactLicenseUtils.getFinalLicenses(artifact); addLicensesToComponent(licenses.getLicenses(), c); addHashesToComponent(artifact, c); if (c.getPurl() == null) { createGenericPurl(c, artifact); } return c; } }
ArtifactToComponentConverter { public static Component toComponent(Artifact artifact) { if (artifact == null) { throw new IllegalArgumentException("Artifact must not be null"); } Component c = new Component(); c.setType(Component.Type.LIBRARY); setCoordinatesForComponent(artifact, c); LicenseInformation licenses = ArtifactLicenseUtils.getFinalLicenses(artifact); addLicensesToComponent(licenses.getLicenses(), c); addHashesToComponent(artifact, c); if (c.getPurl() == null) { createGenericPurl(c, artifact); } return c; } private  ArtifactToComponentConverter(); }
ArtifactToComponentConverter { public static Component toComponent(Artifact artifact) { if (artifact == null) { throw new IllegalArgumentException("Artifact must not be null"); } Component c = new Component(); c.setType(Component.Type.LIBRARY); setCoordinatesForComponent(artifact, c); LicenseInformation licenses = ArtifactLicenseUtils.getFinalLicenses(artifact); addLicensesToComponent(licenses.getLicenses(), c); addHashesToComponent(artifact, c); if (c.getPurl() == null) { createGenericPurl(c, artifact); } return c; } private  ArtifactToComponentConverter(); static Component toComponent(Artifact artifact); }
ArtifactToComponentConverter { public static Component toComponent(Artifact artifact) { if (artifact == null) { throw new IllegalArgumentException("Artifact must not be null"); } Component c = new Component(); c.setType(Component.Type.LIBRARY); setCoordinatesForComponent(artifact, c); LicenseInformation licenses = ArtifactLicenseUtils.getFinalLicenses(artifact); addLicensesToComponent(licenses.getLicenses(), c); addHashesToComponent(artifact, c); if (c.getPurl() == null) { createGenericPurl(c, artifact); } return c; } private  ArtifactToComponentConverter(); static Component toComponent(Artifact artifact);  }