1
1
/*
2
- * Copyright 2019 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
23
23
import static org .assertj .core .api .Assertions .assertThat ;
24
24
import static org .assertj .core .api .Assertions .assertThatThrownBy ;
25
25
26
- import org .junit .Rule ;
27
- import org .junit .Test ;
26
+ import org .junit .jupiter . api . Test ;
27
+ import org .junit .jupiter . api . extension . RegisterExtension ;
28
28
29
29
import com .linecorp .centraldogma .common .Author ;
30
30
import com .linecorp .centraldogma .common .ChangeConflictException ;
31
31
import com .linecorp .centraldogma .common .ProjectExistsException ;
32
32
import com .linecorp .centraldogma .common .RepositoryExistsException ;
33
33
import com .linecorp .centraldogma .common .RepositoryNotFoundException ;
34
34
import com .linecorp .centraldogma .server .command .Command ;
35
- import com .linecorp .centraldogma .testing .internal .ProjectManagerRule ;
35
+ import com .linecorp .centraldogma .testing .internal .ProjectManagerExtension ;
36
36
37
- public class MetadataServiceTest {
37
+ class MetadataServiceTest {
38
38
39
- @ Rule
40
- public final ProjectManagerRule rule = new ProjectManagerRule () {
39
+ @ RegisterExtension
40
+ final ProjectManagerExtension manager = new ProjectManagerExtension () {
41
41
@ Override
42
42
protected void afterExecutorStarted () {
43
43
MigrationUtil .migrate (projectManager (), executor ());
44
44
// Create a project and its metadata here.
45
45
executor ().execute (Command .createProject (author , project1 )).join ();
46
46
}
47
+
48
+ @ Override
49
+ protected boolean runForEachTest () {
50
+ return true ;
51
+ }
47
52
};
48
53
49
54
private static final String project1 = "foo" ;
@@ -60,14 +65,13 @@ protected void afterExecutorStarted() {
60
65
new PerRolePermissions (READ_WRITE , NO_PERMISSION , NO_PERMISSION );
61
66
62
67
@ Test
63
- public void project () throws Exception {
64
- final MetadataService mds = newMetadataService (rule );
68
+ void project () {
69
+ final MetadataService mds = newMetadataService (manager );
65
70
66
71
ProjectMetadata metadata ;
67
72
metadata = mds .getProject (project1 ).join ();
68
73
69
- assertThatThrownBy (() -> rule .executor ().execute (Command .createProject (author , project1 ))
70
- .join ())
74
+ assertThatThrownBy (() -> manager .executor ().execute (Command .createProject (author , project1 )).join ())
71
75
.hasCauseInstanceOf (ProjectExistsException .class );
72
76
73
77
assertThat (metadata .name ()).isEqualTo (project1 );
@@ -91,8 +95,8 @@ public void project() throws Exception {
91
95
}
92
96
93
97
@ Test
94
- public void repository () throws Exception {
95
- final MetadataService mds = newMetadataService (rule );
98
+ void repository () {
99
+ final MetadataService mds = newMetadataService (manager );
96
100
97
101
final ProjectMetadata metadata ;
98
102
RepositoryMetadata repositoryMetadata ;
@@ -135,8 +139,8 @@ public void repository() throws Exception {
135
139
}
136
140
137
141
@ Test
138
- public void perRolePermissions () throws Exception {
139
- final MetadataService mds = newMetadataService (rule );
142
+ void perRolePermissions () {
143
+ final MetadataService mds = newMetadataService (manager );
140
144
141
145
final ProjectMetadata metadata ;
142
146
RepositoryMetadata repositoryMetadata ;
@@ -170,8 +174,8 @@ public void perRolePermissions() throws Exception {
170
174
}
171
175
172
176
@ Test
173
- public void perUserPermissions () throws Exception {
174
- final MetadataService mds = newMetadataService (rule );
177
+ void perUserPermissions () {
178
+ final MetadataService mds = newMetadataService (manager );
175
179
176
180
mds .addRepo (author , project1 , repo1 , ownerOnly ).join ();
177
181
@@ -210,8 +214,8 @@ public void perUserPermissions() throws Exception {
210
214
}
211
215
212
216
@ Test
213
- public void perTokenPermissions () throws Exception {
214
- final MetadataService mds = newMetadataService (rule );
217
+ void perTokenPermissions () {
218
+ final MetadataService mds = newMetadataService (manager );
215
219
216
220
mds .addRepo (author , project1 , repo1 , ownerOnly ).join ();
217
221
mds .createToken (author , app1 ).join ();
@@ -250,8 +254,8 @@ public void perTokenPermissions() throws Exception {
250
254
}
251
255
252
256
@ Test
253
- public void removeMember () throws Exception {
254
- final MetadataService mds = newMetadataService (rule );
257
+ void removeMember () {
258
+ final MetadataService mds = newMetadataService (manager );
255
259
256
260
mds .addRepo (author , project1 , repo1 , ownerOnly ).join ();
257
261
@@ -277,8 +281,8 @@ public void removeMember() throws Exception {
277
281
}
278
282
279
283
@ Test
280
- public void removeToken () throws Exception {
281
- final MetadataService mds = newMetadataService (rule );
284
+ void removeToken () {
285
+ final MetadataService mds = newMetadataService (manager );
282
286
283
287
mds .addRepo (author , project1 , repo1 , ownerOnly ).join ();
284
288
mds .createToken (author , app1 ).join ();
@@ -303,8 +307,8 @@ public void removeToken() throws Exception {
303
307
}
304
308
305
309
@ Test
306
- public void destroyToken () throws Exception {
307
- final MetadataService mds = newMetadataService (rule );
310
+ void destroyToken () {
311
+ final MetadataService mds = newMetadataService (manager );
308
312
309
313
mds .addRepo (author , project1 , repo1 , ownerOnly ).join ();
310
314
mds .createToken (author , app1 ).join ();
@@ -331,8 +335,8 @@ public void destroyToken() throws Exception {
331
335
}
332
336
333
337
@ Test
334
- public void tokenActivationAndDeactivation () throws Exception {
335
- final MetadataService mds = newMetadataService (rule );
338
+ void tokenActivationAndDeactivation () {
339
+ final MetadataService mds = newMetadataService (manager );
336
340
337
341
Token token ;
338
342
mds .createToken (author , app1 ).join ();
@@ -343,6 +347,7 @@ public void tokenActivationAndDeactivation() throws Exception {
343
347
mds .deactivateToken (author , app1 ).join ();
344
348
token = mds .getTokens ().join ().get (app1 );
345
349
assertThat (token .isActive ()).isFalse ();
350
+ assertThat (token .deactivation ()).isNotNull ();
346
351
assertThat (token .deactivation ().user ()).isEqualTo (owner .id ());
347
352
348
353
mds .activateToken (author , app1 ).join ();
@@ -354,8 +359,8 @@ private static RepositoryMetadata getRepo1(MetadataService mds) {
354
359
return metadata .repo (repo1 );
355
360
}
356
361
357
- private static MetadataService newMetadataService (ProjectManagerRule rule ) {
358
- return new MetadataService (rule .projectManager (), rule .executor ());
362
+ private static MetadataService newMetadataService (ProjectManagerExtension extension ) {
363
+ return new MetadataService (extension .projectManager (), extension .executor ());
359
364
}
360
365
361
366
private static ProjectMetadata getProject (MetadataService mds , String projectName ) {
0 commit comments