diff --git a/.github/workflows/pre-merge-postman-test.yaml b/.github/workflows/pre-merge-postman-test.yaml index df3446d..2c9eb9d 100644 --- a/.github/workflows/pre-merge-postman-test.yaml +++ b/.github/workflows/pre-merge-postman-test.yaml @@ -1,4 +1,4 @@ -name: Pull request review +name: Postman Test on: pull_request: diff --git a/build.gradle b/build.gradle index 944b49f..102e2b2 100644 --- a/build.gradle +++ b/build.gradle @@ -12,8 +12,8 @@ repositories { dependencies { implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") - implementation 'io.quarkus:quarkus-resteasy-reactive-jackson' implementation 'io.quarkus:quarkus-resteasy-reactive' + implementation 'io.quarkus:quarkus-resteasy-reactive-jackson' implementation 'io.quarkus:quarkus-arc' implementation "org.projectlombok:lombok:${lombokVersion}" implementation 'io.quarkus:quarkus-hibernate-validator' diff --git a/gradle.properties b/gradle.properties index 1641d06..307dc38 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ quarkusPlatformVersion=3.7.3 lombokVersion=1.18.30 jacocoToolVersion=0.8.11 -sonarPluginVersion=4.4.1.3373 +sonarPluginVersion=5.0.0.4638 sonarProjectKey=pagopa_mil-terminal-registry projectVersion=1.3.0 diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index d4ad450..f42552a 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -4902,6 +4902,11 @@ + + + + + @@ -4942,6 +4947,14 @@ + + + + + + + + diff --git a/src/main/java/it/pagopa/swclient/mil/dao/PageMetadata.java b/src/main/java/it/pagopa/swclient/mil/dao/PageMetadata.java index f001bfe..e7d210c 100644 --- a/src/main/java/it/pagopa/swclient/mil/dao/PageMetadata.java +++ b/src/main/java/it/pagopa/swclient/mil/dao/PageMetadata.java @@ -1,4 +1,7 @@ package it.pagopa.swclient.mil.dao; +import io.quarkus.runtime.annotations.RegisterForReflection; + +@RegisterForReflection public record PageMetadata(int size, long totalElements, int totalPages) { } diff --git a/src/main/java/it/pagopa/swclient/mil/dao/TerminalEntity.java b/src/main/java/it/pagopa/swclient/mil/dao/TerminalEntity.java index 8b5b465..a982507 100644 --- a/src/main/java/it/pagopa/swclient/mil/dao/TerminalEntity.java +++ b/src/main/java/it/pagopa/swclient/mil/dao/TerminalEntity.java @@ -1,6 +1,7 @@ package it.pagopa.swclient.mil.dao; import io.quarkus.mongodb.panache.common.MongoEntity; +import org.bson.codecs.pojo.annotations.BsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @@ -15,10 +16,13 @@ public class TerminalEntity { @BsonId + @BsonProperty("terminalUuid") private String terminalUuid; + @BsonProperty("terminalHandler") private String terminalHandler; + @BsonProperty("serviceProviderId") private String serviceProviderId; private Terminal terminal; diff --git a/src/main/java/it/pagopa/swclient/mil/dao/TerminalPageResponse.java b/src/main/java/it/pagopa/swclient/mil/dao/TerminalPageResponse.java index f5c32ad..1efaba6 100644 --- a/src/main/java/it/pagopa/swclient/mil/dao/TerminalPageResponse.java +++ b/src/main/java/it/pagopa/swclient/mil/dao/TerminalPageResponse.java @@ -1,6 +1,8 @@ package it.pagopa.swclient.mil.dao; import java.util.List; +import io.quarkus.runtime.annotations.RegisterForReflection; +@RegisterForReflection public record TerminalPageResponse(List terminals, PageMetadata page) { } diff --git a/src/test/java/it/pagopa/swclient/mil/service/TerminalServiceTest.java b/src/test/java/it/pagopa/swclient/mil/service/TerminalServiceTest.java index 37269e6..7afd0ae 100644 --- a/src/test/java/it/pagopa/swclient/mil/service/TerminalServiceTest.java +++ b/src/test/java/it/pagopa/swclient/mil/service/TerminalServiceTest.java @@ -73,17 +73,25 @@ void testCreateTerminal_Failure() { @Test void whenGetTerminalListThenSuccess() { + TerminalEntity terminalEntity1 = new TerminalEntity(); + TerminalEntity terminalEntity2 = new TerminalEntity(); + terminalEntity1.terminalUuid = "uuid1"; + terminalEntity1.serviceProviderId = "serviceProviderId"; + terminalEntity2.terminalUuid = "uuid2"; + terminalEntity2.serviceProviderId = "serviceProviderId"; + List terminalEntities= List.of(terminalEntity1,terminalEntity2); + ReactivePanacheQuery query = Mockito.mock(ReactivePanacheQuery.class); Mockito.when(query.page(anyInt(), anyInt())).thenReturn(query); - Mockito.when(query.list()).thenReturn(Uni.createFrom().item(mockedList())); + Mockito.when(query.list()).thenReturn(Uni.createFrom().item(terminalEntities)); Mockito.when(terminalRepository.find("serviceProviderId", "serviceProviderId")).thenReturn(query); var terminalList = terminalService.getTerminalListPaged("serviceProviderId", 0, 10); - terminalList .subscribe() .withSubscriber(UniAssertSubscriber.create()) - .assertItem(mockedList()); + .assertItem(terminalEntities); + } @Test @@ -98,7 +106,7 @@ void whenGetTerminalCountThenSuccess() { .withSubscriber(UniAssertSubscriber.create()) .assertItem(10L); } - + @Test void testFindTerminal_Success() { ReactivePanacheQuery query = Mockito.mock(ReactivePanacheQuery.class); diff --git a/src/test/java/it/pagopa/swclient/mil/util/TerminalTestData.java b/src/test/java/it/pagopa/swclient/mil/util/TerminalTestData.java index fcd8b9d..9b6bc42 100644 --- a/src/test/java/it/pagopa/swclient/mil/util/TerminalTestData.java +++ b/src/test/java/it/pagopa/swclient/mil/util/TerminalTestData.java @@ -28,7 +28,7 @@ public static TerminalEntity getCorrectTerminalEntity() { terminalEntity.setTerminalUuid("c7a1b24b0583477292ebdbaa"); terminalEntity.setTerminalHandler("45856"); terminalEntity.setTerminal(terminal); - + return terminalEntity; } } diff --git a/src/test/postman/mil-terminal-registry.postman_collection.json b/src/test/postman/mil-terminal-registry.postman_collection.json index 18ad60e..3ab44bf 100644 --- a/src/test/postman/mil-terminal-registry.postman_collection.json +++ b/src/test/postman/mil-terminal-registry.postman_collection.json @@ -8,7 +8,7 @@ }, "item": [ { - "name": "getTerminalRegistryAccessToken", + "name": "Get Terminal Registry Access Token", "event": [ { "listen": "test", @@ -57,7 +57,7 @@ "header": [ { "key": "RequestId", - "value": "{{$guid}}", + "value": "{{requestId}}", "type": "text" }, { @@ -99,22 +99,29 @@ "response": [] }, { - "name": "createTerminal", + "name": "Create New Terminal", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 201\", function () {", + " pm.response.to.have.status(201);", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], "request": { "method": "POST", "header": [ { "description": "(Required) Request Id that will be logged by services", "key": "RequestId", - "value": "{{$guid}}" - }, - { - "key": "Content-Type", - "value": "application/json" - }, - { - "key": "Accept", - "value": "application/json" + "value": "{{requestId}}" } ], "body": { @@ -138,6 +145,57 @@ "description": "Creates a new terminal" }, "response": [] + }, + { + "name": "Get Terminal List", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "description": "(Required) Request Id that will be logged by services", + "key": "RequestId", + "value": "{{requestId}}" + } + ], + "url": { + "raw": "{{MIL_TR_BASE_URL}}/terminals?page={{getTerminalPage}}&size={{getTerminalPageSize}}", + "host": [ + "{{MIL_TR_BASE_URL}}" + ], + "path": [ + "terminals" + ], + "query": [ + { + "key": "page", + "value": "{{getTerminalPage}}", + "description": "(Required) Number of the requested page of data" + }, + { + "key": "size", + "value": "{{getTerminalPageSize}}", + "description": "(Required) Size of the requested page of data" + } + ] + }, + "description": "Returns a page of terminals" + }, + "response": [] } ], "auth": { @@ -224,6 +282,18 @@ { "key": "mil_auth_api_version", "value": "1.0.0" + }, + { + "key": "getTerminalPage", + "value": "0" + }, + { + "key": "getTerminalPageSize", + "value": "10" + }, + { + "key": "requestId", + "value": "d0d654e6-97da-4848-b568-99fedccb642b" } ] } \ No newline at end of file