1717import org .omg .sysml .ApiException ;
1818import org .omg .sysml .Configuration ;
1919import org .omg .sysml .model .Commit ;
20- import org .omg .sysml .model .CommitContainingProject ;
2120import org .omg .sysml .model .Element ;
2221import org .omg .sysml .model .ElementVersion ;
2322import org .omg .sysml .model .Project ;
24- import org .omg .sysml .model .Record ;
2523
2624import java .util .UUID ;
2725import org .junit .Test ;
3533import java .util .List ;
3634
3735/**
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
3840 * API tests for CommitApi
3941 */
4042@ FixMethodOrder (MethodSorters .NAME_ASCENDING )
@@ -43,8 +45,8 @@ public class CommitApiTest {
4345 private final static CommitApi api = new CommitApi ();
4446 private final static ProjectApi projectApi = new ProjectApi ();
4547 private static UUID projectId ;
46- // private static UUID commitId;
47- private static Commit commit ;
48+ private static UUID commitId ;
49+ // private static Commit commit;
4850
4951 @ BeforeClass
5052 public static void setUp () {
@@ -64,22 +66,6 @@ public static void setUp() {
6466
6567 }
6668
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- }
8369 /**
8470 * Get commits by project
8571 *
@@ -88,29 +74,28 @@ public void getCommitByProjectAndIdTest() throws ApiException {
8874 * if the Api call fails
8975 */
9076 @ Test
91- public void get2CommitsByProjectTest () {
77+ public void a_getCommitsByProjectTest () {
9278
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 ;
10882 }
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+ }
10996
11097 }
111-
112-
113-
98+
11499 /**
115100 * Get commit by project and ID
116101 *
@@ -120,21 +105,23 @@ public void get2CommitsByProjectTest() {
120105 * if the Api call fails
121106 */
122107 @ 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" );
138125 }
139126 }
140127
@@ -168,7 +155,7 @@ public void postCommitByProjectTest() {
168155 elementVersion .setId (UUID .randomUUID ());
169156 //elementVersion.setIdentity(identity);
170157
171- CommitContainingProject containingProject = new CommitContainingProject ();
158+ /* CommitContainingProject containingProject = new CommitContainingProject();
172159 containingProject.setId(UUID.randomUUID());
173160
174161 body.addChangeItem(elementVersion);
@@ -178,7 +165,7 @@ public void postCommitByProjectTest() {
178165 Record previousCommit = new Record();
179166 previousCommit.setId(commit.getId());
180167 body.setPreviousCommit(previousCommit);
181-
168+ */
182169 UUID branchId = null ;
183170
184171 try {
0 commit comments