Skip to content

Commit

Permalink
Migrate tests to JUnit5 (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan-WorkGH authored Oct 17, 2024
1 parent a27325c commit 0e5f4b5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ target/
# IntelliJ
/.idea
*.iml
?/
?/
42 changes: 4 additions & 38 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

<dependencyManagement>
<dependencies>
<!-- overrides of imports -->
<!-- overrides of imports -->

<!-- imports -->
<dependency>
Expand All @@ -74,6 +74,8 @@
<type>pom</type>
<scope>import</scope>
</dependency>

<!-- project specific dependencies -->
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -129,9 +131,7 @@
<scope>runtime</scope>
</dependency>
<dependency>
<!--
To remove when liquibase implements schema creation through r2dbc instead of jdbc
-->
<!-- To remove when liquibase implements schema creation through r2dbc instead of jdbc -->
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
Expand All @@ -157,39 +157,6 @@
<artifactId>r2dbc-h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<!--
To remove when liquibase implements schema creation through r2dbc instead of jdbc
-->
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand All @@ -201,5 +168,4 @@
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.config.server.service;

import org.gridsuite.config.server.ConfigService;
Expand Down
34 changes: 13 additions & 21 deletions src/test/java/org/gridsuite/config/server/ConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@
*/
package org.gridsuite.config.server;

import java.util.List;

import org.gridsuite.config.server.dto.ParameterInfos;
import org.gridsuite.config.server.repository.ParametersRepository;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
import org.springframework.boot.test.context.SpringBootTest;
Expand All @@ -25,24 +20,22 @@
import org.springframework.http.MediaType;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.reactive.server.WebTestClient;
import org.springframework.web.reactive.config.EnableWebFlux;

import static org.gridsuite.config.server.service.NotificationService.HEADER_USER_ID;
import static org.gridsuite.config.server.service.NotificationService.HEADER_APP_NAME;
import static org.gridsuite.config.server.service.NotificationService.HEADER_PARAMETER_NAME;
import java.util.List;

import static org.gridsuite.config.server.service.NotificationService.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

/**
* @author Abdelsalem Hedhili <abdelsalem.hedhili at rte-france.com>
*/
@RunWith(SpringRunner.class)
@AutoConfigureWebTestClient
@EnableWebFlux
@SpringBootTest
@ContextConfiguration(classes = {ConfigApplication.class, TestChannelBinderConfiguration.class})
public class ConfigTest {
@SpringBootTest(classes = {ConfigApplication.class, TestChannelBinderConfiguration.class})
class ConfigTest {

@Autowired
private WebTestClient webTestClient;
Expand All @@ -53,13 +46,13 @@ public class ConfigTest {
@Autowired
private ParametersRepository parametersRepository;

@Before
public void setup() {
@AfterEach
void setup() {
parametersRepository.deleteAll().block();
}

@Test
public void testCreateParameters() {
void testCreateParameters() {
//get all config parameters for 'foo' application -> expect empty list
webTestClient.get()
.uri("/v1/applications/foo/parameters")
Expand Down Expand Up @@ -158,7 +151,7 @@ public void testCreateParameters() {
}

@Test
public void testGetParameters() {
void testGetParameters() {
//get all config parameters -> expect empty list
webTestClient.get()
.uri("/v1/parameters")
Expand Down Expand Up @@ -316,4 +309,3 @@ public void describeTo(Description description) {
}
}
}

0 comments on commit 0e5f4b5

Please sign in to comment.