use of org.sonar.java.se.checks.SECheck in project sonar-java by SonarSource.
the class ExceptionalCheckBasedYieldTest method exceptionType_is_required.
@Test
public void exceptionType_is_required() {
thrown.expect(IllegalArgumentException.class);
final Class<? extends SECheck> seCheckClass = new SECheck() {
}.getClass();
String exceptionType = null;
new ExceptionalCheckBasedYield(SV_CAUSING_EXCEPTION, exceptionType, seCheckClass, null, mockMethodBehavior());
}
use of org.sonar.java.se.checks.SECheck in project sonar-java by SonarSource.
the class ExceptionalCheckBasedYieldTest method test_equals.
@Test
public void test_equals() {
final Class<? extends SECheck> seCheckClass1 = new SECheck() {
}.getClass();
final Class<? extends SECheck> seCheckClass2 = (new SECheck() {
}).getClass();
MethodBehavior mb = mockMethodBehavior();
String mockedExceptionType1 = "SomeException";
ExceptionalCheckBasedYield yield = new ExceptionalCheckBasedYield(SV_CAUSING_EXCEPTION, mockedExceptionType1, seCheckClass1, null, mb);
ExceptionalYield otherYield = new ExceptionalCheckBasedYield(SV_CAUSING_EXCEPTION, mockedExceptionType1, seCheckClass1, null, mb);
assertThat(yield).isNotEqualTo(null);
assertThat(yield).isEqualTo(yield);
assertThat(yield).isEqualTo(otherYield);
// same exception, but simple exceptional yield
otherYield = new ExceptionalYield(null, mb);
otherYield.setExceptionType(mockedExceptionType1);
assertThat(yield).isNotEqualTo(otherYield);
// same exception, different SV
otherYield = new ExceptionalCheckBasedYield(new SymbolicValue(), mockedExceptionType1, seCheckClass2, null, mb);
assertThat(yield).isNotEqualTo(otherYield);
// same exception, different check
otherYield = new ExceptionalCheckBasedYield(SV_CAUSING_EXCEPTION, mockedExceptionType1, seCheckClass2, null, mb);
assertThat(yield).isNotEqualTo(otherYield);
// different exception, same check
otherYield = new ExceptionalCheckBasedYield(SV_CAUSING_EXCEPTION, "SomeOtherException", seCheckClass1, null, mb);
assertThat(yield).isNotEqualTo(otherYield);
}
Aggregations