Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spring test support for CallActivity mocking #104

Open
ghost opened this issue Dec 4, 2019 · 3 comments
Open

Add spring test support for CallActivity mocking #104

ghost opened this issue Dec 4, 2019 · 3 comments

Comments

@ghost
Copy link

ghost commented Dec 4, 2019

Following code is not working for Spring tests:
CallActivityMock deployFlowMock = ProcessExpressions.registerCallActivityMock(testDeployFlow).onExecutionAddVariable("var", "val"); deployFlowMock.deploy(processEngine);
As I think it happens because of using different contexts for mocks. I went deep to the mocking code and saw that all stubs are registered with Mocks.register(name, instance); and it puts into static ThreadLocal map. But Spring doesn't see this things.
Could you provide an API which will register mocks depends on current context (which we can define with annotation, for example)?

@fml2
Copy link
Contributor

fml2 commented Mar 22, 2020

Since I also think this would be a very useful feature, I hat a take at this. My intermediate result is in https://github.com/fml2/camunda-bpm-mockito/tree/feature/Mock-CallActivity-in-Spring-context.

The usage would be:

new CallActivityMockForSpringContext(processKey, springBeanRegistry).... (all the known methods from CallActivityMock)

Please gurus look at this and tell me whether the approach is a promising one.

For now, I can't figure out how to get a SingletonBeanRegistry (used in my class) given an ApplicationContext (usually available in a spring based test).

@jangalinski
Copy link
Collaborator

I appreciate your contribution. Unfortunately, I was having trouble reviewing this ... I am locally not able to build this ... I guess this is some problem on my machine, please give me a day or two to fix this.

@fml2
Copy link
Contributor

fml2 commented Apr 3, 2020

Have you had a chance to look at this?

jangalinski pushed a commit that referenced this issue Nov 3, 2020
* feat: Registering mock delegates as spring beans

* chore: Added comment

* fix: Added constructor with ApplicationContext parameter

Had to make spring-context a needed library
@jangalinski jangalinski added this to the BACKLOG milestone Apr 29, 2022
@jangalinski jangalinski removed this from the BACKLOG milestone Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants