Skip to content

Commit ad9e735

Browse files
timtebeekTeamModerne
authored andcommitted
1 parent b8f696b commit ad9e735

File tree

3 files changed

+46
-65
lines changed

3 files changed

+46
-65
lines changed

src/test/java/org/openrewrite/java/migrate/UpdateSdkManTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.openrewrite.test.RewriteTest;
2222

2323
import static org.assertj.core.api.Assertions.assertThat;
24-
import static org.junit.jupiter.api.Assertions.assertTrue;
2524
import static org.openrewrite.test.SourceSpecs.text;
2625

2726

@@ -118,7 +117,7 @@ void nonExistingDist() {
118117

119118
@Test
120119
void emptyOptions() {
121-
assertTrue(new UpdateSdkMan(null, null).validate(new InMemoryExecutionContext()).isInvalid());
120+
assertThat(new UpdateSdkMan(null, null).validate(new InMemoryExecutionContext()).isInvalid()).isTrue();
122121
}
123122

124123
@Test

src/test/java/org/openrewrite/java/migrate/joda/JodaTimeScannerTest.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
import java.util.Map;
2727

2828
import static org.assertj.core.api.Assertions.assertThat;
29-
import static org.junit.jupiter.api.Assertions.assertEquals;
30-
import static org.junit.jupiter.api.Assertions.assertTrue;
3129
import static org.openrewrite.java.Assertions.java;
3230
import static org.openrewrite.test.RewriteTest.toRecipe;
3331

@@ -68,7 +66,7 @@ private void print(Date date) {
6866
"""
6967
)
7068
);
71-
assertTrue(scanner.getAcc().getUnsafeVars().isEmpty());
69+
assertThat(scanner.getAcc().getUnsafeVars()).isEmpty();
7270
}
7371

7472
@Test
@@ -103,12 +101,11 @@ private void print(DateTime dt) {
103101
);
104102
// The variable 'dtz' is unsafe due to the class variable 'dateTime'.
105103
// The parameter 'dt' in the 'print' method is also unsafe because one of its method calls is unsafe.
106-
assertEquals(3, scanner.getAcc().getUnsafeVars().size());
104+
assertThat(scanner.getAcc().getUnsafeVars()).hasSize(3);
107105
for (J.VariableDeclarations.NamedVariable var : scanner.getAcc().getUnsafeVars()) {
108-
assertTrue("dtz".equals(var.getSimpleName()) ||
109-
"dt".equals(var.getSimpleName()) ||
110-
"dateTime".equals(var.getSimpleName())
111-
);
106+
assertThat("dtz".equals(var.getSimpleName()) ||
107+
"dt".equals(var.getSimpleName()) ||
108+
"dateTime".equals(var.getSimpleName())).isTrue();
112109
}
113110
}
114111

@@ -140,9 +137,9 @@ public void foo(String city) {
140137
)
141138
);
142139
// The local variable dt is unsafe due to class var datetime.
143-
assertEquals(2, scanner.getAcc().getUnsafeVars().size());
140+
assertThat(scanner.getAcc().getUnsafeVars()).hasSize(2);
144141
for (J.VariableDeclarations.NamedVariable var : scanner.getAcc().getUnsafeVars()) {
145-
assertTrue("dateTime".equals(var.getSimpleName()) || "dt".equals(var.getSimpleName()));
142+
assertThat("dateTime".equals(var.getSimpleName()) || "dt".equals(var.getSimpleName())).isTrue();
146143
}
147144
}
148145

@@ -200,9 +197,9 @@ public void bar(DateTime dt) {
200197
)
201198
);
202199
// The bar method parameter dt is unsafe because migration of toDateMidnight() is not yet implemented.
203-
assertEquals(1, scanner.getAcc().getUnsafeVars().size());
200+
assertThat(scanner.getAcc().getUnsafeVars()).hasSize(1);
204201
for (J.VariableDeclarations.NamedVariable var : scanner.getAcc().getUnsafeVars()) {
205-
assertEquals("dt", var.getSimpleName());
202+
assertThat(var.getSimpleName()).isEqualTo("dt");
206203
}
207204
}
208205

src/test/java/org/openrewrite/java/migrate/lang/SwitchUtilsTest.java

Lines changed: 36 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323

2424
import java.util.concurrent.atomic.AtomicReference;
2525

26-
import static org.junit.jupiter.api.Assertions.assertFalse;
27-
import static org.junit.jupiter.api.Assertions.assertTrue;
26+
import static org.assertj.core.api.Assertions.assertThat;
2827

2928
class SwitchUtilsTest {
3029
private static J.Switch extractSwitch(@Language("java") String code) {
@@ -40,10 +39,9 @@ public J.Switch visitSwitch(J.Switch _switch, AtomicReference<J.Switch> switchAt
4039

4140
@Test
4241
void coversAllCasesAllEnums() {
43-
assertTrue(
44-
SwitchUtils.coversAllPossibleValues(
45-
extractSwitch(
46-
"""
42+
assertThat(SwitchUtils.coversAllPossibleValues(
43+
extractSwitch(
44+
"""
4745
class Test {
4846
void method(TrafficLight light) {
4947
switch (light) {
@@ -55,17 +53,15 @@ void method(TrafficLight light) {
5553
enum TrafficLight { RED, YELLOW, GREEN }
5654
}
5755
"""
58-
)
59-
)
60-
);
56+
)
57+
)).isTrue();
6158
}
6259

