17
17
import org .omg .sysml .ApiException ;
18
18
import org .omg .sysml .Configuration ;
19
19
import org .omg .sysml .model .Commit ;
20
- import org .omg .sysml .model .CommitContainingProject ;
21
20
import org .omg .sysml .model .Element ;
22
21
import org .omg .sysml .model .ElementVersion ;
23
22
import org .omg .sysml .model .Project ;
24
- import org .omg .sysml .model .Record ;
25
23
26
24
import java .util .UUID ;
27
25
import org .junit .Test ;
35
33
import java .util .List ;
36
34
37
35
/**
36
+ * test name is prefixed with alphabet to control order
37
+ * using @FixMethodOrder(MethodSorters.NAME_ASCENDING)
38
+ * WIP - getByproject return but using the commitId to get the Commit failed
39
+ * WIP - post
38
40
* API tests for CommitApi
39
41
*/
40
42
@ FixMethodOrder (MethodSorters .NAME_ASCENDING )
@@ -43,8 +45,8 @@ public class CommitApiTest {
43
45
private final static CommitApi api = new CommitApi ();
44
46
private final static ProjectApi projectApi = new ProjectApi ();
45
47
private static UUID projectId ;
46
- // private static UUID commitId;
47
- private static Commit commit ;
48
+ private static UUID commitId ;
49
+ // private static Commit commit;
48
50
49
51
@ BeforeClass
50
52
public static void setUp () {
@@ -64,22 +66,6 @@ public static void setUp() {
64
66
65
67
}
66
68
67
- /**
68
- * Get commit by project and ID
69
- *
70
- *
71
- *
72
- * @throws ApiException
73
- * if the Api call fails
74
- */
75
- @ Test
76
- public void getCommitByProjectAndIdTest () throws ApiException {
77
- UUID projectId = null ;
78
- UUID commitId = null ;
79
- Commit response = api .getCommitByProjectAndId (projectId , commitId );
80
-
81
- // TODO: test validations
82
- }
83
69
/**
84
70
* Get commits by project
85
71
*
@@ -88,29 +74,28 @@ public void getCommitByProjectAndIdTest() throws ApiException {
88
74
* if the Api call fails
89
75
*/
90
76
@ Test
91
- public void get2CommitsByProjectTest () {
77
+ public void a_getCommitsByProjectTest () {
92
78
93
- if (projectId == null )
94
- fail ("Failed - no project is available." );
95
- else {
96
- String pageAfter = null ;
97
- String pageBefore = null ;
98
- Integer pageSize = null ;
99
- try {
100
- List <Commit > response = api .getCommitsByProject (projectId , pageAfter , pageBefore , pageSize );
101
- System .out .println ("=== getCommitsByProjectTest() ===\n " + response );
102
- assertTrue (response .size () > 0 );
103
- commit = response .get (0 );
104
- } catch (ApiException e ) {
105
- e .printStackTrace ();
106
- fail ("Failed - no project available to query commit." );
107
- }
79
+ if (projectId == null ) {
80
+ fail ("Failed - no project available." );
81
+ return ;
108
82
}
83
+
84
+ String pageAfter = null ;
85
+ String pageBefore = null ;
86
+ Integer pageSize = null ;
87
+ try {
88
+ List <Commit > response = api .getCommitsByProject (projectId , pageAfter , pageBefore , pageSize );
89
+ System .out .println ("=== getCommitsByProjectTest() ===\n " + response );
90
+ assertTrue (response .size () > 0 );
91
+ commitId = response .get (0 ).getId ();
92
+ } catch (ApiException e ) {
93
+ e .printStackTrace ();
94
+ fail ("Failed - no Commit returned." );
95
+ }
109
96
110
97
}
111
-
112
-
113
-
98
+
114
99
/**
115
100
* Get commit by project and ID
116
101
*
@@ -120,21 +105,23 @@ public void get2CommitsByProjectTest() {
120
105
* if the Api call fails
121
106
*/
122
107
@ Test
123
- public void get3CommitByProjectAndIdTest () {
124
- UUID commitId ;
125
- if (projectId == null )
126
- fail ("Failed - no project is available." );
127
- else if ((commitId = commit .getId ()) == null )
128
- fail ("Failed - no commit is available." );
129
- else {
130
- try {
131
- Commit response = api .getCommitByProjectAndId (projectId , commitId );
132
- System .out .println ("=== getCommitByProjectAndIdTest() ===\n " + response );
133
- assertTrue (response != null );
134
- } catch (ApiException e ) {
135
- e .printStackTrace ();
136
- fail ("Failed - response(Commit) is null" );
137
- }
108
+ public void b_getCommitByProjectAndIdTest () {
109
+
110
+ if (projectId == null ) {
111
+ fail ("Failed - no project available." );
112
+ return ;
113
+ }
114
+ if (commitId == null ) {
115
+ fail ("Failed - no commitId available" );
116
+ }
117
+
118
+ try {
119
+ Commit response = api .getCommitByProjectAndId (projectId , commitId );
120
+ System .out .println ("=== b_getCommitByProjectAndIdTest() ===\n " + response );
121
+ assertTrue (response != null );
122
+ } catch (ApiException e ) {
123
+ e .printStackTrace ();
124
+ fail ("Failed - response(Commit) is null" );
138
125
}
139
126
}
140
127
@@ -168,7 +155,7 @@ public void postCommitByProjectTest() {
168
155
elementVersion .setId (UUID .randomUUID ());
169
156
//elementVersion.setIdentity(identity);
170
157
171
- CommitContainingProject containingProject = new CommitContainingProject ();
158
+ /* CommitContainingProject containingProject = new CommitContainingProject();
172
159
containingProject.setId(UUID.randomUUID());
173
160
174
161
body.addChangeItem(elementVersion);
@@ -178,7 +165,7 @@ public void postCommitByProjectTest() {
178
165
Record previousCommit = new Record();
179
166
previousCommit.setId(commit.getId());
180
167
body.setPreviousCommit(previousCommit);
181
-
168
+ */
182
169
UUID branchId = null ;
183
170
184
171
try {
0 commit comments