diff --git a/src/main/java/org/tkit/onecx/permission/bff/rs/controllers/AssignmentRestController.java b/src/main/java/org/tkit/onecx/permission/bff/rs/controllers/AssignmentRestController.java index cf2a294..52ec553 100644 --- a/src/main/java/org/tkit/onecx/permission/bff/rs/controllers/AssignmentRestController.java +++ b/src/main/java/org/tkit/onecx/permission/bff/rs/controllers/AssignmentRestController.java @@ -14,6 +14,7 @@ import org.jboss.resteasy.reactive.server.ServerExceptionMapper; import org.tkit.onecx.permission.bff.rs.mappers.AssignmentMapper; import org.tkit.onecx.permission.bff.rs.mappers.ExceptionMapper; +import org.tkit.onecx.permission.bff.rs.mappers.UserMapper; import org.tkit.quarkus.log.cdi.LogService; import gen.org.tkit.onecx.iam.client.api.AdminUserControllerApi; @@ -24,6 +25,7 @@ import gen.org.tkit.onecx.permission.client.api.AssignmentInternalApi; import gen.org.tkit.onecx.permission.client.model.Assignment; import gen.org.tkit.onecx.permission.client.model.AssignmentPageResult; +import gen.org.tkit.onecx.permission.client.model.UserAssignmentPageResult; import gen.org.tkit.onecx.permission.exim.client.api.PermissionExportImportApi; import gen.org.tkit.onecx.permission.exim.client.model.AssignmentSnapshot; @@ -47,6 +49,9 @@ public class AssignmentRestController implements AssignmentApiService { @Inject AssignmentMapper mapper; + @Inject + UserMapper userMapper; + @Inject ExceptionMapper exceptionMapper; @@ -150,7 +155,7 @@ public Response searchAssignments(AssignmentSearchCriteriaDTO assignmentSearchCr @Override public Response searchUserAssignments(AssignmentUserSearchCriteriaDTO assignmentUserSearchCriteriaDTO) { - AssignmentPageResult pageResult; + UserAssignmentPageResult pageResult; List roles = List.of(); try (Response response = iamClient.getUserRoles(assignmentUserSearchCriteriaDTO.getUserId())) { UserRolesResponseIamV1 roleResponse = response.readEntity(UserRolesResponseIamV1.class); @@ -163,8 +168,8 @@ public Response searchUserAssignments(AssignmentUserSearchCriteriaDTO assignment } try (Response assignmentResponse = assignmentClient .searchAssignmentsByRoles(mapper.map(assignmentUserSearchCriteriaDTO, roles))) { - pageResult = assignmentResponse.readEntity(AssignmentPageResult.class); - return Response.status(assignmentResponse.getStatus()).entity(mapper.map(pageResult)).build(); + pageResult = assignmentResponse.readEntity(UserAssignmentPageResult.class); + return Response.status(assignmentResponse.getStatus()).entity(userMapper.map(pageResult)).build(); } } diff --git a/src/main/openapi/openapi-bff.yaml b/src/main/openapi/openapi-bff.yaml index 953383f..bc8eb69 100644 --- a/src/main/openapi/openapi-bff.yaml +++ b/src/main/openapi/openapi-bff.yaml @@ -374,7 +374,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/AssignmentPageResult' + $ref: '#/components/schemas/UserAssignmentPageResult' 400: description: Bad request content: diff --git a/src/test/java/org/tkit/onecx/permission/rs/AssignmentRestControllerTest.java b/src/test/java/org/tkit/onecx/permission/rs/AssignmentRestControllerTest.java index 0359002..1909141 100644 --- a/src/test/java/org/tkit/onecx/permission/rs/AssignmentRestControllerTest.java +++ b/src/test/java/org/tkit/onecx/permission/rs/AssignmentRestControllerTest.java @@ -478,9 +478,9 @@ void searchUsersAssignmentsByCriteriaTest() { AssignmentRolesSearchCriteria criteria = new AssignmentRolesSearchCriteria(); criteria.pageNumber(1).pageSize(1).roles(List.of("role1")); - AssignmentPageResult pageResult = new AssignmentPageResult(); - Assignment assignment = new Assignment(); - assignment.permissionId("permission1").roleId("role1"); + UserAssignmentPageResult pageResult = new UserAssignmentPageResult(); + UserAssignment assignment = new UserAssignment(); + assignment.productName("product1").roleName("role1"); pageResult.stream(List.of(assignment)).size(1).number(1).totalElements(1L).totalPages(1L); // create mock rest endpoint @@ -504,13 +504,13 @@ void searchUsersAssignmentsByCriteriaTest() { .then() .statusCode(Response.Status.OK.getStatusCode()) .contentType(APPLICATION_JSON) - .extract().as(AssignmentPageResultDTO.class); + .extract().as(UserAssignmentPageResultDTO.class); Assertions.assertNotNull(output); Assertions.assertEquals(pageResult.getSize(), output.getSize()); Assertions.assertEquals(pageResult.getStream().size(), output.getStream().size()); - Assertions.assertEquals(pageResult.getStream().get(0).getRoleId(), output.getStream().get(0).getRoleId()); - Assertions.assertEquals(pageResult.getStream().get(0).getPermissionId(), output.getStream().get(0).getPermissionId()); + Assertions.assertEquals(pageResult.getStream().get(0).getRoleName(), output.getStream().get(0).getRoleName()); + Assertions.assertEquals(pageResult.getStream().get(0).getProductName(), output.getStream().get(0).getProductName()); mockServerClient.clear(MOCKID); mockServerClient.clear("MOCK_IAM_KC");