Skip to content
This repository has been archived by the owner on May 18, 2020. It is now read-only.

feat: Add example unit test for running Activiti 7 process #315

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

igdianov
Copy link
Contributor

@igdianov igdianov commented Aug 17, 2019

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

image

Fixes Activiti/Activiti#2865

@igdianov igdianov self-assigned this Aug 17, 2019
@igdianov igdianov requested a review from erdemedeiros August 17, 2019 07:49
@igdianov
Copy link
Contributor Author

@slamkalukas I have created a PR with example unit test for Activiti7 process: #315. Let me know if you have any questions

Copy link
Contributor

@erdemedeiros erdemedeiros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @igdianov that's a useful example. See my questions below.


}

public static class TestIntegrationResultSender {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

@igdianov igdianov force-pushed the igdianov-GH-2865-add-connector-process-unti-test branch from 70f9dee to 7bf3b7c Compare August 26, 2019 07:17
@igdianov igdianov force-pushed the igdianov-GH-2865-add-connector-process-unti-test branch 2 times, most recently from 2f72dc0 to d2f5a08 Compare September 11, 2019 20:11
@igdianov igdianov force-pushed the igdianov-GH-2865-add-connector-process-unti-test branch from d2f5a08 to 80fbca0 Compare September 12, 2019 05:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add example unit test for running Activiti 7 process
2 participants