22
22
import static org .junit .jupiter .api .Assertions .fail ;
23
23
24
24
import java .io .Reader ;
25
+ import java .lang .annotation .Annotation ;
25
26
import java .lang .reflect .Method ;
26
27
import java .util .ArrayList ;
27
28
import java .util .Collections ;
@@ -299,13 +300,13 @@ void methodOverload() throws NoSuchMethodException {
299
300
300
301
@ Test
301
302
@ SuppressWarnings ("deprecation" )
302
- void notSqlProvider () {
303
+ void notSqlProvider () throws NoSuchMethodException {
304
+ Object testAnnotation = getClass ().getDeclaredMethod ("notSqlProvider" ).getAnnotation (Test .class );
303
305
try {
304
- new ProviderSqlSource (new Configuration (), new Object (), null , null );
306
+ new ProviderSqlSource (new Configuration (), testAnnotation );
305
307
fail ();
306
308
} catch (BuilderException e ) {
307
- assertTrue (e .getMessage ().contains ("Error creating SqlSource for SqlProvider." ));
308
- assertTrue (e .getCause ().getCause ().getCause ().getMessage ().contains ("java.lang.Object.type()" ));
309
+ assertTrue (e .getMessage ().contains ("Error creating SqlSource for SqlProvider. Cause: java.lang.NoSuchMethodException: org.junit.jupiter.api.Test.type()" ));
309
310
}
310
311
}
311
312
@@ -650,15 +651,6 @@ void providerContextAndMap() {
650
651
}
651
652
}
652
653
653
- @ Test
654
- @ SuppressWarnings ("deprecation" )
655
- void keepBackwardCompatibilityOnDeprecatedConstructor () throws NoSuchMethodException {
656
- Class <?> mapperType = StaticMethodSqlProviderMapper .class ;
657
- Method mapperMethod = mapperType .getMethod ("noArgument" );
658
- ProviderSqlSource sqlSource = new ProviderSqlSource (new Configuration (), new SqlProviderConfig (), mapperType , mapperMethod );
659
- assertEquals ("SELECT 1" , sqlSource .getBoundSql (null ).getSql ());
660
- }
661
-
662
654
@ Test
663
655
@ SuppressWarnings ("deprecation" )
664
656
void keepBackwardCompatibilityOnDeprecatedConstructorWithAnnotation () throws NoSuchMethodException {
@@ -668,23 +660,6 @@ void keepBackwardCompatibilityOnDeprecatedConstructorWithAnnotation() throws NoS
668
660
assertEquals ("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS" , sqlSource .getBoundSql (null ).getSql ());
669
661
}
670
662
671
- public static class SqlProviderConfig {
672
- public Class <?> type () {
673
- return SqlProvider .class ;
674
- }
675
- public Class <?> value () {
676
- return void .class ;
677
- }
678
- public String method () {
679
- return "provideSql" ;
680
- }
681
- public static class SqlProvider {
682
- public static String provideSql () {
683
- return "SELECT 1" ;
684
- }
685
- }
686
- }
687
-
688
663
public interface ErrorMapper {
689
664
@ SelectProvider (type = ErrorSqlBuilder .class , method = "methodNotFound" )
690
665
void methodNotFound ();
0 commit comments