-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change example rule detection used for template testing
Changed to use underscore instead of hyphen as hyphens make things awkward when templating. Also added dup check for detection value names and warning.
- Loading branch information
Showing
5 changed files
with
133 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...s/stroom-analytics-impl/src/test/java/stroom/analytics/impl/TestAnalyticsServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package stroom.analytics.impl; | ||
|
||
import stroom.ui.config.shared.AnalyticUiDefaultConfig; | ||
import stroom.util.logging.LambdaLogger; | ||
import stroom.util.logging.LambdaLoggerFactory; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class TestAnalyticsServiceImpl { | ||
|
||
private static final LambdaLogger LOGGER = LambdaLoggerFactory.getLogger(TestAnalyticsServiceImpl.class); | ||
|
||
@Mock | ||
private EmailSender mockEmailSender; | ||
|
||
final RuleEmailTemplatingService templatingService = new RuleEmailTemplatingService(); | ||
|
||
/** | ||
* Verify that our example template from config works with our example detection | ||
*/ | ||
@Test | ||
void testExampleDetection() { | ||
final AnalyticsServiceImpl analyticsService = new AnalyticsServiceImpl( | ||
mockEmailSender, | ||
templatingService); | ||
|
||
final Detection exampleDetection = analyticsService.getExampleDetection(); | ||
final String template = new AnalyticUiDefaultConfig().getDefaultBodyTemplate(); | ||
final String output = templatingService.renderTemplate(exampleDetection, template); | ||
|
||
LOGGER.info("output:\n{}", output); | ||
|
||
assertThat(output) | ||
.contains("<li><strong>name_1</strong>: value_A</li>") | ||
.contains("<li><strong>name_4</strong>: </li>") | ||
.contains("<li>Environment: Test Environment, Stream ID: 1001, Event ID: 2</li>"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
* Change the key names in the example rule detection to remove `-`. Not sensible to encourage keys with a `-` in them as that prevents doing `values.key-1`. Also add a warning if there are multiple detection values with the same name/key (only the first will be used in each case). | ||
|
||
|
||
```sh | ||
# ONLY the top line will be included as a change entry in the CHANGELOG. | ||
# The entry should be in GitHub flavour markdown and should be written on a SINGLE | ||
# line with no hard breaks. You can have multiple change files for a single GitHub issue. | ||
# The entry should be written in the imperative mood, i.e. 'Fix nasty bug' rather than | ||
# 'Fixed nasty bug'. | ||
# | ||
# Examples of acceptable entries are: | ||
# | ||
# | ||
# * Issue **123** : Fix bug with an associated GitHub issue in this repository | ||
# | ||
# * Issue **namespace/other-repo#456** : Fix bug with an associated GitHub issue in another repository | ||
# | ||
# * Fix bug with no associated GitHub issue. | ||
``` |