Skip to content

Commit

Permalink
Update r2dbc adapter adding basic unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Santiago Calle Gomez committed Feb 3, 2023
1 parent 7c99228 commit 7fb1ab7
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package {{package}}.r2dbc.config;

import {{package}}.r2dbc.config.PostgreSQLConnectionPool;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

class PostgreSQLConnectionPoolTest {
// TODO: change four you own tests
@Test
void getConnectionConfig() {
PostgreSQLConnectionPool postgreSQLConnectionPool= new PostgreSQLConnectionPool();
Assertions.assertNotNull(postgreSQLConnectionPool.getConnectionConfig());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
"files": {},
"java": {
"driven-adapter/r2dbc-postgresql/config/postgresql-connection-pool.java.mustache": "infrastructure/driven-adapters/r2dbc-postgresql/src/main/{{language}}/{{packagePath}}/r2dbc/config/PostgreSQLConnectionPool.java",
"driven-adapter/r2dbc-postgresql/config/postgresql-connection-pool.unit.test.java.mustache": "infrastructure/driven-adapters/r2dbc-postgresql/src/test/{{language}}/{{packagePath}}/r2dbc/PostgreSQLConnectionPoolTest.java",
"driven-adapter/r2dbc-postgresql/config/postgresql-connection-properties.java.mustache": "infrastructure/driven-adapters/r2dbc-postgresql/src/main/{{language}}/{{packagePath}}/r2dbc/config/PostgresqlConnectionProperties.java",
"driven-adapter/r2dbc-postgresql/helper/reactive-adapter-operations.java.mustache": "infrastructure/driven-adapters/r2dbc-postgresql/src/main/{{language}}/{{packagePath}}/r2dbc/helper/ReactiveAdapterOperations.java",
"driven-adapter/r2dbc-postgresql/my-reactive-repository.java.mustache": "infrastructure/driven-adapters/r2dbc-postgresql/src/main/{{language}}/{{packagePath}}/r2dbc/MyReactiveRepository.java",
"driven-adapter/r2dbc-postgresql/my-reactive-repository-adapter.java.mustache": "infrastructure/driven-adapters/r2dbc-postgresql/src/main/{{language}}/{{packagePath}}/r2dbc/MyReactiveRepositoryAdapter.java",
"driven-adapter/r2dbc-postgresql/my-reactive-repository-adapter.unit.test.java.mustache": "infrastructure/driven-adapters/r2dbc-postgresql/src/test/{{language}}/{{packagePath}}/r2dbc/MyReactiveRepositoryAdapterTest.java",
"driven-adapter/r2dbc-postgresql/build.gradle.mustache": "infrastructure/driven-adapters/r2dbc-postgresql/build.gradle"
},
"kotlin": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package {{package}}.r2dbc;

import {{package}}.r2dbc.MyReactiveRepository;
import {{package}}.r2dbc.MyReactiveRepositoryAdapter;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.reactivecommons.utils.ObjectMapper;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;

import static org.mockito.Mockito.when;

@ExtendWith(MockitoExtension.class)
class MyReactiveRepositoryAdapterTest {
// TODO: change four you own tests
@InjectMocks
MyReactiveRepositoryAdapter repositoryAdapter;
@Mock
MyReactiveRepository repository;
@Mock
ObjectMapper mapper;
@Test
void mustFindValueById() {
when(repository.findById("1")).thenReturn(Mono.just("test"));
when(mapper.map("test", Object.class)).thenReturn("test");
Mono<Object> result = repositoryAdapter.findById("1");
StepVerifier.create(result)
.expectNextMatches(value -> value.equals("test"))
.verifyComplete();
}
}

0 comments on commit 7fb1ab7

Please sign in to comment.