From 6d82744e7fbf434e02fb484d85d6404e4824e824 Mon Sep 17 00:00:00 2001 From: hirst Date: Fri, 31 May 2024 08:25:42 +0200 Subject: [PATCH] started to add test --- dummy/pom.xml | 56 ++++++++++--------- .../learningpulse/dummy/DummyApplication.java | 2 +- .../java/com/learningpulse/dummy/Test.java | 16 ------ .../learningpulse/dummy/TestController.java | 20 +++++++ .../config/DummyOpenAPIConfiguration.java | 15 +++++ dummy/src/main/resources/application.yml | 6 +- .../com/learningpulse/dummy/SmokeTest.java | 19 +++++++ gateway/pom.xml | 19 +++---- .../gateway/GatewayApplication.java | 2 - gateway/src/main/resources/application.yml | 3 +- pom.xml | 8 --- 11 files changed, 99 insertions(+), 67 deletions(-) delete mode 100644 dummy/src/main/java/com/learningpulse/dummy/Test.java create mode 100644 dummy/src/main/java/com/learningpulse/dummy/TestController.java create mode 100644 dummy/src/main/java/com/learningpulse/dummy/config/DummyOpenAPIConfiguration.java create mode 100644 dummy/src/test/java/com/learningpulse/dummy/SmokeTest.java diff --git a/dummy/pom.xml b/dummy/pom.xml index 071da9e..41cf127 100644 --- a/dummy/pom.xml +++ b/dummy/pom.xml @@ -6,6 +6,7 @@ com.learningpulse server 0.0.1 + dummy 0.0.1 @@ -15,10 +16,10 @@ - - org.springframework.boot - spring-boot-starter-web - + + + + org.projectlombok @@ -35,27 +36,31 @@ org.springframework.cloud spring-cloud-config-server - - org.springframework.boot - spring-boot-starter-oauth2-resource-server - - - org.springframework.security.oauth - spring-security-oauth2 - 2.5.2.RELEASE - + + + + + + + + + + + + + + + + + - org.springframework.security - spring-security-oauth2-resource-server - - - - org.springframework.boot - spring-boot-starter-security + org.springdoc + springdoc-openapi-starter-webmvc-ui + 2.5.0 @@ -63,11 +68,10 @@ postgresql runtime - - org.springframework.security - spring-security-test - test - + + + + + - diff --git a/dummy/src/main/java/com/learningpulse/dummy/DummyApplication.java b/dummy/src/main/java/com/learningpulse/dummy/DummyApplication.java index 54e1e05..28dd3a0 100644 --- a/dummy/src/main/java/com/learningpulse/dummy/DummyApplication.java +++ b/dummy/src/main/java/com/learningpulse/dummy/DummyApplication.java @@ -5,8 +5,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; -@SpringBootApplication @EnableDiscoveryClient +@SpringBootApplication public class DummyApplication { public static void main(String[] args) { diff --git a/dummy/src/main/java/com/learningpulse/dummy/Test.java b/dummy/src/main/java/com/learningpulse/dummy/Test.java deleted file mode 100644 index 7da105e..0000000 --- a/dummy/src/main/java/com/learningpulse/dummy/Test.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.learningpulse.dummy; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/api/v1/dummy") -public class Test { - - @GetMapping("/test") - public ResponseEntity test() { - return ResponseEntity.ok("Hello, World!"); - } -} diff --git a/dummy/src/main/java/com/learningpulse/dummy/TestController.java b/dummy/src/main/java/com/learningpulse/dummy/TestController.java new file mode 100644 index 0000000..450c7f2 --- /dev/null +++ b/dummy/src/main/java/com/learningpulse/dummy/TestController.java @@ -0,0 +1,20 @@ +package com.learningpulse.dummy; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/api/v1/dummy/test") +public class TestController { + + @GetMapping("/") + public ResponseEntity test() { + return ResponseEntity.ok("Hello, World!"); + } + + @PutMapping("/{id}") + @ResponseStatus(HttpStatus.OK) + public void updateBook(){ + } +} diff --git a/dummy/src/main/java/com/learningpulse/dummy/config/DummyOpenAPIConfiguration.java b/dummy/src/main/java/com/learningpulse/dummy/config/DummyOpenAPIConfiguration.java new file mode 100644 index 0000000..a0a049b --- /dev/null +++ b/dummy/src/main/java/com/learningpulse/dummy/config/DummyOpenAPIConfiguration.java @@ -0,0 +1,15 @@ +package com.learningpulse.dummy.config; + +import io.swagger.v3.oas.models.OpenAPI; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; + +@Component +@Configuration +public class DummyOpenAPIConfiguration { + @Bean + public OpenAPI dummyOpenAPI() { + return new OpenAPI(); + } +} diff --git a/dummy/src/main/resources/application.yml b/dummy/src/main/resources/application.yml index a50a127..e42bee1 100644 --- a/dummy/src/main/resources/application.yml +++ b/dummy/src/main/resources/application.yml @@ -1,5 +1,5 @@ app: - eureka-server: localhost + eureka-server: eureka server: port: 0 @@ -14,14 +14,14 @@ spring: name: admin password: admin +# TODO this does NOT want to work springdoc: - enable-native-support: true api-docs: - enabled: true path: /api/v1/dummy/v3/api-docs swagger-ui: path: /api/v1/dummy/swagger-ui.html + management: endpoints: web: diff --git a/dummy/src/test/java/com/learningpulse/dummy/SmokeTest.java b/dummy/src/test/java/com/learningpulse/dummy/SmokeTest.java new file mode 100644 index 0000000..6a4f847 --- /dev/null +++ b/dummy/src/test/java/com/learningpulse/dummy/SmokeTest.java @@ -0,0 +1,19 @@ +package com.learningpulse.dummy; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +@SpringBootTest +public class SmokeTest { + + @Autowired + private TestController controller; + + @Test + void contextLoads() throws Exception { + assertThat(controller).isNull(); + } +} diff --git a/gateway/pom.xml b/gateway/pom.xml index 018a68c..00445bc 100644 --- a/gateway/pom.xml +++ b/gateway/pom.xml @@ -6,7 +6,6 @@ com.learningpulse server 0.0.1 - gateway 0.0.1 @@ -24,10 +23,10 @@ org.springframework.cloud spring-cloud-starter-gateway - - org.springframework.boot - spring-boot-starter-security - + + + + org.springframework.boot spring-boot-starter-webflux @@ -35,12 +34,12 @@ org.springdoc springdoc-openapi-starter-webflux-ui - 2.2.0 - - - org.springframework.boot - spring-boot-starter-oauth2-resource-server + 2.5.0 + + + + org.springframework.cloud spring-cloud-starter-netflix-eureka-client diff --git a/gateway/src/main/java/com/learningpulse/gateway/GatewayApplication.java b/gateway/src/main/java/com/learningpulse/gateway/GatewayApplication.java index bb4e61d..774aee8 100644 --- a/gateway/src/main/java/com/learningpulse/gateway/GatewayApplication.java +++ b/gateway/src/main/java/com/learningpulse/gateway/GatewayApplication.java @@ -3,10 +3,8 @@ package com.learningpulse.gateway; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; -import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; @SpringBootApplication -@EnableWebFluxSecurity @EnableDiscoveryClient public class GatewayApplication { diff --git a/gateway/src/main/resources/application.yml b/gateway/src/main/resources/application.yml index 9b2ea0b..947cde6 100644 --- a/gateway/src/main/resources/application.yml +++ b/gateway/src/main/resources/application.yml @@ -57,8 +57,9 @@ management: gateway: enabled: true +# TODO doesnt want to work springdoc: - enable-native-support: true +# enable-native-support: true api-docs: enabled: true groups: diff --git a/pom.xml b/pom.xml index ebd117c..2cf3142 100644 --- a/pom.xml +++ b/pom.xml @@ -68,14 +68,6 @@ spring-boot-maven-plugin - - - - org.springframework.boot - spring-boot-maven-plugin - - -