7
7
import io .github .lvyahui8 .spring .autoconfigure .BeanAggregateProperties ;
8
8
import io .github .lvyahui8 .spring .example .context .ExampleAppContext ;
9
9
import io .github .lvyahui8 .spring .example .context .RequestContext ;
10
+ import io .github .lvyahui8 .spring .example .facade .UserQueryFacade ;
10
11
import io .github .lvyahui8 .spring .example .model .Category ;
11
12
import io .github .lvyahui8 .spring .example .model .Post ;
12
13
import io .github .lvyahui8 .spring .example .model .User ;
31
32
@ Slf4j
32
33
public class DataBeanAggregateQueryFacadeTest {
33
34
35
+ private static final int NUM = 100 ;
36
+
34
37
@ Autowired
35
38
private DataBeanAggregateQueryFacade dataBeanAggregateQueryFacade ;
36
39
37
40
@ Autowired
38
41
private BeanAggregateProperties beanAggregateProperties ;
39
42
43
+ @ Autowired
44
+ UserQueryFacade userQueryFacade ;
45
+
46
+ @ Test
47
+ public void testSample () throws Exception {
48
+ {
49
+ User user = dataBeanAggregateQueryFacade .get ("userWithPosts" , Collections .singletonMap ("userId" ,1L ), User .class );
50
+ Assert .notNull (user ,"user not null" );
51
+ Assert .notNull (user .getPosts (),"user posts not null" );
52
+ log .info ("user.name:{},user.posts.size:{}" ,
53
+ user .getUsername (),user .getPosts ().size ());
54
+ }
55
+
56
+ log .info ("------------------------------------------------------------------" );
57
+
58
+ {
59
+ User user = userQueryFacade .getUserFinal (1L );
60
+ Assert .notNull (user .getFollowers (),"user followers not null" );
61
+ }
62
+
63
+ log .info ("------------------------------------------------------------------" );
64
+
65
+ {
66
+ for (int i = 0 ; i < NUM ; i ++) {
67
+ String s = dataBeanAggregateQueryFacade .get ("categoryTitle" , Collections .singletonMap ("categoryId" , 1L ), String .class );
68
+ Assert .isTrue (org .apache .commons .lang3 .StringUtils .isNotEmpty (s ),"s not null" );
69
+ }
70
+ }
71
+ }
72
+
40
73
@ Test
41
74
public void testExceptionProcessing () throws Exception {
42
75
boolean success = false ;
@@ -46,15 +79,12 @@ public void testExceptionProcessing() throws Exception {
46
79
Collections .singletonMap ("userId" , 1L ), User .class );
47
80
} catch (Exception e ) {
48
81
log .info ("default settings is SUSPEND, catch an exception: {}" ,e .getMessage (),e );
49
- success = true ;
50
82
}
51
83
} else {
52
84
User user = dataBeanAggregateQueryFacade .get ("userWithPosts" ,
53
85
Collections .singletonMap ("userId" , 1L ), User .class );
54
- System .out .println (user );
55
- success = true ;
86
+ Assert .notNull (user ,"user must be not null!" );
56
87
}
57
- Assert .isTrue (success ,"exception handle success" );
58
88
}
59
89
60
90
@ Test
0 commit comments