Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement][Test] Migrate all UT cases from jUnit4 to jUnit5 in task-plugin module as an example #12299

Merged
merged 2 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/

package org.apache.dolphinscheduler.plugin.task.api;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class AbstractTaskTest {

Expand All @@ -33,8 +34,8 @@ public void testFindFlinkJobId() {
if (matcher.find()) {
str = matcher.group();
}
Assert.assertNotNull(str);
Assert.assertEquals(jobId, str.substring(6));
Assertions.assertNotNull(str);
Assertions.assertEquals(jobId, str.substring(6));
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,31 @@

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

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class CheckTypeTest {

@Test
public void testGetCode() {
assertEquals(0, CheckType.COMPARISON_MINUS_STATISTICS.getCode());
assertEquals(1, CheckType.STATISTICS_MINUS_COMPARISON.getCode());
assertEquals(2, CheckType.STATISTICS_COMPARISON_PERCENTAGE.getCode());
assertEquals(3, CheckType.STATISTICS_COMPARISON_DIFFERENCE_COMPARISON_PERCENTAGE.getCode());
Assertions.assertEquals(0, CheckType.COMPARISON_MINUS_STATISTICS.getCode());
Assertions.assertEquals(1, CheckType.STATISTICS_MINUS_COMPARISON.getCode());
Assertions.assertEquals(2, CheckType.STATISTICS_COMPARISON_PERCENTAGE.getCode());
Assertions.assertEquals(3, CheckType.STATISTICS_COMPARISON_DIFFERENCE_COMPARISON_PERCENTAGE.getCode());
}

@Test
public void testGetDescription() {
assertEquals("comparison_minus_statistics", CheckType.COMPARISON_MINUS_STATISTICS.getDescription());
assertEquals("statistics_minus_comparison", CheckType.STATISTICS_MINUS_COMPARISON.getDescription());
assertEquals("statistics_comparison_percentage", CheckType.STATISTICS_COMPARISON_PERCENTAGE.getDescription());
assertEquals("statistics_comparison_difference_comparison_percentage", CheckType.STATISTICS_COMPARISON_DIFFERENCE_COMPARISON_PERCENTAGE.getDescription());
Assertions.assertEquals("comparison_minus_statistics", CheckType.COMPARISON_MINUS_STATISTICS.getDescription());
Assertions.assertEquals("statistics_minus_comparison", CheckType.STATISTICS_MINUS_COMPARISON.getDescription());
Assertions.assertEquals("statistics_comparison_percentage",
CheckType.STATISTICS_COMPARISON_PERCENTAGE.getDescription());
Assertions.assertEquals("statistics_comparison_difference_comparison_percentage",
CheckType.STATISTICS_COMPARISON_DIFFERENCE_COMPARISON_PERCENTAGE.getDescription());
}

@Test
public void testOf() {
assertEquals(CheckType.COMPARISON_MINUS_STATISTICS, CheckType.of(0));
Assertions.assertEquals(CheckType.COMPARISON_MINUS_STATISTICS, CheckType.of(0));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,25 @@

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

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class ConnectorTypeTest {

@Test
public void testGetCode() {
assertEquals(0, ConnectorType.JDBC.getCode());
assertEquals(1, ConnectorType.HIVE.getCode());
Assertions.assertEquals(0, ConnectorType.JDBC.getCode());
Assertions.assertEquals(1, ConnectorType.HIVE.getCode());
}

@Test
public void testGetDescription() {
assertEquals("JDBC", ConnectorType.JDBC.getDescription());
assertEquals("HIVE", ConnectorType.HIVE.getDescription());
Assertions.assertEquals("JDBC", ConnectorType.JDBC.getDescription());
Assertions.assertEquals("HIVE", ConnectorType.HIVE.getDescription());
}

@Test
public void testOf() {
assertEquals(ConnectorType.JDBC, ConnectorType.of(0));
Assertions.assertEquals(ConnectorType.JDBC, ConnectorType.of(0));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,26 @@

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

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class DqFailureStrategyTest {

@Test
public void testGetCode() {
assertEquals(0, DqFailureStrategy.ALERT.getCode());
assertEquals(1, DqFailureStrategy.BLOCK.getCode());
Assertions.assertEquals(0, DqFailureStrategy.ALERT.getCode());
Assertions.assertEquals(1, DqFailureStrategy.BLOCK.getCode());
}

@Test
public void testGetDescription() {
assertEquals("alert", DqFailureStrategy.ALERT.getDescription());
assertEquals("block", DqFailureStrategy.BLOCK.getDescription());
Assertions.assertEquals("alert", DqFailureStrategy.ALERT.getDescription());
Assertions.assertEquals("block", DqFailureStrategy.BLOCK.getDescription());
}

@Test
public void testOf() {
assertEquals(DqFailureStrategy.ALERT, DqFailureStrategy.of(0));
assertEquals(DqFailureStrategy.BLOCK, DqFailureStrategy.of(1));
Assertions.assertEquals(DqFailureStrategy.ALERT, DqFailureStrategy.of(0));
Assertions.assertEquals(DqFailureStrategy.BLOCK, DqFailureStrategy.of(1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,29 @@

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

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class DqTaskStateTest {

@Test
public void testGetCode() {
assertEquals(0, DqTaskState.DEFAULT.getCode());
assertEquals(1, DqTaskState.SUCCESS.getCode());
assertEquals(2, DqTaskState.FAILURE.getCode());
Assertions.assertEquals(0, DqTaskState.DEFAULT.getCode());
Assertions.assertEquals(1, DqTaskState.SUCCESS.getCode());
Assertions.assertEquals(2, DqTaskState.FAILURE.getCode());
}

@Test
public void testGetDescription() {
assertEquals("default", DqTaskState.DEFAULT.getDescription());
assertEquals("success", DqTaskState.SUCCESS.getDescription());
assertEquals("failure", DqTaskState.FAILURE.getDescription());
Assertions.assertEquals("default", DqTaskState.DEFAULT.getDescription());
Assertions.assertEquals("success", DqTaskState.SUCCESS.getDescription());
Assertions.assertEquals("failure", DqTaskState.FAILURE.getDescription());
}

@Test
public void testOf() {
assertEquals(DqTaskState.DEFAULT, DqTaskState.of(0));
assertEquals(DqTaskState.SUCCESS, DqTaskState.of(1));
assertEquals(DqTaskState.FAILURE, DqTaskState.of(2));
Assertions.assertEquals(DqTaskState.DEFAULT, DqTaskState.of(0));
Assertions.assertEquals(DqTaskState.SUCCESS, DqTaskState.of(1));
Assertions.assertEquals(DqTaskState.FAILURE, DqTaskState.of(2));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,29 @@

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

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class ExecuteSqlTypeTest {

@Test
public void testGetCode() {
assertEquals(0, ExecuteSqlType.MIDDLE.getCode());
assertEquals(1, ExecuteSqlType.STATISTICS.getCode());
assertEquals(2, ExecuteSqlType.COMPARISON.getCode());
Assertions.assertEquals(0, ExecuteSqlType.MIDDLE.getCode());
Assertions.assertEquals(1, ExecuteSqlType.STATISTICS.getCode());
Assertions.assertEquals(2, ExecuteSqlType.COMPARISON.getCode());
}

@Test
public void testGetDescription() {
assertEquals("middle", ExecuteSqlType.MIDDLE.getDescription());
assertEquals("statistics", ExecuteSqlType.STATISTICS.getDescription());
assertEquals("comparison", ExecuteSqlType.COMPARISON.getDescription());
Assertions.assertEquals("middle", ExecuteSqlType.MIDDLE.getDescription());
Assertions.assertEquals("statistics", ExecuteSqlType.STATISTICS.getDescription());
Assertions.assertEquals("comparison", ExecuteSqlType.COMPARISON.getDescription());
}

@Test
public void testOf() {
assertEquals(ExecuteSqlType.MIDDLE, ExecuteSqlType.of(0));
assertEquals(ExecuteSqlType.STATISTICS, ExecuteSqlType.of(1));
assertEquals(ExecuteSqlType.COMPARISON, ExecuteSqlType.of(2));
Assertions.assertEquals(ExecuteSqlType.MIDDLE, ExecuteSqlType.of(0));
Assertions.assertEquals(ExecuteSqlType.STATISTICS, ExecuteSqlType.of(1));
Assertions.assertEquals(ExecuteSqlType.COMPARISON, ExecuteSqlType.of(2));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,32 @@

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

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class InputTypeTest {

@Test
public void testGetCode() {
assertEquals(0, InputType.DEFAULT.getCode());
assertEquals(1, InputType.STATISTICS.getCode());
assertEquals(2, InputType.COMPARISON.getCode());
assertEquals(3, InputType.CHECK.getCode());
Assertions.assertEquals(0, InputType.DEFAULT.getCode());
Assertions.assertEquals(1, InputType.STATISTICS.getCode());
Assertions.assertEquals(2, InputType.COMPARISON.getCode());
Assertions.assertEquals(3, InputType.CHECK.getCode());
}

@Test
public void testGetDescription() {
assertEquals("default", InputType.DEFAULT.getDescription());
assertEquals("statistics", InputType.STATISTICS.getDescription());
assertEquals("comparison", InputType.COMPARISON.getDescription());
assertEquals("check", InputType.CHECK.getDescription());
Assertions.assertEquals("default", InputType.DEFAULT.getDescription());
Assertions.assertEquals("statistics", InputType.STATISTICS.getDescription());
Assertions.assertEquals("comparison", InputType.COMPARISON.getDescription());
Assertions.assertEquals("check", InputType.CHECK.getDescription());
}

@Test
public void testOf() {
assertEquals(InputType.DEFAULT, InputType.of(0));
assertEquals(InputType.STATISTICS, InputType.of(1));
assertEquals(InputType.COMPARISON, InputType.of(2));
assertEquals(InputType.CHECK, InputType.of(3));
Assertions.assertEquals(InputType.DEFAULT, InputType.of(0));
Assertions.assertEquals(InputType.STATISTICS, InputType.of(1));
Assertions.assertEquals(InputType.COMPARISON, InputType.of(2));
Assertions.assertEquals(InputType.CHECK, InputType.of(3));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,38 @@

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

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class OperatorTypeTest {

@Test
public void testGetCode() {
assertEquals(0, OperatorType.EQ.getCode());
assertEquals(1, OperatorType.LT.getCode());
assertEquals(2, OperatorType.LE.getCode());
assertEquals(3, OperatorType.GT.getCode());
assertEquals(4, OperatorType.GE.getCode());
assertEquals(5, OperatorType.NE.getCode());
Assertions.assertEquals(0, OperatorType.EQ.getCode());
Assertions.assertEquals(1, OperatorType.LT.getCode());
Assertions.assertEquals(2, OperatorType.LE.getCode());
Assertions.assertEquals(3, OperatorType.GT.getCode());
Assertions.assertEquals(4, OperatorType.GE.getCode());
Assertions.assertEquals(5, OperatorType.NE.getCode());
}

@Test
public void testGetDescription() {
assertEquals("equal", OperatorType.EQ.getDescription());
assertEquals("little than", OperatorType.LT.getDescription());
assertEquals("little and equal", OperatorType.LE.getDescription());
assertEquals("great than", OperatorType.GT.getDescription());
assertEquals("great and equal", OperatorType.GE.getDescription());
assertEquals("not equal", OperatorType.NE.getDescription());
Assertions.assertEquals("equal", OperatorType.EQ.getDescription());
Assertions.assertEquals("little than", OperatorType.LT.getDescription());
Assertions.assertEquals("little and equal", OperatorType.LE.getDescription());
Assertions.assertEquals("great than", OperatorType.GT.getDescription());
Assertions.assertEquals("great and equal", OperatorType.GE.getDescription());
Assertions.assertEquals("not equal", OperatorType.NE.getDescription());
}

@Test
public void testOf() {
assertEquals(OperatorType.EQ, OperatorType.of(0));
assertEquals(OperatorType.LT, OperatorType.of(1));
assertEquals(OperatorType.LE, OperatorType.of(2));
assertEquals(OperatorType.GT, OperatorType.of(3));
assertEquals(OperatorType.GE, OperatorType.of(4));
assertEquals(OperatorType.NE, OperatorType.of(5));
Assertions.assertEquals(OperatorType.EQ, OperatorType.of(0));
Assertions.assertEquals(OperatorType.LT, OperatorType.of(1));
Assertions.assertEquals(OperatorType.LE, OperatorType.of(2));
Assertions.assertEquals(OperatorType.GT, OperatorType.of(3));
Assertions.assertEquals(OperatorType.GE, OperatorType.of(4));
Assertions.assertEquals(OperatorType.NE, OperatorType.of(5));
}
}
Loading