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

Clean up usage of jmte Engine and use singleton instance #3564

Merged
merged 1 commit into from
Mar 6, 2017

Conversation

joschi
Copy link
Contributor

@joschi joschi commented Mar 3, 2017

Instead of instantiating the jmte template engine all over the place, this PR cleans up a bit and injects a compiling template engine as a singleton into the relevant classes.

@joschi joschi added this to the 2.3.0 milestone Mar 3, 2017
@dennisoelkers dennisoelkers self-assigned this Mar 3, 2017

@Test
public void testFormat() {

final DecoratorImpl decorator = getDecoratorConfig("${field_a}: ${field_b}", "message", true);

final FormatStringDecorator formatStringDecorator = new FormatStringDecorator(decorator);
final FormatStringDecorator formatStringDecorator = new FormatStringDecorator(decorator, templateEngine);
Copy link
Member

Choose a reason for hiding this comment

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

Why is it not possible to mock out the engine instead of supplying a real instance?

Copy link
Contributor Author

@joschi joschi Mar 6, 2017

Choose a reason for hiding this comment

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

It's possible, but what advantage would using a mock over the real engine have here?

Copy link
Member

Choose a reason for hiding this comment

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

That we are only testing this class and not an external dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In which test case exactly?

FWIW, I'm trying to use real objects and not mocks whenever possible, also see https://martinfowler.com/articles/mocksArentStubs.html#ClassicalAndMockistTesting

Copy link
Member

Choose a reason for hiding this comment

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


@Before
public void setUp() throws Exception {
this.emailAlertSender = new FormattedEmailAlertSender(new EmailConfiguration(), mockNotificationService, mockNodeId);
this.emailAlertSender = new FormattedEmailAlertSender(new EmailConfiguration(), mockNotificationService, mockNodeId, templateEngine);
Copy link
Member

@dennisoelkers dennisoelkers Mar 6, 2017

Choose a reason for hiding this comment

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

It's possible, but what advantage would using a mock over the real engine have here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What advantage would using a mock over the real engine have here?

Copy link
Member

Choose a reason for hiding this comment

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

@dennisoelkers dennisoelkers merged commit 8ddf6d7 into master Mar 6, 2017
@dennisoelkers dennisoelkers deleted the jmte-cleanup branch March 6, 2017 15:38
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.

None yet

2 participants