1
1
/*
2
- * Copyright 2018 LINE Corporation
2
+ * Copyright 2020 LINE Corporation
3
3
*
4
4
* LINE Corporation licenses this file to you under the Apache License,
5
5
* version 2.0 (the "License"); you may not use this file except in compliance
28
28
import java .util .Set ;
29
29
30
30
import org .apache .thrift .async .AsyncMethodCallback ;
31
- import org .junit .Before ;
32
- import org .junit .Rule ;
33
- import org .junit .Test ;
31
+ import org .junit .jupiter .api .BeforeEach ;
32
+ import org .junit .jupiter .api .Test ;
34
33
import org .mockito .Mock ;
35
- import org .mockito .junit .MockitoJUnit ;
36
- import org .mockito .junit .MockitoRule ;
37
34
38
35
import com .google .common .collect .ImmutableList ;
39
36
import com .google .common .collect .ImmutableMap ;
72
69
import com .linecorp .centraldogma .internal .thrift .WatchFileResult ;
73
70
import com .linecorp .centraldogma .internal .thrift .WatchRepositoryResult ;
74
71
75
- public class LegacyCentralDogmaTest {
76
- private static final String TIMESTAMP = "2016-01-02T03:04:05Z" ;
72
+ class LegacyCentralDogmaTest {
77
73
78
- @ Rule
79
- public MockitoRule rule = MockitoJUnit .rule ();
74
+ private static final String TIMESTAMP = "2016-01-02T03:04:05Z" ;
80
75
81
76
@ Mock
82
77
private CentralDogmaService .AsyncIface iface ;
83
78
84
79
private CentralDogma client ;
85
80
86
- @ Before
87
- public void setup () {
81
+ @ BeforeEach
82
+ void setUp () {
88
83
client = new LegacyCentralDogma (CommonPools .workerGroup (), iface );
89
84
}
90
85
91
86
@ Test
92
- public void createProject () throws Exception {
87
+ void createProject () throws Exception {
93
88
doAnswer (invocation -> {
94
89
final AsyncMethodCallback <Void > callback = invocation .getArgument (1 );
95
90
callback .onComplete (null );
@@ -100,7 +95,7 @@ public void createProject() throws Exception {
100
95
}
101
96
102
97
@ Test
103
- public void removeProject () throws Exception {
98
+ void removeProject () throws Exception {
104
99
doAnswer (invocation -> {
105
100
final AsyncMethodCallback <Void > callback = invocation .getArgument (1 );
106
101
callback .onComplete (null );
@@ -111,7 +106,7 @@ public void removeProject() throws Exception {
111
106
}
112
107
113
108
@ Test
114
- public void purgeProject () throws Exception {
109
+ void purgeProject () throws Exception {
115
110
doAnswer (invocation -> {
116
111
final AsyncMethodCallback <Void > callback = invocation .getArgument (1 );
117
112
callback .onComplete (null );
@@ -122,7 +117,7 @@ public void purgeProject() throws Exception {
122
117
}
123
118
124
119
@ Test
125
- public void unremoveProject () throws Exception {
120
+ void unremoveProject () throws Exception {
126
121
doAnswer (invocation -> {
127
122
final AsyncMethodCallback <Void > callback = invocation .getArgument (1 );
128
123
callback .onComplete (null );
@@ -133,7 +128,7 @@ public void unremoveProject() throws Exception {
133
128
}
134
129
135
130
@ Test
136
- public void listProjects () throws Exception {
131
+ void listProjects () throws Exception {
137
132
doAnswer (invocation -> {
138
133
final AsyncMethodCallback <List <Project >> callback = invocation .getArgument (0 );
139
134
callback .onComplete (ImmutableList .of (new Project ("project" )));
@@ -144,7 +139,7 @@ public void listProjects() throws Exception {
144
139
}
145
140
146
141
@ Test
147
- public void listRemovedProjects () throws Exception {
142
+ void listRemovedProjects () throws Exception {
148
143
doAnswer (invocation -> {
149
144
final AsyncMethodCallback <Set <String >> callback = invocation .getArgument (0 );
150
145
callback .onComplete (ImmutableSet .of ("project" ));
@@ -155,7 +150,7 @@ public void listRemovedProjects() throws Exception {
155
150
}
156
151
157
152
@ Test
158
- public void createRepository () throws Exception {
153
+ void createRepository () throws Exception {
159
154
doAnswer (invocation -> {
160
155
final AsyncMethodCallback <Void > callback = invocation .getArgument (2 );
161
156
callback .onComplete (null );
@@ -166,7 +161,7 @@ public void createRepository() throws Exception {
166
161
}
167
162
168
163
@ Test
169
- public void removeRepository () throws Exception {
164
+ void removeRepository () throws Exception {
170
165
doAnswer (invocation -> {
171
166
final AsyncMethodCallback <Void > callback = invocation .getArgument (2 );
172
167
callback .onComplete (null );
@@ -177,7 +172,7 @@ public void removeRepository() throws Exception {
177
172
}
178
173
179
174
@ Test
180
- public void purgeRepository () throws Exception {
175
+ void purgeRepository () throws Exception {
181
176
doAnswer (invocation -> {
182
177
final AsyncMethodCallback <Void > callback = invocation .getArgument (2 );
183
178
callback .onComplete (null );
@@ -188,7 +183,7 @@ public void purgeRepository() throws Exception {
188
183
}
189
184
190
185
@ Test
191
- public void unremoveRepository () throws Exception {
186
+ void unremoveRepository () throws Exception {
192
187
doAnswer (invocation -> {
193
188
final AsyncMethodCallback <Void > callback = invocation .getArgument (2 );
194
189
callback .onComplete (null );
@@ -199,7 +194,7 @@ public void unremoveRepository() throws Exception {
199
194
}
200
195
201
196
@ Test
202
- public void listRepositories () throws Exception {
197
+ void listRepositories () throws Exception {
203
198
doAnswer (invocation -> {
204
199
final AsyncMethodCallback <List <Repository >> callback = invocation .getArgument (1 );
205
200
final Repository repository = new Repository ("repo" ).setHead (
@@ -216,7 +211,7 @@ public void listRepositories() throws Exception {
216
211
}
217
212
218
213
@ Test
219
- public void listRemovedRepositories () throws Exception {
214
+ void listRemovedRepositories () throws Exception {
220
215
doAnswer (invocation -> {
221
216
final AsyncMethodCallback <Set <String >> callback = invocation .getArgument (1 );
222
217
callback .onComplete (ImmutableSet .of ("repo" ));
@@ -227,7 +222,7 @@ public void listRemovedRepositories() throws Exception {
227
222
}
228
223
229
224
@ Test
230
- public void normalizeRevision () throws Exception {
225
+ void normalizeRevision () throws Exception {
231
226
doAnswer (invocation -> {
232
227
final AsyncMethodCallback <TRevision > callback = invocation .getArgument (3 );
233
228
callback .onComplete (new TRevision (3 ));
@@ -239,7 +234,7 @@ public void normalizeRevision() throws Exception {
239
234
}
240
235
241
236
@ Test
242
- public void listFiles () throws Exception {
237
+ void listFiles () throws Exception {
243
238
doAnswer (invocation -> {
244
239
final AsyncMethodCallback <List <TEntry >> callback = invocation .getArgument (4 );
245
240
final TEntry entry = new TEntry ("/a.txt" , TEntryType .TEXT );
@@ -253,13 +248,7 @@ public void listFiles() throws Exception {
253
248
}
254
249
255
250
@ Test
256
- public void getFiles () throws Exception {
257
- doAnswer (invocation -> {
258
- final AsyncMethodCallback <com .linecorp .centraldogma .internal .thrift .Revision > callback =
259
- invocation .getArgument (3 );
260
- callback .onComplete (new com .linecorp .centraldogma .internal .thrift .Revision (1 , 0 ));
261
- return null ;
262
- }).when (iface ).normalizeRevision (any (), any (), any (), any ());
251
+ void getFiles () throws Exception {
263
252
doAnswer (invocation -> {
264
253
final AsyncMethodCallback <List <TEntry >> callback = invocation .getArgument (4 );
265
254
final TEntry entry = new TEntry ("/b.txt" , TEntryType .TEXT );
@@ -273,7 +262,7 @@ public void getFiles() throws Exception {
273
262
}
274
263
275
264
@ Test
276
- public void getHistory () throws Exception {
265
+ void getHistory () throws Exception {
277
266
doAnswer (invocation -> {
278
267
final AsyncMethodCallback <List <TCommit >> callback = invocation .getArgument (5 );
279
268
callback .onComplete (ImmutableList .of (new TCommit (
@@ -294,7 +283,7 @@ public void getHistory() throws Exception {
294
283
}
295
284
296
285
@ Test
297
- public void getDiffs () throws Exception {
286
+ void getDiffs () throws Exception {
298
287
doAnswer (invocation -> {
299
288
final AsyncMethodCallback <List <TChange >> callback = invocation .getArgument (5 );
300
289
final TChange change = new TChange ("/a.txt" , ChangeType .UPSERT_TEXT );
@@ -308,7 +297,7 @@ public void getDiffs() throws Exception {
308
297
}
309
298
310
299
@ Test
311
- public void getPreviewDiffs () throws Exception {
300
+ void getPreviewDiffs () throws Exception {
312
301
doAnswer (invocation -> {
313
302
final AsyncMethodCallback <List <TChange >> callback = invocation .getArgument (4 );
314
303
final TChange change = new TChange ("/a.txt" , ChangeType .UPSERT_TEXT );
@@ -323,7 +312,7 @@ public void getPreviewDiffs() throws Exception {
323
312
}
324
313
325
314
@ Test
326
- public void push () throws Exception {
315
+ void push () throws Exception {
327
316
doAnswer (invocation -> {
328
317
final AsyncMethodCallback <TCommit > callback = invocation .getArgument (7 );
329
318
callback .onComplete (new TCommit (
@@ -345,13 +334,7 @@ public void push() throws Exception {
345
334
}
346
335
347
336
@ Test
348
- public void getFile () throws Exception {
349
- doAnswer (invocation -> {
350
- final AsyncMethodCallback <com .linecorp .centraldogma .internal .thrift .Revision > callback =
351
- invocation .getArgument (3 );
352
- callback .onComplete (new com .linecorp .centraldogma .internal .thrift .Revision (1 , 0 ));
353
- return null ;
354
- }).when (iface ).normalizeRevision (any (), any (), any (), any ());
337
+ void getFile () throws Exception {
355
338
doAnswer (invocation -> {
356
339
final AsyncMethodCallback <GetFileResult > callback = invocation .getArgument (4 );
357
340
callback .onComplete (new GetFileResult (TEntryType .TEXT , "content" ));
@@ -363,13 +346,7 @@ public void getFile() throws Exception {
363
346
}
364
347
365
348
@ Test
366
- public void getFile_path () throws Exception {
367
- doAnswer (invocation -> {
368
- final AsyncMethodCallback <com .linecorp .centraldogma .internal .thrift .Revision > callback =
369
- invocation .getArgument (3 );
370
- callback .onComplete (new com .linecorp .centraldogma .internal .thrift .Revision (1 , 0 ));
371
- return null ;
372
- }).when (iface ).normalizeRevision (any (), any (), any (), any ());
349
+ void getFile_path () throws Exception {
373
350
doAnswer (invocation -> {
374
351
final AsyncMethodCallback <GetFileResult > callback = invocation .getArgument (4 );
375
352
callback .onComplete (new GetFileResult (TEntryType .TEXT , "content" ));
@@ -381,7 +358,7 @@ public void getFile_path() throws Exception {
381
358
}
382
359
383
360
@ Test
384
- public void mergeFiles () throws Exception {
361
+ void mergeFiles () throws Exception {
385
362
doAnswer (invocation -> {
386
363
final AsyncMethodCallback <MergedEntry > callback = invocation .getArgument (4 );
387
364
callback .onComplete (new MergedEntry (new TRevision (1 ), TEntryType .JSON , "{\" foo\" : \" bar\" }" ,
@@ -399,7 +376,7 @@ public void mergeFiles() throws Exception {
399
376
}
400
377
401
378
@ Test
402
- public void diffFile () throws Exception {
379
+ void diffFile () throws Exception {
403
380
doAnswer (invocation -> {
404
381
final AsyncMethodCallback <DiffFileResult > callback = invocation .getArgument (5 );
405
382
callback .onComplete (new DiffFileResult (ChangeType .UPSERT_TEXT , "some_text" ));
@@ -412,7 +389,7 @@ public void diffFile() throws Exception {
412
389
}
413
390
414
391
@ Test
415
- public void watchRepository () throws Exception {
392
+ void watchRepository () throws Exception {
416
393
doAnswer (invocation -> {
417
394
final AsyncMethodCallback <WatchRepositoryResult > callback = invocation .getArgument (5 );
418
395
callback .onComplete (new WatchRepositoryResult ().setRevision (new TRevision (42 )));
@@ -424,7 +401,7 @@ public void watchRepository() throws Exception {
424
401
}
425
402
426
403
@ Test
427
- public void watchRepositoryTimedOut () throws Exception {
404
+ void watchRepositoryTimedOut () throws Exception {
428
405
doAnswer (invocation -> {
429
406
AsyncMethodCallback <WatchRepositoryResult > callback = invocation .getArgument (5 );
430
407
callback .onComplete (new WatchRepositoryResult ());
@@ -436,7 +413,7 @@ public void watchRepositoryTimedOut() throws Exception {
436
413
}
437
414
438
415
@ Test
439
- public void watchFile () throws Exception {
416
+ void watchFile () throws Exception {
440
417
doAnswer (invocation -> {
441
418
AsyncMethodCallback <WatchFileResult > callback = invocation .getArgument (5 );
442
419
callback .onComplete (new WatchFileResult ().setRevision (new TRevision (42 ))
@@ -450,7 +427,7 @@ public void watchFile() throws Exception {
450
427
}
451
428
452
429
@ Test
453
- public void watchFileTimedOut () throws Exception {
430
+ void watchFileTimedOut () throws Exception {
454
431
doAnswer (invocation -> {
455
432
AsyncMethodCallback <WatchFileResult > callback = invocation .getArgument (5 );
456
433
callback .onComplete (new WatchFileResult ());
0 commit comments