mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 17:07:15 +02:00
Use assertThrows() to avoid having empty catch blocks
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=173439894
This commit is contained in:
parent
ea1ed3219b
commit
e02ee5b647
1 changed files with 4 additions and 19 deletions
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.util;
|
package google.registry.util;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.junit.Assert.fail;
|
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -125,12 +125,7 @@ public class ComparingInvocationHandlerTest {
|
||||||
when(myActualMock.func(3, "str")).thenThrow(myException);
|
when(myActualMock.func(3, "str")).thenThrow(myException);
|
||||||
when(mySecondMock.func(3, "str")).thenReturn(SECOND_RESULT);
|
when(mySecondMock.func(3, "str")).thenReturn(SECOND_RESULT);
|
||||||
|
|
||||||
try {
|
assertThrows(MyException.class, () -> comparator.func(3, "str"));
|
||||||
comparator.func(3, "str");
|
|
||||||
fail("Should have thrown MyException");
|
|
||||||
} catch (MyException expected) {
|
|
||||||
}
|
|
||||||
|
|
||||||
assertThat(log)
|
assertThat(log)
|
||||||
.containsExactly(
|
.containsExactly(
|
||||||
String.format(
|
String.format(
|
||||||
|
@ -162,12 +157,7 @@ public class ComparingInvocationHandlerTest {
|
||||||
when(myActualMock.func(3, "str")).thenThrow(myException);
|
when(myActualMock.func(3, "str")).thenThrow(myException);
|
||||||
when(mySecondMock.func(3, "str")).thenThrow(myOtherException);
|
when(mySecondMock.func(3, "str")).thenThrow(myOtherException);
|
||||||
|
|
||||||
try {
|
assertThrows(MyException.class, () -> comparator.func(3, "str"));
|
||||||
comparator.func(3, "str");
|
|
||||||
fail("Should have thrown MyException");
|
|
||||||
} catch (MyException expected) {
|
|
||||||
}
|
|
||||||
|
|
||||||
assertThat(log).isEmpty();
|
assertThat(log).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,12 +169,7 @@ public class ComparingInvocationHandlerTest {
|
||||||
when(myActualMock.func(3, "str")).thenThrow(myException);
|
when(myActualMock.func(3, "str")).thenThrow(myException);
|
||||||
when(mySecondMock.func(3, "str")).thenThrow(myOtherException);
|
when(mySecondMock.func(3, "str")).thenThrow(myOtherException);
|
||||||
|
|
||||||
try {
|
assertThrows(MyException.class, () -> comparator.func(3, "str"));
|
||||||
comparator.func(3, "str");
|
|
||||||
fail("Should have thrown MyException");
|
|
||||||
} catch (MyException expected) {
|
|
||||||
}
|
|
||||||
|
|
||||||
assertThat(log)
|
assertThat(log)
|
||||||
.containsExactly(
|
.containsExactly(
|
||||||
String.format(
|
String.format(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue