diff --git a/src/main/java/org/kohsuke/github/GHLicense.java b/src/main/java/org/kohsuke/github/GHLicense.java index 89cc08cf2a..be9bb48fd2 100644 --- a/src/main/java/org/kohsuke/github/GHLicense.java +++ b/src/main/java/org/kohsuke/github/GHLicense.java @@ -49,7 +49,7 @@ public class GHLicense extends GHObject { /** The name. */ // these fields are always present, even in the short form - protected String key, name; + protected String key, name, spdxId; /** The featured. */ // the rest is only after populated @@ -85,6 +85,15 @@ public String getName() { return name; } + /** + * Gets SPDX ID. + * + * @return the spdx id + */ + public String getSpdxId() { + return spdxId; + } + /** * Featured licenses are bold in the new repository drop-down. * diff --git a/src/test/java/org/kohsuke/github/GHLicenseTest.java b/src/test/java/org/kohsuke/github/GHLicenseTest.java index 0ae1730b0f..fc47e72068 100644 --- a/src/test/java/org/kohsuke/github/GHLicenseTest.java +++ b/src/test/java/org/kohsuke/github/GHLicenseTest.java @@ -83,6 +83,7 @@ public void getLicense() throws IOException { GHLicense license = gitHub.getLicense(key); assertThat(license, notNullValue()); assertThat("The name is correct", license.getName(), equalTo("MIT License")); + assertThat("The SPDX ID is correct", license.getSpdxId(), is(equalTo("MIT"))); assertThat("The HTML URL is correct", license.getHtmlUrl(), equalTo(new URL("http://choosealicense.com/licenses/mit/"))); @@ -111,6 +112,7 @@ public void checkRepositoryLicense() throws IOException { GHLicense license = repo.getLicense(); assertThat("The license is populated", license, notNullValue()); assertThat("The key is correct", license.getKey(), equalTo("mit")); + assertThat("The SPDX ID is correct", license.getSpdxId(), is(equalTo("MIT"))); assertThat("The name is correct", license.getName(), equalTo("MIT License")); assertThat("The URL is correct", license.getUrl(), @@ -129,6 +131,7 @@ public void checkRepositoryLicenseAtom() throws IOException { GHLicense license = repo.getLicense(); assertThat("The license is populated", license, notNullValue()); assertThat("The key is correct", license.getKey(), equalTo("mit")); + assertThat("The SPDX ID is correct", license.getSpdxId(), is(equalTo("MIT"))); assertThat("The name is correct", license.getName(), equalTo("MIT License")); assertThat("The URL is correct", license.getUrl(), @@ -148,6 +151,7 @@ public void checkRepositoryLicensePomes() throws IOException { GHLicense license = repo.getLicense(); assertThat("The license is populated", license, notNullValue()); assertThat("The key is correct", license.getKey(), equalTo("apache-2.0")); + assertThat("The SPDX ID is correct", license.getSpdxId(), is(equalTo("Apache-2.0"))); assertThat("The name is correct", license.getName(), equalTo("Apache License 2.0")); assertThat("The URL is correct", license.getUrl(), @@ -181,6 +185,7 @@ public void checkRepositoryFullLicense() throws IOException { GHLicense license = repo.getLicense(); assertThat("The license is populated", license, notNullValue()); assertThat("The key is correct", license.getKey(), equalTo("mit")); + assertThat("The SPDX ID is correct", license.getSpdxId(), is(equalTo("MIT"))); assertThat("The name is correct", license.getName(), equalTo("MIT License")); assertThat("The URL is correct", license.getUrl(),