feat: Add example unit test for running Activiti 7 process#315
feat: Add example unit test for running Activiti 7 process#315igdianov wants to merge 5 commits into
Conversation
|
@slamkalukas I have created a PR with example unit test for Activiti7 process: #315. Let me know if you have any questions |
erdemedeiros
left a comment
There was a problem hiding this comment.
Thank you @igdianov that's a useful example. See my questions below.
|
|
||
| } | ||
|
|
||
| public static class TestIntegrationResultSender { |
There was a problem hiding this comment.
Wouldn't be easier to add the dependency to activiti-cloud-starter-connector in test scope so you can use the provided IntegrationResultSender?
activiti-cloud-starter-connector is also bringing IntegrationResultBuilder: https://github.com/Activiti/ttc-connectors-dummytwitter/blob/master/src/main/java/org/activiti/cloud/connectors/twitter/connectors/TweetConnector.java#L60
There was a problem hiding this comment.
@erdemedeiros I have tried to add starter connector dependency in test scope. It is causing a problem with overriding bean definitions:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.2.RELEASE)
2019-08-26 00:28:16.265 INFO [-,,,] 15596 --- [ main] o.a.c.r.RuntimeBundleApplicationTest : No active profile set, falling back to default profiles: default
2019-08-26 00:28:17.037 INFO [-,,,] 15596 --- [ main] o.s.c.a.ConfigurationClassParser : Properties location [classpath:/activiti-audit-producer.properties] not resolvable: class path resource [activiti-audit-producer.properties] cannot be opened because it does not exist
2019-08-26 00:28:17.235 INFO [-,,,] 15596 --- [ main] o.s.c.a.ConfigurationClassParser : Properties location [classpath:/activiti-audit-producer.properties] not resolvable: class path resource [activiti-audit-producer.properties] cannot be opened because it does not exist
2019-08-26 00:28:18.653 WARN [-,,,] 15596 --- [ main] o.s.w.c.s.GenericWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'keycloakPreAuthActionsFilter' defined in class path resource [org/activiti/cloud/services/identity/keycloak/config/RuntimeBundleSecurityAutoConfiguration.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=runtimeBundleSecurityAutoConfiguration; factoryMethodName=keycloakPreAuthActionsFilter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/activiti/cloud/services/identity/keycloak/config/RuntimeBundleSecurityAutoConfiguration.class]] for bean 'keycloakPreAuthActionsFilter': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=commonSecurityAutoConfiguration; factoryMethodName=keycloakPreAuthActionsFilter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/activiti/cloud/services/common/security/keycloak/config/CommonSecurityAutoConfiguration.class]] bound.
2019-08-26 00:28:18.663 INFO [-,,,] 15596 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-08-26 00:28:18.668 ERROR [-,,,] 15596 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'keycloakPreAuthActionsFilter', defined in class path resource [org/activiti/cloud/services/identity/keycloak/config/RuntimeBundleSecurityAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/activiti/cloud/services/common/security/keycloak/config/CommonSecurityAutoConfiguration.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
There was a problem hiding this comment.
After enabling bean override, it blows up with the error due to component scan:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-08-26 00:38:47.794 ERROR [-,,,] 37240 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'commonSecurityAutoConfiguration': Unsatisfied dependency expressed through field 'keycloakConfigResolver'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'runtimeBundleSecurityAutoConfiguration': Unsatisfied dependency expressed through field 'keycloakConfigResolver'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'KeycloakConfigResolver': Requested bean is currently in creation: Is there an unresolvable circular reference?
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
There was a problem hiding this comment.
@erdemedeiros The activiti-cloud-starter-connector module component scan problem is fixed now. I have updated unit test example to use IntegrationResultBuilder and removed hacks from previous commits.
70f9dee to
7bf3b7c
Compare
2f72dc0 to
d2f5a08
Compare
d2f5a08 to
80fbca0
Compare
This PR adds example how to create a unit test for Activiti7 process with Cloud Connector task using Spring Test Integration Binder: https://cloud.spring.io/spring-cloud-static/spring-cloud-stream/2.1.0.RELEASE/multi/multi__testing.html#spring_integration_test_binder
Fixes Activiti/Activiti#2865