diff --git a/pom.xml b/pom.xml index 72c9f7a..e4065ac 100644 --- a/pom.xml +++ b/pom.xml @@ -93,12 +93,8 @@ - - - 1.15.0 - - + diff --git a/src/main/java/org/jenkinsci/plugins/elasticaxisplugin/ElasticAxis.java b/src/main/java/org/jenkinsci/plugins/elasticaxisplugin/ElasticAxis.java index 62023b3..1b3a4d4 100644 --- a/src/main/java/org/jenkinsci/plugins/elasticaxisplugin/ElasticAxis.java +++ b/src/main/java/org/jenkinsci/plugins/elasticaxisplugin/ElasticAxis.java @@ -34,8 +34,7 @@ public class ElasticAxis extends LabelAxis { private final boolean dontExpandLabels; @DataBoundConstructor - public ElasticAxis( - String name, String labelString, boolean ignoreOffline, boolean dontExpandLabels) { + public ElasticAxis(String name, String labelString, boolean ignoreOffline, boolean dontExpandLabels) { super(name, computeAllNodesInLabel(labelString, dontExpandLabels)); this.label = labelString; this.ignoreOffline = ignoreOffline; @@ -86,8 +85,7 @@ private static List computeNodesInLabel( hudson.model.Label agentLabel = Jenkins.get().getLabel(aLabel.trim()); if (agentLabel != null) { for (Node node : agentLabel.getNodes()) { - if (shouldAddNode(restrictToOnlineNodes, node.toComputer())) - onlineNodesForLabel = true; + if (shouldAddNode(restrictToOnlineNodes, node.toComputer())) onlineNodesForLabel = true; } if (onlineNodesForLabel) { computedNodes.add(agentLabel.getExpression()); @@ -125,28 +123,24 @@ public Axis newInstance(StaplerRequest req, JSONObject formData) throws FormExce } @RequirePOST - public FormValidation doCheckLabelString( - @AncestorInPath Job job, @QueryParameter String value) { + public FormValidation doCheckLabelString(@AncestorInPath Job job, @QueryParameter String value) { job.checkPermission(hudson.model.Item.CONFIGURE); String[] labels = value.split(","); List aggregatedNotOkValidations = new ArrayList<>(); for (String oneLabel : labels) { FormValidation validation = LabelExpression.validate(oneLabel, job); if (!validation.equals(FormValidation.ok())) { - LOGGER.log( - Level.FINEST, - "Remembering not ok validation {1} for label {0}", - new Object[] {oneLabel, validation}); + LOGGER.log(Level.FINEST, "Remembering not ok validation {1} for label {0}", new Object[] { + oneLabel, validation + }); aggregatedNotOkValidations.add(validation); } } if (!aggregatedNotOkValidations.isEmpty()) { - FormValidation aggregatedValidations = - FormValidation.aggregate(aggregatedNotOkValidations); - LOGGER.log( - Level.FINEST, - "Returning aggregated not ok validation {1} for labels {0}", - new Object[] {labels, aggregatedValidations}); + FormValidation aggregatedValidations = FormValidation.aggregate(aggregatedNotOkValidations); + LOGGER.log(Level.FINEST, "Returning aggregated not ok validation {1} for labels {0}", new Object[] { + labels, aggregatedValidations + }); return aggregatedValidations; } LOGGER.log(Level.FINEST, "Returning ok validation for labels {0}", labels); diff --git a/src/test/java/org/jenkinsci/plugins/elasticaxisplugin/ElasticAxisTest.java b/src/test/java/org/jenkinsci/plugins/elasticaxisplugin/ElasticAxisTest.java index b3058fa..5bc032e 100644 --- a/src/test/java/org/jenkinsci/plugins/elasticaxisplugin/ElasticAxisTest.java +++ b/src/test/java/org/jenkinsci/plugins/elasticaxisplugin/ElasticAxisTest.java @@ -28,7 +28,8 @@ @RunWith(Parameterized.class) public class ElasticAxisTest { - @ClassRule public static JenkinsRule j = new JenkinsRule(); + @ClassRule + public static JenkinsRule j = new JenkinsRule(); private final String axisName; private final String labelString; @@ -79,15 +80,11 @@ public static Collection permuteTestArguments() { for (Boolean doNotExpandLabels : possibleValues) { for (String labelSuffix : LABEL_SUFFIXES) { // Test for known agents - Object[] argument = { - AGENT_PREFIX + labelSuffix, ignoreOffline, doNotExpandLabels - }; + Object[] argument = {AGENT_PREFIX + labelSuffix, ignoreOffline, doNotExpandLabels}; arguments.add(argument); } // Test that a non-existing agent matches nothing - Object[] argument = { - AGENT_PREFIX + DOES_NOT_EXIST_SUFFIX, ignoreOffline, doNotExpandLabels - }; + Object[] argument = {AGENT_PREFIX + DOES_NOT_EXIST_SUFFIX, ignoreOffline, doNotExpandLabels}; arguments.add(argument); } } @@ -141,9 +138,7 @@ public void testGetValues() { public void testGetValuesForController() { // selfLabel will be "master" before 2.307 and "built-in" after 2.307 String expectedLabel = j.jenkins.getSelfLabel().getName(); - elasticAxis = - new ElasticAxis( - axisName, expectedLabel + " || built-in", ignoreOffline, doNotExpandLabels); + elasticAxis = new ElasticAxis(axisName, expectedLabel + " || built-in", ignoreOffline, doNotExpandLabels); if (doNotExpandLabels) { assertThat(elasticAxis.getValues(), hasItem(expectedLabel + "||built-in")); } else { @@ -153,8 +148,7 @@ public void testGetValuesForController() { @Test public void testGetValuesForAgentAOrAgentB() { - elasticAxis = - new ElasticAxis(axisName, "label-A || label-B", ignoreOffline, doNotExpandLabels); + elasticAxis = new ElasticAxis(axisName, "label-A || label-B", ignoreOffline, doNotExpandLabels); if (doNotExpandLabels) { assertThat(elasticAxis.getValues(), hasItem("label-A||label-B")); } else {