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

refactor: fix unit tests after app-config changes #359

Merged
merged 1 commit into from
Dec 23, 2020

Conversation

pleku
Copy link
Contributor

@pleku pleku commented Dec 23, 2020

Adds necessary mocking for application configuration for CdiServlet
in unit tests.

Related to vaadin/flow#9642

Adds necessary mocking for application configuration for CdiServlet
in unit tests.

Related to vaadin/flow#9642
@pleku pleku requested a review from denis-anisimov December 23, 2020 09:28
@@ -61,6 +66,14 @@ public void setUp() throws ServletException {
Mockito.when(servletContext.getAttribute(Lookup.class.getName()))
.thenReturn(lookup);

final DefaultApplicationConfigurationFactory applicationConfigurationFactory

Choose a reason for hiding this comment

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

There is no need to mock DefaultApplicationConfigurationFactory or its interface.
It's enough to properly mock ServletContext:
the ApplicationConfiguration is retrieved from the context by the attribute ApplicationConfiguration.class.getName().

If there is no attribute value then the factory is called. But if the attribute is given right away then it will be just returned without asking the factory.

But this is not really important. It just allows to reduce a number of lines.

@pleku pleku merged commit ee39f39 into master Dec 23, 2020
@pleku pleku deleted the fix/appconfiguration branch December 23, 2020 10:23
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

Successfully merging this pull request may close these issues.

2 participants