From f73094b5198fd43c3ffaa8c7ac715de55b26e271 Mon Sep 17 00:00:00 2001 From: Stefan Spieker Date: Fri, 22 Mar 2024 21:49:58 +0100 Subject: [PATCH] Minor improvements to readability within tests (#9059) minor improvements to readability --- test/src/test/java/hudson/model/AbstractProjectTest.java | 7 +------ test/src/test/java/hudson/model/ViewTest.java | 4 ++-- .../java/jenkins/model/JenkinsReloadConfigurationTest.java | 2 +- test/src/test/java/jenkins/telemetry/TelemetryTest.java | 5 ++--- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/test/src/test/java/hudson/model/AbstractProjectTest.java b/test/src/test/java/hudson/model/AbstractProjectTest.java index d4108e3a4c93..290096ae30bc 100644 --- a/test/src/test/java/hudson/model/AbstractProjectTest.java +++ b/test/src/test/java/hudson/model/AbstractProjectTest.java @@ -245,12 +245,7 @@ public SCMDescriptor getDescriptor() { }; } }); - Thread t = new Thread() { - @Override - public void run() { - p.pollSCMChanges(StreamTaskListener.fromStdout()); - } - }; + Thread t = new Thread(() -> p.poll(StreamTaskListener.fromStdout())); try { t.start(); Future f = p.scheduleBuild2(0); diff --git a/test/src/test/java/hudson/model/ViewTest.java b/test/src/test/java/hudson/model/ViewTest.java index 1c32f3ed314a..99a7a75d9ed3 100644 --- a/test/src/test/java/hudson/model/ViewTest.java +++ b/test/src/test/java/hudson/model/ViewTest.java @@ -127,8 +127,8 @@ public void roundTrip() throws Exception { j.configRoundtrip(view); assertEquals("Some description", view.getDescription()); - assertEquals(true, view.isFilterExecutors()); - assertEquals(true, view.isFilterQueue()); + assertTrue(view.isFilterExecutors()); + assertTrue(view.isFilterQueue()); } @Issue("JENKINS-7100") diff --git a/test/src/test/java/jenkins/model/JenkinsReloadConfigurationTest.java b/test/src/test/java/jenkins/model/JenkinsReloadConfigurationTest.java index a783ff67f052..3fb166ec92d9 100644 --- a/test/src/test/java/jenkins/model/JenkinsReloadConfigurationTest.java +++ b/test/src/test/java/jenkins/model/JenkinsReloadConfigurationTest.java @@ -48,7 +48,7 @@ public void reloadAgentConfig() throws Exception { } private void modifyNode(Node node) throws Exception { - replace(node.getNodeName().equals("") ? "config.xml" : String.format("nodes/%s/config.xml", node.getNodeName()), "oldLabel", "newLabel"); + replace(node.getNodeName().isEmpty() ? "config.xml" : String.format("nodes/%s/config.xml", node.getNodeName()), "oldLabel", "newLabel"); assertEquals("oldLabel", node.getLabelString()); diff --git a/test/src/test/java/jenkins/telemetry/TelemetryTest.java b/test/src/test/java/jenkins/telemetry/TelemetryTest.java index 034e9dcdd648..f465fdf2fd8a 100644 --- a/test/src/test/java/jenkins/telemetry/TelemetryTest.java +++ b/test/src/test/java/jenkins/telemetry/TelemetryTest.java @@ -19,7 +19,6 @@ import java.io.StringWriter; import java.nio.charset.StandardCharsets; import java.time.LocalDate; -import java.time.temporal.ChronoUnit; import java.util.HashSet; import java.util.Set; import java.util.SortedSet; @@ -203,7 +202,7 @@ public String getDisplayName() { @NonNull @Override public LocalDate getStart() { - return LocalDate.now().plus(1, ChronoUnit.DAYS); + return LocalDate.now().plusDays(1); } @NonNull @@ -243,7 +242,7 @@ public LocalDate getStart() { @NonNull @Override public LocalDate getEnd() { - return LocalDate.now().minus(1, ChronoUnit.DAYS); + return LocalDate.now().minusDays(1); } @NonNull