6360
@Test
6461
void coversAllCasesMissingEnums() {
65-
assertFalse(
66-
SwitchUtils.coversAllPossibleValues(
67-
extractSwitch(
68-
"""
62+
assertThat(SwitchUtils.coversAllPossibleValues(
63+
extractSwitch(
64+
"""
6965
class Test {
7066
void method(TrafficLight light) {
7167
switch (light) {
@@ -76,17 +72,15 @@ void method(TrafficLight light) {
7672
enum TrafficLight { RED, YELLOW, GREEN }
7773
}
7874
"""
79-
)
80-
)
81-
);
75+
)
76+
)).isFalse();
8277
}
8378

8479
@Test
8580
void coversAllCasesMissingEnumsWithDefault() {
86-
assertTrue(
87-
SwitchUtils.coversAllPossibleValues(
88-
extractSwitch(
89-
"""
81+
assertThat(SwitchUtils.coversAllPossibleValues(
82+
extractSwitch(
83+
"""
9084
class Test {
9185
void method(TrafficLight light) {
9286
switch (light) {
@@ -98,17 +92,15 @@ void method(TrafficLight light) {
9892
enum TrafficLight { RED, YELLOW, GREEN }
9993
}
10094
"""
101-
)
102-
)
103-
);
95+
)
96+
)).isTrue();
10497
}
10598

10699
@Test
107100
void coversAllCasesEnumOnlyDefault() {
108-
assertTrue(
109-
SwitchUtils.coversAllPossibleValues(
110-
extractSwitch(
111-
"""
101+
assertThat(SwitchUtils.coversAllPossibleValues(
102+
extractSwitch(
103+
"""
112104
class Test {
113105
void method(TrafficLight light) {
114106
switch (light) {
@@ -118,17 +110,15 @@ void method(TrafficLight light) {
118110
enum TrafficLight { RED, YELLOW, GREEN }
119111
}
120112
"""
121-
)
122-
)
123-
);
113+
)
114+
)).isTrue();
124115
}
125116

126117
@Test
127118
void coversAllCasesObjectOnlyDefault() {
128-
assertTrue(
129-
SwitchUtils.coversAllPossibleValues(
130-
extractSwitch(
131-
"""
119+
assertThat(SwitchUtils.coversAllPossibleValues(
120+
extractSwitch(
121+
"""
132122
class Test {
133123
void method(Object obj) {
134124
switch (obj) {
@@ -137,17 +127,15 @@ void method(Object obj) {
137127
}
138128
}
139129
"""
140-
)
141-
)
142-
);
130+
)
131+
)).isTrue();
143132
}
144133

145134
@Test
146135
void coversAllCasesAllSealedClasses() {
147-
assertFalse(
148-
SwitchUtils.coversAllPossibleValues(
149-
extractSwitch(
150-
"""
136+
assertThat(SwitchUtils.coversAllPossibleValues(
137+
extractSwitch(
138+
"""
151139
class Test {
152140
sealed abstract class Shape permits Circle, Square, Rectangle {}
153141
void method(Shape shape) {
@@ -159,17 +147,15 @@ void method(Shape shape) {
159147
}
160148
}
161149
"""
162-
)
163-
), "Not implemented yet for sealed classes"
164-
);
150+
)
151+
)).as("Not implemented yet for sealed classes").isFalse();
165152
}
166153

167154
@Test
168155
void coversAllCasesEnumWithExtraMembers() {
169-
assertTrue(
170-
SwitchUtils.coversAllPossibleValues(
171-
extractSwitch(
172-
"""
156+
assertThat(SwitchUtils.coversAllPossibleValues(
157+
extractSwitch(
158+
"""
173159
class Test {
174160
enum EnumWithExtraMembers {
175161
ONE, TWO;
@@ -183,8 +169,7 @@ void method(EnumWithExtraMembers e) {
183169
}
184170
}
185171
"""
186-
)
187-
)
188-
);
172+
)
173+
)).isTrue();
189174
}
190175
}

0 commit comments

Comments
 (0)