### Question:
RollbackRule implements Serializable { public int getDepth(Throwable ex) { return getDepth(ex.getClass(), 0); } RollbackRule(String exceptionName);  RollbackRule(Class<?> clazz); String getExceptionName(); int getDepth(Throwable ex); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void foundImmediatelyWithString() { RollbackRule rr = new RollbackRule(Exception.class.getName()); assertThat(rr.getDepth(new Exception())).isEqualTo(0); }
@Test public void notFound() { RollbackRule rr = new RollbackRule(java.io.IOException.class.getName()); assertThat(rr.getDepth(new MyRuntimeException(""))).isEqualTo(-1); }
@Test public void ancestry() { RollbackRule rr = new RollbackRule(java.lang.Exception.class.getName()); assertThat(rr.getDepth(new MyRuntimeException(""))).isEqualTo(2); }
@Test public void alwaysTrueForThrowable() { RollbackRule rr = new RollbackRule(java.lang.Throwable.class.getName()); assertThat(rr.getDepth(new MyRuntimeException("")) > 0).isTrue(); assertThat(rr.getDepth(new IOException()) > 0).isTrue(); assertThat(rr.getDepth(new ShouldNeverHappenException(null, null)) > 0).isTrue(); assertThat(rr.getDepth(new RuntimeException()) > 0).isTrue(); }