Skip to content

Commit 0f4eda8

Browse files
Refactor: Replace deprecated org.junit.Assert.assertThat (#322)
I replaced all usages of `org.junit.Assert.assertThat` with the recommended `org.hamcrest.MatcherAssert.assertThat`. This change updates the import statements in the affected test files. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent 007c2be commit 0f4eda8

25 files changed

+68
-60
lines changed

src/test/java/org/javacs/ArtifactTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.javacs;
22

33
import static org.hamcrest.Matchers.*;
4-
import static org.junit.Assert.*;
4+
import static org.hamcrest.MatcherAssert.assertThat;
55

66
import org.junit.Test;
77

src/test/java/org/javacs/ClassesTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package org.javacs;
22

33
import static org.hamcrest.Matchers.*;
4-
import static org.junit.Assert.*;
4+
import static org.hamcrest.MatcherAssert.assertThat;
5+
import static org.junit.Assert.assertTrue;
56

67
import java.net.URI;
78
import java.nio.file.FileSystems;

src/test/java/org/javacs/CodeActionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.javacs;
22

33
import static org.hamcrest.Matchers.*;
4-
import static org.junit.Assert.*;
4+
import static org.hamcrest.MatcherAssert.assertThat;
55

66
import java.util.ArrayList;
77
import java.util.List;

src/test/java/org/javacs/CodeLensTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.javacs;
22

33
import static org.hamcrest.Matchers.*;
4-
import static org.junit.Assert.*;
4+
import static org.hamcrest.MatcherAssert.assertThat;
55

66
import java.util.ArrayList;
77
import java.util.List;

src/test/java/org/javacs/CompletionsScopesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import static org.hamcrest.Matchers.hasItems;
44
import static org.hamcrest.Matchers.not;
5-
import static org.junit.Assert.assertThat;
5+
import static org.hamcrest.MatcherAssert.assertThat;
66

77
import org.junit.Test;
88

src/test/java/org/javacs/CompletionsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package org.javacs;
22

33
import static org.hamcrest.Matchers.*;
4-
import static org.junit.Assert.*;
4+
import static org.hamcrest.MatcherAssert.assertThat;
5+
import static org.junit.Assert.fail;
56

67
import java.io.IOException;
78
import java.nio.file.Files;
Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
package org.javacs;
2-
3-
import static org.hamcrest.Matchers.equalTo;
4-
import static org.junit.Assert.assertThat;
5-
6-
import java.nio.file.Paths;
7-
import java.util.Set;
8-
import org.junit.Test;
9-
import org.junit.Before;
10-
11-
/**
12-
* These tests are isolated because bugs caused by encoding issues could cause
13-
* phantom failures in other tests.
14-
*/
15-
public class FileEncodingTest {
16-
17-
@Before
18-
public void resetSourcesBefore() {
19-
FileStore.reset();
20-
}
21-
22-
@Test
23-
public void packageNameForNonUnicodeSource() {
24-
var encodingTestRoot = Paths.get("src/test/examples/encoding").normalize();
25-
26-
// If an exception is thrown due to an unknown encoding it would
27-
// be here.
28-
FileStore.setWorkspaceRoots(Set.of(encodingTestRoot));
29-
30-
var file = FindResource.path("/org/javacs/example/EncodingWindows1252.java");
31-
32-
// Currently, non-unicode files are ignored. This test will change if
33-
// support is added in the future.
34-
assertThat(FileStore.suggestedPackageName(file), equalTo(""));
35-
}
36-
}
1+
package org.javacs;
2+
3+
import static org.hamcrest.Matchers.equalTo;
4+
import static org.hamcrest.MatcherAssert.assertThat;
5+
6+
import java.nio.file.Paths;
7+
import java.util.Set;
8+
import org.junit.Test;
9+
import org.junit.Before;
10+
11+
/**
12+
* These tests are isolated because bugs caused by encoding issues could cause
13+
* phantom failures in other tests.
14+
*/
15+
public class FileEncodingTest {
16+
17+
@Before
18+
public void resetSourcesBefore() {
19+
FileStore.reset();
20+
}
21+
22+
@Test
23+
public void packageNameForNonUnicodeSource() {
24+
var encodingTestRoot = Paths.get("src/test/examples/encoding").normalize();
25+
26+
// If an exception is thrown due to an unknown encoding it would
27+
// be here.
28+
FileStore.setWorkspaceRoots(Set.of(encodingTestRoot));
29+
30+
var file = FindResource.path("/org/javacs/example/EncodingWindows1252.java");
31+
32+
// Currently, non-unicode files are ignored. This test will change if
33+
// support is added in the future.
34+
assertThat(FileStore.suggestedPackageName(file), equalTo(""));
35+
}
36+
}

src/test/java/org/javacs/FileStoreTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.javacs;
22

33
import static org.hamcrest.Matchers.*;
4-
import static org.junit.Assert.assertThat;
4+
import static org.hamcrest.MatcherAssert.assertThat;
55

66
import java.util.Set;
77
import org.junit.Before;

src/test/java/org/javacs/FindReferencesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.javacs;
22

33
import static org.hamcrest.Matchers.*;
4-
import static org.junit.Assert.*;
4+
import static org.hamcrest.MatcherAssert.assertThat;
55

66
import java.util.ArrayList;
77
import java.util.List;

src/test/java/org/javacs/FindSrcZipTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package org.javacs;
22

33
import static org.hamcrest.Matchers.*;
4-
import static org.junit.Assert.*;
4+
import static org.hamcrest.MatcherAssert.assertThat;
5+
import static org.junit.Assert.assertTrue;
56

67
import java.nio.file.Files;
78
import java.nio.file.Path;

0 commit comments

Comments
 (0)