justinleet commented on a change in pull request #1554: METRON-2307: Migrate to
JUnit5
URL: https://github.com/apache/metron/pull/1554#discussion_r347037300
##########
File path:
metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/GrokServiceImplTest.java
##########
@@ -84,44 +78,37 @@ public void
getCommonGrokPattersShouldCallGrokToGetPatternsAndNotAlterValue() th
}
@Test
- public void
validateGrokStatementShouldThrowExceptionWithNullStringAsPatternLabel() throws
Exception {
- exception.expect(RestException.class);
- exception.expectMessage("Pattern label is required");
-
+ public void
validateGrokStatementShouldThrowExceptionWithNullStringAsPatternLabel() {
GrokValidation grokValidation = new GrokValidation();
grokValidation.setResults(new HashMap<>());
grokValidation.setSampleData("asdf asdf");
grokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2}");
- grokService.validateGrokStatement(grokValidation);
+ RestException e = assertThrows(RestException.class, () ->
grokService.validateGrokStatement(grokValidation));
+ assertEquals("Pattern label is required", e.getMessage());
}
@Test
- public void
validateGrokStatementShouldThrowExceptionWithEmptyStringAsStatement() throws
Exception {
- exception.expect(RestException.class);
- exception.expectMessage("Grok statement is required");
-
+ public void
validateGrokStatementShouldThrowExceptionWithEmptyStringAsStatement() {
GrokValidation grokValidation = new GrokValidation();
grokValidation.setResults(new HashMap<>());
grokValidation.setSampleData("asdf asdf");
grokValidation.setPatternLabel("LABEL");
grokValidation.setStatement("");
- grokService.validateGrokStatement(grokValidation);
+ RestException e = assertThrows(RestException.class, () ->
grokService.validateGrokStatement(grokValidation));
Review comment:
Good catch. Added.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services