started to add test

This commit is contained in:
hirst 2024-05-31 08:25:42 +02:00
parent 09a253f3cc
commit 6d82744e7f
11 changed files with 99 additions and 67 deletions

View file

@ -6,6 +6,7 @@
<groupId>com.learningpulse</groupId> <groupId>com.learningpulse</groupId>
<artifactId>server</artifactId> <artifactId>server</artifactId>
<version>0.0.1</version> <version>0.0.1</version>
</parent> </parent>
<artifactId>dummy</artifactId> <artifactId>dummy</artifactId>
<version>0.0.1</version> <version>0.0.1</version>
@ -15,10 +16,10 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency> <!-- <dependency>-->
<groupId>org.springframework.boot</groupId> <!-- <groupId>org.springframework.boot</groupId>-->
<artifactId>spring-boot-starter-web</artifactId> <!-- <artifactId>spring-boot-starter-web</artifactId>-->
</dependency> <!-- </dependency>-->
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
@ -35,27 +36,31 @@
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId> <artifactId>spring-cloud-config-server</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.security.oauth/spring-security-oauth2 --> <!-- https://mvnrepository.com/artifact/org.springframework.security.oauth/spring-security-oauth2 -->
<dependency> <!-- <dependency>-->
<groupId>org.springframework.security.oauth</groupId> <!-- <groupId>org.springframework.security.oauth</groupId>-->
<artifactId>spring-security-oauth2</artifactId> <!-- <artifactId>spring-security-oauth2</artifactId>-->
<version>2.5.2.RELEASE</version> <!-- <version>2.5.2.RELEASE</version>-->
</dependency> <!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-oauth2-resource-server</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.security</groupId>-->
<!-- <artifactId>spring-security-oauth2-resource-server</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-security</artifactId>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>org.springframework.security</groupId> <groupId>org.springdoc</groupId>
<artifactId>spring-security-oauth2-resource-server</artifactId> <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
</dependency> <version>2.5.0</version>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency> </dependency>
<dependency> <dependency>
@ -63,11 +68,10 @@
<artifactId>postgresql</artifactId> <artifactId>postgresql</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>org.springframework.security</groupId> <!-- <groupId>org.springframework.security</groupId>-->
<artifactId>spring-security-test</artifactId> <!-- <artifactId>spring-security-test</artifactId>-->
<scope>test</scope> <!-- <scope>test</scope>-->
</dependency> <!-- </dependency>-->
</dependencies> </dependencies>
</project> </project>

View file

@ -5,8 +5,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@SpringBootApplication
@EnableDiscoveryClient @EnableDiscoveryClient
@SpringBootApplication
public class DummyApplication { public class DummyApplication {
public static void main(String[] args) { public static void main(String[] args) {

View file

@ -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<String> test() {
return ResponseEntity.ok("Hello, World!");
}
}

View file

@ -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<String> test() {
return ResponseEntity.ok("Hello, World!");
}
@PutMapping("/{id}")
@ResponseStatus(HttpStatus.OK)
public void updateBook(){
}
}

View file

@ -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();
}
}

View file

@ -1,5 +1,5 @@
app: app:
eureka-server: localhost eureka-server: eureka
server: server:
port: 0 port: 0
@ -14,14 +14,14 @@ spring:
name: admin name: admin
password: admin password: admin
# TODO this does NOT want to work
springdoc: springdoc:
enable-native-support: true
api-docs: api-docs:
enabled: true
path: /api/v1/dummy/v3/api-docs path: /api/v1/dummy/v3/api-docs
swagger-ui: swagger-ui:
path: /api/v1/dummy/swagger-ui.html path: /api/v1/dummy/swagger-ui.html
management: management:
endpoints: endpoints:
web: web:

View file

@ -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();
}
}

View file

@ -6,7 +6,6 @@
<groupId>com.learningpulse</groupId> <groupId>com.learningpulse</groupId>
<artifactId>server</artifactId> <artifactId>server</artifactId>
<version>0.0.1</version> <version>0.0.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<artifactId>gateway</artifactId> <artifactId>gateway</artifactId>
<version>0.0.1</version> <version>0.0.1</version>
@ -24,10 +23,10 @@
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId> <artifactId>spring-cloud-starter-gateway</artifactId>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>org.springframework.boot</groupId> <!-- <groupId>org.springframework.boot</groupId>-->
<artifactId>spring-boot-starter-security</artifactId> <!-- <artifactId>spring-boot-starter-security</artifactId>-->
</dependency> <!-- </dependency>-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId> <artifactId>spring-boot-starter-webflux</artifactId>
@ -35,12 +34,12 @@
<dependency> <dependency>
<groupId>org.springdoc</groupId> <groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId> <artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
<version>2.2.0</version> <version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-oauth2-resource-server</artifactId>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>

View file

@ -3,10 +3,8 @@ package com.learningpulse.gateway;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
@SpringBootApplication @SpringBootApplication
@EnableWebFluxSecurity
@EnableDiscoveryClient @EnableDiscoveryClient
public class GatewayApplication { public class GatewayApplication {

View file

@ -57,8 +57,9 @@ management:
gateway: gateway:
enabled: true enabled: true
# TODO doesnt want to work
springdoc: springdoc:
enable-native-support: true # enable-native-support: true
api-docs: api-docs:
enabled: true enabled: true
groups: groups:

View file

@ -68,14 +68,6 @@
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
</plugin> </plugin>
</plugins> </plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</pluginManagement>
</build> </build>
</project> </project>