@@ -81,7 +81,6 @@ public abstract class AbstractMavenTest {
81
81
.addPlugin (FileLocation .of ("../property-dump-plugin/target/property-dump-plugin-1-SNAPSHOT.jar" ))
82
82
.build ();
83
83
84
- protected HttpConnector wsConnector ;
85
84
protected WsClient wsClient ;
86
85
87
86
@ BeforeAll
@@ -125,11 +124,11 @@ protected static String[] cleanPackageSonarGoal() {
125
124
126
125
@ BeforeEach
127
126
public void setUpWsClient () {
128
- wsConnector = HttpConnector .newBuilder ()
127
+ wsClient = WsClientFactories .getDefault ()
128
+ .newClient (HttpConnector .newBuilder ()
129
129
.url (ORCHESTRATOR .getServer ().getUrl ())
130
130
.credentials (Server .ADMIN_LOGIN , Server .ADMIN_PASSWORD )
131
- .build ();
132
- wsClient = WsClientFactories .getDefault ().newClient (wsConnector );
131
+ .build ());
133
132
}
134
133
135
134
protected static Version mojoVersion () {
@@ -152,24 +151,24 @@ protected static Version mojoVersion() {
152
151
}
153
152
154
153
@ CheckForNull
155
- static Measure getMeasure (String componentKey , String metricKey ) {
156
- Measures .ComponentWsResponse response = newWsClient () .measures ().component (new ComponentRequest ()
154
+ Measure getMeasure (String componentKey , String metricKey ) {
155
+ Measures .ComponentWsResponse response = wsClient .measures ().component (new ComponentRequest ()
157
156
.setComponent (componentKey )
158
157
.setMetricKeys (singletonList (metricKey )));
159
158
List <Measure > measures = response .getComponent ().getMeasuresList ();
160
159
return measures .size () == 1 ? measures .get (0 ) : null ;
161
160
}
162
161
163
162
@ CheckForNull
164
- static Integer getMeasureAsInteger (String componentKey , String metricKey ) {
163
+ Integer getMeasureAsInteger (String componentKey , String metricKey ) {
165
164
Measure measure = getMeasure (componentKey , metricKey );
166
165
return (measure == null ) ? null : Integer .parseInt (measure .getValue ());
167
166
}
168
167
169
168
@ CheckForNull
170
- static Component getComponent (String componentKey ) {
169
+ Component getComponent (String componentKey ) {
171
170
try {
172
- return newWsClient () .components ().show (new ShowRequest ().setComponent (componentKey )).getComponent ();
171
+ return wsClient .components ().show (new ShowRequest ().setComponent (componentKey )).getComponent ();
173
172
} catch (HttpException e ) {
174
173
if (e .code () == 404 ) {
175
174
return null ;
@@ -178,19 +177,6 @@ static Component getComponent(String componentKey) {
178
177
}
179
178
}
180
179
181
- static WsClient newWsClient () {
182
- return WsClientFactories .getDefault ().newClient (HttpConnector .newBuilder ()
183
- .url (ORCHESTRATOR .getServer ().getUrl ())
184
- .build ());
185
- }
186
-
187
- static WsClient newAuthenticatedWsClient () {
188
- return WsClientFactories .getDefault ().newClient (HttpConnector .newBuilder ()
189
- .url (ORCHESTRATOR .getServer ().getUrl ())
190
- .credentials (Server .ADMIN_LOGIN , Server .ADMIN_PASSWORD )
191
- .build ());
192
- }
193
-
194
180
Version mavenVersion = null ;
195
181
196
182
protected Version getMavenVersion () {
@@ -222,7 +208,7 @@ public BuildResult executeBuildAndValidateWithCE(Build<?> build) {
222
208
return validateBuildWithCE (ORCHESTRATOR .executeBuild (build ));
223
209
}
224
210
225
- public static BuildResult validateBuildWithCE (BuildResult result ) {
211
+ public BuildResult validateBuildWithCE (BuildResult result ) {
226
212
assertBuildResultStatuses (result , 0 );
227
213
List <String > ceTaskIds = extractCETaskIds (result );
228
214
if (ceTaskIds .isEmpty ()) {
@@ -272,10 +258,9 @@ public static List<String> extractCETaskIds(BuildResult result) {
272
258
private static final long POLLING_TIME = 500 ; // 0.5 second
273
259
private static final long MAX_WAIT_TIME = 20_000 ; // 20 seconds
274
260
275
- private static void waitForCeTaskToBeFinished (String ceTaskId ) {
261
+ private void waitForCeTaskToBeFinished (String ceTaskId ) {
276
262
LOG .info ("Waiting for CE task {} to be finished" , ceTaskId );
277
263
try {
278
- WsClient wsClient = newAuthenticatedWsClient ();
279
264
long start = System .currentTimeMillis ();
280
265
while (true ) {
281
266
TaskStatus status = wsClient .ce ().task (new TaskRequest ().setId (ceTaskId )).getTask ().getStatus ();
0 commit comments