2323
2424package org .gitlab4j .api ;
2525
26- import org .gitlab4j .api .GitLabApi .ApiVersion ;
27- import org .gitlab4j .api .models .*;
28- import org .glassfish .jersey .internal .guava .Lists ;
29- import org .junit .*;
30- import org .junit .runners .MethodSorters ;
26+ import static org .junit .Assert .assertEquals ;
27+ import static org .junit .Assert .assertNotNull ;
28+ import static org .junit .Assume .assumeTrue ;
3129
32- import javax .ws .rs .core .Response ;
3330import java .util .Arrays ;
3431import java .util .List ;
35- import java .util .Map ;
36- import java .util .Optional ;
3732
38- import static org .junit .Assert .*;
39- import static org .junit .Assume .assumeTrue ;
33+ import org .gitlab4j .api .GitLabApi .ApiVersion ;
34+ import org .gitlab4j .api .models .Project ;
35+ import org .gitlab4j .api .models .Runner ;
36+ import org .gitlab4j .api .models .RunnerDetail ;
37+ import org .junit .Before ;
38+ import org .junit .BeforeClass ;
39+ import org .junit .FixMethodOrder ;
40+ import org .junit .Test ;
41+ import org .junit .runners .MethodSorters ;
4042
4143/**
4244 * In order for these tests to run you must set the following properties in ~/test-gitlab4j.properties
4345 * <p>
4446 * TEST_NAMESPACE
45- * TEST_PROJECT_NAME
4647 * TEST_HOST_URL
4748 * TEST_PRIVATE_TOKEN
48- * TEST_GROUP_PROJECT
4949 * <p>
5050 * If any of the above are NULL, all tests in this class will be skipped.
5151 * <p>
@@ -56,24 +56,15 @@ public class TestRunnersApi {
5656
5757 // The following needs to be set to your test repository
5858 private static final String TEST_NAMESPACE ;
59- private static final String TEST_PROJECT_NAME ;
6059 private static final String TEST_HOST_URL ;
6160 private static final String TEST_PRIVATE_TOKEN ;
62- private static final String TEST_GROUP ;
63- private static final String TEST_GROUP_PROJECT ;
6461
6562 static {
6663 TEST_NAMESPACE = TestUtils .getProperty ("TEST_NAMESPACE" );
67- TEST_PROJECT_NAME = TestUtils .getProperty ("TEST_PROJECT_NAME" );
6864 TEST_HOST_URL = TestUtils .getProperty ("TEST_HOST_URL" );
6965 TEST_PRIVATE_TOKEN = TestUtils .getProperty ("TEST_PRIVATE_TOKEN" );
70- TEST_GROUP = TestUtils .getProperty ("TEST_GROUP" );
71- TEST_GROUP_PROJECT = TestUtils .getProperty ("TEST_GROUP_PROJECT" );
7266 }
7367
74- private static final String TEST_PROJECT_NAME_1 = "test-gitlab4j-create-project" ;
75- private static final String TEST_PROJECT_NAME_2 = "test-gitlab4j-create-project-2" ;
76- private static final String TEST_PROJECT_NAME_UPDATE = "test-gitlab4j-create-project-update" ;
7768 private static GitLabApi gitLabApi ;
7869
7970 public TestRunnersApi () {
@@ -112,34 +103,25 @@ public static void setup() throws GitLabApiException {
112103 }
113104
114105 allRunners = gitLabApi .getRunnersApi ().getAllRunners ();
115-
116106 assertEquals (0 , allRunners .size ());
117107 }
118-
119108 }
120109
121110 /**
122111 * creates a new runner for a random project
123112 */
124- private static void createRunner () throws GitLabApiException {
113+ private static Runner createRunner () throws GitLabApiException {
125114
126- // WHEN
127115 Project project = gitLabApi .getProjectApi ().getProjects ().get (0 );
128116 project = gitLabApi .getProjectApi ().getProject (project .getId ());
129117 String runnersToken = project .getRunnersToken ();
130118
131- // THEN
132- gitLabApi .getRunnersApi ().registerRunner (runnersToken ,
119+ return (gitLabApi .getRunnersApi ().registerRunner (runnersToken ,
133120 "Junit registered runner" , true ,
134121 Arrays .asList ("wow" ), false ,
135- false , null );
136-
137- // ASSERT
138- List <Runner > allRunners = gitLabApi .getRunnersApi ().getAllRunners ();
139-
122+ false , null ));
140123 }
141124
142-
143125 @ Before
144126 public void beforeMethod () throws GitLabApiException {
145127 assumeTrue (gitLabApi != null );
@@ -150,42 +132,34 @@ public void beforeMethod() throws GitLabApiException {
150132 RunnerDetail runnerDetail = gitLabApi .getRunnersApi ().getRunnerDetail (runner .getId ());
151133 gitLabApi .getRunnersApi ().deleteRunner (runnerDetail .getToken ());
152134 }
153-
154135 }
155136
156137 @ Test
157138 public void shouldHaveRunnerDetails () throws GitLabApiException {
158139
159- createRunner ();
140+ assertNotNull ( "Runner was not created" , createRunner () );
160141
161142 List <Runner > runners = gitLabApi .getRunnersApi ().getAllRunners ();
162-
163143 assertEquals (1 , runners .size ());
164144 assertNotNull ("Description should not be null" , runners .get (0 ).getDescription ());
165-
166145 }
167146
168147 @ Test
169148 public void shouldDeleteRunner () throws GitLabApiException {
170149
171- createRunner ();
172- createRunner ();
173- createRunner ();
150+ assertNotNull ( "Runner was not created" , createRunner () );
151+ assertNotNull ( "Runner was not created" , createRunner () );
152+ assertNotNull ( "Runner was not created" , createRunner () );
174153
175154 List <Runner > allRunners = gitLabApi .getRunnersApi ().getAllRunners ();
176155 assertEquals (3 , allRunners .size ());
177156
178-
179157 for (Runner runner : allRunners ) {
180158 RunnerDetail runnerDetail = gitLabApi .getRunnersApi ().getRunnerDetail (runner .getId ());
181159 gitLabApi .getRunnersApi ().deleteRunner (runnerDetail .getToken ());
182160 }
183161
184162 allRunners = gitLabApi .getRunnersApi ().getAllRunners ();
185163 assertEquals (0 , allRunners .size ());
186-
187-
188164 }
189-
190-
191165}
0 commit comments