Files
java-tutorials/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredThrowableExceptionIntegrationTest.java
T
Loredana Crusoveanu 7ab2f437ee Revert "BAEL-4134"
2020-07-07 14:18:10 +03:00

26 lines
866 B
Java

package com.baeldung.undeclared;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.lang.reflect.UndeclaredThrowableException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = UndeclaredApplication.class)
public class UndeclaredThrowableExceptionIntegrationTest {
@Autowired private UndeclaredService service;
@Test
public void givenAnAspect_whenCallingAdvisedMethod_thenShouldWrapTheException() {
assertThatThrownBy(service::doSomething)
.isInstanceOf(UndeclaredThrowableException.class)
.hasCauseInstanceOf(SomeCheckedException.class);
}
}