From bef7284e193a4c68235c1f9af4f06d736706cf29 Mon Sep 17 00:00:00 2001 From: Kevin Silva Date: Tue, 19 Dec 2023 16:11:15 +0100 Subject: [PATCH] add implementation for users list --- app/src/main/resources/swagger/api-docs.json | 76 +++++++++++++++++++ .../mscore/core/SchedulerServiceImpl.java | 9 ++- .../core/InstitutionServiceImplTest.java | 2 +- .../mscore/core/UserServiceImplTest.java | 8 +- 4 files changed, 89 insertions(+), 6 deletions(-) diff --git a/app/src/main/resources/swagger/api-docs.json b/app/src/main/resources/swagger/api-docs.json index 8cdcc9899..d2f6dc714 100644 --- a/app/src/main/resources/swagger/api-docs.json +++ b/app/src/main/resources/swagger/api-docs.json @@ -4555,6 +4555,82 @@ } ] } }, + "/scheduler/users" : { + "post" : { + "tags" : [ "scheduler" ], + "summary" : "startUsers", + "description" : "${swagger.ms-core.scheduler.api.start.users}", + "operationId" : "startUsersUsingPOST", + "parameters" : [ { + "name" : "size", + "in" : "query", + "description" : "size", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + }, { + "name" : "productsFilter", + "in" : "query", + "description" : "productsFilter", + "required" : true, + "style" : "form", + "explode" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "userId", + "in" : "path", + "description" : "userId", + "required" : true, + "style" : "simple", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK" + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "409" : { + "description" : "Conflict", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, "/tokens/products/{productId}" : { "get" : { "tags" : [ "Token", "external-v2" ], diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/SchedulerServiceImpl.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/SchedulerServiceImpl.java index dd50a1f40..186a91228 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/SchedulerServiceImpl.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/SchedulerServiceImpl.java @@ -117,9 +117,16 @@ private void regenerateUserNotifications(Optional userId){ else { do { List users = userConnector.findAll(page, page_size_api.orElse(USER_PAGE_SIZE)); - + sendDataLakeUserNotifications(users, productId); + page += 1; + if (users.size() < USER_PAGE_SIZE) { + nextPage = false; + log.debug("[KAFKA] USER TOTAL NUMBER {}", page * USER_PAGE_SIZE + users.size()); + } }while(nextPage); } + page_size_api = Optional.empty(); + schedulerConfig.setScheduler(false); } } diff --git a/core/src/test/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImplTest.java b/core/src/test/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImplTest.java index 0f4778256..56edec02c 100644 --- a/core/src/test/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImplTest.java +++ b/core/src/test/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImplTest.java @@ -1567,7 +1567,7 @@ void getInstitutionUsers() { User user = new User(); user.setId("id"); when(userConnector.findByInstitutionId(any())).thenReturn(List.of(userInfo)); - when(userRegistryConnector.getUserByInternalId(any(), true)).thenReturn(user); + when(userRegistryConnector.getUserByInternalId(any(), anyBoolean())).thenReturn(user); List userInfos = institutionServiceImpl.getInstitutionUsers("test"); assertNotNull(userInfos); assertFalse(userInfos.isEmpty()); diff --git a/core/src/test/java/it/pagopa/selfcare/mscore/core/UserServiceImplTest.java b/core/src/test/java/it/pagopa/selfcare/mscore/core/UserServiceImplTest.java index 5d11d8bb1..36e530ff0 100644 --- a/core/src/test/java/it/pagopa/selfcare/mscore/core/UserServiceImplTest.java +++ b/core/src/test/java/it/pagopa/selfcare/mscore/core/UserServiceImplTest.java @@ -144,9 +144,9 @@ void testRetrieveUserFromUserRegistry() { user.setId("42"); user.setName(certifiedField2); user.setWorkContacts(new HashMap<>()); - when(userRegistryConnector.getUserByInternalId( any(), true)).thenReturn(user); + when(userRegistryConnector.getUserByInternalId( any(), anyBoolean())).thenReturn(user); assertSame(user, userServiceImpl.retrieveUserFromUserRegistry("42")); - verify(userRegistryConnector).getUserByInternalId( any(), true); + verify(userRegistryConnector).getUserByInternalId( user.getId(), true); } /** @@ -420,7 +420,7 @@ void retrievePersonOk(){ CertifiedField certMail = new CertifiedField<>(); certMail.setValue("mail@test.it"); user.setEmail(certMail); - when(userRegistryConnector.getUserByInternalId(any(), true)).thenReturn(user); + when(userRegistryConnector.getUserByInternalId(any(), anyBoolean())).thenReturn(user); Map map = new HashMap<>(); WorkContact contact = new WorkContact(); CertifiedField mail = new CertifiedField<>(); @@ -461,7 +461,7 @@ void retrievePersonOkWithoutProductFilter(){ contact.setEmail(mail); map.put("id", contact); user.setWorkContacts(map); - when(userRegistryConnector.getUserByInternalId(any(), true)).thenReturn(user); + when(userRegistryConnector.getUserByInternalId(any(), anyBoolean())).thenReturn(user); User response = userServiceImpl.retrievePerson("userId",null, null);