1313
1414package io .dapr .springboot .examples .wfp ;
1515
16+
1617import io .dapr .testcontainers .Component ;
1718import io .dapr .testcontainers .DaprContainer ;
18- import io .dapr .testcontainers .DaprLogLevel ;
19+ import io .dapr .testcontainers .WorkflowDashboardContainer ;
1920import io .github .microcks .testcontainers .MicrocksContainersEnsemble ;
2021import org .junit .runner .Description ;
2122import org .junit .runners .model .Statement ;
2627import org .springframework .test .context .DynamicPropertyRegistrar ;
2728import org .testcontainers .DockerClientFactory ;
2829import org .testcontainers .containers .Network ;
30+ import org .testcontainers .postgresql .PostgreSQLContainer ;
31+ import org .testcontainers .utility .DockerImageName ;
2932
30- import java .util .Collections ;
33+ import java .util .HashMap ;
3134import java .util .List ;
35+ import java .util .Map ;
3236
3337import static io .dapr .testcontainers .DaprContainerConstants .DAPR_RUNTIME_IMAGE_TAG ;
3438
4549@ TestConfiguration (proxyBeanMethods = false )
4650public class DaprTestContainersConfig {
4751
52+ Map <String , String > postgreSQLDetails = new HashMap <>();
53+
54+ {{
55+ postgreSQLDetails .put ("host" , "postgresql" );
56+ postgreSQLDetails .put ("user" , "postgres" );
57+ postgreSQLDetails .put ("password" , "postgres" );
58+ postgreSQLDetails .put ("database" , "dapr" );
59+ postgreSQLDetails .put ("port" , "5432" );
60+ postgreSQLDetails .put ("actorStateStore" , String .valueOf (true ));
61+
62+ }}
63+
64+ private Component stateStoreComponent = new Component ("kvstore" ,
65+ "state.postgresql" , "v2" , postgreSQLDetails );
66+
4867 @ Bean
4968 @ ServiceConnection
50- public DaprContainer daprContainer (Network network ) {
69+ public DaprContainer daprContainer (Network network , PostgreSQLContainer postgreSQLContainer ) {
5170
5271 return new DaprContainer (DAPR_RUNTIME_IMAGE_TAG )
5372 .withAppName ("workflow-patterns-app" )
54- .withComponent (new Component ( "kvstore" , "state.in-memory" , "v1" , Collections . singletonMap ( "actorStateStore" , String . valueOf ( true ))) )
73+ .withComponent (stateStoreComponent )
5574 .withAppPort (8080 )
5675 .withNetwork (network )
5776 .withAppHealthCheckPath ("/actuator/health" )
58- .withAppChannelAddress ("host.testcontainers.internal" );
77+ .withAppChannelAddress ("host.testcontainers.internal" )
78+ .dependsOn (postgreSQLContainer );
5979 }
6080
81+ @ Bean
82+ public PostgreSQLContainer postgreSQLContainer (Network network ) {
83+ return new PostgreSQLContainer (DockerImageName .parse ("postgres" ))
84+ .withNetworkAliases ("postgresql" )
85+ .withDatabaseName ("dapr" )
86+ .withUsername ("postgres" )
87+ .withPassword ("postgres" )
88+ .withNetwork (network );
89+ }
6190
6291 @ Bean
6392 MicrocksContainersEnsemble microcksEnsemble (Network network ) {
@@ -66,6 +95,14 @@ MicrocksContainersEnsemble microcksEnsemble(Network network) {
6695 .withMainArtifacts ("third-parties/remote-http-service.yaml" );
6796 }
6897
98+ @ Bean
99+ public WorkflowDashboardContainer workflowDashboard (Network network ) {
100+ return new WorkflowDashboardContainer (WorkflowDashboardContainer .getDefaultImageName ())
101+ .withNetwork (network )
102+ .withStateStoreComponent (stateStoreComponent )
103+ .withExposedPorts (8080 );
104+ }
105+
69106 @ Bean
70107 public DynamicPropertyRegistrar endpointsProperties (MicrocksContainersEnsemble ensemble ) {
71108 // We need to replace the default endpoints with those provided by Microcks.
0 commit comments