diff --git a/src/main/docs/openapi/api-selfcare-user-docs.json b/src/main/docs/openapi/api-selfcare-user-docs.json index 0aceba1c..572c8f4d 100644 --- a/src/main/docs/openapi/api-selfcare-user-docs.json +++ b/src/main/docs/openapi/api-selfcare-user-docs.json @@ -1,7 +1,7 @@ { "openapi" : "3.0.3", "info" : { - "title" : "user-ms API", + "title" : "User API", "version" : "1.0.0" }, "servers" : [ { @@ -11,17 +11,34 @@ "url" : "http://0.0.0.0:8080", "description" : "Auto generated value" } ], + "tags" : [ { + "name" : "Events" + }, { + "name" : "Institution" + }, { + "name" : "User" + }, { + "name" : "external-pnpg" + }, { + "name" : "external-v2" + }, { + "name" : "internal-v1" + }, { + "name" : "support" + }, { + "name" : "support-pnpg" + } ], "paths" : { - "/authorize/{institutionId}" : { + "/authorize" : { "get" : { "tags" : [ "User Permission Controller" ], "summary" : "Get permission for a user in an institution", + "description" : "Determines if the authenticated user possesses a specific permission within the given institution and product context.", + "operationId" : "getPermission", "parameters" : [ { "name" : "institutionId", - "in" : "path", - "required" : true, + "in" : "query", "schema" : { - "minLength" : 1, "type" : "string" } }, { @@ -49,11 +66,53 @@ } } }, + "401" : { + "description" : "Not Authorized" + }, "403" : { "description" : "Not Allowed" + } + }, + "security" : [ { + "SecurityScheme" : [ ] + } ] + } + }, + "/events/sc-users" : { + "post" : { + "tags" : [ "Events" ], + "summary" : "Resend all user events based on institutionId, userId, and fromDate", + "description" : "Resends all events for a specific user within a given institution starting from the specified date and time. This endpoint allows administrators to trigger the reprocessing or notification of user-related events that occurred after the provided `fromDate`.", + "operationId" : "sendUsersEvents", + "parameters" : [ { + "name" : "fromDate", + "in" : "query", + "required" : true, + "schema" : { + "$ref" : "#/components/schemas/OffsetDateTime" + } + }, { + "name" : "institutionId", + "in" : "query", + "schema" : { + "type" : "string" + } + }, { + "name" : "userId", + "in" : "query", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "201" : { + "description" : "Created" }, "401" : { "description" : "Not Authorized" + }, + "403" : { + "description" : "Not Allowed" } }, "security" : [ { @@ -61,10 +120,54 @@ } ] } }, - "/institutions/{institutionId}/products/{productId}/createdAt" : { + "/institutions/{institutionId}" : { "put" : { - "tags" : [ "Institution Controller" ], - "summary" : "The API updates user's onboarded product with createdAt passed in input", + "tags" : [ "Institution" ], + "summary" : "Update institution's description across all userInstitution records", + "description" : "Modifies the description field in all occurrences of `userInstitution` entities associated with a given institutionId. This ensures that the institution's descriptive information is consistently updated across all related user records.", + "operationId" : "updateInstitutionDescription", + "parameters" : [ { + "name" : "institutionId", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/UpdateDescriptionDto" + } + } + } + }, + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { } + } + }, + "401" : { + "description" : "Not Authorized" + }, + "403" : { + "description" : "Not Allowed" + } + }, + "security" : [ { + "SecurityScheme" : [ ] + } ] + } + }, + "/institutions/{institutionId}/products/{productId}/created-at" : { + "put" : { + "tags" : [ "Institution" ], + "summary" : "Update user's onboarded product creation date", + "description" : "Updates the `createdAt` timestamp for a user's onboarded product based on the provided institutionId, productId, and list of userIds. This is useful for tracking when a user was onboarded to a specific product within an institution.", + "operationId" : "updateUserProductCreatedAt", "parameters" : [ { "name" : "institutionId", "in" : "path", @@ -84,7 +187,7 @@ "in" : "query", "required" : true, "schema" : { - "$ref" : "#/components/schemas/LocalDateTime" + "$ref" : "#/components/schemas/OffsetDateTime" } }, { "name" : "userIds", @@ -104,11 +207,11 @@ "application/json" : { } } }, - "403" : { - "description" : "Not Allowed" - }, "401" : { "description" : "Not Authorized" + }, + "403" : { + "description" : "Not Allowed" } }, "security" : [ { @@ -118,8 +221,10 @@ }, "/institutions/{institutionId}/user-institutions" : { "get" : { - "tags" : [ "Institution Controller" ], - "summary" : "The API retrieves users with optional filters in input as query params", + "tags" : [ "Institution" ], + "summary" : "Retrieve users with optional filters", + "description" : "Fetches a list of users associated with a specific institution, applying optional filters such as userId, roles, states, products, and productRoles. This allows for flexible querying based on various user attributes and statuses.", + "operationId" : "retrieveUserInstitutions", "parameters" : [ { "name" : "institutionId", "in" : "path", @@ -184,11 +289,11 @@ } } }, - "403" : { - "description" : "Not Allowed" - }, "401" : { "description" : "Not Authorized" + }, + "403" : { + "description" : "Not Allowed" } }, "security" : [ { @@ -198,8 +303,10 @@ }, "/institutions/{institutionId}/users" : { "get" : { - "tags" : [ "Institution Controller" ], - "summary" : "The API retrieves user's info including details of roles on products", + "tags" : [ "support", "support-pnpg", "Institution" ], + "summary" : "Retrieve user's information including product role details", + "description" : "Fetches detailed information about users associated with a specific institution, including their roles on various products. This endpoint is useful for administrators to obtain comprehensive user-role mappings within an institution.", + "operationId" : "getInstitutionUsersUsingGET", "parameters" : [ { "name" : "institutionId", "in" : "path", @@ -222,11 +329,45 @@ } } }, - "403" : { - "description" : "Not Allowed" + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } }, "401" : { - "description" : "Not Authorized" + "description" : "Not Authorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "403" : { + "description" : "Forbidden", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } } }, "security" : [ { @@ -236,8 +377,10 @@ }, "/users" : { "get" : { - "tags" : [ "User Controller" ], - "summary" : "The API retrieves paged users with optional filters in input as query params", + "tags" : [ "User" ], + "summary" : "Retrieve paged users with optional query filters", + "description" : "The API retrieves paged users with optional filters in input as query params", + "operationId" : "retrievePaginatedAndFilteredUser", "parameters" : [ { "name" : "institutionId", "in" : "query", @@ -276,7 +419,7 @@ "schema" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/PartyRole" + "type" : "string" } } }, { @@ -317,11 +460,11 @@ } } }, - "403" : { - "description" : "Not Allowed" - }, "401" : { "description" : "Not Authorized" + }, + "403" : { + "description" : "Not Allowed" } }, "security" : [ { @@ -329,8 +472,10 @@ } ] }, "post" : { - "tags" : [ "User Controller" ], - "summary" : "The createOrUpdateByFiscalCode function is used to create a new user or update an existing one.", + "tags" : [ "User" ], + "summary" : "Create or update a user by fiscal code", + "description" : "The createOrUpdateByFiscalCode function is used to create a new user or update an existing one.", + "operationId" : "createOrUpdateByFiscalCode", "requestBody" : { "content" : { "application/json" : { @@ -342,7 +487,7 @@ }, "responses" : { "200" : { - "description" : "OK", + "description" : "User created or updated!", "content" : { "application/json" : { "schema" : { @@ -351,11 +496,14 @@ } } }, - "403" : { - "description" : "Not Allowed" + "201" : { + "description" : "User already has the active role for that product!" }, "401" : { "description" : "Not Authorized" + }, + "403" : { + "description" : "Not Allowed" } }, "security" : [ { @@ -365,8 +513,10 @@ }, "/users/emails" : { "get" : { - "tags" : [ "User Controller" ], - "summary" : "The API retrieves Users' emails using institution id and product id", + "tags" : [ "User" ], + "summary" : "Retrieve users' emails by institution ID and product ID", + "description" : "The API retrieves Users' emails using institution id and product id", + "operationId" : "getUsersEmailByInstitutionAndProduct", "parameters" : [ { "name" : "institutionId", "in" : "query", @@ -396,11 +546,11 @@ } } }, - "403" : { - "description" : "Not Allowed" - }, "401" : { "description" : "Not Authorized" + }, + "403" : { + "description" : "Not Allowed" } }, "security" : [ { @@ -410,8 +560,10 @@ }, "/users/ids" : { "get" : { - "tags" : [ "User Controller" ], - "summary" : "Retrieve all users given their userIds", + "tags" : [ "User" ], + "summary" : "Retrieve multiple users by their user IDs", + "description" : "Retrieve all users given their userIds", + "operationId" : "findAllByIds", "parameters" : [ { "name" : "userIds", "in" : "query", @@ -436,11 +588,11 @@ } } }, - "403" : { - "description" : "Not Allowed" - }, "401" : { "description" : "Not Authorized" + }, + "403" : { + "description" : "Not Allowed" } }, "security" : [ { @@ -450,8 +602,10 @@ }, "/users/notification" : { "get" : { - "tags" : [ "User Controller" ], - "summary" : "Retrieve all SC-User for DataLake filtered by optional productId", + "tags" : [ "User" ], + "summary" : "Retrieve all SC-Users for DataLake with optional product filter", + "description" : "Retrieve all SC-User for DataLake filtered by optional productId", + "operationId" : "getUsers", "parameters" : [ { "name" : "page", "in" : "query", @@ -486,11 +640,11 @@ } } }, - "403" : { - "description" : "Not Allowed" - }, "401" : { "description" : "Not Authorized" + }, + "403" : { + "description" : "Not Allowed" } }, "security" : [ { @@ -500,8 +654,10 @@ }, "/users/search" : { "post" : { - "tags" : [ "User Controller" ], - "summary" : "Search user by fiscalCode", + "tags" : [ "User" ], + "summary" : "Search for a user using fiscal code", + "description" : "Search user by fiscalCode", + "operationId" : "searchUserByFiscalCode", "parameters" : [ { "name" : "institutionId", "in" : "query", @@ -529,11 +685,11 @@ } } }, - "403" : { - "description" : "Not Allowed" - }, "401" : { "description" : "Not Authorized" + }, + "403" : { + "description" : "Not Allowed" } }, "security" : [ { @@ -543,8 +699,10 @@ }, "/users/{id}" : { "get" : { - "tags" : [ "User Controller" ], - "summary" : "Retrieves user given userId and optional ProductId", + "tags" : [ "User", "external-v2", "support", "support-pnpg", "external-pnpg" ], + "summary" : "Retrieve user information by userId and optional ProductId", + "description" : "Retrieves user given userId and optional ProductId", + "operationId" : "getUserInfoUsingGET", "parameters" : [ { "name" : "id", "in" : "path", @@ -576,11 +734,45 @@ } } }, - "403" : { - "description" : "Not Allowed" + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } }, "401" : { - "description" : "Not Authorized" + "description" : "Not Authorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "403" : { + "description" : "Forbidden", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } } }, "security" : [ { @@ -590,8 +782,10 @@ }, "/users/{id}/details" : { "get" : { - "tags" : [ "User Controller" ], - "summary" : "Retrieves user's information from pdv: name, familyName, email, fiscalCode and workContacts", + "tags" : [ "User" ], + "summary" : "Retrieve detailed user information from PDV by userId", + "description" : "Retrieves user's information from pdv: name, familyName, email, fiscalCode and workContacts", + "operationId" : "getUserDetailsById", "parameters" : [ { "name" : "id", "in" : "path", @@ -623,11 +817,11 @@ } } }, - "403" : { - "description" : "Not Allowed" - }, "401" : { "description" : "Not Authorized" + }, + "403" : { + "description" : "Not Allowed" } }, "security" : [ { @@ -637,8 +831,10 @@ }, "/users/{id}/institution/{institutionId}/product/{productId}/status" : { "put" : { - "tags" : [ "User Controller" ], - "summary" : "Service to update user product status", + "tags" : [ "User" ], + "summary" : "Update the status of a user's product", + "description" : "Service to update user product status", + "operationId" : "updateUserProductStatus", "parameters" : [ { "name" : "id", "in" : "path", @@ -660,6 +856,12 @@ "schema" : { "type" : "string" } + }, { + "name" : "productRole", + "in" : "query", + "schema" : { + "type" : "string" + } }, { "name" : "status", "in" : "query", @@ -672,11 +874,11 @@ "204" : { "description" : "No Content" }, - "403" : { - "description" : "Not Allowed" - }, "401" : { "description" : "Not Authorized" + }, + "403" : { + "description" : "Not Allowed" } }, "security" : [ { @@ -686,8 +888,10 @@ }, "/users/{id}/status" : { "put" : { - "tags" : [ "User Controller" ], - "summary" : "Update user status with optional filter for institution, product, role and productRole", + "tags" : [ "User", "internal-v1" ], + "summary" : "Update a user's product status with optional filters", + "description" : "Update user status with optional filter for institution, product, role and productRole", + "operationId" : "updateUserStatusUsingPUT", "parameters" : [ { "name" : "id", "in" : "path", @@ -717,7 +921,8 @@ "name" : "role", "in" : "query", "schema" : { - "$ref" : "#/components/schemas/PartyRole" + "description" : "Available values: MANAGER, DELEGATE, SUB_DELEGATE, OPERATOR, ADMIN_EA", + "type" : "string" } }, { "name" : "status", @@ -727,17 +932,48 @@ } } ], "responses" : { - "200" : { - "description" : "OK", + "204" : { + "description" : "No Content" + }, + "400" : { + "description" : "Bad Request", "content" : { - "application/json" : { } + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Not Authorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } } }, "403" : { - "description" : "Not Allowed" + "description" : "Forbidden", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } }, - "401" : { - "description" : "Not Authorized" + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } } }, "security" : [ { @@ -747,8 +983,10 @@ }, "/users/{id}/user-registry" : { "put" : { - "tags" : [ "User Controller" ], - "summary" : "Service to update user in user-registry and send notification when user data gets updated", + "tags" : [ "User" ], + "summary" : "Update user registry and send notification upon data update", + "description" : "Service to update user in user-registry and send notification when user data gets updated", + "operationId" : "updateUserRegistryAndSendNotification", "parameters" : [ { "name" : "id", "in" : "path", @@ -779,11 +1017,11 @@ "application/json" : { } } }, - "403" : { - "description" : "Not Allowed" - }, "401" : { "description" : "Not Authorized" + }, + "403" : { + "description" : "Not Allowed" } }, "security" : [ { @@ -793,8 +1031,10 @@ }, "/users/{userId}" : { "post" : { - "tags" : [ "User Controller" ], - "summary" : "The createOrUpdateByUserId function is used to update existing user adding userRole.", + "tags" : [ "User" ], + "summary" : "Update or create a user by userId with a new role", + "description" : "The createOrUpdateByUserId function is used to update existing user adding userRole.", + "operationId" : "createOrUpdateByUserId", "parameters" : [ { "name" : "userId", "in" : "path", @@ -814,16 +1054,19 @@ }, "responses" : { "200" : { - "description" : "OK", + "description" : "User created or updated!", "content" : { "application/json" : { } } }, - "403" : { - "description" : "Not Allowed" + "201" : { + "description" : "User already has the active role for that product!" }, "401" : { "description" : "Not Authorized" + }, + "403" : { + "description" : "Not Allowed" } }, "security" : [ { @@ -833,8 +1076,10 @@ }, "/users/{userId}/institution/{institutionId}" : { "get" : { - "tags" : [ "User Controller" ], - "summary" : "The retrieveUsers function is used to retrieve a list of users from the UserInstitution collection and userRegistry.\nAt first it try to retrieve a UserInstitution document associated with a logged user (admin)\nIf this userInstitution object is not null, so user has AdminRole, it try to retriew the userInstitutions filtered by given institutionId, roles, states, products and productRoles\nand optional given personId, otherwise it do the same query using the logged user id instead of personId.\nAfter that it retrieve personal user data, foreach userId retrieved, from userRegistry and return a stream of UserDataResponse objects containing the requested user data.", + "tags" : [ "User" ], + "summary" : "Retrieve a list of users with optional filters and permissions", + "description" : "The retrieveUsers function is used to retrieve a list of users from the UserInstitution collection and userRegistry.\nAt first it try to retrieve a UserInstitution document associated with a logged user (admin)\nIf this userInstitution object is not null, so user has AdminRole, it try to retriew the userInstitutions filtered by given institutionId, roles, states, products and productRoles\nand optional given personId, otherwise it do the same query using the logged user id instead of personId.\nAfter that it retrieve personal user data, foreach userId retrieved, from userRegistry and return a stream of UserDataResponse objects containing the requested user data.", + "operationId" : "retrieveUsers", "parameters" : [ { "name" : "institutionId", "in" : "path", @@ -906,11 +1151,11 @@ } } }, - "403" : { - "description" : "Not Allowed" - }, "401" : { "description" : "Not Authorized" + }, + "403" : { + "description" : "Not Allowed" } }, "security" : [ { @@ -920,8 +1165,10 @@ }, "/users/{userId}/institutions" : { "get" : { - "tags" : [ "User Controller" ], - "summary" : "Retrieves products info and role which the user is enabled", + "tags" : [ "User" ], + "summary" : "Retrieve product information and user roles", + "description" : "Retrieves products info and role which the user is enabled", + "operationId" : "getUserProductsInfo", "parameters" : [ { "name" : "userId", "in" : "path", @@ -956,11 +1203,61 @@ } } }, + "401" : { + "description" : "Not Authorized" + }, "403" : { "description" : "Not Allowed" + } + }, + "security" : [ { + "SecurityScheme" : [ ] + } ] + } + }, + "/users/{userId}/institutions/{institutionId}" : { + "get" : { + "tags" : [ "User" ], + "summary" : "Retrieve userInstitution data with permitted actions for each product", + "description" : "Retrieves userInstitution data with list of actions permitted for each user's product", + "operationId" : "getUserInstitutionWithPermission", + "parameters" : [ { + "name" : "institutionId", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "userId", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "productId", + "in" : "query", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/UserInstitutionWithActions" + } + } + } }, "401" : { "description" : "Not Authorized" + }, + "403" : { + "description" : "Not Allowed" } }, "security" : [ { @@ -970,8 +1267,10 @@ }, "/users/{userId}/institutions/{institutionId}/products/{productId}" : { "delete" : { - "tags" : [ "User Controller" ], - "summary" : "Delete logically the association institution and product", + "tags" : [ "User" ], + "summary" : "Logically delete the association between institution and product", + "description" : "Delete logically the association institution and product", + "operationId" : "deleteProducts", "parameters" : [ { "name" : "institutionId", "in" : "path", @@ -998,11 +1297,11 @@ "204" : { "description" : "No Content" }, - "403" : { - "description" : "Not Allowed" - }, "401" : { "description" : "Not Authorized" + }, + "403" : { + "description" : "Not Allowed" } }, "security" : [ { @@ -1082,10 +1381,21 @@ "enum" : [ "ROOT", "DEV", "COLL", "PROD" ], "type" : "string" }, - "LocalDateTime" : { + "InvalidParam" : { + "type" : "object", + "properties" : { + "name" : { + "type" : "string" + }, + "reason" : { + "type" : "string" + } + } + }, + "OffsetDateTime" : { "format" : "date-time", "type" : "string", - "example" : "2022-03-10T12:15:50" + "example" : "2022-03-10T12:15:50-04:00" }, "OnboardedProductResponse" : { "type" : "object", @@ -1103,16 +1413,17 @@ "type" : "string" }, "role" : { - "$ref" : "#/components/schemas/PartyRole" + "description" : "Available values: MANAGER, DELEGATE, SUB_DELEGATE, OPERATOR, ADMIN_EA", + "type" : "string" }, "env" : { "$ref" : "#/components/schemas/Env" }, "createdAt" : { - "$ref" : "#/components/schemas/LocalDateTime" + "$ref" : "#/components/schemas/OffsetDateTime" }, "updatedAt" : { - "$ref" : "#/components/schemas/LocalDateTime" + "$ref" : "#/components/schemas/OffsetDateTime" } } }, @@ -1120,16 +1431,78 @@ "enum" : [ "ACTIVE", "PENDING", "TOBEVALIDATED", "SUSPENDED", "DELETED", "REJECTED" ], "type" : "string" }, - "PartyRole" : { - "enum" : [ "MANAGER", "DELEGATE", "SUB_DELEGATE", "OPERATOR" ], - "type" : "string" + "OnboardedProductWithActions" : { + "type" : "object", + "properties" : { + "productId" : { + "type" : "string" + }, + "tokenId" : { + "type" : "string" + }, + "status" : { + "$ref" : "#/components/schemas/OnboardedProductState" + }, + "productRole" : { + "type" : "string" + }, + "role" : { + "description" : "Available values: MANAGER, DELEGATE, SUB_DELEGATE, OPERATOR, ADMIN_EA", + "type" : "string" + }, + "env" : { + "$ref" : "#/components/schemas/Env" + }, + "createdAt" : { + "$ref" : "#/components/schemas/OffsetDateTime" + }, + "updatedAt" : { + "$ref" : "#/components/schemas/OffsetDateTime" + }, + "delegationId" : { + "type" : "string" + }, + "userProductActions" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + } }, "PermissionTypeEnum" : { "enum" : [ "ADMIN", "ANY" ], "type" : "string" }, + "Problem" : { + "type" : "object", + "properties" : { + "detail" : { + "type" : "string" + }, + "instance" : { + "type" : "string" + }, + "invalidParams" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/InvalidParam" + } + }, + "status" : { + "format" : "int32", + "type" : "integer" + }, + "title" : { + "type" : "string" + }, + "type" : { + "type" : "string" + } + } + }, "Product" : { - "required" : [ "productId", "role" ], + "required" : [ "productId", "role", "productRoles" ], "type" : "object", "properties" : { "productId" : { @@ -1137,7 +1510,8 @@ "type" : "string" }, "role" : { - "$ref" : "#/components/schemas/PartyRole" + "description" : "Available values: MANAGER, DELEGATE, SUB_DELEGATE, OPERATOR, ADMIN_EA", + "type" : "string" }, "tokenId" : { "type" : "string" @@ -1147,11 +1521,14 @@ "items" : { "type" : "string" } + }, + "delegationId" : { + "type" : "string" } } }, "Product1" : { - "required" : [ "productId", "role" ], + "required" : [ "productId", "role", "productRoles" ], "type" : "object", "properties" : { "productId" : { @@ -1159,7 +1536,8 @@ "type" : "string" }, "role" : { - "$ref" : "#/components/schemas/PartyRole" + "description" : "Available values: MANAGER, DELEGATE, SUB_DELEGATE, OPERATOR, ADMIN_EA", + "type" : "string" }, "tokenId" : { "type" : "string" @@ -1185,7 +1563,21 @@ } } }, + "UpdateDescriptionDto" : { + "required" : [ "institutionDescription" ], + "type" : "object", + "properties" : { + "institutionDescription" : { + "minLength" : 1, + "type" : "string" + }, + "institutionRootName" : { + "type" : "string" + } + } + }, "UpdateUserRequest" : { + "required" : [ "email" ], "type" : "object", "properties" : { "name" : { @@ -1342,13 +1734,40 @@ "type" : "string" }, "role" : { - "$ref" : "#/components/schemas/PartyRole" + "description" : "Available values: MANAGER, DELEGATE, SUB_DELEGATE, OPERATOR, ADMIN_EA", + "type" : "string" }, "status" : { "$ref" : "#/components/schemas/OnboardedProductState" } } }, + "UserInstitutionWithActions" : { + "type" : "object", + "properties" : { + "userId" : { + "type" : "string" + }, + "institutionId" : { + "type" : "string" + }, + "institutionDescription" : { + "type" : "string" + }, + "institutionRootName" : { + "type" : "string" + }, + "products" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/OnboardedProductWithActions" + } + }, + "userMailUuid" : { + "type" : "string" + } + } + }, "UserNotificationResponse" : { "type" : "object", "properties" : { @@ -1365,10 +1784,10 @@ "type" : "string" }, "createdAt" : { - "$ref" : "#/components/schemas/LocalDateTime" + "$ref" : "#/components/schemas/OffsetDateTime" }, "updatedAt" : { - "$ref" : "#/components/schemas/LocalDateTime" + "$ref" : "#/components/schemas/OffsetDateTime" }, "eventType" : { "$ref" : "#/components/schemas/QueueEvent" @@ -1450,7 +1869,8 @@ "type" : "string" }, "role" : { - "$ref" : "#/components/schemas/PartyRole" + "description" : "Available values: MANAGER, DELEGATE, SUB_DELEGATE, OPERATOR, ADMIN_EA", + "type" : "string" }, "productRole" : { "type" : "string" diff --git a/src/main/java/it/pagopa/selfcare/external_api/client/MsUserApiRestClient.java b/src/main/java/it/pagopa/selfcare/external_api/client/MsUserApiRestClient.java index 765bf175..a4478b68 100644 --- a/src/main/java/it/pagopa/selfcare/external_api/client/MsUserApiRestClient.java +++ b/src/main/java/it/pagopa/selfcare/external_api/client/MsUserApiRestClient.java @@ -1,8 +1,8 @@ package it.pagopa.selfcare.external_api.client; -import it.pagopa.selfcare.user.generated.openapi.v1.api.UserControllerApi; +import it.pagopa.selfcare.user.generated.openapi.v1.api.UserApi; import org.springframework.cloud.openfeign.FeignClient; @FeignClient(name = "${rest-client.ms-user-api.serviceCode}", url = "${rest-client.ms-user-api.base-url}") -public interface MsUserApiRestClient extends UserControllerApi { +public interface MsUserApiRestClient extends UserApi { } diff --git a/src/main/java/it/pagopa/selfcare/external_api/mapper/UserMapper.java b/src/main/java/it/pagopa/selfcare/external_api/mapper/UserMapper.java index b388b4ca..fd6e79bf 100644 --- a/src/main/java/it/pagopa/selfcare/external_api/mapper/UserMapper.java +++ b/src/main/java/it/pagopa/selfcare/external_api/mapper/UserMapper.java @@ -39,7 +39,7 @@ public ProductService getProductService(){ @Named("toProductRoleLabel") protected String toProductRoleLabel(OnboardedProductResponse onboardedProduct, Product product) { ProductRole productRole = null; - try { productRole = ProductUtils.getProductRole(onboardedProduct.getProductRole(), PartyRole.valueOf(onboardedProduct.getRole().name()), product); } + try { productRole = ProductUtils.getProductRole(onboardedProduct.getProductRole(), PartyRole.valueOf(onboardedProduct.getRole()), product); } catch (IllegalArgumentException ignored) {} return Optional.ofNullable(productRole) diff --git a/src/main/java/it/pagopa/selfcare/external_api/service/InstitutionServiceImpl.java b/src/main/java/it/pagopa/selfcare/external_api/service/InstitutionServiceImpl.java index 603bdb71..db340648 100644 --- a/src/main/java/it/pagopa/selfcare/external_api/service/InstitutionServiceImpl.java +++ b/src/main/java/it/pagopa/selfcare/external_api/service/InstitutionServiceImpl.java @@ -128,7 +128,7 @@ public List getInstitutionUserProductsV2(String institutionId, InstitutionResponse institutionResponse = institutionApiClient._retrieveInstitutionByIdUsingGET(institutionId).getBody(); Set productsSet = new HashSet<>(); - ResponseEntity> response = msUserApiRestClient._usersUserIdInstitutionInstitutionIdGet(institutionId, userId, userId, null, null, null, List.of(ACTIVE.name())); + ResponseEntity> response = msUserApiRestClient._retrieveUsers(institutionId, userId, userId, null, null, null, List.of(ACTIVE.name())); if (Objects.nonNull(response) && Objects.nonNull(response.getBody()) && !response.getBody().isEmpty()) { //There is only a document for the couple institutionId/userId productsSet = response.getBody().get(0).getProducts().stream() @@ -154,7 +154,7 @@ public Collection getInstitutionProductUsersV2(String insti Assert.hasText(productId, "A Product id is required"); List productRolesList = CollectionUtils.isEmpty(productRoles) ? null : new ArrayList<>(productRoles); - List usersInstitutions = Objects.requireNonNull(msUserApiRestClient._usersGet( + List usersInstitutions = Objects.requireNonNull(msUserApiRestClient._retrievePaginatedAndFilteredUser( institutionId, null, productRolesList, List.of(productId), null , null, List.of(ACTIVE.name()), userId).getBody()) .stream().map(userMapper::toUserInstitutionsFromUserInstitutionResponse).toList(); @@ -170,7 +170,7 @@ public Collection getInstitutionProductUsersV2(String insti userProduct.setRoles(userInstitution.getProducts().stream().map(OnboardedProductResponse::getProductRole).toList()); return userProduct; }) - .collect(Collectors.toList()); + .toList(); log.debug(LogUtils.CONFIDENTIAL_MARKER, "getInstitutionProductUsers result = {}", userProductResponses); log.trace("getInstitutionProductUsers end"); diff --git a/src/main/java/it/pagopa/selfcare/external_api/service/OnboardingServiceImpl.java b/src/main/java/it/pagopa/selfcare/external_api/service/OnboardingServiceImpl.java index a1b9b0ac..4e15ecda 100644 --- a/src/main/java/it/pagopa/selfcare/external_api/service/OnboardingServiceImpl.java +++ b/src/main/java/it/pagopa/selfcare/external_api/service/OnboardingServiceImpl.java @@ -106,7 +106,7 @@ private List processUsersWithId(Map productRoles) { it.pagopa.selfcare.user.generated.openapi.v1.dto.Product product = it.pagopa.selfcare.user.generated.openapi.v1.dto.Product.builder() .productId(productId) - .role(it.pagopa.selfcare.user.generated.openapi.v1.dto.PartyRole.valueOf(role)) + .role(role) .productRoles(productRoles) .build(); @@ -117,7 +117,7 @@ private String addUserRole(String userId, Institution institution, String produc .institutionRootName(institution.getParentDescription()) .build(); - msUserApiRestClient._usersUserIdPost(userId, addUserRoleDto); + msUserApiRestClient._createOrUpdateByUserId(userId, addUserRoleDto); return userId; } @@ -141,7 +141,7 @@ private String createUser(Institution institution, String productId, String role Product1 product = Product1.builder() .productId(productId) - .role(it.pagopa.selfcare.user.generated.openapi.v1.dto.PartyRole.valueOf(role)) + .role(role) .productRoles(productRoles) .build(); @@ -154,7 +154,7 @@ private String createUser(Institution institution, String productId, String role .institutionRootName(institution.getParentDescription()) .build(); - String userId = msUserApiRestClient._usersPost(createUserDto).getBody(); + String userId = msUserApiRestClient._createOrUpdateByFiscalCode(createUserDto).getBody(); log.info("User created with id: {}", userId); return userId; } diff --git a/src/main/java/it/pagopa/selfcare/external_api/service/UserServiceImpl.java b/src/main/java/it/pagopa/selfcare/external_api/service/UserServiceImpl.java index 00e5e93c..9759c970 100644 --- a/src/main/java/it/pagopa/selfcare/external_api/service/UserServiceImpl.java +++ b/src/main/java/it/pagopa/selfcare/external_api/service/UserServiceImpl.java @@ -40,7 +40,7 @@ public class UserServiceImpl implements UserService { public UserInfoWrapper getUserInfoV2(String fiscalCode, List userStatuses) { log.trace("geUserInfo start"); it.pagopa.selfcare.user.generated.openapi.v1.dto.SearchUserDto searchUserDto = new it.pagopa.selfcare.user.generated.openapi.v1.dto.SearchUserDto(fiscalCode); - final User user = userMapper.toUserFromUserDetailResponse(msUserApiRestClient._usersSearchPost(null, searchUserDto).getBody()); + final User user = userMapper.toUserFromUserDetailResponse(msUserApiRestClient._searchUserByFiscalCode(null, searchUserDto).getBody()); List onboardedInstitutions = getOnboardedInstitutionsDetails(user.getId(), null); List userStatusesString = userStatuses == null ? Collections.emptyList() : userStatuses.stream().map(RelationshipState::toString).toList(); @@ -67,7 +67,7 @@ public UserInfoWrapper getUserInfoV2(String fiscalCode, List @Override public UserDetailsWrapper getUserOnboardedProductsDetailsV2(String userId, String institutionId, String productId) { - List usersInstitutions = Objects.requireNonNull(msUserApiRestClient._usersGet( + List usersInstitutions = Objects.requireNonNull(msUserApiRestClient._retrievePaginatedAndFilteredUser( institutionId, null, null, List.of(productId), null , null, null, userId).getBody()) .stream().map(userMapper::toUserInstitutionsFromUserInstitutionResponse).toList(); @@ -106,7 +106,7 @@ public UserDetailsWrapper getUserOnboardedProductsDetailsV2(String userId, Strin public List getOnboardedInstitutionsDetails(String userId, String productId) { //fix temporanea per il funzionamento della getUserInfo di support - List usersInstitutions = Objects.requireNonNull(msUserApiRestClient._usersGet( + List usersInstitutions = Objects.requireNonNull(msUserApiRestClient._retrievePaginatedAndFilteredUser( null, null, null, Objects.isNull(productId) ? null : List.of(productId), null , 350, null, userId).getBody()) .stream().map(userMapper::toUserInstitutionsFromUserInstitutionResponse).toList(); @@ -167,7 +167,7 @@ private List getInstitutionDetails(String institutionI @Override public List getOnboardedInstitutionsDetailsActive(String userId, String productId) { - List institutionsWithProductActive = Objects.requireNonNull(msUserApiRestClient._usersGet( + List institutionsWithProductActive = Objects.requireNonNull(msUserApiRestClient._retrievePaginatedAndFilteredUser( null, null, null, Objects.isNull(productId) ? null : List.of(productId), null , null, List.of(ACTIVE.name()), userId).getBody()) .stream().map(userMapper::toUserInstitutionsFromUserInstitutionResponse) @@ -218,22 +218,9 @@ private void retrieveBilling(Institution institution, String productId, Onboarde @Override public List getUsersInstitutions(String userId, String institutionId, Integer page, Integer size, List productRoles, List products, List roles, List states){ - return Objects.requireNonNull(msUserApiRestClient._usersGet( - institutionId, page, productRoles, products, toDtoPartyRole(roles) - , size, states, userId).getBody()) + return Objects.requireNonNull(msUserApiRestClient._retrievePaginatedAndFilteredUser( + institutionId, page, productRoles, products, Optional.ofNullable(roles).map(rolesList -> rolesList.stream().map(PartyRole::name).toList()).orElse(null), + size, states, userId).getBody()) .stream().map(userMapper::toUserInstitutionsFromUserInstitutionResponse).toList(); } - - private List toDtoPartyRole(List roles) { - List partyRoles = new ArrayList<>(); - if (roles != null) { - roles.forEach(partyRole -> { - it.pagopa.selfcare.user.generated.openapi.v1.dto.PartyRole role = it.pagopa.selfcare.user.generated.openapi.v1.dto.PartyRole.valueOf(partyRole.name()); - partyRoles.add(role); - }); - } else { - return Collections.emptyList(); - } - return partyRoles; - } } diff --git a/src/test/java/it/pagopa/selfcare/external_api/service/InstitutionServiceImplTest.java b/src/test/java/it/pagopa/selfcare/external_api/service/InstitutionServiceImplTest.java index 139aba6c..61ef0566 100644 --- a/src/test/java/it/pagopa/selfcare/external_api/service/InstitutionServiceImplTest.java +++ b/src/test/java/it/pagopa/selfcare/external_api/service/InstitutionServiceImplTest.java @@ -103,7 +103,7 @@ void getInstitutionUserProducts_WithOneMatch() { it.pagopa.selfcare.user.generated.openapi.v1.dto.OnboardedProductResponse onboardedProductResponse2 = new it.pagopa.selfcare.user.generated.openapi.v1.dto.OnboardedProductResponse(); onboardedProductResponse2.setProductId("123"); userDataResponse.setProducts(List.of(onboardedProductResponse, onboardedProductResponse2)); - when(msUserApiRestClient._usersUserIdInstitutionInstitutionIdGet(institutionId, userId, userId, null, null, null, List.of(ACTIVE.name()))) + when(msUserApiRestClient._retrieveUsers(institutionId, userId, userId, null, null, null, List.of(ACTIVE.name()))) .thenReturn(ResponseEntity.ok(List.of(userDataResponse))); Product product = new Product(); @@ -129,7 +129,7 @@ void getInstitutionUserProducts_WithTwoMatch() { it.pagopa.selfcare.user.generated.openapi.v1.dto.OnboardedProductResponse onboardedProductResponse2 = new it.pagopa.selfcare.user.generated.openapi.v1.dto.OnboardedProductResponse(); onboardedProductResponse.setProductId("id2"); userDataResponse.setProducts(List.of(onboardedProductResponse, onboardedProductResponse2)); - when(msUserApiRestClient._usersUserIdInstitutionInstitutionIdGet(institutionId, userId, userId, null, null, null, List.of(ACTIVE.name()))) + when(msUserApiRestClient._retrieveUsers(institutionId, userId, userId, null, null, null, List.of(ACTIVE.name()))) .thenReturn(ResponseEntity.ok(List.of(userDataResponse))); Product product = new Product(); @@ -172,7 +172,7 @@ void getInstitutionProductUserV2EmptyList() throws Exception { List userInstitutions = objectMapper.readValue(resourceStream, new TypeReference<>() { }); userInstitutions.forEach(userInstitutionResponse -> userInstitutionResponse.setProducts(Collections.emptyList())); - Mockito.when(msUserApiRestClient._usersGet(institutionId, null, null, List.of(productId), null, null, List.of(ACTIVE.name()), userId)) + Mockito.when(msUserApiRestClient._retrievePaginatedAndFilteredUser(institutionId, null, null, List.of(productId), null, null, List.of(ACTIVE.name()), userId)) .thenReturn(ResponseEntity.ok(userInstitutions)); @@ -195,7 +195,7 @@ void getInstitutionProductUserV2WithUuidInServiceType() throws Exception { byte[] resourceStream = Files.readAllBytes(resource.getFile().toPath()); List userInstitutions = objectMapper.readValue(resourceStream, new TypeReference<>() { }); - Mockito.when(msUserApiRestClient._usersGet(institutionId, null, null, List.of(productId), null, null, List.of(ACTIVE.name()), userId)) + Mockito.when(msUserApiRestClient._retrievePaginatedAndFilteredUser(institutionId, null, null, List.of(productId), null, null, List.of(ACTIVE.name()), userId)) .thenReturn(ResponseEntity.ok(userInstitutions)); when(productService.getProductRaw(productId)).thenReturn(dummyProduct(productId)); @@ -225,7 +225,7 @@ void getInstitutionProductUserV2WithoutUuidInServiceType() throws Exception { byte[] resourceStream = Files.readAllBytes(resource.getFile().toPath()); List userInstitutions = objectMapper.readValue(resourceStream, new TypeReference<>() { }); - Mockito.when(msUserApiRestClient._usersGet(institutionId, null, null, List.of(productId), null, null, List.of(ACTIVE.name()), userId)) + Mockito.when(msUserApiRestClient._retrievePaginatedAndFilteredUser(institutionId, null, null, List.of(productId), null, null, List.of(ACTIVE.name()), userId)) .thenReturn(ResponseEntity.ok(userInstitutions)); ClassPathResource userResource = new ClassPathResource("expectations/UserV2.json"); diff --git a/src/test/java/it/pagopa/selfcare/external_api/service/OnboardingServiceImplTest.java b/src/test/java/it/pagopa/selfcare/external_api/service/OnboardingServiceImplTest.java index 74954e72..a594e75b 100644 --- a/src/test/java/it/pagopa/selfcare/external_api/service/OnboardingServiceImplTest.java +++ b/src/test/java/it/pagopa/selfcare/external_api/service/OnboardingServiceImplTest.java @@ -7,10 +7,8 @@ import it.pagopa.selfcare.external_api.client.MsOnboardingControllerApi; import it.pagopa.selfcare.external_api.client.MsUserApiRestClient; import it.pagopa.selfcare.external_api.exception.ResourceNotFoundException; -import it.pagopa.selfcare.external_api.mapper.OnboardingMapper; import it.pagopa.selfcare.external_api.mapper.OnboardingMapperImpl; import it.pagopa.selfcare.external_api.mapper.UserResourceMapper; -import it.pagopa.selfcare.external_api.model.institution.Institution; import it.pagopa.selfcare.external_api.model.onboarding.InstitutionUpdate; import it.pagopa.selfcare.external_api.model.onboarding.OnboardingData; import it.pagopa.selfcare.external_api.model.onboarding.OnboardingUsersRequest; @@ -21,7 +19,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.Mockito; import org.mockito.Spy; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.core.io.ClassPathResource; @@ -32,7 +29,9 @@ import java.util.List; import static it.pagopa.selfcare.onboarding.common.InstitutionType.*; -import static org.mockito.Mockito.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.when; @ExtendWith({MockitoExtension.class}) class OnboardingServiceImplTest extends BaseServiceTestUtils { @@ -54,6 +53,7 @@ class OnboardingServiceImplTest extends BaseServiceTestUtils { @Spy private OnboardingMapperImpl onboardingMapper; + @Override @BeforeEach public void setUp() { super.setUp(); @@ -105,18 +105,6 @@ void onboardingUsers_noInstitutionFound() throws Exception { "Institution not found for given value"); } - @Test - void onboardingUsers_noInstitutionFound2() throws Exception { - ClassPathResource inputResource = new ClassPathResource("expectations/OnboardingUsersRequest.json"); - byte[] onboardingUsersRequestStream = Files.readAllBytes(inputResource.getFile().toPath()); - OnboardingUsersRequest onboardingUsersRequest = objectMapper.readValue(onboardingUsersRequestStream, OnboardingUsersRequest.class); - when(institutionApiClient._getInstitutionsUsingGET(onboardingUsersRequest.getInstitutionTaxCode(), onboardingUsersRequest.getInstitutionSubunitCode(), null, null)) - .thenReturn(ResponseEntity.ok(new InstitutionsResponse().institutions(Collections.emptyList()))); - Assertions.assertThrows(ResourceNotFoundException.class, - () -> onboardingService.onboardingUsers(onboardingUsersRequest, "userName", "surname"), - "Institution not found for given value"); - } - @Test void onboardingUsers_happyPath() throws Exception { @@ -130,10 +118,10 @@ void onboardingUsers_happyPath() throws Exception { }); when(institutionApiClient._getInstitutionsUsingGET(onboardingUsersRequest.getInstitutionTaxCode(), onboardingUsersRequest.getInstitutionSubunitCode(), null, null)) .thenReturn(ResponseEntity.ok(new InstitutionsResponse().institutions(institutions))); - when(msUserApiRestClient._usersPost(any())).thenReturn(ResponseEntity.ok("userId")); - when(msUserApiRestClient._usersUserIdPost(any(), any())).thenReturn(ResponseEntity.ok().build()); + when(msUserApiRestClient._createOrUpdateByFiscalCode(any())).thenReturn(ResponseEntity.ok("userId")); + when(msUserApiRestClient._createOrUpdateByUserId(any(), any())).thenReturn(ResponseEntity.ok().build()); List result = onboardingService.onboardingUsers(onboardingUsersRequest, "userName", "surname"); - assert result.size() == 2; + assertEquals(result.size(), 2); } } diff --git a/src/test/java/it/pagopa/selfcare/external_api/service/UserServiceImplTest.java b/src/test/java/it/pagopa/selfcare/external_api/service/UserServiceImplTest.java index 81644ee1..45265964 100644 --- a/src/test/java/it/pagopa/selfcare/external_api/service/UserServiceImplTest.java +++ b/src/test/java/it/pagopa/selfcare/external_api/service/UserServiceImplTest.java @@ -83,7 +83,7 @@ void getUserOnboardedProductDetailsV2() throws Exception { byte[] resourceStream = Files.readAllBytes(resource.getFile().toPath()); List userInstitutions = objectMapper.readValue(resourceStream, new TypeReference<>() { }); - Mockito.when(msUserApiRestClient._usersGet(institutionId, null, null, List.of(PRODUCT_ID), null, null, null,userId)) + Mockito.when(msUserApiRestClient._retrievePaginatedAndFilteredUser(institutionId, null, null, List.of(PRODUCT_ID), null, null, null,userId)) .thenReturn(ResponseEntity.ok(userInstitutions)); Mockito.when(userMapper.getProductService()).thenReturn(productService); Mockito.when(productService.getProductRaw(any())).thenReturn(TestUtils.dummyProduct(PRODUCT_ID)); @@ -107,7 +107,7 @@ void getUserOnboardedProductDetailsV2CheckDateMapping() throws Exception { byte[] resourceStream = Files.readAllBytes(resource.getFile().toPath()); List userInstitutions = objectMapper.readValue(resourceStream, new TypeReference<>() { }); - Mockito.when(msUserApiRestClient._usersGet(institutionId, null, null, List.of(PRODUCT_ID), null, null, null,userId)) + Mockito.when(msUserApiRestClient._retrievePaginatedAndFilteredUser(institutionId, null, null, List.of(PRODUCT_ID), null, null, null,userId)) .thenReturn(ResponseEntity.ok(userInstitutions)); Mockito.when(userMapper.getProductService()).thenReturn(productService); Mockito.when(productService.getProductRaw(any())).thenReturn(TestUtils.dummyProduct(PRODUCT_ID)); @@ -124,7 +124,7 @@ void getUserOnboardedProductDetailsV2WithoutMatch() throws Exception { byte[] resourceStream = Files.readAllBytes(resource.getFile().toPath()); List userInstitutions = objectMapper.readValue(resourceStream, new TypeReference<>() { }); - Mockito.when(msUserApiRestClient._usersGet(institutionId, null, null, List.of(PRODUCT_ID), null, null, null,userId)) + Mockito.when(msUserApiRestClient._retrievePaginatedAndFilteredUser(institutionId, null, null, List.of(PRODUCT_ID), null, null, null,userId)) .thenReturn(ResponseEntity.ok(userInstitutions)); Mockito.when(userMapper.getProductService()).thenReturn(productService); Mockito.when(productService.getProductRaw(any())).thenReturn(TestUtils.dummyProduct(PRODUCT_ID)); @@ -143,7 +143,7 @@ void getOnboardedInstitutionDetailsActiveEmptyList() throws Exception { byte[] resourceStream = Files.readAllBytes(resource.getFile().toPath()); List userInstitutions = objectMapper.readValue(resourceStream, new TypeReference<>() { }); - Mockito.when(msUserApiRestClient._usersGet(null, null, null, List.of(PRODUCT_ID), null, null, List.of(ACTIVE.name()),userId)) + Mockito.when(msUserApiRestClient._retrievePaginatedAndFilteredUser(null, null, null, List.of(PRODUCT_ID), null, null, List.of(ACTIVE.name()),userId)) .thenReturn(ResponseEntity.ok(userInstitutions)); Mockito.when(userMapper.getProductService()).thenReturn(productService); Mockito.when(productService.getProductRaw(any())).thenReturn(TestUtils.dummyProduct(PRODUCT_ID)); @@ -167,7 +167,7 @@ void getOnboardedInstitutionDetailsActive() throws Exception { byte[] resourceStream = Files.readAllBytes(resource.getFile().toPath()); List userInstitutions = objectMapper.readValue(resourceStream, new TypeReference<>() { }); - Mockito.when(msUserApiRestClient._usersGet(null, null, null, List.of(PRODUCT_ID), null, null, List.of(ACTIVE.name()),userId)) + Mockito.when(msUserApiRestClient._retrievePaginatedAndFilteredUser(null, null, null, List.of(PRODUCT_ID), null, null, List.of(ACTIVE.name()),userId)) .thenReturn(ResponseEntity.ok(userInstitutions)); InstitutionResponse institution = getInstitutionResponse(PRODUCT_ID, productIdDeleted, institutionId); Mockito.when(institutionApiClient._retrieveInstitutionByIdUsingGET(institutionId)).thenReturn(ResponseEntity.ok(institution)); @@ -204,14 +204,14 @@ void getUserInfoV2WithEmptyOnboardedInstitutions() throws Exception { ClassPathResource userResource = new ClassPathResource("expectations/User.json"); byte[] userStream = Files.readAllBytes(userResource.getFile().toPath()); UserDetailResponse user = objectMapper.readValue(userStream, UserDetailResponse.class); - Mockito.when(msUserApiRestClient._usersSearchPost(any(), any())).thenReturn(ResponseEntity.ok(user)); + Mockito.when(msUserApiRestClient._searchUserByFiscalCode(any(), any())).thenReturn(ResponseEntity.ok(user)); ClassPathResource userInstitutionResource = new ClassPathResource("expectations/UserInstitution.json"); byte[] userInstitutionStream = Files.readAllBytes(userInstitutionResource.getFile().toPath()); List userInstitutions = objectMapper.readValue(userInstitutionStream, new TypeReference<>() { }); - Mockito.when(msUserApiRestClient._usersGet(null, null, null, null, null, 350, null,user.getId())) + Mockito.when(msUserApiRestClient._retrievePaginatedAndFilteredUser(null, null, null, null, null, 350, null,user.getId())) .thenReturn(ResponseEntity.ok(userInstitutions)); Mockito.when(userMapper.getProductService()).thenReturn(productService); Mockito.when(productService.getProductRaw(any())).thenReturn(TestUtils.dummyProduct(PRODUCT_ID)); @@ -232,13 +232,13 @@ void getUserInfoV2WithValidOnboardedInstitutions() throws Exception { ClassPathResource userResource = new ClassPathResource("expectations/User.json"); byte[] userStream = Files.readAllBytes(userResource.getFile().toPath()); UserDetailResponse user = objectMapper.readValue(userStream, UserDetailResponse.class); - Mockito.when(msUserApiRestClient._usersSearchPost(any(), any())).thenReturn(ResponseEntity.ok(user)); + Mockito.when(msUserApiRestClient._searchUserByFiscalCode(any(), any())).thenReturn(ResponseEntity.ok(user)); ClassPathResource userInstitutionResource = new ClassPathResource("expectations/UserInstitution.json"); byte[] userInstitutionStream = Files.readAllBytes(userInstitutionResource.getFile().toPath()); List userInstitutions = objectMapper.readValue(userInstitutionStream, new TypeReference<>() { }); - Mockito.when(msUserApiRestClient._usersGet(null, null, null, null, null, 350, null,user.getId())) + Mockito.when(msUserApiRestClient._retrievePaginatedAndFilteredUser(null, null, null, null, null, 350, null,user.getId())) .thenReturn(ResponseEntity.ok(userInstitutions)); Mockito.when(userMapper.getProductService()).thenReturn(productService); Mockito.when(productService.getProductRaw(any())).thenReturn(TestUtils.dummyProduct(PRODUCT_ID)); @@ -291,9 +291,9 @@ void testGetUsersInstitutions_Success() { UserInstitutionResponse response2 = createUserInstitutionResponse("resp2", institutionId); List responseList = Arrays.asList(response1, response2); - // Mock the API client's _usersGet method to return the dummy responses + // Mock the API client's _retrievePaginatedAndFilteredUser method to return the dummy responses ResponseEntity> mockResponseEntity = ResponseEntity.ok(responseList); - when(msUserApiRestClient._usersGet( + when(msUserApiRestClient._retrievePaginatedAndFilteredUser( eq(institutionId), eq(page), eq(productRoles), @@ -312,7 +312,7 @@ void testGetUsersInstitutions_Success() { assertThat(result).hasSize(2); // Verify interactions with mocks - verify(msUserApiRestClient, times(1))._usersGet( + verify(msUserApiRestClient, times(1))._retrievePaginatedAndFilteredUser( eq(institutionId), eq(page), eq(productRoles), @@ -340,9 +340,9 @@ void testGetUsersInstitutions_EmptyResponse() { List roles = Arrays.asList(PartyRole.MANAGER, PartyRole.OPERATOR); List states = Arrays.asList("active", "pending"); - // Mock the API client's _usersGet method to return an empty list + // Mock the API client's _retrievePaginatedAndFilteredUser method to return an empty list ResponseEntity> mockResponseEntity = ResponseEntity.ok(Collections.emptyList()); - when(msUserApiRestClient._usersGet( + when(msUserApiRestClient._retrievePaginatedAndFilteredUser( eq(institutionId), eq(page), eq(productRoles), @@ -361,7 +361,7 @@ void testGetUsersInstitutions_EmptyResponse() { assertThat(result).isEmpty(); // Verify interactions with mocks - verify(msUserApiRestClient, times(1))._usersGet( + verify(msUserApiRestClient, times(1))._retrievePaginatedAndFilteredUser( eq(institutionId), eq(page), eq(productRoles), @@ -390,9 +390,9 @@ void testGetUsersInstitutions_NullResponseBody() { List roles = Arrays.asList(PartyRole.MANAGER, PartyRole.OPERATOR); List states = Arrays.asList("active", "pending"); - // Mock the API client's _usersGet method to return a response with null body + // Mock the API client's _retrievePaginatedAndFilteredUser method to return a response with null body ResponseEntity> mockResponseEntity = ResponseEntity.ok(null); - when(msUserApiRestClient._usersGet( + when(msUserApiRestClient._retrievePaginatedAndFilteredUser( eq(institutionId), eq(page), eq(productRoles), @@ -408,7 +408,7 @@ void testGetUsersInstitutions_NullResponseBody() { .isInstanceOf(NullPointerException.class); // Verify interactions with mocks - verify(msUserApiRestClient, times(1))._usersGet( + verify(msUserApiRestClient, times(1))._retrievePaginatedAndFilteredUser( eq(institutionId), eq(page), eq(productRoles), @@ -437,8 +437,8 @@ void testGetUsersInstitutions_ApiThrowsException() { List roles = Arrays.asList(PartyRole.MANAGER, PartyRole.OPERATOR); List states = Arrays.asList("active", "pending"); - // Mock the API client's _usersGet method to throw a RuntimeException - when(msUserApiRestClient._usersGet( + // Mock the API client's _retrievePaginatedAndFilteredUser method to throw a RuntimeException + when(msUserApiRestClient._retrievePaginatedAndFilteredUser( eq(institutionId), eq(page), eq(productRoles), @@ -455,7 +455,7 @@ void testGetUsersInstitutions_ApiThrowsException() { .hasMessageContaining("API error"); // Verify interactions with mocks - verify(msUserApiRestClient, times(1))._usersGet( + verify(msUserApiRestClient, times(1))._retrievePaginatedAndFilteredUser( eq(institutionId), eq(page), eq(productRoles),