Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 67326ce

Browse files
committed
refactor assertEquals to use assertThat whe appropriate
1 parent 99f38fb commit 67326ce

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353
<version>${junit.jupiter.version}</version>
5454
<scope>test</scope>
5555
</dependency>
56+
<dependency>
57+
<groupId>org.hamcrest</groupId>
58+
<artifactId>hamcrest</artifactId>
59+
<version>2.1</version>
60+
<scope>test</scope>
61+
</dependency>
5662

5763
<dependency>
5864
<groupId>ch.qos.logback</groupId>

src/test/java/org/utplsql/api/JavaApiVersionTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
import org.junit.jupiter.api.Test;
44

5-
import static org.junit.jupiter.api.Assertions.assertTrue;
5+
import static org.hamcrest.MatcherAssert.assertThat;
6+
import static org.hamcrest.Matchers.startsWith;
67

78
class JavaApiVersionTest {
89

910
@Test
1011
void getJavaApiVersion() {
11-
assertTrue(JavaApiVersionInfo.getVersion().startsWith("3.1"));
12+
assertThat(JavaApiVersionInfo.getVersion(), startsWith("3.1"));
1213
}
1314
}

src/test/java/org/utplsql/api/OutputBufferIT.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
import java.util.List;
1818
import java.util.concurrent.*;
1919

20-
import static org.junit.jupiter.api.Assertions.*;
20+
import static org.hamcrest.MatcherAssert.assertThat;
21+
import static org.hamcrest.Matchers.emptyIterable;
22+
import static org.hamcrest.Matchers.not;
23+
import static org.junit.jupiter.api.Assertions.assertEquals;
24+
import static org.junit.jupiter.api.Assertions.fail;
2125

2226
/**
2327
* Integration-test for OutputBuffers
@@ -104,7 +108,7 @@ void fetchAllLines() throws SQLException {
104108

105109
List<String> outputLines = reporter.getOutputBuffer().fetchAll(getConnection());
106110

107-
assertTrue(outputLines.size() > 0);
111+
assertThat(outputLines, not(emptyIterable()));
108112
}
109113

110114
@Test
@@ -118,7 +122,7 @@ void getOutputFromSonarReporter() throws SQLException {
118122

119123
List<String> outputLines = reporter.getOutputBuffer().fetchAll(getConnection());
120124

121-
assertTrue(outputLines.size() > 0);
125+
assertThat(outputLines, not(emptyIterable()));
122126
}
123127

124128
@Test

src/test/java/org/utplsql/api/ReporterFactoryIT.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.utplsql.api;
22

3+
import org.hamcrest.Matchers;
34
import org.junit.jupiter.api.Test;
45
import org.utplsql.api.compatibility.CompatibilityProxy;
56
import org.utplsql.api.reporter.CoreReporters;
@@ -9,7 +10,7 @@
910

1011
import java.sql.SQLException;
1112

12-
import static org.junit.jupiter.api.Assertions.assertTrue;
13+
import static org.hamcrest.MatcherAssert.assertThat;
1314

1415
class ReporterFactoryIT extends AbstractDatabaseTest {
1516

@@ -20,7 +21,7 @@ void createDefaultReporterFactoryMethod() throws SQLException {
2021

2122
ReporterFactory reporterFactory = ReporterFactory.createDefault(proxy);
2223

23-
assertTrue( reporterFactory.createReporter(CoreReporters.UT_DOCUMENTATION_REPORTER.name()) instanceof DocumentationReporter );
24-
assertTrue( reporterFactory.createReporter(CoreReporters.UT_COVERAGE_HTML_REPORTER.name()) instanceof CoverageHTMLReporter);
24+
assertThat(reporterFactory.createReporter(CoreReporters.UT_DOCUMENTATION_REPORTER.name()), Matchers.isA(DocumentationReporter.class));
25+
assertThat(reporterFactory.createReporter(CoreReporters.UT_COVERAGE_HTML_REPORTER.name()), Matchers.isA(CoverageHTMLReporter.class));
2526
}
2627
}

0 commit comments

Comments
 (0)