diff options
author | Fiete Ostkamp <fiete.ostkamp@telekom.de> | 2024-10-23 07:34:42 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2024-10-23 07:34:42 +0000 |
commit | 21e98a42bc6255ddf5a78794b2f3e830634665c0 (patch) | |
tree | 8dc2891709ea9997dcb5a87e4115cbe752681ebd /app/src | |
parent | f5d22b1a6c7083530431b78f112bc65c2619c9be (diff) | |
parent | cd116feda5f14db413ae5eba57d14d55202a0de5 (diff) |
Diffstat (limited to 'app/src')
17 files changed, 129 insertions, 124 deletions
diff --git a/app/src/test/java/org/onap/portalng/bff/BaseIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/BaseIntegrationTest.java index 528568d..a69516c 100644 --- a/app/src/test/java/org/onap/portalng/bff/BaseIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/BaseIntegrationTest.java @@ -36,7 +36,7 @@ import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.UUID; -import org.apache.http.client.utils.URIBuilder; +import org.apache.hc.core5.net.URIBuilder; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.onap.portalng.bff.config.BffConfig; @@ -86,8 +86,7 @@ public abstract class BaseIntegrationTest { WireMock.stubFor( WireMock.get( - WireMock.urlMatching( - String.format("/realms/%s/protocol/openid-connect/certs", realm))) + WireMock.urlMatching("/realms/%s/protocol/openid-connect/certs".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", JWKSet.MIME_TYPE) @@ -98,8 +97,7 @@ public abstract class BaseIntegrationTest { WireMock.stubFor( WireMock.post( - WireMock.urlMatching( - String.format("/realms/%s/protocol/openid-connect/token", realm))) + WireMock.urlMatching("/realms/%s/protocol/openid-connect/token".formatted(realm))) .withBasicAuth("test", "test") .withRequestBody(WireMock.containing("grant_type=client_credentials")) .willReturn( diff --git a/app/src/test/java/org/onap/portalng/bff/TokenGenerator.java b/app/src/test/java/org/onap/portalng/bff/TokenGenerator.java index 0c6aa89..5ffe3ef 100644 --- a/app/src/test/java/org/onap/portalng/bff/TokenGenerator.java +++ b/app/src/test/java/org/onap/portalng/bff/TokenGenerator.java @@ -116,7 +116,7 @@ public class TokenGenerator { @Builder.Default private final List<String> roles = Collections.emptyList(); public String issuer() { - return String.format("http://localhost:%d/realms/%s", port, realm); + return "http://localhost:%d/realms/%s".formatted(port, realm); } } } diff --git a/app/src/test/java/org/onap/portalng/bff/actions/ActionsMocks.java b/app/src/test/java/org/onap/portalng/bff/actions/ActionsMocks.java index 39fc3dc..7275737 100644 --- a/app/src/test/java/org/onap/portalng/bff/actions/ActionsMocks.java +++ b/app/src/test/java/org/onap/portalng/bff/actions/ActionsMocks.java @@ -25,7 +25,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.github.tomakehurst.wiremock.client.WireMock; import com.github.tomakehurst.wiremock.matching.EqualToPattern; import io.restassured.http.Header; -import org.apache.http.HttpHeaders; +import org.apache.hc.core5.http.HttpHeaders; import org.onap.portalng.bff.BaseIntegrationTest; import org.onap.portalng.bff.openapi.client_history.model.ActionResponseHistoryDto; import org.onap.portalng.bff.openapi.client_history.model.ActionsListResponseHistoryDto; diff --git a/app/src/test/java/org/onap/portalng/bff/preferences/CreatePreferencesIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/preferences/CreatePreferencesIntegrationTest.java index 3b16664..801ebb2 100644 --- a/app/src/test/java/org/onap/portalng/bff/preferences/CreatePreferencesIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/preferences/CreatePreferencesIntegrationTest.java @@ -38,25 +38,29 @@ class CreatePreferencesIntegrationTest extends PreferencesMocks { void thatPreferencesCanBeCreated() throws Exception { PreferencesPreferencesDto preferencesPreferencesDto = new PreferencesPreferencesDto(); preferencesPreferencesDto.setProperties( - "{\n" - + "\"properties\": {\n" - + "\"appStarter\": \"value1\",\n" - + "\"dashboard\": {\"key1:\" : \"value2\"}\n" - + "}\n" - + "\n" - + "}"); + """ + { + "properties": { + "appStarter": "value1", + "dashboard": {"key1:" : "value2"} + } + + }\ + """); mockCreatePreferences(preferencesPreferencesDto); final CreatePreferencesRequestApiDto request = new CreatePreferencesRequestApiDto() .properties( - "{\n" - + "\"properties\": {\n" - + "\"appStarter\": \"value1\",\n" - + "\"dashboard\": {\"key1:\" : \"value2\"}\n" - + "}\n" - + "\n" - + "}"); + """ + { + "properties": { + "appStarter": "value1", + "dashboard": {"key1:" : "value2"} + } + + }\ + """); final PreferencesResponseApiDto response = createPreferences(request); assertThat(response).isNotNull(); assertThat(response.getProperties()).isEqualTo(preferencesPreferencesDto.getProperties()); @@ -72,25 +76,29 @@ class CreatePreferencesIntegrationTest extends PreferencesMocks { final PreferencesPreferencesDto preferencesPreferencesDto = new PreferencesPreferencesDto() .properties( - "{\n" - + "\"properties\": {\n" - + "\"appStarter\": \"value1\",\n" - + "\"dashboard\": {\"key1:\" : \"value2\"}\n" - + "}\n" - + "\n" - + "}"); + """ + { + "properties": { + "appStarter": "value1", + "dashboard": {"key1:" : "value2"} + } + + }\ + """); mockCreatePreferencesError(preferencesPreferencesDto, problemPreferencesDto); CreatePreferencesRequestApiDto responseBody = new CreatePreferencesRequestApiDto() .properties( - "{\n" - + "\"properties\": {\n" - + "\"appStarter\": \"value1\",\n" - + "\"dashboard\": {\"key1:\" : \"value2\"}\n" - + "}\n" - + "\n" - + "}"); + """ + { + "properties": { + "appStarter": "value1", + "dashboard": {"key1:" : "value2"} + } + + }\ + """); final ProblemApiDto response = requestSpecification() .given() diff --git a/app/src/test/java/org/onap/portalng/bff/preferences/PreferencesMocks.java b/app/src/test/java/org/onap/portalng/bff/preferences/PreferencesMocks.java index 9c5be75..64486c8 100644 --- a/app/src/test/java/org/onap/portalng/bff/preferences/PreferencesMocks.java +++ b/app/src/test/java/org/onap/portalng/bff/preferences/PreferencesMocks.java @@ -28,7 +28,7 @@ import com.github.tomakehurst.wiremock.matching.EqualToPattern; import io.restassured.http.Header; import java.io.File; import java.io.IOException; -import org.apache.http.HttpHeaders; +import org.apache.hc.core5.http.HttpHeaders; import org.onap.portalng.bff.BaseIntegrationTest; import org.onap.portalng.bff.openapi.client_preferences.model.PreferencesPreferencesDto; import org.onap.portalng.bff.openapi.client_preferences.model.ProblemPreferencesDto; diff --git a/app/src/test/java/org/onap/portalng/bff/preferences/UpdatePreferencesIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/preferences/UpdatePreferencesIntegrationTest.java index 1cd9a70..0c19b7d 100644 --- a/app/src/test/java/org/onap/portalng/bff/preferences/UpdatePreferencesIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/preferences/UpdatePreferencesIntegrationTest.java @@ -38,25 +38,29 @@ class UpdatePreferencesIntegrationTest extends PreferencesMocks { void thatPreferencesCanBeUpdated() throws Exception { PreferencesPreferencesDto preferencesPreferencesDto = new PreferencesPreferencesDto(); preferencesPreferencesDto.setProperties( - "{\n" - + "\"properties\": {\n" - + "\"appStarter\": \"value1\",\n" - + "\"dashboard\": {\"key1:\" : \"value2\"}\n" - + "}\n" - + "\n" - + "}"); + """ + { + "properties": { + "appStarter": "value1", + "dashboard": {"key1:" : "value2"} + } + + }\ + """); mockUpdatePreferences(preferencesPreferencesDto); final CreatePreferencesRequestApiDto requestApiDto = new CreatePreferencesRequestApiDto() .properties( - "{\n" - + "\"properties\": {\n" - + "\"appStarter\": \"value1\",\n" - + "\"dashboard\": {\"key1:\" : \"value2\"}\n" - + "}\n" - + "\n" - + "}"); + """ + { + "properties": { + "appStarter": "value1", + "dashboard": {"key1:" : "value2"} + } + + }\ + """); final PreferencesResponseApiDto response = updatePreferences(requestApiDto); assertThat(response).isNotNull(); assertThat(response.getProperties()).isEqualTo(preferencesPreferencesDto.getProperties()); @@ -72,25 +76,29 @@ class UpdatePreferencesIntegrationTest extends PreferencesMocks { final PreferencesPreferencesDto preferencesPreferencesDto = new PreferencesPreferencesDto() .properties( - "{\n" - + "\"properties\": {\n" - + "\"appStarter\": \"value1\",\n" - + "\"dashboard\": {\"key1:\" : \"value2\"}\n" - + "}\n" - + "\n" - + "}"); + """ + { + "properties": { + "appStarter": "value1", + "dashboard": {"key1:" : "value2"} + } + + }\ + """); mockUpdatePreferencesError(preferencesPreferencesDto, problemPreferencesDto); CreatePreferencesRequestApiDto requestApiDto = new CreatePreferencesRequestApiDto() .properties( - "{\n" - + "\"properties\": {\n" - + "\"appStarter\": \"value1\",\n" - + "\"dashboard\": {\"key1:\" : \"value2\"}\n" - + "}\n" - + "\n" - + "}"); + """ + { + "properties": { + "appStarter": "value1", + "dashboard": {"key1:" : "value2"} + } + + }\ + """); final ProblemApiDto response = requestSpecification() .given() diff --git a/app/src/test/java/org/onap/portalng/bff/roles/ListRealmRolesIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/roles/ListRealmRolesIntegrationTest.java index d9fa9e0..8b0215b 100644 --- a/app/src/test/java/org/onap/portalng/bff/roles/ListRealmRolesIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/roles/ListRealmRolesIntegrationTest.java @@ -59,7 +59,7 @@ class ListRealmRolesIntegrationTest extends RolesMocks { new ErrorResponseKeycloakDto().errorMessage("Some error message"); WireMock.stubFor( - WireMock.get(WireMock.urlMatching(String.format("/admin/realms/%s/roles", realm))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/roles".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/roles/RolesMocks.java b/app/src/test/java/org/onap/portalng/bff/roles/RolesMocks.java index 2f61995..1422043 100644 --- a/app/src/test/java/org/onap/portalng/bff/roles/RolesMocks.java +++ b/app/src/test/java/org/onap/portalng/bff/roles/RolesMocks.java @@ -48,7 +48,7 @@ public class RolesMocks extends BaseIntegrationTest { protected void mockListRealmRoles(List<RoleKeycloakDto> roles) throws Exception { WireMock.stubFor( - WireMock.get(WireMock.urlMatching(String.format("/admin/realms/%s/roles", realm))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/roles".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/users/CreateUserIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/CreateUserIntegrationTest.java index 7928c3b..51c870d 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/CreateUserIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/CreateUserIntegrationTest.java @@ -220,19 +220,17 @@ class CreateUserIntegrationTest extends BaseIntegrationTest { protected void mockCreateUser(UserKeycloakDto request, String userId) throws Exception { WireMock.stubFor( - WireMock.post(WireMock.urlMatching(String.format("/admin/realms/%s/users", realm))) + WireMock.post(WireMock.urlMatching("/admin/realms/%s/users".formatted(realm))) .withRequestBody(WireMock.equalToJson(objectMapper.writeValueAsString(request))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) - .withHeader( - "location", String.format("/admin/realms/%s/users/%s", realm, userId)))); + .withHeader("location", "/admin/realms/%s/users/%s".formatted(realm, userId)))); } protected void mockGetUser(String userId, UserKeycloakDto response) throws Exception { WireMock.stubFor( - WireMock.get( - WireMock.urlMatching(String.format("/admin/realms/%s/users/%s", realm, userId))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/users/%s".formatted(realm, userId))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -243,7 +241,7 @@ class CreateUserIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.post( WireMock.urlMatching( - String.format("/admin/realms/%s/users/%s/role-mappings/realm", realm, userId))) + "/admin/realms/%s/users/%s/role-mappings/realm".formatted(realm, userId))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -258,8 +256,7 @@ class CreateUserIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.put( WireMock.urlMatching( - String.format( - "/admin/realms/%s/users/%s/execute-actions-email", realm, userId))) + "/admin/realms/%s/users/%s/execute-actions-email".formatted(realm, userId))) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(request))) .willReturn( WireMock.aResponse() @@ -273,7 +270,7 @@ class CreateUserIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/%s/role-mappings/realm", realm, userID))) + "/admin/realms/%s/users/%s/role-mappings/realm".formatted(realm, userID))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -285,8 +282,7 @@ class CreateUserIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.put( WireMock.urlMatching( - String.format( - "/admin/realms/%s/users/%s/execute-actions-email", realm, userId))) + "/admin/realms/%s/users/%s/execute-actions-email".formatted(realm, userId))) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(request))) .willReturn( WireMock.aResponse().withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE))); @@ -294,7 +290,7 @@ class CreateUserIntegrationTest extends BaseIntegrationTest { protected void mockListRealmRoles(List<RoleKeycloakDto> roles) throws Exception { WireMock.stubFor( - WireMock.get(WireMock.urlMatching(String.format("/admin/realms/%s/roles", realm))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/roles".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/users/DeleteUserIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/DeleteUserIntegrationTest.java index 15ba9ee..61cff96 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/DeleteUserIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/DeleteUserIntegrationTest.java @@ -37,7 +37,7 @@ class DeleteUserIntegrationTest extends BaseIntegrationTest { @Test void userCanBeDeleted() { WireMock.stubFor( - WireMock.delete(WireMock.urlMatching(String.format("/admin/realms/%s/users/1", realm))) + WireMock.delete(WireMock.urlMatching("/admin/realms/%s/users/1".formatted(realm))) .willReturn(WireMock.aResponse().withStatus(204))); requestSpecification() @@ -55,7 +55,7 @@ class DeleteUserIntegrationTest extends BaseIntegrationTest { new ErrorResponseKeycloakDto().errorMessage("Some error message"); WireMock.stubFor( - WireMock.delete(WireMock.urlMatching(String.format("/admin/realms/%s/users/1", realm))) + WireMock.delete(WireMock.urlMatching("/admin/realms/%s/users/1".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/users/GetUserDetailIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/GetUserDetailIntegrationTest.java index 337d3e3..c26ce2e 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/GetUserDetailIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/GetUserDetailIntegrationTest.java @@ -46,7 +46,7 @@ class GetUserDetailIntegrationTest extends BaseIntegrationTest { new UserKeycloakDto().id("1").username("user1").email("user1@localhost").enabled(true); WireMock.stubFor( - WireMock.get(WireMock.urlMatching(String.format("/admin/realms/%s/users/1", realm))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/users/1".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -85,7 +85,7 @@ class GetUserDetailIntegrationTest extends BaseIntegrationTest { new ErrorResponseKeycloakDto().errorMessage("Some error message"); WireMock.stubFor( - WireMock.get(WireMock.urlMatching(String.format("/admin/realms/%s/users/1", realm))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/users/1".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) @@ -117,7 +117,7 @@ class GetUserDetailIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/%s/role-mappings/realm", realm, userID))) + "/admin/realms/%s/users/%s/role-mappings/realm".formatted(realm, userID))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/users/ListAssignedRolesIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/ListAssignedRolesIntegrationTest.java index 901308c..d06fb3a 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/ListAssignedRolesIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/ListAssignedRolesIntegrationTest.java @@ -47,7 +47,7 @@ class ListAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -82,7 +82,7 @@ class ListAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/users/ListAvailableRolesIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/ListAvailableRolesIntegrationTest.java index 06d9b89..87579eb 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/ListAvailableRolesIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/ListAvailableRolesIntegrationTest.java @@ -47,7 +47,7 @@ class ListAvailableRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm/available", realm))) + "/admin/realms/%s/users/1/role-mappings/realm/available".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -82,7 +82,7 @@ class ListAvailableRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm/available", realm))) + "/admin/realms/%s/users/1/role-mappings/realm/available".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/users/ListUsersIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/ListUsersIntegrationTest.java index 2b5fdb4..93c83f4 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/ListUsersIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/ListUsersIntegrationTest.java @@ -162,7 +162,7 @@ class ListUsersIntegrationTest extends BaseIntegrationTest { protected void mockGetUserCount(Integer userCount) { WireMock.stubFor( - WireMock.get(WireMock.urlMatching(String.format("/admin/realms/%s/users/count", realm))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/users/count".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -174,7 +174,7 @@ class ListUsersIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users\\?first=%s&max=%s", realm, first, max))) + "/admin/realms/%s/users\\?first=%s&max=%s".formatted(realm, first, max))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -183,7 +183,7 @@ class ListUsersIntegrationTest extends BaseIntegrationTest { protected void mockListRealmRoles(List<RoleKeycloakDto> roles) throws Exception { WireMock.stubFor( - WireMock.get(WireMock.urlMatching(String.format("/admin/realms/%s/roles", realm))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/roles".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -194,8 +194,7 @@ class ListUsersIntegrationTest extends BaseIntegrationTest { throws Exception { WireMock.stubFor( WireMock.get( - WireMock.urlMatching( - String.format("/admin/realms/%s/roles/%s/users", realm, roleName))) + WireMock.urlMatching("/admin/realms/%s/roles/%s/users".formatted(realm, roleName))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -225,7 +224,7 @@ class ListUsersIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users\\?first=%s&max=%s", realm, first, max))) + "/admin/realms/%s/users\\?first=%s&max=%s".formatted(realm, first, max))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/users/UpdateAssignedRolesIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/UpdateAssignedRolesIntegrationTest.java index 9fcff3b..d3b3de3 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/UpdateAssignedRolesIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/UpdateAssignedRolesIntegrationTest.java @@ -54,7 +54,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm/available", realm))) + "/admin/realms/%s/users/1/role-mappings/realm/available".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .willReturn( @@ -65,7 +65,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .willReturn( @@ -76,7 +76,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.post( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(keycloakRolesToAdd))) @@ -86,7 +86,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs("rolesUpdated") .willReturn( @@ -137,7 +137,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm/available", realm))) + "/admin/realms/%s/users/1/role-mappings/realm/available".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .willReturn( @@ -148,7 +148,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .willReturn( @@ -159,7 +159,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.delete( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .withRequestBody( @@ -169,7 +169,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.post( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(keycloakRolesToAdd))) @@ -179,7 +179,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs("rolesUpdated") .willReturn( @@ -224,7 +224,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm/available", realm))) + "/admin/realms/%s/users/1/role-mappings/realm/available".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -233,7 +233,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.delete( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .withRequestBody( WireMock.equalTo(objectMapper.writeValueAsString(keycloakRolesToRemove))) .willReturn(WireMock.aResponse().withStatus(HttpStatus.NO_CONTENT.value()))); @@ -241,7 +241,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -285,7 +285,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm/available", realm))) + "/admin/realms/%s/users/1/role-mappings/realm/available".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .willReturn( @@ -296,7 +296,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .willReturn( @@ -307,7 +307,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.post( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(keycloakRolesToAdd))) @@ -317,7 +317,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs("rolesUpdated") .willReturn( @@ -370,7 +370,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm/available", realm))) + "/admin/realms/%s/users/1/role-mappings/realm/available".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .willReturn( @@ -381,7 +381,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .willReturn( @@ -393,7 +393,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.delete( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .withRequestBody( @@ -403,7 +403,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.post( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(keycloakRolesToAdd))) @@ -413,7 +413,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs("rolesUpdated") .willReturn( diff --git a/app/src/test/java/org/onap/portalng/bff/users/UpdateUserIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/UpdateUserIntegrationTest.java index 349909f..ee62a50 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/UpdateUserIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/UpdateUserIntegrationTest.java @@ -66,7 +66,7 @@ class UpdateUserIntegrationTest extends BaseIntegrationTest { final UserKeycloakDto keycloakRequest = new UserKeycloakDto().firstName("User1").enabled(false); WireMock.stubFor( - WireMock.put(WireMock.urlMatching(String.format("/admin/realms/%s/users/1", realm))) + WireMock.put(WireMock.urlMatching("/admin/realms/%s/users/1".formatted(realm))) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(keycloakRequest))) .willReturn( WireMock.aResponse() @@ -100,8 +100,7 @@ class UpdateUserIntegrationTest extends BaseIntegrationTest { protected void mockUpdateUser(UserKeycloakDto request, String userId) throws Exception { WireMock.stubFor( - WireMock.put( - WireMock.urlMatching(String.format("/admin/realms/%s/users/%s", realm, userId))) + WireMock.put(WireMock.urlMatching("/admin/realms/%s/users/%s".formatted(realm, userId))) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(request))) .willReturn( WireMock.aResponse().withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE))); @@ -109,8 +108,7 @@ class UpdateUserIntegrationTest extends BaseIntegrationTest { protected void mockGetUser(String userId, UserKeycloakDto response) throws Exception { WireMock.stubFor( - WireMock.get( - WireMock.urlMatching(String.format("/admin/realms/%s/users/%s", realm, userId))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/users/%s".formatted(realm, userId))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -122,7 +120,7 @@ class UpdateUserIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/%s/role-mappings/realm", realm, userID))) + "/admin/realms/%s/users/%s/role-mappings/realm".formatted(realm, userID))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/users/UpdateUserPasswordIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/UpdateUserPasswordIntegrationTest.java index 11634a8..b88ebff 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/UpdateUserPasswordIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/UpdateUserPasswordIntegrationTest.java @@ -43,8 +43,7 @@ class UpdateUserPasswordIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.put( - WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/reset-password", realm))) + WireMock.urlMatching("/admin/realms/%s/users/1/reset-password".formatted(realm))) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(keycloakRequest))) .willReturn(WireMock.aResponse().withStatus(204))); @@ -72,8 +71,7 @@ class UpdateUserPasswordIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.put( - WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/reset-password", realm))) + WireMock.urlMatching("/admin/realms/%s/users/1/reset-password".formatted(realm))) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(keycloakRequest))) .willReturn( WireMock.aResponse() |