46
46
*/
47
47
@ SpringBootTest (classes = BasicConfiguration .class )
48
48
@ CassandraKeyspace
49
- public class CassandraOperationsIntegrationTests {
49
+ class CassandraOperationsIntegrationTests {
50
50
51
51
52
52
@ Autowired CqlSession session ;
53
53
@ Autowired CassandraOperations template ;
54
54
55
55
@ BeforeEach
56
- public void setUp () throws Exception {
56
+ void setUp () throws Exception {
57
57
template .getCqlOperations ().execute ("TRUNCATE users" );
58
58
}
59
59
@@ -62,20 +62,20 @@ public void setUp() throws Exception {
62
62
* mapping layer.
63
63
*/
64
64
@ Test
65
- public void insertAndSelect () {
65
+ void insertAndSelect () {
66
66
67
- Insert insert = QueryBuilder .insertInto ("users" ).value ("user_id" , QueryBuilder .literal (42L )) //
67
+ var insert = QueryBuilder .insertInto ("users" ).value ("user_id" , QueryBuilder .literal (42L )) //
68
68
.value ("uname" , QueryBuilder .literal ("heisenberg" )) //
69
69
.value ("fname" , QueryBuilder .literal ("Walter" )) //
70
70
.value ("lname" , QueryBuilder .literal ("White" )) //
71
71
.ifNotExists (); //
72
72
73
73
template .getCqlOperations ().execute (insert .asCql ());
74
74
75
- User user = template .selectOneById (42L , User .class );
75
+ var user = template .selectOneById (42L , User .class );
76
76
assertThat (user .getUsername ()).isEqualTo ("heisenberg" );
77
77
78
- List < User > users = template .select (QueryBuilder .selectFrom ("users" ).all ().asCql (), User .class );
78
+ var users = template .select (QueryBuilder .selectFrom ("users" ).all ().asCql (), User .class );
79
79
assertThat (users ).hasSize (1 );
80
80
assertThat (users .get (0 )).isEqualTo (user );
81
81
}
@@ -85,9 +85,9 @@ public void insertAndSelect() {
85
85
* {@code select}.
86
86
*/
87
87
@ Test
88
- public void insertAndUpdate () {
88
+ void insertAndUpdate () {
89
89
90
- User user = new User ();
90
+ var user = new User ();
91
91
user .setId (42L );
92
92
user .setUsername ("heisenberg" );
93
93
user .setFirstname ("Walter" );
@@ -98,7 +98,7 @@ public void insertAndUpdate() {
98
98
user .setFirstname (null );
99
99
template .update (user );
100
100
101
- User loaded = template .selectOneById (42L , User .class );
101
+ var loaded = template .selectOneById (42L , User .class );
102
102
assertThat (loaded .getUsername ()).isEqualTo ("heisenberg" );
103
103
assertThat (loaded .getFirstname ()).isNull ();
104
104
}
@@ -107,25 +107,25 @@ public void insertAndUpdate() {
107
107
* Asynchronous query execution using callbacks.
108
108
*/
109
109
@ Test
110
- public void insertAsynchronously () throws InterruptedException {
110
+ void insertAsynchronously () throws InterruptedException {
111
111
112
- User user = new User ();
112
+ var user = new User ();
113
113
user .setId (42L );
114
114
user .setUsername ("heisenberg" );
115
115
user .setFirstname ("Walter" );
116
116
user .setLastname ("White" );
117
117
118
- final CountDownLatch countDownLatch = new CountDownLatch (1 );
118
+ final var countDownLatch = new CountDownLatch (1 );
119
119
120
- AsyncCassandraTemplate asyncTemplate = new AsyncCassandraTemplate (session );
120
+ var asyncTemplate = new AsyncCassandraTemplate (session );
121
121
122
- ListenableFuture < User > future = asyncTemplate .insert (user );
122
+ var future = asyncTemplate .insert (user );
123
123
124
124
future .addCallback (it -> countDownLatch .countDown (), throwable -> countDownLatch .countDown ());
125
125
126
126
countDownLatch .await (5 , TimeUnit .SECONDS );
127
127
128
- User loaded = template .selectOneById (user .getId (), User .class );
128
+ var loaded = template .selectOneById (user .getId (), User .class );
129
129
assertThat (loaded ).isEqualTo (user );
130
130
}
131
131
@@ -135,20 +135,20 @@ public void insertAsynchronously() throws InterruptedException {
135
135
*/
136
136
@ Test
137
137
@ SuppressWarnings ("unchecked" )
138
- public void selectProjections () {
138
+ void selectProjections () {
139
139
140
- User user = new User ();
140
+ var user = new User ();
141
141
user .setId (42L );
142
142
user .setUsername ("heisenberg" );
143
143
user .setFirstname ("Walter" );
144
144
user .setLastname ("White" );
145
145
146
146
template .insert (user );
147
147
148
- Long id = template .selectOne (QueryBuilder .selectFrom ("users" ).column ("user_id" ).asCql (), Long .class );
148
+ var id = template .selectOne (QueryBuilder .selectFrom ("users" ).column ("user_id" ).asCql (), Long .class );
149
149
assertThat (id ).isEqualTo (user .getId ());
150
150
151
- Row row = template .selectOne (QueryBuilder .selectFrom ("users" ).column ("user_id" ).asCql (), Row .class );
151
+ var row = template .selectOne (QueryBuilder .selectFrom ("users" ).column ("user_id" ).asCql (), Row .class );
152
152
assertThat (row .getLong (0 )).isEqualTo (user .getId ());
153
153
154
154
Map <String , Object > map = template .selectOne (QueryBuilder .selectFrom ("users" ).all ().asCql (), Map .class );
0 commit comments