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

View file

@ -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) {

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:
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:

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>
<artifactId>server</artifactId>
<version>0.0.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<artifactId>gateway</artifactId>
<version>0.0.1</version>
@ -24,10 +23,10 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-security</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
@ -35,12 +34,12 @@
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
<version>2.5.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-oauth2-resource-server</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<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.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
@SpringBootApplication
@EnableWebFluxSecurity
@EnableDiscoveryClient
public class GatewayApplication {

View file

@ -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:

View file

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