Use assertj instead of hamcrest (#1662)

* Use assertj instead of hamcrest

* Trim README
This commit is contained in:
dotasek 2024-06-20 10:20:45 -04:00 committed by GitHub
parent c631f6c808
commit 9b437438ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 39 additions and 42 deletions

View File

@ -282,4 +282,3 @@ This project is maintained by [Grahame Grieve][Link-grahameGithub], [James Agnew
[Badge-cliSonatypeSnapshot]: https://img.shields.io/nexus/s/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.validation.cli.svg "Sonatype Snapshots"
[Badge-validationSonatypeRelease]: https://img.shields.io/nexus/r/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.validation.svg "Sonatype Releases"
[Badge-validationSonatypeSnapshot]: https://img.shields.io/nexus/s/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.validation.svg "Sonatype Snapshots"

View File

@ -161,6 +161,13 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockftpserver</groupId>
<artifactId>MockFtpServer</artifactId>

View File

@ -1,7 +1,6 @@
package org.hl7.fhir.utilities;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import java.io.ByteArrayOutputStream;
@ -29,7 +28,7 @@ public class FileFormatTest {
if (Charset.defaultCharset().equals(StandardCharsets.UTF_8)) {
assertEquals(0, allWrittenLines.length());
} else {
assertThat(allWrittenLines, containsString("WARNING"));
assertThat(allWrittenLines).contains("WARNING");
}
}
}

View File

@ -1,7 +1,6 @@
package org.hl7.fhir.utilities.i18n;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
@ -67,11 +66,11 @@ class I18nBaseTest {
//Answer value must be of the type {1}
String resultOne = testClass.formatMessagePlural(1, I18nConstants.QUESTIONNAIRE_QR_ITEM_WRONGTYPE);
assertThat(resultOne, containsString("be of the type"));
assertThat(resultOne).contains("be of the type");
//Answer value must be one of the {0} types {1}
String resultMany = testClass.formatMessagePlural(3, I18nConstants.QUESTIONNAIRE_QR_ITEM_WRONGTYPE);
assertThat(resultMany, containsString("one of the 3 types "));
assertThat(resultMany).contains("one of the 3 types ");
}
@ -83,11 +82,11 @@ class I18nBaseTest {
testClass.setLocale(Locale.GERMAN);
//Answer value muss vom Typ {0} sein.
String resultOne = testClass.formatMessagePlural(1, I18nConstants.QUESTIONNAIRE_QR_ITEM_WRONGTYPE);
assertThat(resultOne, containsString("muss vom Typ"));
assertThat(resultOne).contains("muss vom Typ");
//Answer value muss einer der Typen {1} sein
String resultMany = testClass.formatMessagePlural(3, I18nConstants.QUESTIONNAIRE_QR_ITEM_WRONGTYPE);
assertThat(resultMany, containsString("einer der Typen "));
assertThat(resultMany).contains("einer der Typen ");
}

View File

@ -1,7 +1,6 @@
package org.hl7.fhir.utilities.npm;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.StringStartsWith.startsWith;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
@ -149,7 +148,7 @@ public class PackageServerTest {
private static void assertBasicAuthorization(RecordedRequest packageRequest) {
String authorizationHeader = packageRequest.getHeader("Authorization");
assertThat(authorizationHeader, startsWith("Basic"));
assertThat(authorizationHeader).startsWith("Basic");
byte[] data = Base64.getDecoder().decode(authorizationHeader.substring(6));
String authorizationValue = new String(data, StandardCharsets.UTF_8);
String[] authorizationColumns = authorizationValue.split(":");
@ -161,7 +160,7 @@ public class PackageServerTest {
private static void assertTokenAuthorization(RecordedRequest packageRequest) {
String authorizationHeader = packageRequest.getHeader("Authorization");
assertThat(authorizationHeader, startsWith("Bearer"));
assertThat(authorizationHeader).startsWith("Bearer");
String token = authorizationHeader.substring(7);
assertEquals(MockPackageServer.DUMMY_TOKEN, token);

View File

@ -248,19 +248,6 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>${hamcrest_version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>${hamcrest_version}</version>
<scope>compile</scope>
</dependency>
<!-- /org.hl7.fhir.core test-jar dependencies -->

View File

@ -249,6 +249,12 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>

View File

@ -1,9 +1,5 @@
package org.hl7.fhir.validation;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.MatcherAssert.assertThat;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;

View File

@ -1,7 +1,6 @@
package org.hl7.fhir.validation.cli.utils;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import java.io.File;
@ -33,6 +32,6 @@ public class ParamsTests {
java.lang.Error error = Assertions.assertThrows(java.lang.Error.class, () -> {
CliContext cliContext = Params.loadCliContext(new String[]{"-fhir-settings", "this-does-not-exist.json"});
});
assertThat(error.getMessage(), containsString("this-does-not-exist.json"));
assertThat(error.getMessage()).contains("this-does-not-exist.json");
}
}

22
pom.xml
View File

@ -314,6 +314,12 @@
<artifactId>logback-core</artifactId>
<version>1.2.13</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.22.0</version>
</dependency>
</dependencies>
</dependencyManagement>
@ -398,14 +404,14 @@
<goals>
<goal>checkstyle</goal>
</goals>
<configuration>
<failsOnError>true</failsOnError>
<suppressionsLocation>${project.basedir}/checkstyle_suppressions.xml</suppressionsLocation>
<enableRulesSummary>true</enableRulesSummary>
<enableSeveritySummary>true</enableSeveritySummary>
<consoleOutput>true</consoleOutput>
<configLocation>${checkstyle_config_location}/checkstyle.xml</configLocation>
</configuration>
<configuration>
<failsOnError>true</failsOnError>
<suppressionsLocation>${project.basedir}/checkstyle_suppressions.xml</suppressionsLocation>
<enableRulesSummary>true</enableRulesSummary>
<enableSeveritySummary>true</enableSeveritySummary>
<consoleOutput>true</consoleOutput>
<configLocation>${checkstyle_config_location}/checkstyle.xml</configLocation>
</configuration>
</execution>
</executions>
</plugin>