Browse Source

[improvement] Migrate all UT cases from jUnit4 to jUnit5 in dao module (#12328)

* [improvement] Migrate all UT cases from jUnit4 to jUnit5 in dao module

Co-authored-by: Jackie <‘2875334588@qq.com’>
3.2.0-release
fuchanghai 2 years ago committed by GitHub
parent
commit
22103f975e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/AlertDaoTest.java
  2. 6
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/BaseDaoTest.java
  3. 6
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinitionTest.java
  4. 12
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/entity/TaskInstanceTest.java
  5. 8
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/entity/UdfFuncTest.java
  6. 42
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapperTest.java
  7. 32
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapperTest.java
  8. 16
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AlertMapperTest.java
  9. 18
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AlertPluginInstanceMapperTest.java
  10. 8
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AlertSendStatusMapperTest.java
  11. 8
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AuditLogMapperTest.java
  12. 32
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ClusterMapperTest.java
  13. 34
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/CommandMapperTest.java
  14. 43
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/DataSourceMapperTest.java
  15. 14
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/DataSourceUserMapperTest.java
  16. 2
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/DqRuleInputEntryMapperTest.java
  17. 32
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/EnvironmentMapperTest.java
  18. 20
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/EnvironmentWorkerGroupRelationMapperTest.java
  19. 8
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapperTest.java
  20. 24
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/K8sNamespaceMapperTest.java
  21. 16
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/PluginDefineTest.java
  22. 20
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionLogMapperTest.java
  23. 32
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapperTest.java
  24. 14
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapMapperTest.java
  25. 43
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapperTest.java
  26. 6
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessTaskRelationLogMapperTest.java
  27. 12
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessTaskRelationMapperTest.java
  28. 31
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapperTest.java
  29. 17
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectUserMapperTest.java
  30. 26
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/QueueMapperTest.java
  31. 67
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapperTest.java
  32. 19
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceUserMapperTest.java
  33. 18
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ScheduleMapperTest.java
  34. 12
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/SessionMapperTest.java
  35. 12
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionLogMapperTest.java
  36. 28
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionMapperTest.java
  37. 21
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupMapperTest.java
  38. 16
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupQueueMapperTest.java
  39. 32
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapperTest.java
  40. 21
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TenantMapperTest.java
  41. 14
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UDFUserMapperTest.java
  42. 28
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapperTest.java
  43. 26
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UserMapperTest.java
  44. 12
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/WorkFlowLineageMapperTest.java
  45. 24
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/WorkerGroupMapperTest.java
  46. 9
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/upgrade/ProcessDefinitionDaoTest.java
  47. 30
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/upgrade/SchemaUtilsTest.java
  48. 28
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/upgrade/WorkerGroupDaoTest.java
  49. 6
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/utils/ResourceProcessDefinitionUtilsTest.java
  50. 106
      dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/utils/DagHelperTest.java

18
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/AlertDaoTest.java

@ -23,20 +23,20 @@ import org.apache.dolphinscheduler.dao.entity.Alert;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
@ActiveProfiles(ProfileType.H2)
@RunWith(SpringRunner.class)
@ExtendWith(MockitoExtension.class)
@SpringBootApplication(scanBasePackageClasses = DaoConfiguration.class)
@SpringBootTest(classes = DaoConfiguration.class)
@Transactional
@ -57,14 +57,14 @@ public class AlertDaoTest {
alertDao.addAlert(alert);
List<Alert> alerts = alertDao.listPendingAlerts();
Assert.assertNotNull(alerts);
Assert.assertNotEquals(0, alerts.size());
Assertions.assertNotNull(alerts);
Assertions.assertNotEquals(0, alerts.size());
}
@Test
public void testAddAlertSendStatus() {
int insertCount = alertDao.addAlertSendStatus(AlertStatus.EXECUTION_SUCCESS,"success",1,1);
Assert.assertEquals(1, insertCount);
Assertions.assertEquals(1, insertCount);
}
@Test
@ -78,6 +78,6 @@ public class AlertDaoTest {
.stream()
.filter(alert -> alert.getContent().contains(host))
.count();
Assert.assertEquals(1L, count);
Assertions.assertEquals(1L, count);
}
}

6
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/BaseDaoTest.java

@ -17,15 +17,15 @@
package org.apache.dolphinscheduler.dao;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
@RunWith(SpringRunner.class)
@ExtendWith(MockitoExtension.class)
@SpringBootTest(classes = DaoConfiguration.class)
@SpringBootApplication(scanBasePackageClasses = DaoConfiguration.class)
@Transactional

6
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinitionTest.java

@ -17,8 +17,8 @@
package org.apache.dolphinscheduler.dao.entity;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class ProcessDefinitionTest {
@ -33,7 +33,7 @@ public class ProcessDefinitionTest {
taskInstance.setGlobalParams("[{\"prop\":\"selenium_global_parameters_1\",\"direct\":\"IN\",\"type\":\"VARCHAR\",\"value\":\"selenium_global_parameters_value_1\"}]");
taskInstance.getGlobalParamMap();
Assert.assertEquals("{selenium_global_parameters_1=selenium_global_parameters_value_1}",taskInstance.getGlobalParamMap().toString());
Assertions.assertEquals("{selenium_global_parameters_1=selenium_global_parameters_value_1}",taskInstance.getGlobalParamMap().toString());
}
}

12
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/entity/TaskInstanceTest.java

