@Test public void catagorizeApache11OnlyByURL() { License cl = new License(); cl.setUrl("http://www.apache.org/licenses/LICENSE-1.1"); Assert.assertFalse(result.isValid(cl)); Assert.assertFalse(result.isInvalid(cl)); Assert.assertTrue(result.isWarning(cl)); Assert.assertFalse(result.isUnknown(cl)); }
@Test public void catagorizeGPL20() { License cl = new License(); cl.setName("GNU General Public License, version 3"); cl.setUrl("http://www.gnu.org/licenses/gpl-3.0.txt"); Assert.assertFalse(result.isValid(cl)); Assert.assertTrue(result.isInvalid(cl)); Assert.assertFalse(result.isWarning(cl)); Assert.assertFalse(result.isUnknown(cl)); }
@Test public void categorizeApache20WithWrongURL() { License cl = new License(); cl.setName("The Apache Software License, Version 2.0"); cl.setUrl("/LICENSE.txt"); Assert.assertTrue(result.isValid(cl)); Assert.assertFalse(result.isInvalid(cl)); Assert.assertFalse(result.isWarning(cl)); Assert.assertFalse(result.isUnknown(cl)); }
@Test public void catagorizeApache20() { License cl = new License(); cl.setName("Apache Software License, Version 2.0"); cl.setUrl("http://apache.org/licenses/LICENSE-2.0.txt"); Assert.assertTrue(result.isValid(cl)); Assert.assertFalse(result.isInvalid(cl)); Assert.assertFalse(result.isWarning(cl)); Assert.assertFalse(result.isUnknown(cl)); }
@Test public void catagorizeCPLV10() { License cl = new License(); cl.setName("Common Public License Version 1.0"); cl.setUrl("http://www.opensource.org/licenses/cpl1.0.txt"); Assert.assertTrue(result.isValid(cl)); Assert.assertFalse(result.isInvalid(cl)); Assert.assertFalse(result.isWarning(cl)); Assert.assertFalse(result.isUnknown(cl)); }
@Test public void catagorizeUnknown() { License cl = new License(); cl.setName("Unknown License"); cl.setUrl(null); Assert.assertFalse(result.isValid(cl)); Assert.assertFalse(result.isInvalid(cl)); Assert.assertFalse(result.isWarning(cl)); Assert.assertTrue(result.isUnknown(cl)); }
// TODO: download custom licenses content private ExtensionLicense getExtensionLicense(License license) { if (license.getName() == null) { return new ExtensionLicense("noname", null); } ExtensionLicense extensionLicense = this.licenseManager.getLicense(license.getName()); return extensionLicense != null ? extensionLicense : new ExtensionLicense(license.getName(), null); }
public GemSpecification createSpecification(final MavenArtifact artifact) { final GemSpecification result = new GemSpecification(); // this is fix result.setPlatform(this.PLATFORM_JAVA); // the must ones result.setName( createGemName( artifact.getCoordinates().getGroupId(), artifact.getCoordinates().getArtifactId(), artifact.getCoordinates().getVersion())); result.setVersion(new GemVersion(createGemVersion(artifact.getCoordinates().getVersion()))); // dependencies if (artifact.getPom().getDependencies().size() > 0) { for (final Dependency dependency : artifact.getPom().getDependencies()) { if (!dependency.isOptional()) { result.getDependencies().add(convertDependency(artifact, dependency)); } } } // and other stuff "nice to have" result.setDate(new Date()); // now result.setDescription( sanitizeStringValue( artifact.getPom().getDescription() != null ? artifact.getPom().getDescription() : artifact.getPom().getName())); result.setSummary(sanitizeStringValue(artifact.getPom().getName())); result.setHomepage(sanitizeStringValue(artifact.getPom().getUrl())); if (artifact.getPom().getLicenses().size() > 0) { for (final License license : artifact.getPom().getLicenses()) { result .getLicenses() .add(sanitizeStringValue(license.getName() + " (" + license.getUrl() + ")")); } } if (artifact.getPom().getDevelopers().size() > 0) { for (final Developer developer : artifact.getPom().getDevelopers()) { result .getAuthors() .add(sanitizeStringValue(developer.getName() + " (" + developer.getEmail() + ")")); } } // by default, we pack into lib/ inside gem (where is the jar and the // stub ruby) result.getRequire_paths().add("lib"); return result; }
/** * Adds information about references licenses. * * @param pomDescriptor The descriptor for the current POM. * @param model The Maven Model. * @param store The database. */ private void addLicenses(MavenPomDescriptor pomDescriptor, Model model, Store store) { List<License> licenses = model.getLicenses(); for (License license : licenses) { MavenLicenseDescriptor licenseDescriptor = store.create(MavenLicenseDescriptor.class); licenseDescriptor.setUrl(license.getUrl()); licenseDescriptor.setComments(license.getComments()); licenseDescriptor.setName(license.getName()); licenseDescriptor.setDistribution(license.getDistribution()); pomDescriptor.getLicenses().add(licenseDescriptor); } }
private String createDefaultLicenseText() { String toRet = "License terms:\n"; List licenses = project.getLicenses(); if (licenses != null && licenses.size() > 0) { Iterator lic = licenses.iterator(); while (lic.hasNext()) { License ll = (License) lic.next(); if (ll.getName() != null) { toRet = toRet + ll.getName() + " - "; } if (ll.getUrl() != null) { toRet = toRet + ll.getUrl(); } if (lic.hasNext()) { toRet = toRet + ",\n"; } } } else { toRet = toRet + "Unknown"; } return toRet; }
@Test public void catagorizeArtifactValidWithTwoLicensesNameAndURL() { License cl1 = new License(); cl1.setName("Test License"); cl1.setUrl(null); License cl2 = new License(); cl2.setName(null); cl2.setUrl("http://www.testlicense.org/License-1.0.txt"); ArrayList<License> licenses = new ArrayList<License>(); licenses.add(cl1); licenses.add(cl2); Assert.assertTrue(result.isValid(licenses)); Assert.assertFalse(result.isInvalid(licenses)); Assert.assertFalse(result.isWarning(licenses)); Assert.assertFalse(result.isUnknown(licenses)); }
@Test public void catagorizeArtifactValidWithTwoLicensesNames() { License cl1 = new License(); cl1.setName("Test License"); cl1.setUrl(null); License cl2 = new License(); cl2.setName("Test License, Version 1.0"); cl2.setUrl(null); ArrayList<License> licenses = new ArrayList<License>(); licenses.add(cl1); licenses.add(cl2); Assert.assertTrue(result.isValid(licenses)); Assert.assertFalse(result.isInvalid(licenses)); Assert.assertFalse(result.isWarning(licenses)); Assert.assertFalse(result.isUnknown(licenses)); }
@Test public void catagorizeArtifactWithTwoLicensesFromNoCategory() { // whereas the second one is in the "Valid" category License cl1 = new License(); cl1.setName("Unknown License V1.0"); cl1.setUrl(null); License cl2 = new License(); cl2.setName(null); cl2.setUrl("http://www.the-unknown-license.com/license-v.1.0.html"); ArrayList<License> licenses = new ArrayList<License>(); licenses.add(cl1); licenses.add(cl2); Assert.assertFalse(result.isValid(licenses)); Assert.assertFalse(result.isInvalid(licenses)); Assert.assertFalse(result.isWarning(licenses)); Assert.assertTrue(result.isUnknown(licenses)); }
@Test public void catagorizeArtifactWithTwoLicensesFromTwoCategories() { // The first license is in the "Invalid" category // whereas the second one is in the "Valid" category License cl1 = new License(); cl1.setName("GNU General Public License, version 2"); cl1.setUrl(null); License cl2 = new License(); cl2.setName(null); cl2.setUrl("http://www.testlicense.org/License-1.0.txt"); ArrayList<License> licenses = new ArrayList<License>(); licenses.add(cl1); licenses.add(cl2); Assert.assertFalse(result.isValid(licenses)); Assert.assertFalse(result.isInvalid(licenses)); Assert.assertFalse(result.isWarning(licenses)); Assert.assertTrue(result.isUnknown(licenses)); }