Skip to content

Commit

Permalink
test identifier in licence
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin-confino committed May 10, 2024
1 parent 8afb5c6 commit ce60d53
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ConfigExtensionsTest extends JaxRsDataObjectScannerTestBase {
private static final String CONTACT_NAME = "mp.openapi.extensions.smallrye.info.contact.name";
private static final String CONTACT_URL = "mp.openapi.extensions.smallrye.info.contact.url";
private static final String LICENSE_NAME = "mp.openapi.extensions.smallrye.info.license.name";
private static final String LICENSE_IDENTIFIER = "mp.openapi.extensions.smallrye.info.license.identifier";
private static final String LICENSE_URL = "mp.openapi.extensions.smallrye.info.license.url";

@Test
Expand Down Expand Up @@ -67,8 +68,9 @@ void testSettingJustContactEmail() throws IOException, JSONException {
}

@Test
void testSettingJustLicenseName() throws IOException, JSONException {
void testSettingJustLicenseNameAndIdentifier() throws IOException, JSONException {
System.setProperty(LICENSE_NAME, "Apache License 2.0");
System.setProperty(LICENSE_IDENTIFIER, "Apache-2.0");
Config config = ConfigProvider.getConfig();
OpenApiConfig openApiConfig = OpenApiConfig.fromConfig(config);
try {
Expand All @@ -80,6 +82,7 @@ void testSettingJustLicenseName() throws IOException, JSONException {

} finally {
System.clearProperty(LICENSE_NAME);
System.clearProperty(LICENSE_IDENTIFIER);
}
}

Expand All @@ -95,6 +98,7 @@ void testSettingAllInfo() throws IOException, JSONException {
System.setProperty(CONTACT_URL, "https://www.phillip-kruger.com");
System.setProperty(LICENSE_NAME, "Apache License 2.0");
System.setProperty(LICENSE_URL, "https://choosealicense.com/licenses/apache-2.0/");
//Licence Identifier excluded for being exclusive with URL

Config config = ConfigProvider.getConfig();
OpenApiConfig openApiConfig = OpenApiConfig.fromConfig(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"title" : "Generated API",
"version" : "1.0",
"license" : {
"name" : "Apache License 2.0"
"name" : "Apache License 2.0",
"identifier" : "Apache-2.0"
}
},
"paths" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ void basic_info(MavenExecutionResult result) throws IOException {
assertEquals(properties.get("infoContactUrl"), schema.getInfo().getContact().getUrl());
assertEquals(properties.get("infoContactEmail"), schema.getInfo().getContact().getEmail());
assertEquals(properties.get("infoLicenseName"), schema.getInfo().getLicense().getName());
assertEquals(properties.get("infoLicenseUrl"),
schema.getInfo().getLicense().getUrl());
assertEquals(properties.get("infoLicenseIdentifier"),
schema.getInfo().getLicense().getIdentifier());
//The URL is not tested here due to being exclusive with Identifier
assertEquals(properties.get("infoVersion"), schema.getInfo().getVersion());

List<String> servers = schema.getServers().stream().map(Server::getUrl).collect(Collectors.toList());
Expand Down

0 comments on commit ce60d53

Please sign in to comment.