17
17
18
18
package com .cdancy .bitbucket .rest .features ;
19
19
20
- import static org .assertj .core .api .Assertions .assertThat ;
21
- import static org .assertj .core .api .Assertions .fail ;
22
-
23
20
import com .cdancy .bitbucket .rest .BaseBitbucketApiLiveTest ;
24
21
import com .cdancy .bitbucket .rest .domain .branch .Branch ;
25
22
import com .cdancy .bitbucket .rest .domain .branch .BranchModel ;
23
+ import com .cdancy .bitbucket .rest .domain .branch .BranchModelConfiguration ;
26
24
import com .cdancy .bitbucket .rest .domain .branch .BranchPage ;
27
25
import com .cdancy .bitbucket .rest .domain .branch .BranchPermission ;
28
26
import com .cdancy .bitbucket .rest .domain .branch .BranchPermissionEnumType ;
29
27
import com .cdancy .bitbucket .rest .domain .branch .BranchPermissionPage ;
30
28
import com .cdancy .bitbucket .rest .domain .branch .Matcher ;
29
+ import com .cdancy .bitbucket .rest .domain .branch .Type ;
31
30
import com .cdancy .bitbucket .rest .domain .pullrequest .User ;
32
31
import com .cdancy .bitbucket .rest .options .CreateBranch ;
33
32
import org .testng .annotations .AfterClass ;
37
36
import java .util .ArrayList ;
38
37
import java .util .List ;
39
38
39
+ import static org .assertj .core .api .Assertions .assertThat ;
40
+ import static org .assertj .core .api .Assertions .fail ;
41
+
40
42
@ Test (groups = "live" , testName = "BranchApiLiveTest" , singleThreaded = true )
41
43
public class BranchApiLiveTest extends BaseBitbucketApiLiveTest {
42
44
@@ -53,6 +55,7 @@ public class BranchApiLiveTest extends BaseBitbucketApiLiveTest {
53
55
String commitHash = "5284b6cec569346855710b535dafb915423110c2" ;
54
56
String existingGroup = "dev-group" ;
55
57
Long branchPermissionId = null ;
58
+ BranchModelConfiguration branchModelConfiguration = null ;
56
59
57
60
String defaultBranchId = "refs/heads/master" ;
58
61
@@ -62,6 +65,7 @@ public void init() {
62
65
assertThat (branch ).isNotNull ();
63
66
assertThat (branch .errors ().isEmpty ()).isTrue ();
64
67
defaultBranchId = branch .id ();
68
+ commitHash = branch .latestCommit ();
65
69
}
66
70
67
71
@ Test
@@ -136,6 +140,48 @@ public void testDeleteBranchPermission() {
136
140
}
137
141
}
138
142
143
+ @ Test (dependsOnMethods = {"testCreateBranch" , "testListBranches" })
144
+ public void testGetBranchModelConfiguration () {
145
+ branchModelConfiguration = api ().getModelConfiguration (projectKey , repoKey );
146
+ checkDefaultBranchConfiguration ();
147
+ }
148
+
149
+ @ Test (dependsOnMethods = {"testCreateBranch" , "testListBranches" })
150
+ public void testGetBranchModelConfigurationOnError () {
151
+ BranchModelConfiguration configuration = api ().getModelConfiguration (projectKey , "12345" );
152
+ assertThat (configuration .errors ()).isNotEmpty ();
153
+ assertThat (configuration .development ()).isNull ();
154
+ assertThat (configuration .production ()).isNull ();
155
+ assertThat (configuration .types ()).isEmpty ();
156
+ }
157
+
158
+ private void checkDefaultBranchConfiguration () {
159
+ assertThat (branchModelConfiguration ).isNotNull ();
160
+ assertThat (branchModelConfiguration .errors ().isEmpty ()).isTrue ();
161
+ assertThat (branchModelConfiguration .development ().refId ()).isNotNull ();
162
+ assertThat (branchModelConfiguration .production ()).isNull ();
163
+ assertThat (branchModelConfiguration .types ().size () == 4 );
164
+ for (Type type : branchModelConfiguration .types ()) {
165
+ switch (type .id ()) {
166
+ case BUGFIX :
167
+ assertThat (type .prefix ()).isEqualTo ("bugfix/" );
168
+ break ;
169
+ case HOTFIX :
170
+ assertThat (type .prefix ()).isEqualTo ("hotfix/" );
171
+ break ;
172
+ case FEATURE :
173
+ assertThat (type .prefix ()).isEqualTo ("feature/" );
174
+ break ;
175
+ case RELEASE :
176
+ assertThat (type .prefix ()).isEqualTo ("release/" );
177
+ break ;
178
+ default :
179
+ break ;
180
+ }
181
+ assertThat (type .enabled ()).isTrue ();
182
+ }
183
+ }
184
+
139
185
@ AfterClass
140
186
public void fin () {
141
187
boolean success = api ().updateDefault (projectKey , repoKey , defaultBranchId );
0 commit comments