Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove AssertJ for Java 21 support #270

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@
<artifactId>workflow-step-api</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
Expand Down
26 changes: 19 additions & 7 deletions src/test/java/hudson/plugins/ansicolor/AnsiColorStepTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@
import java.util.List;
import java.util.logging.Level;

import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

Expand Down Expand Up @@ -205,8 +208,12 @@ public void canUseAndReportGlobalColorMapName() {
StringWriter writer = new StringWriter();
assertTrue(project.getLastBuild().getLogText().writeHtmlTo(0, writer) > 0);
final String html = writer.toString().replaceAll("<!--.+?-->", "");
assertThat(html).contains(expectedOutput);
assertThat(html).doesNotContain(notExpectedOutput);
for (String expected : expectedOutput) {
assertThat(html, containsString(expected));
}
for (String notExpected : notExpectedOutput) {
assertThat(html, not(containsString(notExpected)));
}
});
}

Expand Down Expand Up @@ -235,7 +242,7 @@ public void canUseAndReportDefaultColorMapName() {
public void canGetConstructorParametersForSnippetGenerator() {
final String colorMapName = AnsiColorMap.VGA.getName();
final AnsiColorStep step = new AnsiColorStep(colorMapName);
assertThat(step.getColorMapName()).isEqualTo(colorMapName);
assertEquals(colorMapName, step.getColorMapName());
}

private void assertOutputOnRunningPipeline(Collection<String> expectedOutput, Collection<String> notExpectedOutput, String pipelineScript) {
Expand All @@ -246,8 +253,12 @@ private void assertOutputOnRunningPipeline(Collection<String> expectedOutput, Co
StringWriter writer = new StringWriter();
assertTrue(project.getLastBuild().getLogText().writeHtmlTo(0, writer) > 0);
final String html = writer.toString().replaceAll("<!--.+?-->", "");
assertThat(html).contains(expectedOutput);
assertThat(html).doesNotContain(notExpectedOutput);
for (String expected : expectedOutput) {
assertThat(html, containsString(expected));
}
for (String notExpected : notExpectedOutput) {
assertThat(html, not(containsString(notExpected)));
}
});
}

Expand All @@ -266,7 +277,8 @@ private void assertNlsOnRunningPipeline() {
.replaceAll("<span.+?>", "")
.replaceAll("<div.+?/div>", "");
final String nl = System.lineSeparator();
assertThat(html).contains("ansiColor" + nl + "[Pipeline] {" + nl + nl).contains("[Pipeline] }" + nl + nl + "[Pipeline] // ansiColor");
assertThat(html, containsString("ansiColor" + nl + "[Pipeline] {" + nl + nl));
assertThat(html, containsString("[Pipeline] }" + nl + nl + "[Pipeline] // ansiColor"));
});
}
}
12 changes: 9 additions & 3 deletions src/test/java/hudson/plugins/ansicolor/JenkinsTestSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertTrue;

public class JenkinsTestSupport {
Expand Down Expand Up @@ -64,8 +66,12 @@ protected void assertOutputOnRunningPipeline(
assertTrue(lastBuild.getLogText().writeHtmlTo(start, writer) > 0);
properties.keySet().forEach(System::clearProperty);
final String html = writer.toString().replaceAll("<!--.+?-->", "");
assertThat(html).contains(expectedOutput);
assertThat(html).doesNotContain(notExpectedOutput);
for (String expected : expectedOutput) {
assertThat(html, containsString(expected));
}
for (String notExpected : notExpectedOutput) {
assertThat(html, not(containsString(notExpected)));
}
});
}

Expand Down