Skip to content

Commit 875682d

Browse files
authored
[Improvement][Test] Migrate all UT cases from jUnit4 to jUnit5 in task-plugin module as an example (#12299)
* Migrate all UT cases from jUnit4 to jUnit5 in task-plugin module as an example
1 parent 18ef0a6 commit 875682d

57 files changed

Lines changed: 1241 additions & 1183 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/AbstractTaskTest.java‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
*/
1717

1818
package org.apache.dolphinscheduler.plugin.task.api;
19+
1920
import java.util.regex.Matcher;
2021
import java.util.regex.Pattern;
2122

22-
import org.junit.Assert;
23-
import org.junit.Test;
23+
import org.junit.jupiter.api.Assertions;
24+
import org.junit.jupiter.api.Test;
2425

2526
public class AbstractTaskTest {
2627

@@ -33,8 +34,8 @@ public void testFindFlinkJobId() {
3334
if (matcher.find()) {
3435
str = matcher.group();
3536
}
36-
Assert.assertNotNull(str);
37-
Assert.assertEquals(jobId, str.substring(6));
37+
Assertions.assertNotNull(str);
38+
Assertions.assertEquals(jobId, str.substring(6));
3839
}
3940

4041
}

‎dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/TaskTest.java‎

Lines changed: 0 additions & 22 deletions
This file was deleted.

‎dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/CheckTypeTest.java‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,31 @@
1717

1818
package org.apache.dolphinscheduler.plugin.task.api.enums.dp;
1919

20-
import static org.junit.Assert.assertEquals;
21-
22-
import org.junit.Test;
20+
import org.junit.jupiter.api.Assertions;
21+
import org.junit.jupiter.api.Test;
2322

2423
public class CheckTypeTest {
2524

2625
@Test
2726
public void testGetCode() {
28-
assertEquals(0, CheckType.COMPARISON_MINUS_STATISTICS.getCode());
29-
assertEquals(1, CheckType.STATISTICS_MINUS_COMPARISON.getCode());
30-
assertEquals(2, CheckType.STATISTICS_COMPARISON_PERCENTAGE.getCode());
31-
assertEquals(3, CheckType.STATISTICS_COMPARISON_DIFFERENCE_COMPARISON_PERCENTAGE.getCode());
27+
Assertions.assertEquals(0, CheckType.COMPARISON_MINUS_STATISTICS.getCode());
28+
Assertions.assertEquals(1, CheckType.STATISTICS_MINUS_COMPARISON.getCode());
29+
Assertions.assertEquals(2, CheckType.STATISTICS_COMPARISON_PERCENTAGE.getCode());
30+
Assertions.assertEquals(3, CheckType.STATISTICS_COMPARISON_DIFFERENCE_COMPARISON_PERCENTAGE.getCode());
3231
}
3332

3433
@Test
3534
public void testGetDescription() {
36-
assertEquals("comparison_minus_statistics", CheckType.COMPARISON_MINUS_STATISTICS.getDescription());
37-
assertEquals("statistics_minus_comparison", CheckType.STATISTICS_MINUS_COMPARISON.getDescription());
38-
assertEquals("statistics_comparison_percentage", CheckType.STATISTICS_COMPARISON_PERCENTAGE.getDescription());
39-
assertEquals("statistics_comparison_difference_comparison_percentage", CheckType.STATISTICS_COMPARISON_DIFFERENCE_COMPARISON_PERCENTAGE.getDescription());
35+
Assertions.assertEquals("comparison_minus_statistics", CheckType.COMPARISON_MINUS_STATISTICS.getDescription());
36+
Assertions.assertEquals("statistics_minus_comparison", CheckType.STATISTICS_MINUS_COMPARISON.getDescription());
37+
Assertions.assertEquals("statistics_comparison_percentage",
38+
CheckType.STATISTICS_COMPARISON_PERCENTAGE.getDescription());
39+
Assertions.assertEquals("statistics_comparison_difference_comparison_percentage",
40+
CheckType.STATISTICS_COMPARISON_DIFFERENCE_COMPARISON_PERCENTAGE.getDescription());
4041
}
4142

4243
@Test
4344
public void testOf() {
44-
assertEquals(CheckType.COMPARISON_MINUS_STATISTICS, CheckType.of(0));
45+
Assertions.assertEquals(CheckType.COMPARISON_MINUS_STATISTICS, CheckType.of(0));
4546
}
4647
}

‎dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ConnectorTypeTest.java‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,25 @@
1717

1818
package org.apache.dolphinscheduler.plugin.task.api.enums.dp;
1919

20-
import static org.junit.Assert.assertEquals;
21-
22-
import org.junit.Test;
20+
import org.junit.jupiter.api.Assertions;
21+
import org.junit.jupiter.api.Test;
2322

2423
public class ConnectorTypeTest {
2524

2625
@Test
2726
public void testGetCode() {
28-
assertEquals(0, ConnectorType.JDBC.getCode());
29-
assertEquals(1, ConnectorType.HIVE.getCode());
27+
Assertions.assertEquals(0, ConnectorType.JDBC.getCode());
28+
Assertions.assertEquals(1, ConnectorType.HIVE.getCode());
3029
}
3130

3231
@Test
3332
public void testGetDescription() {
34-
assertEquals("JDBC", ConnectorType.JDBC.getDescription());
35-
assertEquals("HIVE", ConnectorType.HIVE.getDescription());
33+
Assertions.assertEquals("JDBC", ConnectorType.JDBC.getDescription());
34+
Assertions.assertEquals("HIVE", ConnectorType.HIVE.getDescription());
3635
}
3736

3837
@Test
3938
public void testOf() {
40-
assertEquals(ConnectorType.JDBC, ConnectorType.of(0));
39+
Assertions.assertEquals(ConnectorType.JDBC, ConnectorType.of(0));
4140
}
4241
}

‎dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/DqFailureStrategyTest.java‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,26 @@
1717

1818
package org.apache.dolphinscheduler.plugin.task.api.enums.dp;
1919

20-
import static org.junit.Assert.assertEquals;
21-
22-
import org.junit.Test;
20+
import org.junit.jupiter.api.Assertions;
21+
import org.junit.jupiter.api.Test;
2322

2423
public class DqFailureStrategyTest {
2524

2625
@Test
2726
public void testGetCode() {
28-
assertEquals(0, DqFailureStrategy.ALERT.getCode());
29-
assertEquals(1, DqFailureStrategy.BLOCK.getCode());
27+
Assertions.assertEquals(0, DqFailureStrategy.ALERT.getCode());
28+
Assertions.assertEquals(1, DqFailureStrategy.BLOCK.getCode());
3029
}
3130

3231
@Test
3332
public void testGetDescription() {
34-
assertEquals("alert", DqFailureStrategy.ALERT.getDescription());
35-
assertEquals("block", DqFailureStrategy.BLOCK.getDescription());
33+
Assertions.assertEquals("alert", DqFailureStrategy.ALERT.getDescription());
34+
Assertions.assertEquals("block", DqFailureStrategy.BLOCK.getDescription());
3635
}
3736

3837
@Test
3938
public void testOf() {
40-
assertEquals(DqFailureStrategy.ALERT, DqFailureStrategy.of(0));
41-
assertEquals(DqFailureStrategy.BLOCK, DqFailureStrategy.of(1));
39+
Assertions.assertEquals(DqFailureStrategy.ALERT, DqFailureStrategy.of(0));
40+
Assertions.assertEquals(DqFailureStrategy.BLOCK, DqFailureStrategy.of(1));
4241
}
4342
}

‎dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/DqTaskStateTest.java‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,29 @@
1717

1818
package org.apache.dolphinscheduler.plugin.task.api.enums.dp;
1919

20-
import static org.junit.Assert.assertEquals;
21-
22-
import org.junit.Test;
20+
import org.junit.jupiter.api.Assertions;
21+
import org.junit.jupiter.api.Test;
2322

2423
public class DqTaskStateTest {
2524

2625
@Test
2726
public void testGetCode() {
28-
assertEquals(0, DqTaskState.DEFAULT.getCode());
29-
assertEquals(1, DqTaskState.SUCCESS.getCode());
30-
assertEquals(2, DqTaskState.FAILURE.getCode());
27+
Assertions.assertEquals(0, DqTaskState.DEFAULT.getCode());
28+
Assertions.assertEquals(1, DqTaskState.SUCCESS.getCode());
29+
Assertions.assertEquals(2, DqTaskState.FAILURE.getCode());
3130
}
3231

3332
@Test
3433
public void testGetDescription() {
35-
assertEquals("default", DqTaskState.DEFAULT.getDescription());
36-
assertEquals("success", DqTaskState.SUCCESS.getDescription());
37-
assertEquals("failure", DqTaskState.FAILURE.getDescription());
34+
Assertions.assertEquals("default", DqTaskState.DEFAULT.getDescription());
35+
Assertions.assertEquals("success", DqTaskState.SUCCESS.getDescription());
36+
Assertions.assertEquals("failure", DqTaskState.FAILURE.getDescription());
3837
}
3938

4039
@Test
4140
public void testOf() {
42-
assertEquals(DqTaskState.DEFAULT, DqTaskState.of(0));
43-
assertEquals(DqTaskState.SUCCESS, DqTaskState.of(1));
44-
assertEquals(DqTaskState.FAILURE, DqTaskState.of(2));
41+
Assertions.assertEquals(DqTaskState.DEFAULT, DqTaskState.of(0));
42+
Assertions.assertEquals(DqTaskState.SUCCESS, DqTaskState.of(1));
43+
Assertions.assertEquals(DqTaskState.FAILURE, DqTaskState.of(2));
4544
}
4645
}

‎dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ExecuteSqlTypeTest.java‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,29 @@
1717

1818
package org.apache.dolphinscheduler.plugin.task.api.enums.dp;
1919

20-
import static org.junit.Assert.assertEquals;
21-
22-
import org.junit.Test;
20+
import org.junit.jupiter.api.Assertions;
21+
import org.junit.jupiter.api.Test;
2322

2423
public class ExecuteSqlTypeTest {
2524

2625
@Test
2726
public void testGetCode() {
28-
assertEquals(0, ExecuteSqlType.MIDDLE.getCode());
29-
assertEquals(1, ExecuteSqlType.STATISTICS.getCode());
30-
assertEquals(2, ExecuteSqlType.COMPARISON.getCode());
27+
Assertions.assertEquals(0, ExecuteSqlType.MIDDLE.getCode());
28+
Assertions.assertEquals(1, ExecuteSqlType.STATISTICS.getCode());
29+
Assertions.assertEquals(2, ExecuteSqlType.COMPARISON.getCode());
3130
}
3231

3332
@Test
3433
public void testGetDescription() {
35-
assertEquals("middle", ExecuteSqlType.MIDDLE.getDescription());
36-
assertEquals("statistics", ExecuteSqlType.STATISTICS.getDescription());
37-
assertEquals("comparison", ExecuteSqlType.COMPARISON.getDescription());
34+
Assertions.assertEquals("middle", ExecuteSqlType.MIDDLE.getDescription());
35+
Assertions.assertEquals("statistics", ExecuteSqlType.STATISTICS.getDescription());
36+
Assertions.assertEquals("comparison", ExecuteSqlType.COMPARISON.getDescription());
3837
}
3938

4039
@Test
4140
public void testOf() {
42-
assertEquals(ExecuteSqlType.MIDDLE, ExecuteSqlType.of(0));
43-
assertEquals(ExecuteSqlType.STATISTICS, ExecuteSqlType.of(1));
44-
assertEquals(ExecuteSqlType.COMPARISON, ExecuteSqlType.of(2));
41+
Assertions.assertEquals(ExecuteSqlType.MIDDLE, ExecuteSqlType.of(0));
42+
Assertions.assertEquals(ExecuteSqlType.STATISTICS, ExecuteSqlType.of(1));
43+
Assertions.assertEquals(ExecuteSqlType.COMPARISON, ExecuteSqlType.of(2));
4544
}
4645
}

‎dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/InputTypeTest.java‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,32 @@
1717

1818
package org.apache.dolphinscheduler.plugin.task.api.enums.dp;
1919

20-
import static org.junit.Assert.assertEquals;
21-
22-
import org.junit.Test;
20+
import org.junit.jupiter.api.Assertions;
21+
import org.junit.jupiter.api.Test;
2322

2423
public class InputTypeTest {
2524

2625
@Test
2726
public void testGetCode() {
28-
assertEquals(0, InputType.DEFAULT.getCode());
29-
assertEquals(1, InputType.STATISTICS.getCode());
30-
assertEquals(2, InputType.COMPARISON.getCode());
31-
assertEquals(3, InputType.CHECK.getCode());
27+
Assertions.assertEquals(0, InputType.DEFAULT.getCode());
28+
Assertions.assertEquals(1, InputType.STATISTICS.getCode());
29+
Assertions.assertEquals(2, InputType.COMPARISON.getCode());
30+
Assertions.assertEquals(3, InputType.CHECK.getCode());
3231
}
3332

3433
@Test
3534
public void testGetDescription() {
36-
assertEquals("default", InputType.DEFAULT.getDescription());
37-
assertEquals("statistics", InputType.STATISTICS.getDescription());
38-
assertEquals("comparison", InputType.COMPARISON.getDescription());
39-
assertEquals("check", InputType.CHECK.getDescription());
35+
Assertions.assertEquals("default", InputType.DEFAULT.getDescription());
36+
Assertions.assertEquals("statistics", InputType.STATISTICS.getDescription());
37+
Assertions.assertEquals("comparison", InputType.COMPARISON.getDescription());
38+
Assertions.assertEquals("check", InputType.CHECK.getDescription());
4039
}
4140

4241
@Test
4342
public void testOf() {
44-
assertEquals(InputType.DEFAULT, InputType.of(0));
45-
assertEquals(InputType.STATISTICS, InputType.of(1));
46-
assertEquals(InputType.COMPARISON, InputType.of(2));
47-
assertEquals(InputType.CHECK, InputType.of(3));
43+
Assertions.assertEquals(InputType.DEFAULT, InputType.of(0));
44+
Assertions.assertEquals(InputType.STATISTICS, InputType.of(1));
45+
Assertions.assertEquals(InputType.COMPARISON, InputType.of(2));
46+
Assertions.assertEquals(InputType.CHECK, InputType.of(3));
4847
}
4948
}

‎dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/OperatorTypeTest.java‎

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,38 @@
1717

1818
package org.apache.dolphinscheduler.plugin.task.api.enums.dp;
1919

20-
import static org.junit.Assert.assertEquals;
21-
22-
import org.junit.Test;
20+
import org.junit.jupiter.api.Assertions;
21+
import org.junit.jupiter.api.Test;
2322

2423
public class OperatorTypeTest {
2524

2625
@Test
2726
public void testGetCode() {
28-
assertEquals(0, OperatorType.EQ.getCode());
29-
assertEquals(1, OperatorType.LT.getCode());
30-
assertEquals(2, OperatorType.LE.getCode());
31-
assertEquals(3, OperatorType.GT.getCode());
32-
assertEquals(4, OperatorType.GE.getCode());
33-
assertEquals(5, OperatorType.NE.getCode());
27+
Assertions.assertEquals(0, OperatorType.EQ.getCode());
28+
Assertions.assertEquals(1, OperatorType.LT.getCode());
29+
Assertions.assertEquals(2, OperatorType.LE.getCode());
30+
Assertions.assertEquals(3, OperatorType.GT.getCode());
31+
Assertions.assertEquals(4, OperatorType.GE.getCode());
32+
Assertions.assertEquals(5, OperatorType.NE.getCode());
3433
}
3534

3635
@Test
3736
public void testGetDescription() {
38-
assertEquals("equal", OperatorType.EQ.getDescription());
39-
assertEquals("little than", OperatorType.LT.getDescription());
40-
assertEquals("little and equal", OperatorType.LE.getDescription());
41-
assertEquals("great than", OperatorType.GT.getDescription());
42-
assertEquals("great and equal", OperatorType.GE.getDescription());
43-
assertEquals("not equal", OperatorType.NE.getDescription());
37+
Assertions.assertEquals("equal", OperatorType.EQ.getDescription());
38+
Assertions.assertEquals("little than", OperatorType.LT.getDescription());
39+
Assertions.assertEquals("little and equal", OperatorType.LE.getDescription());
40+
Assertions.assertEquals("great than", OperatorType.GT.getDescription());
41+
Assertions.assertEquals("great and equal", OperatorType.GE.getDescription());
42+
Assertions.assertEquals("not equal", OperatorType.NE.getDescription());
4443
}
4544

4645
@Test
4746
public void testOf() {
48-
assertEquals(OperatorType.EQ, OperatorType.of(0));
49-
assertEquals(OperatorType.LT, OperatorType.of(1));
50-
assertEquals(OperatorType.LE, OperatorType.of(2));
51-
assertEquals(OperatorType.GT, OperatorType.of(3));
52-
assertEquals(OperatorType.GE, OperatorType.of(4));
53-
assertEquals(OperatorType.NE, OperatorType.of(5));
47+
Assertions.assertEquals(OperatorType.EQ, OperatorType.of(0));
48+
Assertions.assertEquals(OperatorType.LT, OperatorType.of(1));
49+
Assertions.assertEquals(OperatorType.LE, OperatorType.of(2));
50+
Assertions.assertEquals(OperatorType.GT, OperatorType.of(3));
51+
Assertions.assertEquals(OperatorType.GE, OperatorType.of(4));
52+
Assertions.assertEquals(OperatorType.NE, OperatorType.of(5));
5453
}
5554
}

0 commit comments

Comments
 (0)