Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private SqlSource createSqlSource(Object parameterObject) {
private Throwable extractRootCause(Exception e) {
Throwable cause = e;
while(cause.getCause() != null) {
cause = e.getCause();
cause = cause.getCause();
}
return cause;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import static org.junit.jupiter.api.Assertions.fail;

import java.io.Reader;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -391,6 +390,20 @@ void invokeError() throws NoSuchMethodException {
}
}

@Test
void invokeNestedError() throws NoSuchMethodException {
try {
Class<?> mapperType = ErrorMapper.class;
Method mapperMethod = mapperType.getMethod("invokeNestedError");
new ProviderSqlSource(new Configuration(),
mapperMethod.getAnnotation(SelectProvider.class), mapperType, mapperMethod)
.getBoundSql(new Object());
fail();
} catch (BuilderException e) {
assertTrue(e.getMessage().contains("Error invoking SqlProvider method 'public java.lang.String org.apache.ibatis.submitted.sqlprovider.SqlProviderTest$ErrorSqlBuilder.invokeNestedError()' with specify parameter 'class java.lang.Object'. Cause: java.lang.UnsupportedOperationException: invokeNestedError"));
}
}

@Test
void invalidArgumentsCombination() throws NoSuchMethodException {
try {
Expand Down Expand Up @@ -670,6 +683,9 @@ public interface ErrorMapper {
@SelectProvider(type = ErrorSqlBuilder.class, method = "invokeError")
void invokeError();

@SelectProvider(type = ErrorSqlBuilder.class, method = "invokeNestedError")
void invokeNestedError();

@SelectProvider(type = ErrorSqlBuilder.class, method = "multipleProviderContext")
void multipleProviderContext();

Expand Down Expand Up @@ -702,6 +718,10 @@ public String invokeError() {
throw new UnsupportedOperationException("invokeError");
}

public String invokeNestedError() {
throw new IllegalStateException(new UnsupportedOperationException("invokeNestedError"));
}

public String multipleProviderContext(ProviderContext providerContext1, ProviderContext providerContext2) {
throw new UnsupportedOperationException("multipleProviderContext");
}
Expand Down