@ -30,8 +30,8 @@ import org.apache.dolphinscheduler.plugin.task.api.parameters.DependentParameter
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class TaskInstanceTest {
@ -44,19 +44,19 @@ public class TaskInstanceTest {
//sub process
taskInstance.setTaskType(TASK_TYPE_SUB_PROCESS);
Assert.assertTrue(taskInstance.isSubProcess());
Assertions.assertTrue(taskInstance.isSubProcess());
//not sub process
taskInstance.setTaskType("HTTP");
Assert.assertFalse(taskInstance.isSubProcess());
Assertions.assertFalse(taskInstance.isSubProcess());
//sub process
taskInstance.setTaskType(TASK_TYPE_CONDITIONS);
Assert.assertTrue(taskInstance.isConditionsTask());
Assertions.assertTrue(taskInstance.isConditionsTask());
//sub process
taskInstance.setTaskType(TASK_TYPE_DEPENDENT);
Assert.assertTrue(taskInstance.isDependTask());
Assertions.assertTrue(taskInstance.isDependTask());
}
/**

8
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/entity/UdfFuncTest.java

@ -21,8 +21,8 @@ import org.apache.dolphinscheduler.dao.entity.UdfFunc.UdfFuncDeserializer;
import java.io.IOException;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class UdfFuncTest {
@ -36,7 +36,7 @@ public class UdfFuncTest {
// UdfFuncDeserializer.deserializeKey key is null
UdfFuncDeserializer udfFuncDeserializer = new UdfFuncDeserializer();
Assert.assertNull(udfFuncDeserializer.deserializeKey(null, null));
Assertions.assertNull(udfFuncDeserializer.deserializeKey(null, null));
//
UdfFunc udfFunc = new UdfFunc();
@ -44,7 +44,7 @@ public class UdfFuncTest {
udfFunc.setResourceId(2);
udfFunc.setClassName("org.apache.dolphinscheduler.test.mrUpdate");
Assert.assertNotNull(udfFuncDeserializer.deserializeKey(udfFunc.toString(), null));
Assertions.assertNotNull(udfFuncDeserializer.deserializeKey(udfFunc.toString(), null));
}
}

42
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapperTest.java

@ -17,13 +17,6 @@
package org.apache.dolphinscheduler.dao.mapper;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.dao.BaseDaoTest;
@ -37,8 +30,8 @@ import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -61,9 +54,8 @@ public class AccessTokenMapperTest extends BaseDaoTest {
@Test
public void testInsert() throws Exception {
Integer userId = 1;
AccessToken accessToken = createAccessToken(userId);
assertThat(accessToken.getId(), greaterThan(0));
Assertions.assertTrue(accessToken.getId() > 0);
}
/**
@ -84,7 +76,7 @@ public class AccessTokenMapperTest extends BaseDaoTest {
}
int deleteCount = accessTokenMapper.deleteAccessTokenByUserId(userId);
Assert.assertEquals(insertCount, deleteCount);
Assertions.assertEquals(insertCount, deleteCount);
}
/**
@ -97,7 +89,7 @@ public class AccessTokenMapperTest extends BaseDaoTest {
Integer userId = 1;
AccessToken accessToken = createAccessToken(userId);
AccessToken resultAccessToken = accessTokenMapper.selectById(accessToken.getId());
assertEquals(accessToken, resultAccessToken);
Assertions.assertEquals(accessToken, resultAccessToken);
}
/**
@ -111,7 +103,7 @@ public class AccessTokenMapperTest extends BaseDaoTest {
AccessToken accessToken = createAccessToken(userId);
AccessToken resultAccessToken = accessTokenMapper.selectById(accessToken.getId());
boolean flag = accessToken.equals(resultAccessToken);
assertTrue(flag);
Assertions.assertTrue(flag);
}
/**
@ -124,7 +116,7 @@ public class AccessTokenMapperTest extends BaseDaoTest {
Integer userId = 1;
AccessToken accessToken = createAccessToken(userId);
int result = accessToken.hashCode();
assertNotNull(result);
Assertions.assertNotNull(Integer.valueOf(result));
}
/**
@ -145,20 +137,20 @@ public class AccessTokenMapperTest extends BaseDaoTest {
// general user and create token user
Page page = new Page(offset, size);
IPage<AccessToken> accessTokenPage = accessTokenMapper.selectAccessTokenPage(page, userName, createTokenUserId);
assertEquals(Integer.valueOf(accessTokenPage.getRecords().size()), size);
Assertions.assertEquals(Integer.valueOf(accessTokenPage.getRecords().size()), size);
// admin user
IPage<AccessToken> adminAccessTokenPage = accessTokenMapper.selectAccessTokenPage(page, userName, 0);
assertEquals(Integer.valueOf(adminAccessTokenPage.getRecords().size()), size);
Assertions.assertEquals(Integer.valueOf(adminAccessTokenPage.getRecords().size()), size);
for (AccessToken accessToken : adminAccessTokenPage.getRecords()) {
AccessToken resultAccessToken = accessTokenMap.get(accessToken.getId());
assertEquals(accessToken, resultAccessToken);
Assertions.assertEquals(accessToken, resultAccessToken);
}
// general user
Integer emptySize = 0;
IPage<AccessToken> generalAccessTokenPage = accessTokenMapper.selectAccessTokenPage(page, userName, 1);
assertEquals(Integer.valueOf(generalAccessTokenPage.getRecords().size()), emptySize);
Assertions.assertEquals(Integer.valueOf(generalAccessTokenPage.getRecords().size()), emptySize);
}
@ -175,10 +167,10 @@ public class AccessTokenMapperTest extends BaseDaoTest {
accessToken.setUpdateTime(DateUtils.getCurrentDate());
int status = accessTokenMapper.updateById(accessToken);
if (status != 1) {
Assert.fail("update access token fail");
Assertions.fail("update access token fail");
}
AccessToken resultAccessToken = accessTokenMapper.selectById(accessToken.getId());
assertEquals(accessToken, resultAccessToken);
Assertions.assertEquals(accessToken, resultAccessToken);
}
/**
@ -191,12 +183,12 @@ public class AccessTokenMapperTest extends BaseDaoTest {
AccessToken accessToken = createAccessToken(userId);
int status = accessTokenMapper.deleteById(accessToken.getId());
if (status != 1) {
Assert.fail("delete access token data fail");
Assertions.fail("delete access token data fail");
}
AccessToken resultAccessToken =
accessTokenMapper.selectById(accessToken.getId());
assertNull(resultAccessToken);
Assertions.assertNull(resultAccessToken);
}
/**
@ -243,7 +235,7 @@ public class AccessTokenMapperTest extends BaseDaoTest {
int status = userMapper.insert(user);
if (status != 1) {
Assert.fail("insert user data error");
Assertions.fail("insert user data error");
}
return user;
@ -269,7 +261,7 @@ public class AccessTokenMapperTest extends BaseDaoTest {
int status = accessTokenMapper.insert(accessToken);
if (status != 1) {
Assert.fail("insert data error");
Assertions.fail("insert data error");
}
return accessToken;
}

32
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapperTest.java

@ -19,10 +19,6 @@ package org.apache.dolphinscheduler.dao.mapper;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.dao.BaseDaoTest;
@ -32,8 +28,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -53,8 +49,8 @@ public class AlertGroupMapperTest extends BaseDaoTest {
@Test
public void testInsert() {
AlertGroup alertGroup = createAlertGroup();
assertNotNull(alertGroup);
assertThat(alertGroup.getId(), greaterThan(0));
Assertions.assertNotNull(alertGroup);
Assertions.assertTrue(alertGroup.getId() > 0);
}
@ -67,8 +63,7 @@ public class AlertGroupMapperTest extends BaseDaoTest {
AlertGroup alertGroup = createAlertGroup();
//query
AlertGroup targetAlert = alertGroupMapper.selectById(alertGroup.getId());
assertEquals(alertGroup, targetAlert);
Assertions.assertEquals(alertGroup, targetAlert);
}
@ -93,12 +88,12 @@ public class AlertGroupMapperTest extends BaseDaoTest {
List<AlertGroup> alertGroupList = alertGroupIPage.getRecords();
assertEquals(alertGroupList.size(), size.intValue());
Assertions.assertEquals(alertGroupList.size(), size.intValue());
for (AlertGroup alertGroup : alertGroupList) {
AlertGroup resultAlertGroup = alertGroupMap.get(alertGroup.getId());
if (resultAlertGroup != null) {
assertEquals(alertGroup, resultAlertGroup);
Assertions.assertEquals(alertGroup, resultAlertGroup);
}
}
@ -119,7 +114,7 @@ public class AlertGroupMapperTest extends BaseDaoTest {
AlertGroup resultAlertGroup = alertGroupMapper.selectById(alertGroup.getId());
assertEquals(alertGroup, resultAlertGroup);
Assertions.assertEquals(alertGroup, resultAlertGroup);
}
@ -135,7 +130,7 @@ public class AlertGroupMapperTest extends BaseDaoTest {
AlertGroup resultAlertGroup = alertGroupMapper.selectById(alertGroup.getId());
assertNull(resultAlertGroup);
Assertions.assertNull(resultAlertGroup);
}
@ -159,7 +154,7 @@ public class AlertGroupMapperTest extends BaseDaoTest {
String groupName = "testGroup";
createAlertGroups(1, groupName);
Assert.assertTrue(alertGroupMapper.existGroupName(groupName));
Assertions.assertTrue(alertGroupMapper.existGroupName(groupName));
}
/**
@ -185,12 +180,12 @@ public class AlertGroupMapperTest extends BaseDaoTest {
private void compareAlertGroups(Map<Integer, AlertGroup> alertGroupMap,
List<AlertGroup> alertGroupList) {
// greaterThanOrEqualTo,beacuse maybe db have already exists
assertThat(alertGroupList.size(), greaterThanOrEqualTo(alertGroupMap.size()));
Assertions.assertTrue(alertGroupList.size() >= alertGroupMap.size());
for (AlertGroup alertGroup : alertGroupList) {
AlertGroup resultAlertGroup = alertGroupMap.get(alertGroup.getId());
if (resultAlertGroup != null) {
assertEquals(alertGroup, resultAlertGroup);
Assertions.assertEquals(alertGroup, resultAlertGroup);
}
}
}
@ -257,8 +252,7 @@ public class AlertGroupMapperTest extends BaseDaoTest {
* @param count create AlertGroup count
* @return AlertGroup map
*/
private Map<Integer, AlertGroup> createAlertGroups(
Integer count) {
private Map<Integer, AlertGroup> createAlertGroups(Integer count) {
Map<Integer, AlertGroup> alertGroupMap = new HashMap<>();
AlertGroup alertGroup = null;

16
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AlertMapperTest.java

@ -17,11 +17,6 @@
package org.apache.dolphinscheduler.dao.mapper;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import org.apache.dolphinscheduler.common.enums.AlertStatus;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.utils.DateUtils;
@ -33,7 +28,8 @@ import org.apache.commons.codec.digest.DigestUtils;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
/**
@ -52,7 +48,7 @@ public class AlertMapperTest extends BaseDaoTest {
@Test
public void testInsert() {
Alert expectedAlert = createAlert();
assertThat(expectedAlert.getId(), greaterThan(0));
Assertions.assertTrue(expectedAlert.getId() > 0);
}
/**
@ -64,7 +60,7 @@ public class AlertMapperTest extends BaseDaoTest {
public void testSelectById() {
Alert expectedAlert = createAlert();
Alert actualAlert = alertMapper.selectById(expectedAlert.getId());
assertEquals(expectedAlert, actualAlert);
Assertions.assertEquals(expectedAlert, actualAlert);
}
/**
@ -83,7 +79,7 @@ public class AlertMapperTest extends BaseDaoTest {
Alert actualAlert = alertMapper.selectById(expectedAlert.getId());
assertEquals(expectedAlert, actualAlert);
Assertions.assertEquals(expectedAlert, actualAlert);
}
/**
@ -97,7 +93,7 @@ public class AlertMapperTest extends BaseDaoTest {
Alert actualAlert = alertMapper.selectById(expectedAlert.getId());
assertNull(actualAlert);
Assertions.assertNull(actualAlert);
}
/**

18
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AlertPluginInstanceMapperTest.java

@ -23,8 +23,8 @@ import org.apache.dolphinscheduler.dao.entity.PluginDefine;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -47,15 +47,15 @@ public class AlertPluginInstanceMapperTest extends BaseDaoTest {
@Test
public void testQueryAllAlertPluginInstanceList() {
List<AlertPluginInstance> withoutSingleOne = alertPluginInstanceMapper.queryAllAlertPluginInstanceList();
Assert.assertEquals(0, withoutSingleOne.size());
Assertions.assertEquals(0, withoutSingleOne.size());
createAlertPluginInstance("test_instance_1");
List<AlertPluginInstance> withExactlyOne = alertPluginInstanceMapper.queryAllAlertPluginInstanceList();
Assert.assertEquals(1, withExactlyOne.size());
Assertions.assertEquals(1, withExactlyOne.size());
createAlertPluginInstance("test_instance_2");
List<AlertPluginInstance> withExactlyTwo = alertPluginInstanceMapper.queryAllAlertPluginInstanceList();
Assert.assertEquals(2, withExactlyTwo.size());
Assertions.assertEquals(2, withExactlyTwo.size());
}
/**
@ -64,9 +64,9 @@ public class AlertPluginInstanceMapperTest extends BaseDaoTest {
@Test
public void testExistInstanceName() {
String instanceName = "test_instance";
Assert.assertNull(alertPluginInstanceMapper.existInstanceName(instanceName));
Assertions.assertNull(alertPluginInstanceMapper.existInstanceName(instanceName));
createAlertPluginInstance(instanceName);
Assert.assertTrue(alertPluginInstanceMapper.existInstanceName(instanceName));
Assertions.assertTrue(alertPluginInstanceMapper.existInstanceName(instanceName));
}
/**
@ -79,10 +79,10 @@ public class AlertPluginInstanceMapperTest extends BaseDaoTest {
Page<AlertPluginInstance> page = new Page<>(1, 10);
IPage<AlertPluginInstance> matchTwoRecord = alertPluginInstanceMapper.queryByInstanceNamePage(page, "test");
Assert.assertEquals(2, matchTwoRecord.getTotal());
Assertions.assertEquals(2, matchTwoRecord.getTotal());
IPage<AlertPluginInstance> matchOneRecord = alertPluginInstanceMapper.queryByInstanceNamePage(page, "pattern");
Assert.assertEquals(1, matchOneRecord.getTotal());
Assertions.assertEquals(1, matchOneRecord.getTotal());
}
/**

8
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AlertSendStatusMapperTest.java

@ -17,15 +17,13 @@
package org.apache.dolphinscheduler.dao.mapper;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertThat;
import org.apache.dolphinscheduler.common.enums.AlertStatus;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.dao.BaseDaoTest;
import org.apache.dolphinscheduler.dao.entity.AlertSendStatus;
import org.junit.Test;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
/**
@ -48,6 +46,6 @@ public class AlertSendStatusMapperTest extends BaseDaoTest {
alertSendStatus.setCreateTime(DateUtils.getCurrentDate());
alertSendStatusMapper.insert(alertSendStatus);
assertThat(alertSendStatus.getId(), greaterThan(0));
Assertions.assertThat(alertSendStatus.getId() > 0);
}
}

8
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AuditLogMapperTest.java

@ -22,8 +22,8 @@ import org.apache.dolphinscheduler.dao.entity.AuditLog;
import java.util.Date;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -59,12 +59,12 @@ public class AuditLogMapperTest extends BaseDaoTest {
int[] operationType = new int[0];
IPage<AuditLog> logIPage = logMapper.queryAuditLog(page, resourceType, operationType, "", null, null);
Assert.assertNotEquals(logIPage.getTotal(), 0);
Assertions.assertNotEquals(logIPage.getTotal(), 0);
}
@Test
public void testQueryResourceNameByType() {
String resourceName = logMapper.queryResourceNameByType("USER", 1);
Assert.assertEquals("admin", resourceName);
Assertions.assertEquals("admin", resourceName);
}
}

32
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ClusterMapperTest.java

@ -23,10 +23,10 @@ import org.apache.dolphinscheduler.dao.entity.Cluster;
import java.util.Date;
import java.util.List;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -56,12 +56,12 @@ public class ClusterMapperTest extends BaseDaoTest {
return cluster;
}
@Before
@BeforeEach
public void setUp() {
clearTestData();
}
@After
@AfterEach
public void after() {
clearTestData();
}
@ -82,7 +82,7 @@ public class ClusterMapperTest extends BaseDaoTest {
cluster.setDescription("new description info");
// update
int update = clusterMapper.updateById(cluster);
Assert.assertEquals(update, 1);
Assertions.assertEquals(update, 1);
}
/**
@ -92,7 +92,7 @@ public class ClusterMapperTest extends BaseDaoTest {
public void testDelete() {
Cluster cluster = insertOne();
int delete = clusterMapper.deleteById(cluster.getId());
Assert.assertEquals(delete, 1);
Assertions.assertEquals(delete, 1);
}
/**
@ -103,7 +103,7 @@ public class ClusterMapperTest extends BaseDaoTest {
insertOne();
// query
List<Cluster> clusters = clusterMapper.selectList(null);
Assert.assertEquals(clusters.size(), 1);
Assertions.assertEquals(clusters.size(), 1);
}
/**
@ -113,7 +113,7 @@ public class ClusterMapperTest extends BaseDaoTest {
public void testQueryByClusterName() {
Cluster entity = insertOne();
Cluster cluster = clusterMapper.queryByClusterName(entity.getName());
Assert.assertEquals(entity.toString(), cluster.toString());
Assertions.assertEquals(entity.toString(), cluster.toString());
}
/**
@ -123,7 +123,7 @@ public class ClusterMapperTest extends BaseDaoTest {
public void testQueryByClusterCode() {
Cluster entity = insertOne();
Cluster cluster = clusterMapper.queryByClusterCode(entity.getCode());
Assert.assertEquals(entity.toString(), cluster.toString());
Assertions.assertEquals(entity.toString(), cluster.toString());
}
/**
@ -133,8 +133,8 @@ public class ClusterMapperTest extends BaseDaoTest {
public void testQueryAllClusterList() {
Cluster entity = insertOne();
List<Cluster> clusters = clusterMapper.queryAllClusterList();
Assert.assertEquals(clusters.size(), 1);
Assert.assertEquals(entity.toString(), clusters.get(0).toString());
Assertions.assertEquals(clusters.size(), 1);
Assertions.assertEquals(entity.toString(), clusters.get(0).toString());
}
/**
@ -146,11 +146,11 @@ public class ClusterMapperTest extends BaseDaoTest {
Page<Cluster> page = new Page<>(1, 10);
IPage<Cluster> clusterIPage = clusterMapper.queryClusterListPaging(page, "");
List<Cluster> clusterList = clusterIPage.getRecords();
Assert.assertEquals(clusterList.size(), 1);
Assertions.assertEquals(clusterList.size(), 1);
clusterIPage = clusterMapper.queryClusterListPaging(page, "abc");
clusterList = clusterIPage.getRecords();
Assert.assertEquals(clusterList.size(), 0);
Assertions.assertEquals(clusterList.size(), 0);
}
/**
@ -160,7 +160,7 @@ public class ClusterMapperTest extends BaseDaoTest {
public void testDeleteByCode() {
Cluster entity = insertOne();
int delete = clusterMapper.deleteByCode(entity.getCode());
Assert.assertEquals(delete, 1);
Assertions.assertEquals(delete, 1);
}
private String getDesc() {

34
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/CommandMapperTest.java

@ -17,13 +17,6 @@
package org.apache.dolphinscheduler.dao.mapper;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.CommandType;
@ -44,7 +37,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
/**
@ -64,7 +58,7 @@ public class CommandMapperTest extends BaseDaoTest {
@Test
public void testInsert() {
Command command = createCommand();
assertThat(command.getId(), greaterThan(0));
Assertions.assertTrue(command.getId() > 0);
}
/**
@ -76,8 +70,8 @@ public class CommandMapperTest extends BaseDaoTest {
// query
Command actualCommand = commandMapper.selectById(expectedCommand.getId());
assertNotNull(actualCommand);
assertEquals(expectedCommand.getProcessDefinitionCode(), actualCommand.getProcessDefinitionCode());
Assertions.assertNotNull(actualCommand);
Assertions.assertEquals(expectedCommand.getProcessDefinitionCode(), actualCommand.getProcessDefinitionCode());
}
/**
@ -95,8 +89,8 @@ public class CommandMapperTest extends BaseDaoTest {
Command actualCommand = commandMapper.selectById(expectedCommand.getId());
assertNotNull(actualCommand);
assertEquals(expectedCommand.getUpdateTime(), actualCommand.getUpdateTime());
Assertions.assertNotNull(actualCommand);
Assertions.assertEquals(expectedCommand.getUpdateTime(), actualCommand.getUpdateTime());
}
@ -111,7 +105,7 @@ public class CommandMapperTest extends BaseDaoTest {
Command actualCommand = commandMapper.selectById(expectedCommand.getId());
assertNull(actualCommand);
Assertions.assertNull(actualCommand);
}
/**
@ -125,7 +119,7 @@ public class CommandMapperTest extends BaseDaoTest {
List<Command> actualCommands = commandMapper.selectList(null);
assertThat(actualCommands.size(), greaterThanOrEqualTo(count));
Assertions.assertTrue(actualCommands.size() >= count);
}
/**
@ -140,7 +134,7 @@ public class CommandMapperTest extends BaseDaoTest {
List<Command> actualCommand = commandMapper.queryCommandPage(1, 0);
assertNotNull(actualCommand);
Assertions.assertNotNull(actualCommand);
}
/**
@ -162,7 +156,7 @@ public class CommandMapperTest extends BaseDaoTest {
List<CommandCount> actualCommandCounts = commandMapper.countCommandState(startTime, endTime, projectCodeArray);
assertThat(actualCommandCounts.size(), greaterThanOrEqualTo(1));
Assertions.assertTrue(actualCommandCounts.size() >= 1);
}
/**
@ -185,11 +179,11 @@ public class CommandMapperTest extends BaseDaoTest {
boolean hit = id % masterCount == thisMasterSlot;
List<Command> commandList = commandMapper.queryCommandPageBySlot(1, 0, masterCount, thisMasterSlot);
if (hit) {
assertEquals(id, commandList.get(0).getId());
Assertions.assertEquals(id, commandList.get(0).getId());
} else {
commandList.forEach(o -> {
assertNotEquals(id, o.getId());
assertEquals(thisMasterSlot, o.getId() % masterCount);
Assertions.assertNotEquals(id, o.getId());
Assertions.assertEquals(thisMasterSlot, o.getId() % masterCount);
});
}
return hit;

43
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/DataSourceMapperTest.java

@ -18,11 +18,6 @@
package org.apache.dolphinscheduler.dao.mapper;
import static java.util.stream.Collectors.toList;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.UserType;
@ -40,8 +35,8 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -73,7 +68,7 @@ public class DataSourceMapperTest extends BaseDaoTest {
@Test
public void testInsert() {
DataSource dataSource = createDataSource();
assertThat(dataSource.getId(), greaterThan(0));
Assertions.assertTrue(dataSource.getId() > 0);
}
/**
@ -83,7 +78,7 @@ public class DataSourceMapperTest extends BaseDaoTest {
public void testSelectById() {
DataSource expectedDataSource = createDataSource();
DataSource actualDataSource = dataSourceMapper.selectById(expectedDataSource.getId());
assertEquals(expectedDataSource, actualDataSource);
Assertions.assertEquals(expectedDataSource, actualDataSource);
}
/**
@ -104,7 +99,7 @@ public class DataSourceMapperTest extends BaseDaoTest {
DataSource actualDataSource = dataSourceMapper.selectById(expectedDataSource.getId());
assertEquals(expectedDataSource, actualDataSource);
Assertions.assertEquals(expectedDataSource, actualDataSource);
}
/**
@ -118,7 +113,7 @@ public class DataSourceMapperTest extends BaseDaoTest {
DataSource actualDataSource = dataSourceMapper.selectById(expectedDataSource.getId());
assertNull(actualDataSource);
Assertions.assertNull(actualDataSource);
}
/**
@ -133,12 +128,12 @@ public class DataSourceMapperTest extends BaseDaoTest {
List<DataSource> actualDataSources = dataSourceMapper.queryDataSourceByType(
0, DbType.MYSQL.ordinal(), Constants.TEST_FLAG_NO);
assertThat(actualDataSources.size(), greaterThanOrEqualTo(2));
Assertions.assertTrue(actualDataSources.size() >= 2);
for (DataSource actualDataSource : actualDataSources) {
DataSource expectedDataSource = datasourceMap.get(actualDataSource.getId());
if (expectedDataSource != null) {
assertEquals(expectedDataSource, actualDataSource);
Assertions.assertEquals(expectedDataSource, actualDataSource);
}
}
@ -162,7 +157,7 @@ public class DataSourceMapperTest extends BaseDaoTest {
for (DataSource actualDataSource : actualDataSources) {
DataSource expectedDataSource = expectedDataSourceMap.get(actualDataSource.getId());
if (expectedDataSource != null) {
assertEquals(expectedDataSource, actualDataSource);
Assertions.assertEquals(expectedDataSource, actualDataSource);
}
}
@ -179,8 +174,8 @@ public class DataSourceMapperTest extends BaseDaoTest {
List<DataSource> actualDataSources = dataSourceMapper.queryDataSourceByName(name);
for (DataSource actualDataSource : actualDataSources) {
if (expectedDataSource.getId() == actualDataSource.getId()) {
assertEquals(expectedDataSource, actualDataSource);
if (expectedDataSource.getId().equals(actualDataSource.getId())) {
Assertions.assertEquals(expectedDataSource, actualDataSource);
}
}
@ -201,7 +196,7 @@ public class DataSourceMapperTest extends BaseDaoTest {
for (DataSource actualDataSource : actualDataSources) {
DataSource expectedDataSource = expectedDataSourceMap.get(actualDataSource.getId());
if (expectedDataSource != null) {
assertEquals(expectedDataSource, actualDataSource);
Assertions.assertEquals(expectedDataSource, actualDataSource);
}
}
@ -222,7 +217,7 @@ public class DataSourceMapperTest extends BaseDaoTest {
for (DataSource actualDataSource : actualDataSources) {
DataSource expectedDataSource = expectedDataSourceMap.get(actualDataSource.getId());
if (expectedDataSource != null) {
assertEquals(expectedDataSource, actualDataSource);
Assertions.assertEquals(expectedDataSource, actualDataSource);
}
}
}
@ -238,12 +233,12 @@ public class DataSourceMapperTest extends BaseDaoTest {
List<DataSource> actualDataSources = dataSourceMapper.listAllDataSourceByType(DbType.MYSQL.ordinal());
assertThat(actualDataSources.size(), greaterThanOrEqualTo(count));
Assertions.assertTrue(actualDataSources.size() >= count);
for (DataSource actualDataSource : actualDataSources) {
DataSource expectedDataSource = expectedDataSourceMap.get(actualDataSource.getId());
if (expectedDataSource != null) {
assertEquals(expectedDataSource, actualDataSource);
Assertions.assertEquals(expectedDataSource, actualDataSource);
}
}
}
@ -264,16 +259,16 @@ public class DataSourceMapperTest extends BaseDaoTest {
List<DataSource> authorizedDataSource =
dataSourceMapper.listAuthorizedDataSource(generalUser1.getId(), dataSourceIds);
assertEquals(generalUser1.getId().intValue(), dataSource.getUserId());
Assert.assertNotEquals(generalUser1.getId().intValue(), unauthorizdDataSource.getUserId());
Assert.assertFalse(authorizedDataSource.stream().map(t -> t.getId()).collect(toList())
Assertions.assertEquals(generalUser1.getId().intValue(), dataSource.getUserId());
Assertions.assertNotEquals(generalUser1.getId().intValue(), unauthorizdDataSource.getUserId());
Assertions.assertFalse(authorizedDataSource.stream().map(t -> t.getId()).collect(toList())
.containsAll(Arrays.asList(dataSourceIds)));
// authorize object unauthorizdDataSource to generalUser1
createUserDataSource(generalUser1, unauthorizdDataSource);
authorizedDataSource = dataSourceMapper.listAuthorizedDataSource(generalUser1.getId(), dataSourceIds);
Assert.assertTrue(authorizedDataSource.stream().map(t -> t.getId()).collect(toList())
Assertions.assertTrue(authorizedDataSource.stream().map(t -> t.getId()).collect(toList())
.containsAll(Arrays.asList(dataSourceIds)));
}

14
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/DataSourceUserMapperTest.java

@ -23,8 +23,8 @@ import org.apache.dolphinscheduler.dao.entity.DatasourceUser;
import java.util.Date;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class DataSourceUserMapperTest extends BaseDaoTest {
@ -59,7 +59,7 @@ public class DataSourceUserMapperTest extends BaseDaoTest {
//update
dataSourceUser.setUpdateTime(new Date());
int update = dataSourceUserMapper.updateById(dataSourceUser);
Assert.assertEquals(update, 1);
Assertions.assertEquals(update, 1);
}
/**
@ -70,7 +70,7 @@ public class DataSourceUserMapperTest extends BaseDaoTest {
DatasourceUser dataSourceUser = insertOne();
int delete = dataSourceUserMapper.deleteById(dataSourceUser.getId());
Assert.assertEquals(delete, 1);
Assertions.assertEquals(delete, 1);
}
/**
@ -81,7 +81,7 @@ public class DataSourceUserMapperTest extends BaseDaoTest {
DatasourceUser dataSourceUser = insertOne();
//query
List<DatasourceUser> dataSources = dataSourceUserMapper.selectList(null);
Assert.assertNotEquals(dataSources.size(), 0);
Assertions.assertNotEquals(dataSources.size(), 0);
}
/**
@ -91,7 +91,7 @@ public class DataSourceUserMapperTest extends BaseDaoTest {
public void testDeleteByUserId() {
DatasourceUser dataSourceUser = insertOne();
int delete = dataSourceUserMapper.deleteByUserId(dataSourceUser.getUserId());
Assert.assertNotEquals(delete, 0);
Assertions.assertNotEquals(delete, 0);
}
/**
@ -101,6 +101,6 @@ public class DataSourceUserMapperTest extends BaseDaoTest {
public void testDeleteByDatasourceId() {
DatasourceUser dataSourceUser = insertOne();
int delete = dataSourceUserMapper.deleteByDatasourceId(dataSourceUser.getDatasourceId());
Assert.assertNotEquals(delete, 0);
Assertions.assertNotEquals(delete, 0);
}
}

2
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/DqRuleInputEntryMapperTest.java

@ -21,7 +21,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.dolphinscheduler.dao.BaseDaoTest;
import org.apache.dolphinscheduler.dao.entity.DqRule;
import org.apache.dolphinscheduler.dao.entity.DqRuleInputEntry;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;

32
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/EnvironmentMapperTest.java

@ -23,10 +23,10 @@ import org.apache.dolphinscheduler.dao.entity.Environment;
import java.util.Date;
import java.util.List;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -56,12 +56,12 @@ public class EnvironmentMapperTest extends BaseDaoTest {
return environment;
}
@Before
@BeforeEach
public void setUp() {
clearTestData();
}
@After
@AfterEach
public void after() {
clearTestData();
}
@ -82,7 +82,7 @@ public class EnvironmentMapperTest extends BaseDaoTest {
environment.setDescription("new description info");
// update
int update = environmentMapper.updateById(environment);
Assert.assertEquals(update, 1);
Assertions.assertEquals(update, 1);
}
/**
@ -92,7 +92,7 @@ public class EnvironmentMapperTest extends BaseDaoTest {
public void testDelete() {
Environment environment = insertOne();
int delete = environmentMapper.deleteById(environment.getId());
Assert.assertEquals(delete, 1);
Assertions.assertEquals(delete, 1);
}
/**
@ -103,7 +103,7 @@ public class EnvironmentMapperTest extends BaseDaoTest {
insertOne();
// query
List<Environment> environments = environmentMapper.selectList(null);
Assert.assertEquals(environments.size(), 1);
Assertions.assertEquals(environments.size(), 1);
}
/**
@ -113,7 +113,7 @@ public class EnvironmentMapperTest extends BaseDaoTest {
public void testQueryByEnvironmentName() {
Environment entity = insertOne();
Environment environment = environmentMapper.queryByEnvironmentName(entity.getName());
Assert.assertEquals(entity.toString(), environment.toString());
Assertions.assertEquals(entity.toString(), environment.toString());
}
/**
@ -123,7 +123,7 @@ public class EnvironmentMapperTest extends BaseDaoTest {
public void testQueryByEnvironmentCode() {
Environment entity = insertOne();
Environment environment = environmentMapper.queryByEnvironmentCode(entity.getCode());
Assert.assertEquals(entity.toString(), environment.toString());
Assertions.assertEquals(entity.toString(), environment.toString());
}
/**
@ -133,8 +133,8 @@ public class EnvironmentMapperTest extends BaseDaoTest {
public void testQueryAllEnvironmentList() {
Environment entity = insertOne();
List<Environment> environments = environmentMapper.queryAllEnvironmentList();
Assert.assertEquals(environments.size(), 1);
Assert.assertEquals(entity.toString(), environments.get(0).toString());
Assertions.assertEquals(environments.size(), 1);
Assertions.assertEquals(entity.toString(), environments.get(0).toString());
}
/**
@ -146,11 +146,11 @@ public class EnvironmentMapperTest extends BaseDaoTest {
Page<Environment> page = new Page<>(1, 10);
IPage<Environment> environmentIPage = environmentMapper.queryEnvironmentListPaging(page, "");
List<Environment> environmentList = environmentIPage.getRecords();
Assert.assertEquals(environmentList.size(), 1);
Assertions.assertEquals(environmentList.size(), 1);
environmentIPage = environmentMapper.queryEnvironmentListPaging(page, "abc");
environmentList = environmentIPage.getRecords();
Assert.assertEquals(environmentList.size(), 0);
Assertions.assertEquals(environmentList.size(), 0);
}
/**
@ -160,7 +160,7 @@ public class EnvironmentMapperTest extends BaseDaoTest {
public void testDeleteByCode() {
Environment entity = insertOne();
int delete = environmentMapper.deleteByCode(entity.getCode());
Assert.assertEquals(delete, 1);
Assertions.assertEquals(delete, 1);
}
private String getDesc() {

20
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/EnvironmentWorkerGroupRelationMapperTest.java

@ -23,10 +23,10 @@ import org.apache.dolphinscheduler.dao.entity.EnvironmentWorkerGroupRelation;
import java.util.Date;
import java.util.List;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class EnvironmentWorkerGroupRelationMapperTest extends BaseDaoTest {
@ -34,12 +34,12 @@ public class EnvironmentWorkerGroupRelationMapperTest extends BaseDaoTest {
@Autowired
private EnvironmentWorkerGroupRelationMapper environmentWorkerGroupRelationMapper;
@Before
@BeforeEach
public void setUp() {
clearTestData();
}
@After
@AfterEach
public void after() {
clearTestData();
}
@ -75,27 +75,27 @@ public class EnvironmentWorkerGroupRelationMapperTest extends BaseDaoTest {
insertOne();
//query
List<EnvironmentWorkerGroupRelation> relations = environmentWorkerGroupRelationMapper.selectList(null);
Assert.assertEquals(relations.size(), 1);
Assertions.assertEquals(relations.size(), 1);
}
@Test
public void testQueryByEnvironmentCode() {
EnvironmentWorkerGroupRelation relation = insertOne();
List<EnvironmentWorkerGroupRelation> environmentWorkerGroupRelations = environmentWorkerGroupRelationMapper.queryByEnvironmentCode(1L);
Assert.assertNotEquals(environmentWorkerGroupRelations.size(), 0);
Assertions.assertNotEquals(environmentWorkerGroupRelations.size(), 0);
}
@Test
public void testQueryByWorkerGroupName() {
EnvironmentWorkerGroupRelation relation = insertOne();
List<EnvironmentWorkerGroupRelation> environmentWorkerGroupRelations = environmentWorkerGroupRelationMapper.queryByWorkerGroupName("default");
Assert.assertNotEquals(environmentWorkerGroupRelations.size(), 0);
Assertions.assertNotEquals(environmentWorkerGroupRelations.size(), 0);
}
@Test
public void testDeleteByCode() {
EnvironmentWorkerGroupRelation relation = insertOne();
int i = environmentWorkerGroupRelationMapper.deleteByCode(1L, "default");
Assert.assertNotEquals(i, 0);
Assertions.assertNotEquals(i, 0);
}
}

8
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapperTest.java

@ -26,8 +26,8 @@ import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
import java.util.Date;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class ErrorCommandMapperTest extends BaseDaoTest {
@ -91,7 +91,7 @@ public class ErrorCommandMapperTest extends BaseDaoTest {
projectCodeArray
);
Assert.assertNotEquals(commandCounts.size(), 0);
Assert.assertNotEquals(commandCounts2.size(), 0);
Assertions.assertNotEquals(commandCounts.size(), 0);
Assertions.assertNotEquals(commandCounts2.size(), 0);
}
}

24
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/K8sNamespaceMapperTest.java

@ -23,10 +23,10 @@ import org.apache.dolphinscheduler.dao.entity.K8sNamespace;
import java.util.Date;
import java.util.List;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -57,12 +57,12 @@ public class K8sNamespaceMapperTest extends BaseDaoTest {
return k8sNamespace;
}
@Before
@BeforeEach
public void setUp() {
clearTestData();
}
@After
@AfterEach
public void after() {
clearTestData();
}
@ -83,7 +83,7 @@ public class K8sNamespaceMapperTest extends BaseDaoTest {
k8sNamespace.setLimitsMemory(200);
// update
int update = k8sNamespaceMapper.updateById(k8sNamespace);
Assert.assertEquals(update, 1);
Assertions.assertEquals(update, 1);
}
/**
@ -93,7 +93,7 @@ public class K8sNamespaceMapperTest extends BaseDaoTest {
public void testDelete() {
K8sNamespace k8sNamespace = insertOne();
int delete = k8sNamespaceMapper.deleteById(k8sNamespace.getId());
Assert.assertEquals(delete, 1);
Assertions.assertEquals(delete, 1);
}
/**
@ -104,7 +104,7 @@ public class K8sNamespaceMapperTest extends BaseDaoTest {
insertOne();
// query
List<K8sNamespace> k8sNamespaces = k8sNamespaceMapper.selectList(null);
Assert.assertEquals(k8sNamespaces.size(), 1);
Assertions.assertEquals(k8sNamespaces.size(), 1);
}
/**
@ -114,7 +114,7 @@ public class K8sNamespaceMapperTest extends BaseDaoTest {
public void testQueryByK8sNamespaceId() {
K8sNamespace entity = insertOne();
K8sNamespace k8sNamespace = k8sNamespaceMapper.selectById(entity.getId());
Assert.assertEquals(entity, k8sNamespace);
Assertions.assertEquals(entity, k8sNamespace);
}
/**
@ -126,11 +126,11 @@ public class K8sNamespaceMapperTest extends BaseDaoTest {
Page<K8sNamespace> page = new Page<>(1, 10);
IPage<K8sNamespace> k8sNamespaceIPage = k8sNamespaceMapper.queryK8sNamespacePaging(page, "");
List<K8sNamespace> k8sNamespaceList = k8sNamespaceIPage.getRecords();
Assert.assertEquals(k8sNamespaceList.size(), 1);
Assertions.assertEquals(k8sNamespaceList.size(), 1);
k8sNamespaceIPage = k8sNamespaceMapper.queryK8sNamespacePaging(page, "abc");
k8sNamespaceList = k8sNamespaceIPage.getRecords();
Assert.assertEquals(k8sNamespaceList.size(), 0);
Assertions.assertEquals(k8sNamespaceList.size(), 0);
}
}

16
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/PluginDefineTest.java

@ -22,8 +22,8 @@ import org.apache.dolphinscheduler.dao.entity.PluginDefine;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class PluginDefineTest extends BaseDaoTest {
@ -35,24 +35,24 @@ public class PluginDefineTest extends BaseDaoTest {
public void testQueryAllPluginDefineList() {
createPluginDefine();
List<PluginDefine> pluginDefines = pluginDefineMapper.queryAllPluginDefineList();
Assert.assertTrue(pluginDefines.size() > 0);
Assertions.assertTrue(pluginDefines.size() > 0);
}
@Test
public void testQeryByPluginType() {
PluginDefine pluginDefine = createPluginDefine();
List<PluginDefine> pluginDefines = pluginDefineMapper.queryByPluginType(pluginDefine.getPluginType());
Assert.assertTrue(pluginDefines.size() > 0);
Assert.assertEquals(pluginDefines.get(0).getPluginType(), pluginDefine.getPluginType());
Assertions.assertTrue(pluginDefines.size() > 0);
Assertions.assertEquals(pluginDefines.get(0).getPluginType(), pluginDefine.getPluginType());
}
@Test
public void testQueryByNameAndType() {
PluginDefine pluginDefine = createPluginDefine();
PluginDefine pluginDefineSaved = pluginDefineMapper.queryByNameAndType(pluginDefine.getPluginName(), pluginDefine.getPluginType());
Assert.assertNotNull(pluginDefineSaved);
Assert.assertEquals(pluginDefineSaved.getPluginType(), pluginDefine.getPluginType());
Assert.assertEquals(pluginDefineSaved.getPluginName(), pluginDefine.getPluginName());
Assertions.assertNotNull(pluginDefineSaved);
Assertions.assertEquals(pluginDefineSaved.getPluginType(), pluginDefine.getPluginType());
Assertions.assertEquals(pluginDefineSaved.getPluginName(), pluginDefine.getPluginName());
}
/**

20
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionLogMapperTest.java

@ -26,8 +26,8 @@ import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Date;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -86,7 +86,7 @@ public class ProcessDefinitionLogMapperTest extends BaseDaoTest {
@Test
public void testInsert() {
ProcessDefinitionLog processDefinitionLog = insertOne();
Assert.assertNotEquals(processDefinitionLog.getId().intValue(), 0);
Assertions.assertNotEquals(processDefinitionLog.getId().intValue(), 0);
}
@Test
@ -108,7 +108,7 @@ public class ProcessDefinitionLogMapperTest extends BaseDaoTest {
List<ProcessDefinitionLog> processDefinitionLogs = processDefinitionLogMapper
.queryByDefinitionName(1L, "def 1");
Assert.assertEquals(1, processDefinitionLogs.size());
Assertions.assertEquals(1, processDefinitionLogs.size());
}
@ -118,7 +118,7 @@ public class ProcessDefinitionLogMapperTest extends BaseDaoTest {
List<ProcessDefinitionLog> processDefinitionLogs = processDefinitionLogMapper
.queryByDefinitionCode(1L);
Assert.assertNotEquals(0, processDefinitionLogs.size());
Assertions.assertNotEquals(0, processDefinitionLogs.size());
}
@Test
@ -127,7 +127,7 @@ public class ProcessDefinitionLogMapperTest extends BaseDaoTest {
ProcessDefinitionLog processDefinitionLogs = processDefinitionLogMapper
.queryByDefinitionCodeAndVersion(1L, 1);
Assert.assertNotEquals(null, processDefinitionLogs);
Assertions.assertNotEquals(null, processDefinitionLogs);
}
@Test
@ -136,7 +136,7 @@ public class ProcessDefinitionLogMapperTest extends BaseDaoTest {
insertTwo();
Integer version = processDefinitionLogMapper.queryMaxVersionForDefinition(1L);
Assert.assertEquals(2, version == null ? 1 : version);
Assertions.assertEquals(2, version == null ? 1 : version);
}
@Test
@ -145,7 +145,7 @@ public class ProcessDefinitionLogMapperTest extends BaseDaoTest {
Page<ProcessDefinitionLog> page = new Page(1, 3);
IPage<ProcessDefinitionLog> processDefinitionLogs =
processDefinitionLogMapper.queryProcessDefinitionVersionsPaging(page, 1L, 1L);
Assert.assertNotEquals(processDefinitionLogs.getTotal(), 0);
Assertions.assertNotEquals(processDefinitionLogs.getTotal(), 0);
}
@Test
@ -153,7 +153,7 @@ public class ProcessDefinitionLogMapperTest extends BaseDaoTest {
insertOne();
Page<ProcessDefinitionLog> page = new Page(1, 3);
int processDefinitionLogs = processDefinitionLogMapper.deleteByProcessDefinitionCodeAndVersion(1L, 1);
Assert.assertNotEquals(processDefinitionLogs, 0);
Assertions.assertNotEquals(processDefinitionLogs, 0);
}
@Test
@ -162,7 +162,7 @@ public class ProcessDefinitionLogMapperTest extends BaseDaoTest {
insertTwo();
ProcessDefinitionLog processDefinitionLog2 = processDefinitionLogMapper.queryMaxVersionDefinitionLog(1L);
Assert.assertEquals(2, processDefinitionLog2.getVersion());
Assertions.assertEquals(2, processDefinitionLog2.getVersion());
}
}

32
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapperTest.java

@ -32,8 +32,8 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -86,7 +86,7 @@ public class ProcessDefinitionMapperTest extends BaseDaoTest {
// update
processDefinition.setUpdateTime(new Date());
int update = processDefinitionMapper.updateById(processDefinition);
Assert.assertEquals(1, update);
Assertions.assertEquals(1, update);
}
/**
@ -96,7 +96,7 @@ public class ProcessDefinitionMapperTest extends BaseDaoTest {
public void testDelete() {
ProcessDefinition processDefinition = insertOne("def 1");
int delete = processDefinitionMapper.deleteById(processDefinition.getId());
Assert.assertEquals(1, delete);
Assertions.assertEquals(1, delete);
}
/**
@ -107,7 +107,7 @@ public class ProcessDefinitionMapperTest extends BaseDaoTest {
insertOne("def 1");
// query
List<ProcessDefinition> dataSources = processDefinitionMapper.selectList(null);
Assert.assertNotEquals(dataSources.size(), 0);
Assertions.assertNotEquals(dataSources.size(), 0);
}
/**
@ -147,7 +147,7 @@ public class ProcessDefinitionMapperTest extends BaseDaoTest {
processDefinition.setUserId(user.getId());
processDefinitionMapper.insert(processDefinition);
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(10L, "xxx");
Assert.assertEquals(definition, null);
Assertions.assertEquals(definition, null);
}
/**
@ -192,7 +192,7 @@ public class ProcessDefinitionMapperTest extends BaseDaoTest {
processDefinitionMapper.insert(processDefinition);
ProcessDefinition processDefinition1 = processDefinitionMapper.queryByDefineName(project.getCode(), "def 1");
Assert.assertNotEquals(processDefinition1, null);
Assertions.assertNotEquals(processDefinition1, null);
}
/**
@ -210,7 +210,7 @@ public class ProcessDefinitionMapperTest extends BaseDaoTest {
processDefinition.setUserId(1234);
processDefinitionMapper.insert(processDefinition);
List<ProcessDefinition> definitions = processDefinitionMapper.queryDefinitionListByTenant(999);
Assert.assertNotEquals(definitions.size(), 0);
Assertions.assertNotEquals(definitions.size(), 0);
}
/**
@ -254,7 +254,7 @@ public class ProcessDefinitionMapperTest extends BaseDaoTest {
processDefinition.setUserId(user.getId());
processDefinitionMapper.insert(processDefinition);
ProcessDefinition definition = processDefinitionMapper.queryByDefineId(333);
Assert.assertEquals(definition, null);
Assertions.assertEquals(definition, null);
}
/**
@ -266,7 +266,7 @@ public class ProcessDefinitionMapperTest extends BaseDaoTest {
Page<ProcessDefinition> page = new Page(1, 3);
IPage<ProcessDefinition> processDefinitionIPage =
processDefinitionMapper.queryDefineListPaging(page, "def", 101, 1010L);
Assert.assertNotEquals(processDefinitionIPage.getTotal(), 0);
Assertions.assertNotEquals(processDefinitionIPage.getTotal(), 0);
}
/**
@ -276,7 +276,7 @@ public class ProcessDefinitionMapperTest extends BaseDaoTest {
public void testQueryAllDefinitionList() {
insertOne("def 1");
List<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryAllDefinitionList(1010L);
Assert.assertNotEquals(processDefinitionIPage.size(), 0);
Assertions.assertNotEquals(processDefinitionIPage.size(), 0);
}
/**
@ -293,7 +293,7 @@ public class ProcessDefinitionMapperTest extends BaseDaoTest {
array[1] = processDefinition1.getId();
List<ProcessDefinition> processDefinitions = processDefinitionMapper.queryDefinitionListByIdList(array);
Assert.assertEquals(2, processDefinitions.size());
Assertions.assertEquals(2, processDefinitions.size());
}
@ -321,7 +321,7 @@ public class ProcessDefinitionMapperTest extends BaseDaoTest {
projectCodes[0] = processDefinition.getProjectCode();
List<DefinitionGroupByUser> processDefinitions =
processDefinitionMapper.countDefinitionByProjectCodes(projectCodes);
Assert.assertNotEquals(processDefinitions.size(), 0);
Assertions.assertNotEquals(processDefinitions.size(), 0);
}
@Test
@ -329,7 +329,7 @@ public class ProcessDefinitionMapperTest extends BaseDaoTest {
ProcessDefinition processDefinition = insertOne("def 1");
processDefinition.setReleaseState(ReleaseState.ONLINE);
List<Map<String, Object>> maps = processDefinitionMapper.listResources();
Assert.assertNotNull(maps);
Assertions.assertNotNull(maps);
}
@Test
@ -337,14 +337,14 @@ public class ProcessDefinitionMapperTest extends BaseDaoTest {
ProcessDefinition processDefinition = insertOne("def 1");
processDefinition.setReleaseState(ReleaseState.ONLINE);
List<Map<String, Object>> maps = processDefinitionMapper.listResourcesByUser(processDefinition.getUserId());
Assert.assertNotNull(maps);
Assertions.assertNotNull(maps);
}
@Test
public void listProjectIds() {
insertOne("def 1");
List<Integer> projectIds = processDefinitionMapper.listProjectIds();
Assert.assertNotNull(projectIds);
Assertions.assertNotNull(projectIds);
}
}

14
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapMapperTest.java

@ -22,8 +22,8 @@ import org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class ProcessInstanceMapMapperTest extends BaseDaoTest {
@ -56,7 +56,7 @@ public class ProcessInstanceMapMapperTest extends BaseDaoTest {
//update
processInstanceMap.setParentProcessInstanceId(1);
int update = processInstanceMapMapper.updateById(processInstanceMap);
Assert.assertEquals(1, update);
Assertions.assertEquals(1, update);
}
/**
@ -66,7 +66,7 @@ public class ProcessInstanceMapMapperTest extends BaseDaoTest {
public void testDelete() {
ProcessInstanceMap processInstanceMap = insertOne();
int delete = processInstanceMapMapper.deleteById(processInstanceMap.getId());
Assert.assertEquals(1, delete);
Assertions.assertEquals(1, delete);
}
/**
@ -77,7 +77,7 @@ public class ProcessInstanceMapMapperTest extends BaseDaoTest {
ProcessInstanceMap processInstanceMap = insertOne();
//query
List<ProcessInstanceMap> dataSources = processInstanceMapMapper.selectList(null);
Assert.assertNotEquals(dataSources.size(), 0);
Assertions.assertNotEquals(dataSources.size(), 0);
}
/**
@ -104,7 +104,7 @@ public class ProcessInstanceMapMapperTest extends BaseDaoTest {
int delete = processInstanceMapMapper.deleteByParentProcessId(
processInstanceMap.getParentProcessInstanceId()
);
Assert.assertEquals(1, delete);
Assertions.assertEquals(1, delete);
}
/**
@ -121,7 +121,7 @@ public class ProcessInstanceMapMapperTest extends BaseDaoTest {
List<Integer> subIds = processInstanceMapMapper.querySubIdListByParentId(processInstanceMap.getParentProcessInstanceId());
Assert.assertNotEquals(subIds.size(), 0);
Assertions.assertNotEquals(subIds.size(), 0);
}

43
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapperTest.java

@ -30,8 +30,9 @@ import java.util.Date;
import java.util.List;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -92,7 +93,7 @@ public class ProcessInstanceMapperTest extends BaseDaoTest {
ProcessInstance processInstanceMap = insertOne();
// update
int update = processInstanceMapper.updateById(processInstanceMap);
Assert.assertEquals(1, update);
Assertions.assertEquals(1, update);
processInstanceMapper.deleteById(processInstanceMap.getId());
}
@ -103,7 +104,7 @@ public class ProcessInstanceMapperTest extends BaseDaoTest {
public void testDelete() {
ProcessInstance processInstanceMap = insertOne();
int delete = processInstanceMapper.deleteById(processInstanceMap.getId());
Assert.assertEquals(1, delete);
Assertions.assertEquals(1, delete);
}
/**
@ -114,7 +115,7 @@ public class ProcessInstanceMapperTest extends BaseDaoTest {
ProcessInstance processInstance = insertOne();
// query
List<ProcessInstance> dataSources = processInstanceMapper.selectList(null);
Assert.assertNotEquals(dataSources.size(), 0);
Assertions.assertNotEquals(dataSources.size(), 0);
processInstanceMapper.deleteById(processInstance.getId());
}
@ -127,7 +128,7 @@ public class ProcessInstanceMapperTest extends BaseDaoTest {
processInstanceMapper.updateById(processInstance);
ProcessInstance processInstance1 = processInstanceMapper.queryDetailById(processInstance.getId());
Assert.assertNotNull(processInstance1);
Assertions.assertNotNull(processInstance1);
processInstanceMapper.deleteById(processInstance.getId());
}
@ -148,7 +149,7 @@ public class ProcessInstanceMapperTest extends BaseDaoTest {
List<ProcessInstance> processInstances = processInstanceMapper.queryByHostAndStatus(null, stateArray);
processInstanceMapper.deleteById(processInstance.getId());
Assert.assertNotEquals(processInstances.size(), 0);
Assertions.assertNotEquals(processInstances.size(), 0);
}
/**
@ -189,7 +190,7 @@ public class ProcessInstanceMapperTest extends BaseDaoTest {
processInstance.getHost(),
null,
null);
Assert.assertNotEquals(processInstanceIPage.getTotal(), 0);
Assertions.assertNotEquals(processInstanceIPage.getTotal(), 0);
processDefinitionMapper.deleteById(processDefinition.getId());
processInstanceMapper.deleteById(processInstance.getId());
@ -212,10 +213,10 @@ public class ProcessInstanceMapperTest extends BaseDaoTest {
processInstanceMapper.updateById(processInstance);
String host = processInstance.getHost();
int update = processInstanceMapper.setFailoverByHostAndStateArray(host, stateArray);
Assert.assertNotEquals(update, 0);
Assertions.assertNotEquals(update, 0);
processInstance = processInstanceMapper.selectById(processInstance.getId());
Assert.assertNull(processInstance.getHost());
Assertions.assertNull(processInstance.getHost());
processInstanceMapper.deleteById(processInstance.getId());
}
@ -235,7 +236,7 @@ public class ProcessInstanceMapperTest extends BaseDaoTest {
ProcessInstance processInstance1 = processInstanceMapper.selectById(processInstance.getId());
processInstanceMapper.deleteById(processInstance.getId());
Assert.assertEquals(WorkflowExecutionStatus.SUCCESS, processInstance1.getState());
Assertions.assertEquals(WorkflowExecutionStatus.SUCCESS, processInstance1.getState());
}
@ -268,7 +269,7 @@ public class ProcessInstanceMapperTest extends BaseDaoTest {
List<ExecuteStatusCount> executeStatusCounts =
processInstanceMapper.countInstanceStateByProjectCodes(null, null, projectCodes);
Assert.assertNotEquals(executeStatusCounts.size(), 0);
Assertions.assertNotEquals(executeStatusCounts.size(), 0);
projectMapper.deleteById(project.getId());
processDefinitionMapper.deleteById(processDefinition.getId());
@ -285,11 +286,11 @@ public class ProcessInstanceMapperTest extends BaseDaoTest {
List<ProcessInstance> processInstances =
processInstanceMapper.queryByProcessDefineCode(processInstance.getProcessDefinitionCode(), 1);
Assert.assertEquals(1, processInstances.size());
Assertions.assertEquals(1, processInstances.size());
processInstances =
processInstanceMapper.queryByProcessDefineCode(processInstance.getProcessDefinitionCode(), 2);
Assert.assertEquals(2, processInstances.size());
Assertions.assertEquals(2, processInstances.size());
processInstanceMapper.deleteById(processInstance.getId());
processInstanceMapper.deleteById(processInstance1.getId());
@ -306,7 +307,7 @@ public class ProcessInstanceMapperTest extends BaseDaoTest {
ProcessInstance processInstance1 =
processInstanceMapper.queryLastSchedulerProcess(processInstance.getProcessDefinitionCode(), null, null, processInstance.getTestFlag());
Assert.assertNotEquals(processInstance1, null);
Assertions.assertNotEquals(processInstance1, null);
processInstanceMapper.deleteById(processInstance.getId());
}
@ -326,7 +327,7 @@ public class ProcessInstanceMapperTest extends BaseDaoTest {
ProcessInstance processInstance1 = processInstanceMapper
.queryLastRunningProcess(processInstance.getProcessDefinitionCode(), null, null, processInstance.getTestFlag(), stateArray);
Assert.assertNotEquals(processInstance1, null);
Assertions.assertNotEquals(processInstance1, null);
processInstanceMapper.deleteById(processInstance.getId());
}
@ -342,12 +343,12 @@ public class ProcessInstanceMapperTest extends BaseDaoTest {
Date end = new Date(2019 - 1900, 1 - 1, 01, 5, 0, 0);
ProcessInstance processInstance1 =
processInstanceMapper.queryLastManualProcess(processInstance.getProcessDefinitionCode(), start, end, processInstance.getTestFlag());
Assert.assertEquals(processInstance1.getId(), processInstance.getId());
Assertions.assertEquals(processInstance1.getId(), processInstance.getId());
start = new Date(2019 - 1900, 1 - 1, 01, 1, 0, 0);
processInstance1 =
processInstanceMapper.queryLastManualProcess(processInstance.getProcessDefinitionCode(), start, end, processInstance.getTestFlag());
Assert.assertNull(processInstance1);
Assertions.assertNull(processInstance1);
processInstanceMapper.deleteById(processInstance.getId());
@ -386,10 +387,10 @@ public class ProcessInstanceMapperTest extends BaseDaoTest {
Date end = new Date(2021, 1, 1, 1, 1, 1);
List<ProcessInstance> processInstances =
processInstanceMapper.queryTopNProcessInstance(2, start, end, WorkflowExecutionStatus.SUCCESS, 0L);
Assert.assertEquals(2, processInstances.size());
Assert.assertTrue(isSortedByDuration(processInstances));
Assertions.assertEquals(2, processInstances.size());
Assertions.assertTrue(isSortedByDuration(processInstances));
for (ProcessInstance processInstance : processInstances) {
Assert.assertTrue(processInstance.getState().isSuccess());
Assertions.assertTrue(processInstance.getState().isSuccess());
}
processInstanceMapper.deleteById(processInstance1.getId());
processInstanceMapper.deleteById(processInstance2.getId());

6
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessTaskRelationLogMapperTest.java

@ -23,8 +23,8 @@ import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelationLog;
import java.util.Date;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class ProcessTaskRelationLogMapperTest extends BaseDaoTest {
@ -57,7 +57,7 @@ public class ProcessTaskRelationLogMapperTest extends BaseDaoTest {
ProcessTaskRelationLog processTaskRelationLog = insertOne();
List<ProcessTaskRelationLog> processTaskRelationLogs = processTaskRelationLogMapper
.queryByProcessCodeAndVersion(1L, 1);
Assert.assertNotEquals(processTaskRelationLogs.size(), 0);
Assertions.assertNotEquals(processTaskRelationLogs.size(), 0);
}
}

12
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessTaskRelationMapperTest.java

@ -24,8 +24,8 @@ import java.util.Date;
import java.util.List;
import org.assertj.core.util.Arrays;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class ProcessTaskRelationMapperTest extends BaseDaoTest {
@ -57,14 +57,14 @@ public class ProcessTaskRelationMapperTest extends BaseDaoTest {
public void testQueryByProcessCode() {
ProcessTaskRelation processTaskRelation = insertOne();
List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByProcessCode(1L, 1L);
Assert.assertNotEquals(processTaskRelations.size(), 0);
Assertions.assertNotEquals(processTaskRelations.size(), 0);
}
@Test
public void testQueryByTaskCode() {
ProcessTaskRelation processTaskRelation = insertOne();
List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByTaskCode(2L);
Assert.assertNotEquals(processTaskRelations.size(), 0);
Assertions.assertNotEquals(processTaskRelations.size(), 0);
}
@Test
@ -73,14 +73,14 @@ public class ProcessTaskRelationMapperTest extends BaseDaoTest {
Long[] codes = Arrays.array(1L, 2L);
List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByTaskCodes(codes);
Assert.assertNotEquals(processTaskRelations.size(), 0);
Assertions.assertNotEquals(processTaskRelations.size(), 0);
}
@Test
public void testDeleteByCode() {
ProcessTaskRelation processTaskRelation = insertOne();
int i = processTaskRelationMapper.deleteByCode(1L, 1L);
Assert.assertNotEquals(i, 0);
Assertions.assertNotEquals(i, 0);
}
}

31
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapperTest.java

@ -22,13 +22,12 @@ import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.ProjectUser;
import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -72,7 +71,7 @@ public class ProjectMapperTest extends BaseDaoTest {
project.setCreateTime(new Date());
//update
int update = projectMapper.updateById(project);
Assert.assertEquals(update, 1);
Assertions.assertEquals(update, 1);
}
/**
@ -82,7 +81,7 @@ public class ProjectMapperTest extends BaseDaoTest {
public void testDelete() {
Project projectMap = insertOne();
int delete = projectMapper.deleteById(projectMap.getId());
Assert.assertEquals(delete, 1);
Assertions.assertEquals(delete, 1);
}
/**
@ -93,7 +92,7 @@ public class ProjectMapperTest extends BaseDaoTest {
Project project = insertOne();
//query
List<Project> projects = projectMapper.selectList(null);
Assert.assertNotEquals(projects.size(), 0);
Assertions.assertNotEquals(projects.size(), 0);
}
/**
@ -111,8 +110,8 @@ public class ProjectMapperTest extends BaseDaoTest {
projectMapper.updateById(project);
Project project1 = projectMapper.queryDetailById(project.getId());
Assert.assertNotEquals(project1, null);
Assert.assertEquals(project1.getUserName(), user.getUserName());
Assertions.assertNotEquals(project1, null);
Assertions.assertEquals(project1.getUserName(), user.getUserName());
}
/**
@ -129,7 +128,7 @@ public class ProjectMapperTest extends BaseDaoTest {
projectMapper.updateById(project);
Project project1 = projectMapper.queryByName(project.getName());
Assert.assertNotEquals(project1, null);
Assertions.assertNotEquals(project1, null);
}
/**
@ -156,8 +155,8 @@ public class ProjectMapperTest extends BaseDaoTest {
null,
project.getName()
);
Assert.assertEquals(projectIPage.getTotal(), 1);
Assert.assertEquals(projectIPage1.getTotal(), 1);
Assertions.assertEquals(projectIPage.getTotal(), 1);
Assertions.assertEquals(projectIPage1.getTotal(), 1);
}
/**
@ -169,7 +168,7 @@ public class ProjectMapperTest extends BaseDaoTest {
List<Project> projects = projectMapper.queryProjectCreatedByUser(project.getUserId());
Assert.assertNotEquals(projects.size(), 0);
Assertions.assertNotEquals(projects.size(), 0);
}
@ -182,7 +181,7 @@ public class ProjectMapperTest extends BaseDaoTest {
List<Project> projects = projectMapper.queryProjectCreatedByUser(project.getUserId());
Assert.assertNotEquals(projects.size(), 0);
Assertions.assertNotEquals(projects.size(), 0);
}
/**
@ -196,7 +195,7 @@ public class ProjectMapperTest extends BaseDaoTest {
100000
);
Assert.assertNotEquals(projects.size(), 0);
Assertions.assertNotEquals(projects.size(), 0);
}
@Test
@ -218,7 +217,7 @@ public class ProjectMapperTest extends BaseDaoTest {
List<Project> allProject = projectMapper.queryAllProject(user.getId());
Assert.assertNotEquals(allProject.size(), 0);
Assertions.assertNotEquals(allProject.size(), 0);
}
/**
@ -228,7 +227,7 @@ public class ProjectMapperTest extends BaseDaoTest {
public void testListAuthorizedProjects() {
Project project = insertOne();
List<Project> projects = projectMapper.listAuthorizedProjects(1, Collections.singletonList(project.getId()));
Assert.assertEquals(projects.size(), 0);
Assertions.assertEquals(projects.size(), 0);
}
}

17
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectUserMapperTest.java

@ -17,17 +17,14 @@
package org.apache.dolphinscheduler.dao.mapper;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import org.apache.dolphinscheduler.dao.BaseDaoTest;
import org.apache.dolphinscheduler.dao.entity.ProjectUser;
import java.util.Date;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class ProjectUserMapperTest extends BaseDaoTest {
@ -59,7 +56,7 @@ public class ProjectUserMapperTest extends BaseDaoTest {
projectUser.setCreateTime(new Date());
//update
int update = projectUserMapper.updateById(projectUser);
Assert.assertEquals(update, 1);
Assertions.assertEquals(update, 1);
}
/**
@ -69,7 +66,7 @@ public class ProjectUserMapperTest extends BaseDaoTest {
public void testDelete() {
ProjectUser projectUserMap = insertOne();
int delete = projectUserMapper.deleteById(projectUserMap.getId());
Assert.assertEquals(delete, 1);
Assertions.assertEquals(delete, 1);
}
/**
@ -80,7 +77,7 @@ public class ProjectUserMapperTest extends BaseDaoTest {
ProjectUser projectUser = insertOne();
//query
List<ProjectUser> projectUsers = projectUserMapper.selectList(null);
Assert.assertNotEquals(projectUsers.size(), 0);
Assertions.assertNotEquals(projectUsers.size(), 0);
}
/**
@ -91,7 +88,7 @@ public class ProjectUserMapperTest extends BaseDaoTest {
ProjectUser projectUser = insertOne();
int delete = projectUserMapper.deleteProjectRelation(projectUser.getProjectId(), projectUser.getUserId());
assertThat(delete,greaterThanOrEqualTo(1));
Assertions.assertTrue(delete >= 1);
}
@ -102,7 +99,7 @@ public class ProjectUserMapperTest extends BaseDaoTest {
public void testQueryProjectRelation() {
ProjectUser projectUser = insertOne();
ProjectUser projectUser1 = projectUserMapper.queryProjectRelation(projectUser.getProjectId(), projectUser.getUserId());
Assert.assertNotEquals(projectUser1, null);
Assertions.assertNotEquals(projectUser1, null);
}
}

26
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/QueueMapperTest.java

@ -24,8 +24,8 @@ import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -62,7 +62,7 @@ public class QueueMapperTest extends BaseDaoTest {
queue.setCreateTime(new Date());
//update
int update = queueMapper.updateById(queue);
Assert.assertEquals(1, update);
Assertions.assertEquals(1, update);
}
/**
@ -72,7 +72,7 @@ public class QueueMapperTest extends BaseDaoTest {
public void testDelete() {
Queue queue = insertOne();
int delete = queueMapper.deleteById(queue.getId());
Assert.assertEquals(1, delete);
Assertions.assertEquals(1, delete);
}
/**
@ -83,7 +83,7 @@ public class QueueMapperTest extends BaseDaoTest {
Queue queue = insertOne();
//query
List<Queue> queues = queueMapper.selectList(null);
Assert.assertNotEquals(queues.size(), 0);
Assertions.assertNotEquals(queues.size(), 0);
}
/**
@ -96,10 +96,10 @@ public class QueueMapperTest extends BaseDaoTest {
Page<Queue> page = new Page(1,3);
IPage<Queue> queueIPage= queueMapper.queryQueuePaging(page, Collections.singletonList(queue.getId()), null);
Assert.assertNotEquals(queueIPage.getTotal(), 0);
Assertions.assertNotEquals(queueIPage.getTotal(), 0);
queueIPage= queueMapper.queryQueuePaging(page, Collections.singletonList(queue.getId()), queue.getQueueName());
Assert.assertNotEquals(queueIPage.getTotal(), 0);
Assertions.assertNotEquals(queueIPage.getTotal(), 0);
}
/**
@ -110,18 +110,18 @@ public class QueueMapperTest extends BaseDaoTest {
Queue queue = insertOne();
List<Queue> queues = queueMapper.queryAllQueueList(queue.getQueue(), null);
Assert.assertNotEquals(queues.size(), 0);
Assertions.assertNotEquals(queues.size(), 0);
queues = queueMapper.queryAllQueueList(null, queue.getQueueName());
Assert.assertNotEquals(queues.size(), 0);
Assertions.assertNotEquals(queues.size(), 0);
}
@Test
public void existQueue() {
Assert.assertNull(queueMapper.existQueue("queue", null));
Assert.assertNull(queueMapper.existQueue(null, "queue"));
Assertions.assertNull(queueMapper.existQueue("queue", null));
Assertions.assertNull(queueMapper.existQueue(null, "queue"));
Queue queue = insertOne();
Assert.assertTrue(queueMapper.existQueue(queue.getQueue(), null) == Boolean.TRUE);
Assert.assertTrue(queueMapper.existQueue(null, queue.getQueueName()) == Boolean.TRUE);
Assertions.assertTrue(queueMapper.existQueue(queue.getQueue(), null) == Boolean.TRUE);
Assertions.assertTrue(queueMapper.existQueue(null, queue.getQueueName()) == Boolean.TRUE);
}
}

67
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapperTest.java

@ -18,9 +18,6 @@
package org.apache.dolphinscheduler.dao.mapper;
import static java.util.stream.Collectors.toList;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.UserType;
@ -38,8 +35,8 @@ import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -75,7 +72,7 @@ public class ResourceMapperTest extends BaseDaoTest {
resource.setUserId(111);
int status = resourceMapper.insert(resource);
if (status != 1) {
Assert.fail("insert data error");
Assertions.fail("insert data error");
}
return resource;
}
@ -97,7 +94,7 @@ public class ResourceMapperTest extends BaseDaoTest {
resource.setUserId(user.getId());
int status = resourceMapper.insert(resource);
if (status != 1) {
Assert.fail("insert data error");
Assertions.fail("insert data error");
}
return resource;
}
@ -134,7 +131,7 @@ public class ResourceMapperTest extends BaseDaoTest {
int status = userMapper.insert(user);
if (status != 1) {
Assert.fail("insert data error");
Assertions.fail("insert data error");
}
return user;
}
@ -159,8 +156,8 @@ public class ResourceMapperTest extends BaseDaoTest {
@Test
public void testInsert() {
Resource resource = insertOne();
assertNotNull(resource.getId());
assertThat(resource.getId(), greaterThan(0));
Assertions.assertNotNull(resource.getId());
Assertions.assertTrue(resource.getId() > 0);
}
/**
@ -173,7 +170,7 @@ public class ResourceMapperTest extends BaseDaoTest {
resource.setCreateTime(new Date());
// update
int update = resourceMapper.updateById(resource);
Assert.assertEquals(1, update);
Assertions.assertEquals(1, update);
}
/**
@ -183,7 +180,7 @@ public class ResourceMapperTest extends BaseDaoTest {
public void testDelete() {
Resource resourceMap = insertOne();
int delete = resourceMapper.deleteById(resourceMap.getId());
Assert.assertEquals(1, delete);
Assertions.assertEquals(1, delete);
}
/**
@ -194,7 +191,7 @@ public class ResourceMapperTest extends BaseDaoTest {
Resource resource = insertOne();
// query
List<Resource> resources = resourceMapper.selectList(null);
Assert.assertNotEquals(resources.size(), 0);
Assertions.assertNotEquals(resources.size(), 0);
}
/**
@ -213,7 +210,7 @@ public class ResourceMapperTest extends BaseDaoTest {
userId,
type);
Assert.assertNotEquals(resources.size(), 0);
Assertions.assertNotEquals(resources.size(), 0);
}
/**
@ -253,8 +250,8 @@ public class ResourceMapperTest extends BaseDaoTest {
resource.getType().ordinal(),
"",
null);
Assert.assertEquals(resourceIPage.getTotal(), 1);
Assert.assertEquals(resourceIPage1.getTotal(), 1);
Assertions.assertEquals(resourceIPage.getTotal(), 1);
Assertions.assertEquals(resourceIPage1.getTotal(), 1);
}
@ -282,8 +279,8 @@ public class ResourceMapperTest extends BaseDaoTest {
List<Resource> resources1 =
CollectionUtils.isEmpty(resIds1) ? new ArrayList<>() : resourceMapper.queryResourceListById(resIds1);
Assert.assertEquals(0, resources.size());
Assert.assertNotEquals(0, resources1.size());
Assertions.assertEquals(0, resources.size());
Assertions.assertNotEquals(0, resources1.size());
}
@ -300,7 +297,7 @@ public class ResourceMapperTest extends BaseDaoTest {
CollectionUtils.isEmpty(resIds) ? new ArrayList<>() : resourceMapper.queryResourceListById(resIds);
resourceMapper.deleteById(resource.getId());
Assert.assertEquals(0, resources.size());
Assertions.assertEquals(0, resources.size());
}
/**
@ -311,7 +308,7 @@ public class ResourceMapperTest extends BaseDaoTest {
Resource resource = insertOne();
List<Resource> resources = resourceMapper.queryResourceExceptUserId(
11111);
Assert.assertNotEquals(resources.size(), 0);
Assertions.assertNotEquals(resources.size(), 0);
}
/**
@ -325,7 +322,7 @@ public class ResourceMapperTest extends BaseDaoTest {
int tenantInsertStatus = tenantMapper.insert(tenant);
if (tenantInsertStatus != 1) {
Assert.fail("insert tenant data error");
Assertions.fail("insert tenant data error");
}
User user = new User();
@ -334,14 +331,14 @@ public class ResourceMapperTest extends BaseDaoTest {
int userInsertStatus = userMapper.insert(user);
if (userInsertStatus != 1) {
Assert.fail("insert user data error");
Assertions.fail("insert user data error");
}
Resource resource = insertOne();
resource.setUserId(user.getId());
int userUpdateStatus = resourceMapper.updateById(resource);
if (userUpdateStatus != 1) {
Assert.fail("update user data error");
Assertions.fail("update user data error");
}
List<Resource> resourceList = resourceMapper.queryResource(resource.getFullName(), ResourceType.FILE.ordinal());
@ -350,7 +347,7 @@ public class ResourceMapperTest extends BaseDaoTest {
User resourceUser = userMapper.selectById(resourceUserId);
Tenant resourceTenant = tenantMapper.selectById(resourceUser.getTenantId());
Assert.assertEquals("ut tenant code for resource", resourceTenant.getTenantCode());
Assertions.assertEquals("ut tenant code for resource", resourceTenant.getTenantCode());
}
@ -368,14 +365,14 @@ public class ResourceMapperTest extends BaseDaoTest {
List<Resource> resources = resourceMapper.listAuthorizedResource(generalUser2.getId(), resNames);
Assert.assertEquals(generalUser2.getId().intValue(), resource.getUserId());
Assert.assertFalse(
Assertions.assertEquals(generalUser2.getId().intValue(), resource.getUserId());
Assertions.assertFalse(
resources.stream().map(t -> t.getFullName()).collect(toList()).containsAll(Arrays.asList(resNames)));
// authorize object unauthorizedResource to generalUser
createResourcesUser(unauthorizedResource, generalUser2);
List<Resource> authorizedResources = resourceMapper.listAuthorizedResource(generalUser2.getId(), resNames);
Assert.assertTrue(authorizedResources.stream().map(t -> t.getFullName()).collect(toList())
Assertions.assertTrue(authorizedResources.stream().map(t -> t.getFullName()).collect(toList())
.containsAll(Arrays.asList(resource.getFullName())));
}
@ -393,7 +390,7 @@ public class ResourceMapperTest extends BaseDaoTest {
resourceList.add(resource.getId());
resourceList.add(resource1.getId());
int result = resourceMapper.deleteIds(resourceList.toArray(new Integer[resourceList.size()]));
Assert.assertEquals(result, 2);
Assertions.assertEquals(result, 2);
}
@Test
@ -407,10 +404,10 @@ public class ResourceMapperTest extends BaseDaoTest {
List<Resource> resourceList =
resourceMapper.queryResourceListAuthored(generalUser2.getId(), ResourceType.FILE.ordinal());
Assert.assertNotNull(resourceList);
Assertions.assertNotNull(resourceList);
resourceList = resourceMapper.queryResourceListAuthored(generalUser2.getId(), ResourceType.FILE.ordinal());
Assert.assertFalse(resourceList.contains(resource));
Assertions.assertFalse(resourceList.contains(resource));
}
@Test
@ -425,7 +422,7 @@ public class ResourceMapperTest extends BaseDaoTest {
resourceList.add(resource);
int result = resourceMapper.batchUpdateResource(resourceList);
if (result != resourceList.size()) {
Assert.fail("batch update resource data error");
Assertions.fail("batch update resource data error");
}
}
@ -434,10 +431,10 @@ public class ResourceMapperTest extends BaseDaoTest {
String fullName = "/ut-resource";
int userId = 111;
int type = ResourceType.FILE.getCode();
Assert.assertNull(resourceMapper.existResourceByUser(fullName, userId, type));
Assert.assertNull(resourceMapper.existResource(fullName, type));
Assertions.assertNull(resourceMapper.existResourceByUser(fullName, userId, type));
Assertions.assertNull(resourceMapper.existResource(fullName, type));
insertOne();
Assert.assertTrue(resourceMapper.existResourceByUser(fullName, userId, type));
Assert.assertTrue(resourceMapper.existResource(fullName, type));
Assertions.assertTrue(resourceMapper.existResourceByUser(fullName, userId, type));
Assertions.assertTrue(resourceMapper.existResource(fullName, type));
}
}

19
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceUserMapperTest.java

@ -19,14 +19,9 @@ package org.apache.dolphinscheduler.dao.mapper;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.dao.BaseDaoTest;
import org.apache.dolphinscheduler.dao.entity.ResourcesUser;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
@ -62,7 +57,7 @@ public class ResourceUserMapperTest extends BaseDaoTest {
queue.setCreateTime(new Date());
//update
int update = resourceUserMapper.updateById(queue);
Assert.assertEquals(1, update);
Assertions.assertEquals(1, update);
}
/**
@ -72,7 +67,7 @@ public class ResourceUserMapperTest extends BaseDaoTest {
public void testDelete(){
ResourcesUser queue = insertOne();
int delete = resourceUserMapper.deleteById(queue.getId());
Assert.assertEquals(1, delete);
Assertions.assertEquals(1, delete);
}
/**
@ -83,7 +78,7 @@ public class ResourceUserMapperTest extends BaseDaoTest {
ResourcesUser queue = insertOne();
//query
List<ResourcesUser> queues = resourceUserMapper.selectList(null);
Assert.assertNotEquals(queues.size(), 0);
Assertions.assertNotEquals(queues.size(), 0);
}
/**
@ -96,7 +91,7 @@ public class ResourceUserMapperTest extends BaseDaoTest {
int delete = resourceUserMapper.deleteResourceUser(
queue.getUserId(),
queue.getResourcesId());
Assert.assertNotEquals(delete, 0);
Assertions.assertNotEquals(delete, 0);
}
/**
@ -110,6 +105,6 @@ public class ResourceUserMapperTest extends BaseDaoTest {
int delete = resourceUserMapper.deleteResourceUserArray(
resourcesUser.getUserId(),
resourceIdArray);
Assert.assertNotEquals(delete, 0);
Assertions.assertNotEquals(delete, 0);
}
}

18
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ScheduleMapperTest.java

@ -29,8 +29,8 @@ import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Date;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -79,7 +79,7 @@ public class ScheduleMapperTest extends BaseDaoTest {
schedule.setCreateTime(new Date());
// update
int update = scheduleMapper.updateById(schedule);
Assert.assertEquals(update, 1);
Assertions.assertEquals(update, 1);
}
/**
@ -89,7 +89,7 @@ public class ScheduleMapperTest extends BaseDaoTest {
public void testDelete() {
Schedule schedule = insertOne();
int delete = scheduleMapper.deleteById(schedule.getId());
Assert.assertEquals(delete, 1);
Assertions.assertEquals(delete, 1);
}
/**
@ -100,7 +100,7 @@ public class ScheduleMapperTest extends BaseDaoTest {
Schedule schedule = insertOne();
// query
List<Schedule> schedules = scheduleMapper.selectList(null);
Assert.assertNotEquals(schedules.size(), 0);
Assertions.assertNotEquals(schedules.size(), 0);
}
/**
@ -138,7 +138,7 @@ public class ScheduleMapperTest extends BaseDaoTest {
Page<Schedule> page = new Page(1, 3);
IPage<Schedule> scheduleIPage = scheduleMapper.queryByProcessDefineCodePaging(page,
processDefinition.getCode(), "");
Assert.assertNotEquals(scheduleIPage.getSize(), 0);
Assertions.assertNotEquals(scheduleIPage.getSize(), 0);
}
/**
@ -177,7 +177,7 @@ public class ScheduleMapperTest extends BaseDaoTest {
List<Schedule> schedules = scheduleMapper.querySchedulerListByProjectName(
project.getName());
Assert.assertNotEquals(schedules.size(), 0);
Assertions.assertNotEquals(schedules.size(), 0);
}
/**
@ -193,7 +193,7 @@ public class ScheduleMapperTest extends BaseDaoTest {
List<Schedule> schedules =
scheduleMapper.selectAllByProcessDefineArray(new long[]{schedule.getProcessDefinitionCode()});
Assert.assertNotEquals(schedules.size(), 0);
Assertions.assertNotEquals(schedules.size(), 0);
}
/**
@ -206,6 +206,6 @@ public class ScheduleMapperTest extends BaseDaoTest {
scheduleMapper.updateById(schedule);
Schedule schedules = scheduleMapper.queryByProcessDefinitionCode(schedule.getProcessDefinitionCode());
Assert.assertNotNull(schedules);
Assertions.assertNotNull(schedules);
}
}

12
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/SessionMapperTest.java

@ -23,8 +23,8 @@ import java.util.Date;
import java.util.List;
import java.util.UUID;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class SessionMapperTest extends BaseDaoTest {
@ -57,7 +57,7 @@ public class SessionMapperTest extends BaseDaoTest {
session.setLastLoginTime(new Date());
//update
int update = sessionMapper.updateById(session);
Assert.assertEquals(update, 1);
Assertions.assertEquals(update, 1);
}
/**
@ -67,7 +67,7 @@ public class SessionMapperTest extends BaseDaoTest {
public void testDelete(){
Session session = insertOne();
int delete = sessionMapper.deleteById(session.getId());
Assert.assertEquals(delete, 1);
Assertions.assertEquals(delete, 1);
}
/**
@ -78,7 +78,7 @@ public class SessionMapperTest extends BaseDaoTest {
Session session = insertOne();
//query
List<Session> sessions = sessionMapper.selectList(null);
Assert.assertNotEquals(sessions.size(), 0);
Assertions.assertNotEquals(sessions.size(), 0);
}
/**
@ -88,7 +88,7 @@ public class SessionMapperTest extends BaseDaoTest {
public void testQueryByUserId() {
Session session = insertOne();
List<Session> sessions = sessionMapper.queryByUserId(session.getUserId());
Assert.assertNotEquals(sessions.size(), 0);
Assertions.assertNotEquals(sessions.size(), 0);
}
}

12
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionLogMapperTest.java

@ -25,8 +25,8 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class TaskDefinitionLogMapperTest extends BaseDaoTest {
@ -57,7 +57,7 @@ public class TaskDefinitionLogMapperTest extends BaseDaoTest {
@Test
public void testInsert() {
TaskDefinitionLog taskDefinitionLog = insertOne();
Assert.assertNotEquals(taskDefinitionLog.getId().intValue(), 0);
Assertions.assertNotEquals(taskDefinitionLog.getId().intValue(), 0);
}
@Test
@ -65,7 +65,7 @@ public class TaskDefinitionLogMapperTest extends BaseDaoTest {
TaskDefinitionLog taskDefinitionLog = insertOne();
int version = taskDefinitionLogMapper
.queryMaxVersionForDefinition(taskDefinitionLog.getCode());
Assert.assertNotEquals(version, 0);
Assertions.assertNotEquals(version, 0);
}
@Test
@ -73,7 +73,7 @@ public class TaskDefinitionLogMapperTest extends BaseDaoTest {
TaskDefinitionLog taskDefinitionLog = insertOne();
TaskDefinitionLog tdl = taskDefinitionLogMapper
.queryByDefinitionCodeAndVersion(taskDefinitionLog.getCode(), taskDefinitionLog.getVersion());
Assert.assertNotNull(tdl);
Assertions.assertNotNull(tdl);
}
@Test
@ -91,7 +91,7 @@ public class TaskDefinitionLogMapperTest extends BaseDaoTest {
TaskDefinitionLog taskDefinitionLog = insertOne();
List<TaskDefinitionLog> taskDefinitionLogs = taskDefinitionLogMapper.queryByTaskDefinitions(taskDefinitions);
Assert.assertNotEquals(taskDefinitionLogs.size(), 0);
Assertions.assertNotEquals(taskDefinitionLogs.size(), 0);
}
}

28
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionMapperTest.java

@ -28,8 +28,8 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class TaskDefinitionMapperTest extends BaseDaoTest {
@ -85,7 +85,7 @@ public class TaskDefinitionMapperTest extends BaseDaoTest {
@Test
public void testInsert() {
TaskDefinition taskDefinition = insertOne();
Assert.assertNotEquals(taskDefinition.getId().intValue(), 0);
Assertions.assertNotEquals(taskDefinition.getId().intValue(), 0);
}
@Test
@ -95,14 +95,14 @@ public class TaskDefinitionMapperTest extends BaseDaoTest {
TaskDefinition result = taskDefinitionMapper.queryByName(taskDefinition.getProjectCode(),
processTaskRelation.getProcessDefinitionCode(), taskDefinition.getName());
Assert.assertNotNull(result);
Assertions.assertNotNull(result);
}
@Test
public void testQueryByDefinitionCode() {
TaskDefinition taskDefinition = insertOne();
TaskDefinition result = taskDefinitionMapper.queryByCode(taskDefinition.getCode());
Assert.assertNotNull(result);
Assertions.assertNotNull(result);
}
@ -111,7 +111,7 @@ public class TaskDefinitionMapperTest extends BaseDaoTest {
TaskDefinition taskDefinition = insertOne();
List<TaskDefinition> taskDefinitions =
taskDefinitionMapper.queryAllDefinitionList(taskDefinition.getProjectCode());
Assert.assertNotEquals(taskDefinitions.size(), 0);
Assertions.assertNotEquals(taskDefinitions.size(), 0);
}
@ -125,7 +125,7 @@ public class TaskDefinitionMapperTest extends BaseDaoTest {
List<DefinitionGroupByUser> users =
taskDefinitionMapper.countDefinitionGroupByUser(new Long[]{taskDefinition.getProjectCode()});
Assert.assertNotEquals(users.size(), 0);
Assertions.assertNotEquals(users.size(), 0);
}
@ -133,7 +133,7 @@ public class TaskDefinitionMapperTest extends BaseDaoTest {
public void testListResources() {
TaskDefinition taskDefinition = insertOne();
List<Map<String, Object>> maps = taskDefinitionMapper.listResources();
Assert.assertNotEquals(maps.size(), 0);
Assertions.assertNotEquals(maps.size(), 0);
}
@ -146,7 +146,7 @@ public class TaskDefinitionMapperTest extends BaseDaoTest {
TaskDefinition taskDefinition = insertOne(un.getId());
List<Map<String, Object>> maps = taskDefinitionMapper.listResourcesByUser(taskDefinition.getUserId());
Assert.assertNotEquals(maps.size(), 0);
Assertions.assertNotEquals(maps.size(), 0);
}
@ -154,7 +154,7 @@ public class TaskDefinitionMapperTest extends BaseDaoTest {
public void testDeleteByCode() {
TaskDefinition taskDefinition = insertOne();
int i = taskDefinitionMapper.deleteByCode(taskDefinition.getCode());
Assert.assertNotEquals(i, 0);
Assertions.assertNotEquals(i, 0);
}
@ -166,13 +166,13 @@ public class TaskDefinitionMapperTest extends BaseDaoTest {
Map<String, String> taskParamsMap = definition.getTaskParamMap();
if (taskParamsMap != null) {
Assert.assertNull(taskParamsMap.get("key"));
Assertions.assertNull(taskParamsMap.get("key"));
} else {
Assert.fail("Deserialize the task definition failed");
Assertions.fail("Deserialize the task definition failed");
}
String newDefinitionJson = JSONUtils.toJsonString(definition);
Assert.assertNotNull("Serialize the task definition success", newDefinitionJson);
Assertions.assertNotNull("Serialize the task definition success", newDefinitionJson);
}
@Test
@ -181,6 +181,6 @@ public class TaskDefinitionMapperTest extends BaseDaoTest {
"{\"failRetryTimes\":\"0\",\"timeoutNotifyStrategy\":\"\",\"code\":\"5195043558720\",\"flag\":\"YES\",\"environmentCode\":\"-1\",\"taskDefinitionIndex\":2,\"taskPriority\":\"MEDIUM\",\"taskParams\":\"{\\\"preStatements\\\":null,\\\"postStatements\\\":null,\\\"type\\\":\\\"ADB_MYSQL\\\",\\\"database\\\":\\\"lijia\\\",\\\"sql\\\":\\\"create table nation_${random_serial_number} as select * from nation\\\",\\\"localParams\\\":null,\\\"Name\\\":\\\"create_table_as_select_nation\\\",\\\"FailRetryTimes\\\":0,\\\"dbClusterId\\\":\\\"amv-bp10o45925jpx959\\\",\\\"sendEmail\\\":false,\\\"displayRows\\\":10,\\\"limit\\\":10000,\\\"agentSource\\\":\\\"Workflow\\\",\\\"agentVersion\\\":\\\"Unkown\\\"}\",\"timeout\":\"0\",\"taskType\":\"ADB_MYSQL\",\"timeoutFlag\":\"CLOSE\",\"projectCode\":\"5191800302720\",\"name\":\"create_table_as_select_nation\",\"delayTime\":\"0\",\"workerGroup\":\"default\"}";
TaskDefinition definition = JSONUtils.parseObject(definitionJson, TaskDefinition.class);
Assert.assertNull("Serialize the task definition success", definition.getTaskParamMap());
Assertions.assertNull(definition.getTaskParamMap(),"Serialize the task definition success");
}
}

21
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupMapperTest.java

@ -20,11 +20,13 @@ package org.apache.dolphinscheduler.dao.mapper;
import org.apache.dolphinscheduler.dao.BaseDaoTest;
import org.apache.dolphinscheduler.dao.entity.TaskGroup;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -54,7 +56,7 @@ public class TaskGroupMapperTest extends BaseDaoTest {
taskGroup.setUpdateTime(date);
taskGroup.setUpdateTime(date);
int i = taskGroupMapper.insert(taskGroup);
taskGroupMapper.insert(taskGroup);
return taskGroup;
}
@ -67,7 +69,7 @@ public class TaskGroupMapperTest extends BaseDaoTest {
taskGroup.setGroupSize(100);
taskGroup.setUpdateTime(new Date(System.currentTimeMillis()));
int i = taskGroupMapper.updateById(taskGroup);
Assert.assertEquals(i, 1);
Assertions.assertEquals(i, 1);
}
/**
@ -77,7 +79,7 @@ public class TaskGroupMapperTest extends BaseDaoTest {
public void testCheckName() {
TaskGroup taskGroup = insertOne();
TaskGroup result = taskGroupMapper.queryByName(taskGroup.getUserId(), taskGroup.getName());
Assert.assertNotNull(result);
Assertions.assertNotNull(result);
}
/**
@ -87,11 +89,14 @@ public class TaskGroupMapperTest extends BaseDaoTest {
public void testQueryTaskGroupPaging() {
TaskGroup taskGroup = insertOne();
Page<TaskGroup> page = new Page(1, 3);
List<Integer> ids = new ArrayList<>();
ids.add(1);
ids.add(2);
IPage<TaskGroup> taskGroupIPage = taskGroupMapper.queryTaskGroupPaging(
page,
Mockito.anyList(),
ids,
taskGroup.getName(), taskGroup.getStatus());
Assert.assertEquals(taskGroupIPage.getTotal(), 1);
Assertions.assertEquals(taskGroupIPage.getTotal(), 1);
}
}

16
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupQueueMapperTest.java

@ -24,8 +24,8 @@ import org.apache.dolphinscheduler.dao.entity.TaskGroupQueue;
import java.util.Date;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class TaskGroupQueueMapperTest extends BaseDaoTest {
@ -59,7 +59,7 @@ public class TaskGroupQueueMapperTest extends BaseDaoTest {
taskGroupQueue.setStatus(TaskGroupQueueStatus.ACQUIRE_SUCCESS);
taskGroupQueue.setUpdateTime(new Date(System.currentTimeMillis()));
int i = taskGroupQueueMapper.updateById(taskGroupQueue);
Assert.assertEquals(i, 1);
Assertions.assertEquals(i, 1);
}
/**
@ -69,7 +69,7 @@ public class TaskGroupQueueMapperTest extends BaseDaoTest {
public void testDelete() {
TaskGroupQueue taskGroupQueue = insertOne();
int i = taskGroupQueueMapper.deleteByTaskId(taskGroupQueue.getId());
Assert.assertEquals(i, 0);
Assertions.assertEquals(i, 0);
}
/**
@ -79,10 +79,10 @@ public class TaskGroupQueueMapperTest extends BaseDaoTest {
public void testSelect() {
TaskGroupQueue taskGroupQueue = insertOne();
TaskGroupQueue result = taskGroupQueueMapper.selectById(taskGroupQueue.getId());
Assert.assertEquals(result.getTaskName(), "task1");
Assertions.assertEquals(result.getTaskName(), "task1");
List<TaskGroupQueue> taskGroupQueues = taskGroupQueueMapper.queryByStatus(taskGroupQueue.getStatus().getCode());
Assert.assertEquals(taskGroupQueues.size(), 1);
Assertions.assertEquals(taskGroupQueues.size(), 1);
}
@ -90,13 +90,13 @@ public class TaskGroupQueueMapperTest extends BaseDaoTest {
public void testUpdateStatusByTaskId() {
TaskGroupQueue taskGroupQueue = insertOne();
int i = taskGroupQueueMapper.updateStatusByTaskId(taskGroupQueue.getTaskId(), 7);
Assert.assertEquals(i, 1);
Assertions.assertEquals(i, 1);
}
@Test
public void testDeleteByTaskId() {
TaskGroupQueue taskGroupQueue = insertOne();
int i = taskGroupQueueMapper.deleteByTaskId(taskGroupQueue.getTaskId());
Assert.assertEquals(i, 1);
Assertions.assertEquals(i, 1);
}
}

32
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapperTest.java

@ -31,8 +31,8 @@ import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -105,7 +105,7 @@ public class TaskInstanceMapperTest extends BaseDaoTest {
TaskInstance taskInstance = insertTaskInstance(processInstance.getId());
// update
int update = taskInstanceMapper.updateById(taskInstance);
Assert.assertEquals(1, update);
Assertions.assertEquals(1, update);
taskInstanceMapper.deleteById(taskInstance.getId());
}
@ -121,7 +121,7 @@ public class TaskInstanceMapperTest extends BaseDaoTest {
TaskInstance taskInstance = insertTaskInstance(processInstance.getId());
int delete = taskInstanceMapper.deleteById(taskInstance.getId());
Assert.assertEquals(1, delete);
Assertions.assertEquals(1, delete);
}
/**
@ -137,7 +137,7 @@ public class TaskInstanceMapperTest extends BaseDaoTest {
// query
List<TaskInstance> taskInstances = taskInstanceMapper.selectList(null);
taskInstanceMapper.deleteById(taskInstance.getId());
Assert.assertNotEquals(taskInstances.size(), 0);
Assertions.assertNotEquals(taskInstances.size(), 0);
}
/**
@ -156,7 +156,7 @@ public class TaskInstanceMapperTest extends BaseDaoTest {
task.getProcessInstanceId(),
TaskExecutionStatus.RUNNING_EXECUTION.getCode());
taskInstanceMapper.deleteById(task.getId());
Assert.assertNotEquals(taskInstances.size(), 0);
Assertions.assertNotEquals(taskInstances.size(), 0);
}
/**
@ -187,8 +187,8 @@ public class TaskInstanceMapperTest extends BaseDaoTest {
processInstance.getTestFlag());
taskInstanceMapper.deleteById(task2.getId());
taskInstanceMapper.deleteById(task.getId());
Assert.assertNotEquals(taskInstances.size(), 0);
Assert.assertNotEquals(taskInstances1.size(), 0);
Assertions.assertNotEquals(taskInstances.size(), 0);
Assertions.assertNotEquals(taskInstances1.size(), 0);
}
/**
@ -207,7 +207,7 @@ public class TaskInstanceMapperTest extends BaseDaoTest {
List<TaskInstance> taskInstances = taskInstanceMapper.queryByHostAndStatus(
task.getHost(), new int[]{TaskExecutionStatus.RUNNING_EXECUTION.getCode()});
taskInstanceMapper.deleteById(task.getId());
Assert.assertNotEquals(taskInstances.size(), 0);
Assertions.assertNotEquals(taskInstances.size(), 0);
}
/**
@ -228,7 +228,7 @@ public class TaskInstanceMapperTest extends BaseDaoTest {
new int[]{TaskExecutionStatus.RUNNING_EXECUTION.getCode()},
TaskExecutionStatus.NEED_FAULT_TOLERANCE);
taskInstanceMapper.deleteById(task.getId());
Assert.assertNotEquals(setResult, 0);
Assertions.assertNotEquals(setResult, 0);
}
/**
@ -248,7 +248,7 @@ public class TaskInstanceMapperTest extends BaseDaoTest {
task.getProcessInstanceId(),
task.getName());
taskInstanceMapper.deleteById(task.getId());
Assert.assertNotEquals(taskInstance, null);
Assertions.assertNotEquals(taskInstance, null);
}
/**
@ -268,7 +268,7 @@ public class TaskInstanceMapperTest extends BaseDaoTest {
task.getProcessInstanceId(),
task.getTaskCode());
taskInstanceMapper.deleteById(task.getId());
Assert.assertNotEquals(taskInstance, null);
Assertions.assertNotEquals(taskInstance, null);
}
/**
@ -288,7 +288,7 @@ public class TaskInstanceMapperTest extends BaseDaoTest {
Collections.singletonList(task.getProcessInstanceId()),
Collections.singletonList(task.getTaskCode()));
taskInstanceMapper.deleteById(task.getId());
Assert.assertEquals(taskInstances.size(), 1);
Assertions.assertEquals(taskInstances.size(), 1);
}
/**
@ -317,8 +317,8 @@ public class TaskInstanceMapperTest extends BaseDaoTest {
new int[]{task.getId()});
taskInstanceMapper.deleteById(task.getId());
processDefinitionMapper.deleteById(definition.getId());
Assert.assertEquals(countTask, 0);
Assert.assertEquals(countTask2, 0);
Assertions.assertEquals(countTask, 0);
Assertions.assertEquals(countTask2, 0);
}
@ -383,7 +383,7 @@ public class TaskInstanceMapperTest extends BaseDaoTest {
processInstanceMapper.deleteById(processInstance.getId());
taskInstanceMapper.deleteById(task.getId());
processDefinitionMapper.deleteById(definition.getId());
Assert.assertEquals(taskInstanceIPage.getTotal(), 0);
Assertions.assertEquals(taskInstanceIPage.getTotal(), 0);
}
}

21
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TenantMapperTest.java

@ -20,13 +20,12 @@ import org.apache.dolphinscheduler.dao.BaseDaoTest;
import org.apache.dolphinscheduler.dao.entity.Queue;
import org.apache.dolphinscheduler.dao.entity.Tenant;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -64,7 +63,7 @@ public class TenantMapperTest extends BaseDaoTest {
tenant.setUpdateTime(new Date());
//update
int update = tenantMapper.updateById(tenant);
Assert.assertEquals(1, update);
Assertions.assertEquals(1, update);
}
/**
@ -74,7 +73,7 @@ public class TenantMapperTest extends BaseDaoTest {
public void testDelete(){
Tenant tenant = insertOne();
int delete = tenantMapper.deleteById(tenant.getId());
Assert.assertEquals(1, delete);
Assertions.assertEquals(1, delete);
}
/**
@ -85,7 +84,7 @@ public class TenantMapperTest extends BaseDaoTest {
Tenant tenant = insertOne();
//query
List<Tenant> tenants = tenantMapper.selectList(null);
Assert.assertNotEquals(tenants.size(), 0);
Assertions.assertNotEquals(tenants.size(), 0);
}
/**
@ -106,7 +105,7 @@ public class TenantMapperTest extends BaseDaoTest {
Tenant tenant1 = tenantMapper.queryById(tenant.getId());
Assert.assertNotEquals(tenant1, null);
Assertions.assertNotEquals(tenant1, null);
}
/**
@ -117,7 +116,7 @@ public class TenantMapperTest extends BaseDaoTest {
Tenant tenant = insertOne();
tenant.setTenantCode("ut code");
tenantMapper.updateById(tenant);
Assert.assertNotNull(tenantMapper.queryByTenantCode("ut code"));
Assertions.assertNotNull(tenantMapper.queryByTenantCode("ut code"));
}
/**
@ -140,13 +139,13 @@ public class TenantMapperTest extends BaseDaoTest {
//tenant.getTenantCode() used instead of tenant.getTenantName()
IPage<Tenant> tenantIPage = tenantMapper.queryTenantPaging(page, Collections.singletonList(tenant.getId()), tenant.getTenantCode());
Assert.assertNotEquals(tenantIPage.getTotal(), 0);
Assertions.assertNotEquals(tenantIPage.getTotal(), 0);
}
public void testExistTenant() {
String tenantCode = "test_code";
Assert.assertNull(tenantMapper.existTenant(tenantCode));
Assertions.assertNull(tenantMapper.existTenant(tenantCode));
insertOne();
Assert.assertTrue(tenantMapper.existTenant(tenantCode));
Assertions.assertTrue(tenantMapper.existTenant(tenantCode));
}
}

14
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UDFUserMapperTest.java

@ -26,8 +26,8 @@ import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Date;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class UDFUserMapperTest extends BaseDaoTest {
@ -121,7 +121,7 @@ public class UDFUserMapperTest extends BaseDaoTest {
udfUser.setUserId(2);
udfUser.setUdfId(2);
int update = udfUserMapper.updateById(udfUser);
Assert.assertEquals(update, 1);
Assertions.assertEquals(update, 1);
}
@ -137,7 +137,7 @@ public class UDFUserMapperTest extends BaseDaoTest {
//insertOne
UDFUser udfUser = insertOne(user, udfFunc);
int delete = udfUserMapper.deleteById(udfUser.getId());
Assert.assertEquals(delete, 1);
Assertions.assertEquals(delete, 1);
}
/**
@ -149,7 +149,7 @@ public class UDFUserMapperTest extends BaseDaoTest {
UDFUser udfUser = insertOne();
//query
List<UDFUser> udfUserList = udfUserMapper.selectList(null);
Assert.assertNotEquals(udfUserList.size(), 0);
Assertions.assertNotEquals(udfUserList.size(), 0);
}
/**
@ -164,7 +164,7 @@ public class UDFUserMapperTest extends BaseDaoTest {
//insertOne
UDFUser udfUser = insertOne(user, udfFunc);
int delete = udfUserMapper.deleteByUserId(user.getId());
Assert.assertEquals(delete, 1);
Assertions.assertEquals(delete, 1);
}
@ -180,6 +180,6 @@ public class UDFUserMapperTest extends BaseDaoTest {
//insertOne
UDFUser udfUser = insertOne(user, udfFunc);
int delete = udfUserMapper.deleteByUdfFuncId(udfFunc.getId());
Assert.assertEquals(delete, 1);
Assertions.assertEquals(delete, 1);
}
}

28
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapperTest.java

@ -31,8 +31,8 @@ import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -171,7 +171,7 @@ public class UdfFuncMapperTest extends BaseDaoTest {
udfFunc.setUpdateTime(new Date());
// update
int update = udfFuncMapper.updateById(udfFunc);
Assert.assertEquals(update, 1);
Assertions.assertEquals(update, 1);
}
@ -184,7 +184,7 @@ public class UdfFuncMapperTest extends BaseDaoTest {
UdfFunc udfFunc = insertOne("func2");
// delete
int delete = udfFuncMapper.deleteById(udfFunc.getId());
Assert.assertEquals(delete, 1);
Assertions.assertEquals(delete, 1);
}
/**
@ -199,7 +199,7 @@ public class UdfFuncMapperTest extends BaseDaoTest {
Integer[] idArray = new Integer[]{udfFunc.getId(), udfFunc1.getId()};
// queryUdfByIdStr
List<UdfFunc> udfFuncList = udfFuncMapper.queryUdfByIdStr(idArray, "");
Assert.assertNotEquals(udfFuncList.size(), 0);
Assertions.assertNotEquals(udfFuncList.size(), 0);
}
/**
@ -216,7 +216,7 @@ public class UdfFuncMapperTest extends BaseDaoTest {
IPage<UdfFunc> udfFuncIPage =
udfFuncMapper.queryUdfFuncPaging(page, Collections.singletonList(udfFunc.getId()), "");
Assert.assertNotEquals(udfFuncIPage.getTotal(), 0);
Assertions.assertNotEquals(udfFuncIPage.getTotal(), 0);
}
@ -232,7 +232,7 @@ public class UdfFuncMapperTest extends BaseDaoTest {
// getUdfFuncByType
List<UdfFunc> udfFuncList =
udfFuncMapper.getUdfFuncByType(Collections.singletonList(udfFunc.getId()), udfFunc.getType().ordinal());
Assert.assertNotEquals(udfFuncList.size(), 0);
Assertions.assertNotEquals(udfFuncList.size(), 0);
}
@ -248,7 +248,7 @@ public class UdfFuncMapperTest extends BaseDaoTest {
UdfFunc udfFunc1 = insertOne(user1);
UdfFunc udfFunc2 = insertOne(user2);
List<UdfFunc> udfFuncList = udfFuncMapper.queryUdfFuncExceptUserId(user1.getId());
Assert.assertNotEquals(udfFuncList.size(), 0);
Assertions.assertNotEquals(udfFuncList.size(), 0);
}
@ -267,7 +267,7 @@ public class UdfFuncMapperTest extends BaseDaoTest {
UDFUser udfUser = insertOneUDFUser(user, udfFunc);
// queryAuthedUdfFunc
List<UdfFunc> udfFuncList = udfFuncMapper.queryAuthedUdfFunc(user.getId());
Assert.assertNotEquals(udfFuncList.size(), 0);
Assertions.assertNotEquals(udfFuncList.size(), 0);
}
@Test
@ -285,15 +285,15 @@ public class UdfFuncMapperTest extends BaseDaoTest {
List<UdfFunc> authorizedUdfFunc = udfFuncMapper.listAuthorizedUdfFunc(generalUser1.getId(), udfFuncIds);
Assert.assertEquals(generalUser1.getId().intValue(), udfFunc.getUserId());
Assert.assertNotEquals(generalUser1.getId().intValue(), unauthorizdUdfFunc.getUserId());
Assert.assertFalse(authorizedUdfFunc.stream().map(t -> t.getId()).collect(toList())
Assertions.assertEquals(generalUser1.getId().intValue(), udfFunc.getUserId());
Assertions.assertNotEquals(generalUser1.getId().intValue(), unauthorizdUdfFunc.getUserId());
Assertions.assertFalse(authorizedUdfFunc.stream().map(t -> t.getId()).collect(toList())
.containsAll(Arrays.asList(udfFuncIds)));
// authorize object unauthorizdUdfFunc to generalUser1
insertOneUDFUser(generalUser1, unauthorizdUdfFunc);
authorizedUdfFunc = udfFuncMapper.listAuthorizedUdfFunc(generalUser1.getId(), udfFuncIds);
Assert.assertTrue(authorizedUdfFunc.stream().map(t -> t.getId()).collect(toList())
Assertions.assertTrue(authorizedUdfFunc.stream().map(t -> t.getId()).collect(toList())
.containsAll(Arrays.asList(udfFuncIds)));
}
@ -305,7 +305,7 @@ public class UdfFuncMapperTest extends BaseDaoTest {
udfFunc.setResourceName("/updateTest");
List<UdfFunc> udfFuncList = new ArrayList<>();
udfFuncList.add(udfFunc);
Assert.assertTrue(udfFuncMapper.batchUpdateUdfFunc(udfFuncList) > 0);
Assertions.assertTrue(udfFuncMapper.batchUpdateUdfFunc(udfFuncList) > 0);
}
}

26
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UserMapperTest.java

@ -30,8 +30,8 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -208,7 +208,7 @@ public class UserMapperTest extends BaseDaoTest {
user.setUserName("user1_update");
user.setUserType(UserType.ADMIN_USER);
int update = userMapper.updateById(user);
Assert.assertEquals(update, 1);
Assertions.assertEquals(update, 1);
}
/**
@ -220,7 +220,7 @@ public class UserMapperTest extends BaseDaoTest {
User user = insertOne();
//delete
int delete = userMapper.deleteById(user.getId());
Assert.assertEquals(delete, 1);
Assertions.assertEquals(delete, 1);
}
/**
@ -232,7 +232,7 @@ public class UserMapperTest extends BaseDaoTest {
User user = insertOne();
//query
List<User> userList = userMapper.selectList(null);
Assert.assertNotEquals(userList.size(), 0);
Assertions.assertNotEquals(userList.size(), 0);
}
/**
@ -244,7 +244,7 @@ public class UserMapperTest extends BaseDaoTest {
User user = insertOne();
//queryAllGeneralUser
List<User> userList = userMapper.queryAllGeneralUser();
Assert.assertNotEquals(userList.size(), 0);
Assertions.assertNotEquals(userList.size(), 0);
}
@ -262,7 +262,7 @@ public class UserMapperTest extends BaseDaoTest {
//queryUserPaging
Page<User> page = new Page(1, 3);
IPage<User> userIPage = userMapper.queryUserPaging(page, user.getUserName());
Assert.assertNotEquals(userIPage.getTotal(), 0);
Assertions.assertNotEquals(userIPage.getTotal(), 0);
}
/**
@ -276,7 +276,7 @@ public class UserMapperTest extends BaseDaoTest {
User user = insertOne(queue, tenant);
//queryDetailsById
User queryUser = userMapper.queryDetailsById(user.getId());
Assert.assertEquals(user.getUserName(), queryUser.getUserName());
Assertions.assertEquals(user.getUserName(), queryUser.getUserName());
}
/**
@ -290,7 +290,7 @@ public class UserMapperTest extends BaseDaoTest {
User user = insertOne(tenant);
//queryTenantCodeByUserId
User queryUser = userMapper.queryTenantCodeByUserId(user.getId());
Assert.assertEquals(queryUser, user);
Assertions.assertEquals(queryUser, user);
}
/**
@ -304,7 +304,7 @@ public class UserMapperTest extends BaseDaoTest {
AccessToken accessToken = insertOneAccessToken(user);
//queryUserByToken
User userToken = userMapper.queryUserByToken(accessToken.getToken(), new Date());
Assert.assertEquals(userToken, user);
Assertions.assertEquals(userToken, user);
}
@ -315,14 +315,14 @@ public class UserMapperTest extends BaseDaoTest {
List<Integer> userIds = new ArrayList<>();
userIds.add(user.getId());
List<User> users = userMapper.selectByIds(userIds);
Assert.assertFalse(users.isEmpty());
Assertions.assertFalse(users.isEmpty());
}
@Test
public void testExistUser() {
String queueName = "queue";
Assert.assertNull(userMapper.existUser(queueName));
Assertions.assertNull(userMapper.existUser(queueName));
insertOne();
Assert.assertTrue(userMapper.existUser(queueName));
Assertions.assertTrue(userMapper.existUser(queueName));
}
}

12
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/WorkFlowLineageMapperTest.java

@ -30,8 +30,8 @@ import org.apache.dolphinscheduler.dao.entity.WorkFlowLineage;
import java.util.Date;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class WorkFlowLineageMapperTest extends BaseDaoTest {
@ -112,7 +112,7 @@ public class WorkFlowLineageMapperTest extends BaseDaoTest {
insertOneSchedule(processDefinition.getId());
List<WorkFlowLineage> workFlowLineages = workFlowLineageMapper.queryWorkFlowLineageByName(processDefinition.getProjectCode(), processDefinition.getName());
Assert.assertNotEquals(workFlowLineages.size(), 0);
Assertions.assertNotEquals(workFlowLineages.size(), 0);
}
@Test
@ -120,7 +120,7 @@ public class WorkFlowLineageMapperTest extends BaseDaoTest {
ProcessTaskRelation processTaskRelation = insertOneProcessTaskRelation();
List<ProcessLineage> workFlowLineages = workFlowLineageMapper.queryProcessLineageByCode(processTaskRelation.getProjectCode(),
processTaskRelation.getProcessDefinitionCode());
Assert.assertNotEquals(workFlowLineages.size(), 0);
Assertions.assertNotEquals(workFlowLineages.size(), 0);
}
@Test
@ -129,7 +129,7 @@ public class WorkFlowLineageMapperTest extends BaseDaoTest {
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(1L);
insertOneProcessTaskRelation();
List<ProcessLineage> workFlowLineages = workFlowLineageMapper.queryProcessLineage(processDefinition.getProjectCode());
Assert.assertNotEquals(workFlowLineages.size(), 0);
Assertions.assertNotEquals(workFlowLineages.size(), 0);
}
@Test
@ -138,7 +138,7 @@ public class WorkFlowLineageMapperTest extends BaseDaoTest {
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(1L);
insertOneSchedule(processDefinition.getId());
WorkFlowLineage workFlowLineages = workFlowLineageMapper.queryWorkFlowLineageByCode(processDefinition.getProjectCode(), processDefinition.getCode());
Assert.assertNotNull(workFlowLineages);
Assertions.assertNotNull(workFlowLineages);
}
}

24
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/WorkerGroupMapperTest.java

@ -20,24 +20,26 @@ package org.apache.dolphinscheduler.dao.mapper;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.apache.dolphinscheduler.dao.BaseDaoTest;
import org.apache.dolphinscheduler.dao.entity.WorkerGroup;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class WorkerGroupMapperTest extends BaseDaoTest {
@Resource
private WorkerGroupMapper workerGroupMapper;
@Before
@BeforeEach
public void setUp() {
clearTestData();
}
@After
@AfterEach
public void after() {
clearTestData();
}
@ -75,7 +77,7 @@ public class WorkerGroupMapperTest extends BaseDaoTest {
public void testQueryAllWorkerGroups() {
insertOneWorkerGroup();
List<WorkerGroup> workerGroups = workerGroupMapper.queryAllWorkerGroup();
Assert.assertEquals(1, workerGroups.size());
Assertions.assertEquals(1, workerGroups.size());
}
/**
@ -85,10 +87,10 @@ public class WorkerGroupMapperTest extends BaseDaoTest {
public void testQueryWorkerGroupByName() {
WorkerGroup workerGroup = insertOneWorkerGroup();
List<WorkerGroup> workerGroups = workerGroupMapper.queryWorkerGroupByName(workerGroup.getName());
Assert.assertEquals(1, workerGroups.size());
Assertions.assertEquals(1, workerGroups.size());
workerGroups = workerGroupMapper.queryWorkerGroupByName("server2");
Assert.assertEquals(0, workerGroups.size());
Assertions.assertEquals(0, workerGroups.size());
}
/**
@ -99,7 +101,7 @@ public class WorkerGroupMapperTest extends BaseDaoTest {
WorkerGroup workerGroup = insertOneWorkerGroup();
workerGroup.setDescription("Server Update");
int update = workerGroupMapper.updateById(workerGroup);
Assert.assertEquals(1, update);
Assertions.assertEquals(1, update);
}
/**
@ -109,6 +111,6 @@ public class WorkerGroupMapperTest extends BaseDaoTest {
public void delete() {
WorkerGroup workerGroup = insertOneWorkerGroup();
int delete = workerGroupMapper.deleteById(workerGroup.getId());
Assert.assertEquals(1, delete);
Assertions.assertEquals(1, delete);
}
}

9
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/upgrade/ProcessDefinitionDaoTest.java

@ -22,7 +22,8 @@ import java.util.Map;
import javax.sql.DataSource;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ActiveProfiles;
@ -50,8 +51,10 @@ public class ProcessDefinitionDaoTest {
//processDefinitionDao.queryAllProcessDefinition(null);
}
@Test(expected = Exception.class)
@Test
public void testUpdateProcessDefinitionJsonException() {
processDefinitionDao.updateProcessDefinitionJson(null,null);
Assertions.assertThrows(Exception.class, () ->
processDefinitionDao.updateProcessDefinitionJson(null, null)
);
}
}

30
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/upgrade/SchemaUtilsTest.java

@ -22,8 +22,8 @@ import org.apache.commons.collections.CollectionUtils;
import java.io.IOException;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class SchemaUtilsTest {
@ -33,31 +33,31 @@ public class SchemaUtilsTest {
try {
SchemaUtils.isAGreatVersion(null, null);
} catch (RuntimeException e) {
Assert.assertEquals("schemaVersion or version is empty", e.getMessage());
Assertions.assertEquals("schemaVersion or version is empty", e.getMessage());
}
// param is ""
try {
SchemaUtils.isAGreatVersion("", "");
} catch (RuntimeException e) {
Assert.assertEquals("schemaVersion or version is empty", e.getMessage());
Assertions.assertEquals("schemaVersion or version is empty", e.getMessage());
}
Assert.assertFalse(SchemaUtils.isAGreatVersion("1", "1"));
Assert.assertTrue(SchemaUtils.isAGreatVersion("2", "1"));
Assert.assertTrue(SchemaUtils.isAGreatVersion("1.1", "1"));
Assert.assertTrue(SchemaUtils.isAGreatVersion("1.1", "1.0.1"));
Assert.assertFalse(SchemaUtils.isAGreatVersion("1.1", "1.2"));
Assert.assertTrue(SchemaUtils.isAGreatVersion("1.1.1", "1.1"));
Assert.assertTrue(SchemaUtils.isAGreatVersion("10.1.1", "1.01.100"));
Assertions.assertFalse(SchemaUtils.isAGreatVersion("1", "1"));
Assertions.assertTrue(SchemaUtils.isAGreatVersion("2", "1"));
Assertions.assertTrue(SchemaUtils.isAGreatVersion("1.1", "1"));
Assertions.assertTrue(SchemaUtils.isAGreatVersion("1.1", "1.0.1"));
Assertions.assertFalse(SchemaUtils.isAGreatVersion("1.1", "1.2"));
Assertions.assertTrue(SchemaUtils.isAGreatVersion("1.1.1", "1.1"));
Assertions.assertTrue(SchemaUtils.isAGreatVersion("10.1.1", "1.01.100"));
try {
SchemaUtils.isAGreatVersion("10.1.1", ".1");
Assert.fail("Should fail");
Assertions.fail("Should fail");
} catch (Exception ignored) {
// This is expected
}
try {
SchemaUtils.isAGreatVersion("a.1.1", "b.1");
Assert.fail("Should fail");
Assertions.fail("Should fail");
} catch (Exception ignored) {
// This is expected
}
@ -69,8 +69,8 @@ public class SchemaUtilsTest {
try {
list = SchemaUtils.getAllSchemaList();
} catch (IOException ex) {
Assert.fail(ex.getMessage());
Assertions.fail(ex.getMessage());
}
Assert.assertFalse("Can not find any schema files", CollectionUtils.isEmpty(list));
Assertions.assertFalse(CollectionUtils.isEmpty(list),"Can not find any schema files");
}
}

28
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/upgrade/WorkerGroupDaoTest.java

@ -16,45 +16,35 @@
*/
package org.apache.dolphinscheduler.dao.upgrade;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.junit.Assert.assertThat;
import org.apache.dolphinscheduler.dao.DaoConfiguration;
import java.util.Map;
import javax.sql.DataSource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
@ActiveProfiles("h2")
@SpringBootTest(classes = DaoConfiguration.class)
@RunWith(SpringRunner.class)
@ExtendWith(MockitoExtension.class)
@SpringBootApplication(scanBasePackageClasses = DaoConfiguration.class)
public class WorkerGroupDaoTest {
@Autowired
protected DataSource dataSource;
@Test
public void testQueryQueryAllOldWorkerGroup() throws Exception {
WorkerGroupDao workerGroupDao = new WorkerGroupDao();
Map<Integer, String> workerGroupMap = workerGroupDao.queryAllOldWorkerGroup(dataSource.getConnection());
assertThat(workerGroupMap.size(), greaterThanOrEqualTo(0));
}
@Test(expected = Exception.class)
public void testQueryQueryAllOldWorkerGroupException() throws Exception {
WorkerGroupDao workerGroupDao = new WorkerGroupDao();
workerGroupDao.queryAllOldWorkerGroup(null);
Assertions.assertThrows(Exception.class, () -> {
WorkerGroupDao workerGroupDao = new WorkerGroupDao();
workerGroupDao.queryAllOldWorkerGroup(null);
});
}

6
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/utils/ResourceProcessDefinitionUtilsTest.java

@ -16,8 +16,8 @@
*/
package org.apache.dolphinscheduler.dao.utils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.HashMap;
@ -35,7 +35,7 @@ public class ResourceProcessDefinitionUtilsTest {
map.put("code",1L);
map.put("resource_ids","1,2,3");
mapList.add(map);
Assert.assertNotNull(ResourceProcessDefinitionUtils.getResourceProcessDefinitionMap(mapList));
Assertions.assertNotNull(ResourceProcessDefinitionUtils.getResourceProcessDefinitionMap(mapList));
}
}

106
dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/utils/DagHelperTest.java

@ -39,8 +39,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.core.JsonProcessingException;
@ -87,16 +87,16 @@ public class DagHelperTest {
processDag.setNodes(taskNodes);
DAG<String, TaskNode, TaskNodeRelation> dag = DagHelper.buildDagGraph(processDag);
boolean canSubmit = DagHelper.haveAllNodeAfterNode(parentNodeCode, dag);
Assert.assertTrue(canSubmit);
Assertions.assertTrue(canSubmit);
boolean haveBlocking = DagHelper.haveBlockingAfterNode(parentNodeCode, dag);
Assert.assertTrue(haveBlocking);
Assertions.assertTrue(haveBlocking);
boolean haveConditions = DagHelper.haveConditionsAfterNode(parentNodeCode, dag);
Assert.assertTrue(haveConditions);
Assertions.assertTrue(haveConditions);
boolean dependent = DagHelper.haveSubAfterNode(parentNodeCode, dag, TaskConstants.TASK_TYPE_DEPENDENT);
Assert.assertFalse(dependent);
Assertions.assertFalse(dependent);
}
/**
@ -121,14 +121,14 @@ public class DagHelperTest {
TaskNode nodex = dag.getNode("4");
nodex.setRunFlag(Constants.FLOWNODE_RUN_FLAG_FORBIDDEN);
canSubmit = DagHelper.allDependsForbiddenOrEnd(taskNode3, dag, skipNodeList, completeTaskList);
Assert.assertEquals(canSubmit, true);
Assertions.assertEquals(canSubmit, true);
// 2forbidden, 3 cannot be submit
completeTaskList.putIfAbsent("2", new TaskInstance());
TaskNode nodey = dag.getNode("4");
nodey.setRunFlag("");
canSubmit = DagHelper.allDependsForbiddenOrEnd(taskNode3, dag, skipNodeList, completeTaskList);
Assert.assertEquals(canSubmit, false);
Assertions.assertEquals(canSubmit, false);
// 2/3 forbidden submit 5
TaskNode node3 = dag.getNode("3");
@ -137,7 +137,7 @@ public class DagHelperTest {
node8.setRunFlag(Constants.FLOWNODE_RUN_FLAG_FORBIDDEN);
TaskNode node5 = dag.getNode("5");
canSubmit = DagHelper.allDependsForbiddenOrEnd(node5, dag, skipNodeList, completeTaskList);
Assert.assertEquals(canSubmit, true);
Assertions.assertEquals(canSubmit, true);
}
/**
@ -153,56 +153,56 @@ public class DagHelperTest {
// complete : null
// expect post: 1/4
postNodes = DagHelper.parsePostNodes(null, skipNodeList, dag, completeTaskList);
Assert.assertEquals(2, postNodes.size());
Assert.assertTrue(postNodes.contains("1"));
Assert.assertTrue(postNodes.contains("4"));
Assertions.assertEquals(2, postNodes.size());
Assertions.assertTrue(postNodes.contains("1"));
Assertions.assertTrue(postNodes.contains("4"));
// complete : 1
// expect post: 2/4
completeTaskList.put("1", new TaskInstance());
postNodes = DagHelper.parsePostNodes(null, skipNodeList, dag, completeTaskList);
Assert.assertEquals(2, postNodes.size());
Assert.assertTrue(postNodes.contains("2"));
Assert.assertTrue(postNodes.contains("4"));
Assertions.assertEquals(2, postNodes.size());
Assertions.assertTrue(postNodes.contains("2"));
Assertions.assertTrue(postNodes.contains("4"));
// complete : 1/2
// expect post: 4
completeTaskList.put("2", new TaskInstance());
postNodes = DagHelper.parsePostNodes(null, skipNodeList, dag, completeTaskList);
Assert.assertEquals(2, postNodes.size());
Assert.assertTrue(postNodes.contains("4"));
Assert.assertTrue(postNodes.contains("8"));
Assertions.assertEquals(2, postNodes.size());
Assertions.assertTrue(postNodes.contains("4"));
Assertions.assertTrue(postNodes.contains("8"));
// complete : 1/2/4
// expect post: 3
completeTaskList.put("4", new TaskInstance());
postNodes = DagHelper.parsePostNodes(null, skipNodeList, dag, completeTaskList);
Assert.assertEquals(2, postNodes.size());
Assert.assertTrue(postNodes.contains("3"));
Assert.assertTrue(postNodes.contains("8"));
Assertions.assertEquals(2, postNodes.size());
Assertions.assertTrue(postNodes.contains("3"));
Assertions.assertTrue(postNodes.contains("8"));
// complete : 1/2/4/3
// expect post: 8/6
completeTaskList.put("3", new TaskInstance());
postNodes = DagHelper.parsePostNodes(null, skipNodeList, dag, completeTaskList);
Assert.assertEquals(2, postNodes.size());
Assert.assertTrue(postNodes.contains("8"));
Assert.assertTrue(postNodes.contains("6"));
Assertions.assertEquals(2, postNodes.size());
Assertions.assertTrue(postNodes.contains("8"));
Assertions.assertTrue(postNodes.contains("6"));
// complete : 1/2/4/3/8
// expect post: 6/5
completeTaskList.put("8", new TaskInstance());
postNodes = DagHelper.parsePostNodes(null, skipNodeList, dag, completeTaskList);
Assert.assertEquals(2, postNodes.size());
Assert.assertTrue(postNodes.contains("5"));
Assert.assertTrue(postNodes.contains("6"));
Assertions.assertEquals(2, postNodes.size());
Assertions.assertTrue(postNodes.contains("5"));
Assertions.assertTrue(postNodes.contains("6"));
// complete : 1/2/4/3/5/6/8
// expect post: 7
completeTaskList.put("6", new TaskInstance());
completeTaskList.put("5", new TaskInstance());
postNodes = DagHelper.parsePostNodes(null, skipNodeList, dag, completeTaskList);
Assert.assertEquals(1, postNodes.size());
Assert.assertTrue(postNodes.contains("7"));
Assertions.assertEquals(1, postNodes.size());
Assertions.assertTrue(postNodes.contains("7"));
}
/**
@ -222,25 +222,25 @@ public class DagHelperTest {
TaskNode node2 = dag.getNode("2");
node2.setRunFlag(Constants.FLOWNODE_RUN_FLAG_FORBIDDEN);
postNodes = DagHelper.parsePostNodes(null, skipNodeList, dag, completeTaskList);
Assert.assertEquals(2, postNodes.size());
Assert.assertTrue(postNodes.contains("4"));
Assert.assertTrue(postNodes.contains("8"));
Assertions.assertEquals(2, postNodes.size());
Assertions.assertTrue(postNodes.contains("4"));
Assertions.assertTrue(postNodes.contains("8"));
// forbid:2/4 complete:1 post:3/8
TaskNode node4 = dag.getNode("4");
node4.setRunFlag(Constants.FLOWNODE_RUN_FLAG_FORBIDDEN);
postNodes = DagHelper.parsePostNodes(null, skipNodeList, dag, completeTaskList);
Assert.assertEquals(2, postNodes.size());
Assert.assertTrue(postNodes.contains("3"));
Assert.assertTrue(postNodes.contains("8"));
Assertions.assertEquals(2, postNodes.size());
Assertions.assertTrue(postNodes.contains("3"));
Assertions.assertTrue(postNodes.contains("8"));
// forbid:2/4/5 complete:1/8 post:3
completeTaskList.put("8", new TaskInstance());
TaskNode node5 = dag.getNode("5");
node5.setRunFlag(Constants.FLOWNODE_RUN_FLAG_FORBIDDEN);
postNodes = DagHelper.parsePostNodes(null, skipNodeList, dag, completeTaskList);
Assert.assertEquals(1, postNodes.size());
Assert.assertTrue(postNodes.contains("3"));
Assertions.assertEquals(1, postNodes.size());
Assertions.assertTrue(postNodes.contains("3"));
}
/**
@ -278,15 +278,15 @@ public class DagHelperTest {
// complete 1/2/3/4 expect:8
completeTaskList.put("3", taskInstance);
postNodes = DagHelper.parsePostNodes(null, skipNodeList, dag, completeTaskList);
Assert.assertEquals(1, postNodes.size());
Assert.assertTrue(postNodes.contains("8"));
Assertions.assertEquals(1, postNodes.size());
Assertions.assertTrue(postNodes.contains("8"));
// 2.complete 1/2/3/4/8 expect:5 skip:6
completeTaskList.put("8", new TaskInstance());
postNodes = DagHelper.parsePostNodes(null, skipNodeList, dag, completeTaskList);
Assert.assertTrue(postNodes.contains("5"));
Assert.assertEquals(1, skipNodeList.size());
Assert.assertTrue(skipNodeList.containsKey("6"));
Assertions.assertTrue(postNodes.contains("5"));
Assertions.assertEquals(1, skipNodeList.size());
Assertions.assertTrue(skipNodeList.containsKey("6"));
// 3.complete 1/2/3/4/5/8 expect post:7 skip:6
skipNodeList.clear();
@ -294,10 +294,10 @@ public class DagHelperTest {
taskInstance.setState(TaskExecutionStatus.SUCCESS);
completeTaskList.put("5", taskInstance1);
postNodes = DagHelper.parsePostNodes(null, skipNodeList, dag, completeTaskList);
Assert.assertEquals(1, postNodes.size());
Assert.assertTrue(postNodes.contains("7"));
Assert.assertEquals(1, skipNodeList.size());
Assert.assertTrue(skipNodeList.containsKey("6"));
Assertions.assertEquals(1, postNodes.size());
Assertions.assertTrue(postNodes.contains("7"));
Assertions.assertEquals(1, skipNodeList.size());
Assertions.assertTrue(skipNodeList.containsKey("6"));
// dag: 1-2-3-5-7 4-3-6
// 3-if , complete:1/2/3/4
@ -312,11 +312,11 @@ public class DagHelperTest {
taskInstance.setState(TaskExecutionStatus.FAILURE);
completeTaskList.put("3", taskInstance);
postNodes = DagHelper.parsePostNodes(null, skipNodeList, dag, completeTaskList);
Assert.assertEquals(1, postNodes.size());
Assert.assertTrue(postNodes.contains("6"));
Assert.assertEquals(2, skipNodeList.size());
Assert.assertTrue(skipNodeList.containsKey("5"));
Assert.assertTrue(skipNodeList.containsKey("7"));
Assertions.assertEquals(1, postNodes.size());
Assertions.assertTrue(postNodes.contains("6"));
Assertions.assertEquals(2, skipNodeList.size());
Assertions.assertTrue(skipNodeList.containsKey("5"));
Assertions.assertTrue(skipNodeList.containsKey("7"));
// dag: 1-2-3-5-7 4-3-6
// 3-if , complete:1/2/3/4
@ -327,7 +327,7 @@ public class DagHelperTest {
taskInstance.setSwitchDependency(getSwitchNode());
completeTaskList.put("1", taskInstance);
postNodes = DagHelper.parsePostNodes("1", skipNodeList, dag, completeTaskList);
Assert.assertEquals(1, postNodes.size());
Assertions.assertEquals(1, postNodes.size());
}
/**
@ -541,7 +541,7 @@ public class DagHelperTest {
List<TaskNode> taskNodeList = processData.getTasks();
ProcessDag processDag = DagHelper.getProcessDag(taskNodeList);
DAG<String, TaskNode, TaskNodeRelation> dag = DagHelper.buildDagGraph(processDag);
Assert.assertNotNull(dag);
Assertions.assertNotNull(dag);
}
}

Loading…
Cancel
Save