Skip to content

Commit

Permalink
Merge pull request #45 from Coreoz/junit5
Browse files Browse the repository at this point in the history
Migrate to Junit5
  • Loading branch information
amanteaux authored Nov 18, 2024
2 parents 595129a + b983fb2 commit 0a483cc
Show file tree
Hide file tree
Showing 30 changed files with 402 additions and 194 deletions.
21 changes: 16 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
/.settings/
/.project
/.idea/
/target/
/.README.md.html
# Eclipse
.classpath
.project
.settings/
bin/
.factorypath
.README.md.html

# Intellij
.idea/
*.iml
*.iws

# Mac
.DS_Store

# Maven
log/
target/

*.xlsx
12 changes: 3 additions & 9 deletions plume-conf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,11 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>com.coreoz</groupId>
<artifactId>plume-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</dependencies>

<dependencyManagement>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.coreoz.plume.conf;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;

import org.junit.Test;
import static org.assertj.core.api.Fail.fail;

import com.typesafe.config.Config;

import org.junit.jupiter.api.Test;

public class ConfigProviderTest {

@Test
Expand All @@ -16,7 +16,7 @@ public void check_that_the_configuration_is_correctly_loaded() {
assertThat(config.getString("generic.property")).isEqualTo("Text property");
assertThat(config.getIntList("generic.to-be-overriden")).containsExactly(4, 5);
}

@Test
public void check_that_failed_include_raises_exception() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@
import java.time.temporal.ChronoUnit;
import java.util.List;

import com.coreoz.test.GuiceTest;
import jakarta.inject.Inject;

import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;

import com.carlosbecker.guice.GuiceModules;
import com.carlosbecker.guice.GuiceTestRunner;
import com.coreoz.plume.db.querydsl.DbQuerydslTestModule;
import com.coreoz.plume.db.querydsl.db.QUser;
import com.coreoz.plume.db.querydsl.db.User;
import com.coreoz.plume.db.querydsl.db.UserDao;

@RunWith(GuiceTestRunner.class)
@GuiceModules(DbQuerydslTestModule.class)
@GuiceTest(DbQuerydslTestModule.class)
public class CrudDaoQuerydslTest {

@Inject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
package com.coreoz.plume.db.querydsl.crud;

import static org.assertj.core.api.Assertions.assertThat;

import java.sql.SQLException;

import jakarta.inject.Inject;
import javax.sql.DataSource;

import org.junit.Test;
import org.junit.runner.RunWith;

import com.carlosbecker.guice.GuiceModules;
import com.carlosbecker.guice.GuiceTestRunner;
import com.coreoz.plume.db.querydsl.DbQuerydslTestModule;
import com.coreoz.plume.db.querydsl.db.User;
import com.coreoz.plume.db.querydsl.db.UserDao;
import com.coreoz.plume.db.querydsl.transaction.TransactionInstancesHolder;
import com.coreoz.test.GuiceTest;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;

import javax.sql.DataSource;
import java.sql.SQLException;

import static org.assertj.core.api.Assertions.assertThat;

/**
* Ensure that transaction management behave as expected for daos
*/
@RunWith(GuiceTestRunner.class)
@GuiceModules(DbQuerydslTestModule.class)
@GuiceTest(DbQuerydslTestModule.class)
public class CrudDaoQuerydslTransactionTest {

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.querydsl.core.types.Order;
import org.junit.Test;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -108,28 +109,32 @@ public void fetch_page_with_page_size_larger_than_total_results_should_return_al
assertThat(page.hasMore()).isFalse(); // No more items because page size exceeds total results
}

@Test(expected = IllegalArgumentException.class)
@Test
public void fetch_page_with_invalid_negative_page_number_should_throw_exception() {
SqlPaginatedQuery
.fromQuery(
transactionManagerQuerydsl.selectQuery()
.select(QUser.user)
.from(QUser.user)
)
.withSort(QUser.user.name, Order.ASC)
.fetchPage(-1, 10); // Invalid negative page number
Assertions.assertThatThrownBy(() -> {
SqlPaginatedQuery
.fromQuery(
transactionManagerQuerydsl.selectQuery()
.select(QUser.user)
.from(QUser.user)
)
.withSort(QUser.user.name, Order.ASC)
.fetchPage(-1, 10); // Invalid negative page number
}).isOfAnyClassIn(IllegalArgumentException.class);
}

@Test(expected = IllegalArgumentException.class)
@Test
public void fetch_page_with_invalid_negative_page_size_should_throw_exception() {
SqlPaginatedQuery
.fromQuery(
transactionManagerQuerydsl.selectQuery()
.select(QUser.user)
.from(QUser.user)
)
.withSort(QUser.user.name, Order.ASC)
.fetchPage(1, -10); // Invalid negative page size
Assertions.assertThatThrownBy(() -> {
SqlPaginatedQuery
.fromQuery(
transactionManagerQuerydsl.selectQuery()
.select(QUser.user)
.from(QUser.user)
)
.withSort(QUser.user.name, Order.ASC)
.fetchPage(1, -10); // Invalid negative page size
}).isOfAnyClassIn(IllegalArgumentException.class);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
package com.coreoz.plume.db.querydsl.transaction;

import static org.assertj.core.api.Assertions.assertThat;

import java.sql.SQLException;

import com.coreoz.plume.db.querydsl.DbQuerydslTestModule;
import com.coreoz.plume.db.querydsl.db.QUser;
import com.coreoz.test.GuiceTest;
import jakarta.inject.Inject;
import javax.sql.DataSource;
import org.junit.jupiter.api.Test;

import org.junit.Test;
import org.junit.runner.RunWith;
import javax.sql.DataSource;
import java.sql.SQLException;

import com.carlosbecker.guice.GuiceModules;
import com.carlosbecker.guice.GuiceTestRunner;
import com.coreoz.plume.db.querydsl.DbQuerydslTestModule;
import com.coreoz.plume.db.querydsl.db.QUser;
import static org.assertj.core.api.Assertions.assertThat;

@RunWith(GuiceTestRunner.class)
@GuiceModules(DbQuerydslTestModule.class)
@GuiceTest(DbQuerydslTestModule.class)
public class TransactionManagerQuerydslTest {

@Inject
Expand Down
34 changes: 10 additions & 24 deletions plume-db-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@
<artifactId>guice</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
<dependency>
<groupId>com.coreoz</groupId>
<artifactId>plume-test</artifactId>
</dependency>

<dependency>
<groupId>org.flywaydb</groupId>
Expand All @@ -42,22 +43,7 @@
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>

<dependency>
<groupId>com.carlosbecker</groupId>
<artifactId>guice-junit-test-runner</artifactId>
<exclusions>
<exclusion>
<artifactId>guice</artifactId>
<groupId>com.google.inject</groupId>
</exclusion>
<exclusion>
<artifactId>javax.inject</artifactId>
<groupId>javax.inject</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencies>

<dependencyManagement>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.coreoz.plume.db.pagination;

import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.coreoz.plume.db.pagination;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.coreoz.plume.db.pagination;

import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

import javax.sql.DataSource;

import org.junit.Test;

import com.typesafe.config.ConfigFactory;
import org.junit.jupiter.api.Test;

public class HikariDataSourcesTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import java.sql.Connection;

import com.zaxxer.hikari.HikariDataSource;
import org.junit.Test;

import com.typesafe.config.ConfigFactory;
import org.junit.jupiter.api.Test;

public class TransactionManagerTest {

Expand Down
35 changes: 28 additions & 7 deletions plume-framework-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@
<maven-model.version>3.9.9</maven-model.version>
<throwing-function.version>1.5.1</throwing-function.version>

<junit.version>4.13.2</junit.version>
<junit.version>5.11.3</junit.version>
<assertj.version>3.26.3</assertj.version>
<guice-runner.version>1.1</guice-runner.version>
<mockito.version>5.14.2</mockito.version>
<guice-junit.version>1.0.0</guice-junit.version>
</properties>

<dependencyManagement>
Expand All @@ -67,6 +68,11 @@
<artifactId>plume-scheduler</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.coreoz</groupId>
<artifactId>plume-test</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.coreoz</groupId>
<artifactId>plume-db</artifactId>
Expand Down Expand Up @@ -272,6 +278,16 @@
<artifactId>jersey-container-grizzly2-http</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
<artifactId>jersey-test-framework-core</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations-jakarta</artifactId>
Expand Down Expand Up @@ -332,8 +348,8 @@

<!-- Tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
Expand All @@ -342,9 +358,14 @@
<version>${assertj.version}</version>
</dependency>
<dependency>
<groupId>com.carlosbecker</groupId>
<artifactId>guice-junit-test-runner</artifactId>
<version>${guice-runner.version}</version>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
</dependency>
<dependency>
<groupId>com.coreoz</groupId>
<artifactId>guice-junit</artifactId>
<version>${guice-junit.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down
Loading

0 comments on commit 0a483cc

Please sign in to comment.