LicenseSupport { public static LicenseInformation fromSPDXExpression(String spdxExpressionString) { SpdxExpression spdxExpression = SpdxExpression.parse(spdxExpressionString); return fromSPDXExpression(spdxExpression); }  static LicenseInformation mapLicenses(Collection<String> licenses); static LicenseInformation mapLicenses(Collection<String> licenses, LicenseOperator operator); static LicenseInformation fromSPDXExpression(String spdxExpressionString); static LicenseInformation fromSPDXExpression(SpdxExpression spdxExpression); static LicenseInformation parseSpdxExpression(String expression); static LicenseInformation fromSpdxLicenseReferenceExpression(SpdxLicenseReferenceExpression spdxLicenseReferenceExpression); static LicenseInformation fromSpdxLicenseIdExpression(SpdxLicenseIdExpression spdxLicenseIdExpression); static LicenseInformation fromSPDXCompoundExpression(SpdxCompoundExpression spdxCompoundExpression, LicenseStatement license);  }
@Test public void testSPDXParsing() { final LicenseInformation licenseInformation = LicenseSupport.fromSPDXExpression("BSD AND APACHE-2.0"); assertThat(licenseInformation.getLicenses().size()) .isEqualTo(2); LicenseStatement licenseStatement = (LicenseStatement) licenseInformation; assertThat(licenseStatement.getOp()) .isEqualTo(LicenseOperator.AND); final LicenseInformation licenseInformation1 = LicenseSupport.fromSPDXExpression(licenseInformation.evaluate()); assertThat(licenseInformation) .isEqualTo(licenseInformation1); }
@Test public void testSPDXParsing2() { final LicenseInformation licenseInformation = LicenseSupport.fromSPDXExpression("BSD AND APACHE-2.0 OR MIT AND GPL-2.0+"); assertThat(licenseInformation.getLicenses().size()) .isEqualTo(4); LicenseStatement licenseStatement = (LicenseStatement) licenseInformation; assertThat(licenseStatement.getOp()) .isEqualTo(LicenseOperator.OR); final LicenseInformation licenseInformation1 = LicenseSupport.fromSPDXExpression(licenseInformation.evaluate()); assertThat(licenseInformation) .isEqualTo(licenseInformation1); }
@Test public void testSPDXParsing3() { final LicenseInformation licenseInformation = LicenseSupport.fromSPDXExpression("MIT OR BSD AND APACHE-2.0 OR GPL-2.0-or-later"); assertThat(licenseInformation.getLicenses().size()) .isEqualTo(4); LicenseStatement licenseStatement = (LicenseStatement) licenseInformation; assertThat(licenseStatement.getOp()) .isEqualTo(LicenseOperator.OR); final LicenseInformation licenseInformation1 = LicenseSupport.fromSPDXExpression(licenseInformation.evaluate()); assertThat(licenseInformation) .isEqualTo(licenseInformation1); }
@Test public void testSPDXParsing4() { final LicenseInformation licenseInformation = LicenseSupport.fromSPDXExpression("(MIT OR BSD) AND (APACHE-2.0 OR GPL-2.0-or-later)"); assertThat(licenseInformation.getLicenses().size()) .isEqualTo(4); LicenseStatement licenseStatement = (LicenseStatement) licenseInformation; assertThat(licenseStatement.getOp()) .isEqualTo(LicenseOperator.AND); final LicenseInformation licenseInformation1 = LicenseSupport.fromSPDXExpression(licenseInformation.evaluate()); assertThat(licenseInformation) .isEqualTo(licenseInformation1); }
@Test public void testSPDXParsing5() { final LicenseInformation licenseInformation = LicenseSupport.fromSPDXExpression("((MIT AND BSD) AND (EPL OR GPL AND APACHE-2.0))"); assertThat(licenseInformation.getLicenses().size()) .isEqualTo(5); assertThat(licenseInformation.evaluate()) .isEqualTo("( MIT AND BSD AND ( EPL OR ( GPL AND APACHE-2.0 ) ) )"); LicenseStatement licenseStatement = (LicenseStatement) licenseInformation; assertThat(licenseStatement.getOp()) .isEqualTo(LicenseOperator.AND); final LicenseInformation licenseInformation1 = LicenseSupport.fromSPDXExpression(licenseInformation.evaluate()); assertThat(licenseInformation) .isEqualTo(licenseInformation1); }
@Test public void testSPDXParsing6() { final LicenseInformation licenseInformation = LicenseSupport.fromSPDXExpression("BSD WITH Exception"); assertThat(licenseInformation.getLicenses().size()) .isEqualTo(1); assertThat(licenseInformation).isInstanceOf(WithLicense.class); assertThat(((WithLicense) licenseInformation).getLicenseId()).isEqualTo("BSD"); assertThat(((WithLicense) licenseInformation).getExceptionId()).isEqualTo("Exception"); }
@Test public void testSPDXParsing7() { final LicenseInformation licenseInformation = LicenseSupport.fromSPDXExpression("Apache-2.0"); assertThat(licenseInformation).isInstanceOf(License.class); assertThat(((License) licenseInformation).getId()).isEqualTo("Apache-2.0"); }