From 84a93ffbd4bca171159760a4ce1dc6733ad5545c Mon Sep 17 00:00:00 2001 From: Daniel Strmecki Date: Tue, 3 Jan 2023 14:52:58 +0100 Subject: [PATCH] Feature/bael 5756 choose api (#13227) * BAEL-5756: Rest controller * BAEL-5756: GraphQL controller (without tests) * BAEL-5756: Fix GraphQL test * BAEL-5756: Fix GraphQL test 2 * BAEL-5756: GRPC working * BAEL-5756: GRPC with Spring Boot * BAEL-5756: Books proto service * BAEL-5756: Fix grpc integration test * BAEL-5756: Refactor * BAEL-5756: Revert some changes * BAEL-5756: Fix integration tests port issue between gRPC and GraphQL * BAEL-5756: Fix pom merge issue * BAEL-5756: Fix typo --- .../spring-boot-graphql/pom.xml | 86 +++++++++---------- .../main/resources/application-chooseapi.yml | 4 +- ...BooksControllerGraphQLIntegrationTest.java | 4 +- .../BooksControllerRestIntegrationTest.java | 4 +- 4 files changed, 52 insertions(+), 46 deletions(-) diff --git a/spring-boot-modules/spring-boot-graphql/pom.xml b/spring-boot-modules/spring-boot-graphql/pom.xml index b4b449166f..bb475679ad 100644 --- a/spring-boot-modules/spring-boot-graphql/pom.xml +++ b/spring-boot-modules/spring-boot-graphql/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-boot-graphql spring-boot-graphql @@ -13,6 +13,47 @@ 1.0.0-SNAPSHOT + + + + kr.motd.maven + os-maven-plugin + 1.7.0 + + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + ${protobuf-plugin.version} + + com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier} + grpc-java + io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier} + + + + + compile + compile-custom + + + + + + + + + 3.19.2 + 0.6.1 + 1.43.2 + 2.13.1.RELEASE + 1.5.1 + 1.3.5 + 1.6.2 + 3.3.2 + + org.springframework.boot @@ -78,45 +119,4 @@ - - - - kr.motd.maven - os-maven-plugin - 1.7.0 - - - - - org.xolstice.maven.plugins - protobuf-maven-plugin - ${protobuf-plugin.version} - - com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier} - grpc-java - io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier} - - - - - compile - compile-custom - - - - - - - - - 3.19.2 - 0.6.1 - 1.43.2 - 2.13.1.RELEASE - 1.5.1 - 1.3.5 - 1.6.2 - 3.3.2 - - \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-graphql/src/main/resources/application-chooseapi.yml b/spring-boot-modules/spring-boot-graphql/src/main/resources/application-chooseapi.yml index 889842df9f..0036bb3284 100644 --- a/spring-boot-modules/spring-boot-graphql/src/main/resources/application-chooseapi.yml +++ b/spring-boot-modules/spring-boot-graphql/src/main/resources/application-chooseapi.yml @@ -2,8 +2,10 @@ server: port: 8082 spring: + main: + allow-bean-definition-overriding: true graphql: graphiql: enabled: true schema: - locations: classpath:chooseapi/ \ No newline at end of file + locations: classpath:chooseapi/ diff --git a/spring-boot-modules/spring-boot-graphql/src/test/java/com/baeldung/chooseapi/controllers/BooksControllerGraphQLIntegrationTest.java b/spring-boot-modules/spring-boot-graphql/src/test/java/com/baeldung/chooseapi/controllers/BooksControllerGraphQLIntegrationTest.java index c1ce711388..48ed73fbde 100644 --- a/spring-boot-modules/spring-boot-graphql/src/test/java/com/baeldung/chooseapi/controllers/BooksControllerGraphQLIntegrationTest.java +++ b/spring-boot-modules/spring-boot-graphql/src/test/java/com/baeldung/chooseapi/controllers/BooksControllerGraphQLIntegrationTest.java @@ -11,7 +11,9 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = ChooseApiApp.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = { "grpc.server.port=-1" }, // Disable gRPC external server + classes = ChooseApiApp.class) @ActiveProfiles("chooseapi") class BooksControllerGraphQLIntegrationTest { diff --git a/spring-boot-modules/spring-boot-graphql/src/test/java/com/baeldung/chooseapi/controllers/BooksControllerRestIntegrationTest.java b/spring-boot-modules/spring-boot-graphql/src/test/java/com/baeldung/chooseapi/controllers/BooksControllerRestIntegrationTest.java index 977a132653..4f2f8e8e51 100644 --- a/spring-boot-modules/spring-boot-graphql/src/test/java/com/baeldung/chooseapi/controllers/BooksControllerRestIntegrationTest.java +++ b/spring-boot-modules/spring-boot-graphql/src/test/java/com/baeldung/chooseapi/controllers/BooksControllerRestIntegrationTest.java @@ -9,13 +9,15 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MockMvc; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -@SpringBootTest +@SpringBootTest(properties = { "grpc.server.port=-1" }) // Disable gRPC external server +@ActiveProfiles("chooseapi") @AutoConfigureMockMvc class BooksControllerRestIntegrationTest {