-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update r2dbc adapter adding basic unit tests
- Loading branch information
Santiago Calle Gomez
committed
Feb 3, 2023
1 parent
7c99228
commit 7fb1ab7
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
...driven-adapter/r2dbc-postgresql/config/postgresql-connection-pool.unit.test.java.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...es/driven-adapter/r2dbc-postgresql/my-reactive-repository-adapter.unit.test.java.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |