Skip to content

Commit 235f4d7

Browse files
sbrannenmarcphilipp
authored andcommitted
Polish [Suite]LauncherDiscoveryRequestBuilder
See #3695 See #3702 (cherry picked from commit e9f1bcc)
1 parent 90ab1fb commit 235f4d7

File tree

2 files changed

+105
-99
lines changed

2 files changed

+105
-99
lines changed

junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/LauncherDiscoveryRequestBuilder.java

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public LauncherDiscoveryRequestBuilder() {
124124
}
125125

126126
/**
127-
* Add all of the supplied {@code selectors} to the request.
127+
* Add all supplied {@code selectors} to the request.
128128
*
129129
* @param selectors the {@code DiscoverySelectors} to add; never {@code null}
130130
* @return this builder for method chaining
@@ -136,7 +136,7 @@ public LauncherDiscoveryRequestBuilder selectors(DiscoverySelector... selectors)
136136
}
137137

138138
/**
139-
* Add all of the supplied {@code selectors} to the request.
139+
* Add all supplied {@code selectors} to the request.
140140
*
141141
* @param selectors the {@code DiscoverySelectors} to add; never {@code null}
142142
* @return this builder for method chaining
@@ -149,7 +149,7 @@ public LauncherDiscoveryRequestBuilder selectors(List<? extends DiscoverySelecto
149149
}
150150

151151
/**
152-
* Add all of the supplied {@code filters} to the request.
152+
* Add all supplied {@code filters} to the request.
153153
*
154154
* <p>The {@code filters} are combined using AND semantics, i.e. all of them
155155
* have to include a resource for it to end up in the test plan.
@@ -185,7 +185,7 @@ public LauncherDiscoveryRequestBuilder configurationParameter(String key, String
185185
}
186186

187187
/**
188-
* Add all of the supplied configuration parameters to the request.
188+
* Add all supplied configuration parameters to the request.
189189
*
190190
* @param configurationParameters the map of configuration parameters to add;
191191
* never {@code null}
@@ -206,23 +206,46 @@ public LauncherDiscoveryRequestBuilder configurationParameters(Map<String, Strin
206206
* {@link #configurationParameters(Map)} takes precedence over the supplied
207207
* configuration parameters.
208208
*
209-
* @param configurationParameters the parent instance to be used for looking
209+
* @param parentConfigurationParameters the parent instance to use for looking
210210
* up configuration parameters that have not been explicitly configured;
211211
* never {@code null}
212+
* @return this builder for method chaining
212213
* @since 1.8
213214
* @see #configurationParameter(String, String)
214215
* @see #configurationParameters(Map)
215216
*/
216217
@API(status = STABLE, since = "1.10")
217218
public LauncherDiscoveryRequestBuilder parentConfigurationParameters(
218-
ConfigurationParameters configurationParameters) {
219-
Preconditions.notNull(configurationParameters, "parent configuration parameters must not be null");
220-
this.parentConfigurationParameters = configurationParameters;
219+
ConfigurationParameters parentConfigurationParameters) {
220+
Preconditions.notNull(parentConfigurationParameters, "parent configuration parameters must not be null");
221+
this.parentConfigurationParameters = parentConfigurationParameters;
221222
return this;
222223
}
223224

224225
/**
225-
* Add all of the supplied discovery listeners to the request.
226+
* Configure whether implicit configuration parameters should be considered.
227+
*
228+
* <p>By default, in addition to those parameters that are passed explicitly
229+
* to this builder, configuration parameters are read from system properties
230+
* and from the {@code junit-platform.properties} classpath resource.
231+
* Passing {@code false} to this method, disables the latter two sources so
232+
* that only explicit configuration parameters are taken into account.
233+
*
234+
* @param enabled {@code true} if implicit configuration parameters should be
235+
* considered
236+
* @return this builder for method chaining
237+
* @since 1.7
238+
* @see #configurationParameter(String, String)
239+
* @see #configurationParameters(Map)
240+
*/
241+
@API(status = STABLE, since = "1.10")
242+
public LauncherDiscoveryRequestBuilder enableImplicitConfigurationParameters(boolean enabled) {
243+
this.implicitConfigurationParametersEnabled = enabled;
244+
return this;
245+
}
246+
247+
/**
248+
* Add all supplied discovery listeners to the request.
226249
*
227250
* <p>In addition to the {@linkplain LauncherDiscoveryListener listeners}
228251
* registered using this method, this builder will add a default listener
@@ -246,25 +269,6 @@ public LauncherDiscoveryRequestBuilder listeners(LauncherDiscoveryListener... li
246269
return this;
247270
}
248271

249-
/**
250-
* Configure whether implicit configuration parameters should be considered.
251-
*
252-
* <p>By default, in addition to those parameters that are passed explicitly
253-
* to this builder, configuration parameters are read from system properties
254-
* and from the {@code junit-platform.properties} classpath resource.
255-
* Passing {@code false} to this method, disables the latter two sources so
256-
* that only explicit configuration parameters are taken into account.
257-
*
258-
* @since 1.7
259-
* @see #configurationParameter(String, String)
260-
* @see #configurationParameters(Map)
261-
*/
262-
@API(status = STABLE, since = "1.10")
263-
public LauncherDiscoveryRequestBuilder enableImplicitConfigurationParameters(boolean enabled) {
264-
this.implicitConfigurationParametersEnabled = enabled;
265-
return this;
266-
}
267-
268272
private void storeFilter(Filter<?> filter) {
269273
if (filter instanceof EngineFilter) {
270274
this.engineFilters.add((EngineFilter) filter);
@@ -298,7 +302,7 @@ private LauncherConfigurationParameters buildLauncherConfigurationParameters() {
298302
.explicitParameters(this.configurationParameters) //
299303
.enableImplicitProviders(this.implicitConfigurationParametersEnabled);
300304

301-
if (parentConfigurationParameters != null) {
305+
if (this.parentConfigurationParameters != null) {
302306
builder.parentConfigurationParameters(this.parentConfigurationParameters);
303307
}
304308

@@ -308,14 +312,14 @@ private LauncherConfigurationParameters buildLauncherConfigurationParameters() {
308312
private LauncherDiscoveryListener getLauncherDiscoveryListener(ConfigurationParameters configurationParameters) {
309313
LauncherDiscoveryListener defaultDiscoveryListener = getDefaultLauncherDiscoveryListener(
310314
configurationParameters);
311-
if (discoveryListeners.isEmpty()) {
315+
if (this.discoveryListeners.isEmpty()) {
312316
return defaultDiscoveryListener;
313317
}
314-
if (discoveryListeners.contains(defaultDiscoveryListener)) {
315-
return LauncherDiscoveryListeners.composite(discoveryListeners);
318+
if (this.discoveryListeners.contains(defaultDiscoveryListener)) {
319+
return LauncherDiscoveryListeners.composite(this.discoveryListeners);
316320
}
317-
List<LauncherDiscoveryListener> allDiscoveryListeners = new ArrayList<>(discoveryListeners.size() + 1);
318-
allDiscoveryListeners.addAll(discoveryListeners);
321+
List<LauncherDiscoveryListener> allDiscoveryListeners = new ArrayList<>(this.discoveryListeners.size() + 1);
322+
allDiscoveryListeners.addAll(this.discoveryListeners);
319323
allDiscoveryListeners.add(defaultDiscoveryListener);
320324
return LauncherDiscoveryListeners.composite(allDiscoveryListeners);
321325
}

0 commit comments

Comments
 (0)