-
Notifications
You must be signed in to change notification settings - Fork 12.9k
[ci] Use assertj/fluent exceptions for cleaner unit testing #977
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/** | ||
* Copyright 2009-2016 the original author or authors. | ||
* Copyright 2009-2017 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -17,17 +17,10 @@ | |
|
||
import java.util.Map; | ||
import org.junit.Assert; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
|
||
import static org.hamcrest.core.Is.is; | ||
|
||
public class ParameterExpressionTest { | ||
|
||
@Rule | ||
public ExpectedException expectedException = ExpectedException.none(); | ||
|
||
@Test | ||
public void simpleProperty() { | ||
Map<String, String> result = new ParameterExpression("id"); | ||
|
@@ -133,16 +126,20 @@ public void shouldIgnoreLeadingAndTrailingSpaces() { | |
|
||
@Test | ||
public void invalidOldJdbcTypeFormat() { | ||
expectedException.expect(BuilderException.class); | ||
expectedException.expectMessage(is("Parsing error in {id:} in position 3")); | ||
new ParameterExpression("id:"); | ||
try { | ||
new ParameterExpression("id:"); | ||
} catch (BuilderException e) { | ||
e.getMessage().contains("Parsing error in {id:} in position 3"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hazendaz , There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! I'll go back through and add those. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, and it also needs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it! I'll try to take care of those tomorrow night. |
||
} | ||
} | ||
|
||
@Test | ||
public void invalidJdbcTypeOptUsingExpression() { | ||
expectedException.expect(BuilderException.class); | ||
expectedException.expectMessage(is("Parsing error in {(expression)+} in position 12")); | ||
new ParameterExpression("(expression)+"); | ||
try { | ||
new ParameterExpression("(expression)+"); | ||
} catch (BuilderException e) { | ||
e.getMessage().contains("Parsing error in {(expression)+} in position 12"); | ||
} | ||
} | ||
|
||
} |
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hazendaz Is need
catch-exception
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the junit rules needed switched to something. So this was required in a number of cases. In fact, I ended up just clearing all junit rules entirely out. One major benefit to using this method is that catch exception proxies the exception so code coverage on unit test looks better. That library isn't necessary once on java 8 though. For now just needed something to fill the gap. Although direct usage of try/catch with reading the exceptions would have also worked.