Skip to content

Commit

Permalink
chore: clean codes
Browse files Browse the repository at this point in the history
  • Loading branch information
hantsy committed Nov 13, 2021
1 parent a5fc191 commit 0d80cea
Show file tree
Hide file tree
Showing 37 changed files with 581 additions and 578 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/boot-data-mongo-auditing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ jobs:
java-version: '17'
distribution: 'adopt'
cache: 'maven'
- name: Start up databases via Docker Compose
run: |
docker-compose up -d mongodb
sleep 5
docker ps -a
- name: Build with Maven
run: |
cd boot-data-mongo-auditing
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/boot-data-mongo-gridfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ jobs:
docker-compose up -d mongodb
sleep 5
docker ps -a
- name: Start up databases via Docker Compose
run: |
docker-compose up -d mongodb
sleep 5
docker ps -a
- name: Build with Maven
run: |
cd boot-data-mongo-gridfs
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/boot-data-mongo-querydsl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ jobs:
java-version: '17'
distribution: 'adopt'
cache: 'maven'
- name: Start up databases via Docker Compose
run: |
docker-compose up -d mongodb
sleep 5
docker ps -a
- name: Build with Maven
run: |
cd boot-data-mongo-querydsl
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/boot-data-mongo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ jobs:
java-version: '17'
distribution: 'adopt'
cache: 'maven'
- name: Start up databases via Docker Compose
run: |
docker-compose up -d mongodb
sleep 5
docker ps -a
- name: Build with Maven
run: |
cd boot-data-mongo
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/boot-mongo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ jobs:
java-version: '17'
distribution: 'adopt'
cache: 'maven'
- name: Start up databases via Docker Compose
run: |
docker-compose up -d mongodb
sleep 5
docker ps -a
- name: Build with Maven
run: |
cd boot-mongo
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/data-mongo-pageable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ jobs:
java-version: '17'
distribution: 'adopt'
cache: 'maven'
- name: Start up databases via Docker Compose
run: |
docker-compose up -d mongodb
sleep 5
docker ps -a
- name: Build with Maven
run: |
cd data-mongo-pageable
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/data-mongo-transaction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ jobs:
java-version: '17'
distribution: 'adopt'
cache: 'maven'
- name: Start up databases via Docker Compose
run: |
docker-compose up -d mongodb
sleep 5
docker ps -a
- name: Build with Maven
run: |
cd data-mongo-transaction
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/data-mongo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ jobs:
java-version: '17'
distribution: 'adopt'
cache: 'maven'
- name: Start up databases via Docker Compose
run: |
docker-compose up -d mongodb
sleep 5
docker ps -a
- name: Build with Maven
run: |
cd data-mongo
Expand Down
3 changes: 1 addition & 2 deletions boot-data-mongo-auditing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<properties>
<java.version>11</java.version>
<java.version>17</java.version>
<testcontainers.version>1.16.2</testcontainers.version>
</properties>

Expand Down Expand Up @@ -113,5 +113,4 @@
</pluginRepository>
</pluginRepositories>


</project>
13 changes: 1 addition & 12 deletions boot-data-mongo-querydsl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<description>Demo project for Spring Boot</description>

<properties>
<java.version>11</java.version>
<java.version>17</java.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -45,17 +45,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>:junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public PostController(PostRepository posts) {
}

@GetMapping("")
public Flux<Post> all(@RequestParam("q") String q) {
public Flux<Post> all(@RequestParam(value = "q", required = false) String q) {
return Optional.ofNullable(q)
.map(
keyword -> this.posts.findAll(QPost.post.title.containsIgnoreCase(keyword)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package com.example.demo;


import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.web.reactive.server.WebTestClient;
import reactor.core.publisher.Flux;

import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.*;

@WebFluxTest(controllers = PostController.class)
public class PostControllerMockitoTests {
public class PostControllerTests {

@Autowired
WebTestClient client;
Expand All @@ -21,16 +19,16 @@ public class PostControllerMockitoTests {
PostRepository posts;

@Test
public void getAllMessagesShouldBeOk() {
Post post1 = Post.builder().content("my test content").title("my test title").build();
Post post2 = Post.builder().content("content of another post").title("another post title").build();
given(this.posts.findAll()).willReturn(Flux.just(post1, post2));

client.get().uri("/posts").exchange()
public void getAllPosts() {
when(posts.findAll()).thenReturn(
Flux.just(
Post.builder().title("post one").content("The content of post one").build()
)
);
client.get().uri("/posts")
.exchange()
.expectStatus().isOk()
.expectBody()
.jsonPath("$.[0].title").isEqualTo("my test title")
.jsonPath("$.[1].title").isEqualTo("another post title");
.expectBody().jsonPath("$.size()").isEqualTo(1);

verify(this.posts, times(1)).findAll();
verifyNoMoreInteractions(this.posts);
Expand Down
30 changes: 1 addition & 29 deletions boot-data-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<properties>
<java.version>14</java.version>
<java.version>17</java.version>
<testcontainers.version>1.16.2</testcontainers.version>
</properties>

Expand All @@ -28,15 +28,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
Expand All @@ -50,23 +41,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>:junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mongodb</artifactId>
Expand All @@ -87,14 +67,6 @@

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>${java.version}</release>
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import org.springframework.test.web.reactive.server.WebTestClient;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnableAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class)
//@AutoConfigureWebTestClient
public class IntegrationTests {

@LocalServerPort
Expand Down
7 changes: 6 additions & 1 deletion boot-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<properties>
<java.version>11</java.version>
<java.version>17</java.version>
<testcontainers.version>1.16.2</testcontainers.version>
</properties>

Expand Down Expand Up @@ -52,6 +52,11 @@
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mongodb</artifactId>
Expand Down
Loading

0 comments on commit 0d80cea

Please sign in to comment.