Browse Source

update UT in pom.xml

pull/2/head
qiaozhanwei 5 years ago
parent
commit
9de9f18c08
  1. 4
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/CommandMapperTest.java
  2. 2
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/DataSourceUserMapperTest.java
  3. 3
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapperTest.java
  4. 12
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapperTest.java
  5. 23
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapMapperTest.java
  6. 12
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapperTest.java
  7. 3
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectUserMapperTest.java
  8. 4
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/QueueMapperTest.java
  9. 9
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapperTest.java
  10. 2
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceUserMapperTest.java
  11. 12
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ScheduleMapperTest.java
  12. 5
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/SessionMapperTest.java
  13. 6
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TenantMapperTest.java
  14. 10
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UDFUserMapperTest.java
  15. 15
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapperTest.java
  16. 9
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UserAlertGroupMapperTest.java
  17. 17
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UserMapperTest.java
  18. 139
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/WorkerGroupMapperTest.java
  19. 21
      pom.xml

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

@ -170,7 +170,7 @@ public class CommandMapperTest {
List<CommandCount> actualCommandCounts = commandMapper.countCommandState(0, startTime, endTime, projectIdArray);
assertThat(actualCommandCounts.size(), greaterThanOrEqualTo(1));
assertThat(actualCommandCounts.size(),greaterThanOrEqualTo(1));
}
@ -262,4 +262,6 @@ public class CommandMapperTest {
return command;
}
}

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

@ -67,7 +67,6 @@ public class DataSourceUserMapperTest {
dataSourceUser.setUpdateTime(new Date());
int update = dataSourceUserMapper.updateById(dataSourceUser);
Assert.assertEquals(update, 1);
dataSourceUserMapper.deleteById(dataSourceUser.getId());
}
/**
@ -90,7 +89,6 @@ public class DataSourceUserMapperTest {
//query
List<DatasourceUser> dataSources = dataSourceUserMapper.selectList(null);
Assert.assertNotEquals(dataSources.size(), 0);
dataSourceUserMapper.deleteById(dataSourceUser.getId());
}
/**

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

@ -72,7 +72,6 @@ public class ErrorCommandMapperTest {
errorCommand.setUpdateTime(new Date());
int update = errorCommandMapper.updateById(errorCommand);
Assert.assertEquals(1,update);
errorCommandMapper.deleteById(errorCommand.getId());
}
/**
@ -120,8 +119,6 @@ public class ErrorCommandMapperTest {
projectIdArray
);
errorCommandMapper.deleteById(errorCommand.getId());
processDefinitionMapper.deleteById(processDefinition.getId());
Assert.assertNotEquals(commandCounts.size(), 0);
Assert.assertNotEquals(commandCounts2.size(), 0);
}

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

@ -82,7 +82,6 @@ public class ProcessDefinitionMapperTest {
processDefinition.setUpdateTime(new Date());
int update = processDefinitionMapper.updateById(processDefinition);
Assert.assertEquals(1, update);
processDefinitionMapper.deleteById(processDefinition.getId());
}
/**
@ -104,7 +103,6 @@ public class ProcessDefinitionMapperTest {
//query
List<ProcessDefinition> dataSources = processDefinitionMapper.selectList(null);
Assert.assertNotEquals(dataSources.size(), 0);
processDefinitionMapper.deleteById(processDefinition.getId());
}
/**
@ -147,11 +145,6 @@ public class ProcessDefinitionMapperTest {
ProcessDefinition processDefinition1 = processDefinitionMapper.queryByDefineName(project.getId(), "def 1");
Assert.assertNotEquals(processDefinition1, null);
processDefinitionMapper.deleteById(processDefinition.getId());
queueMapper.deleteById(queue.getId());
projectMapper.deleteById(project.getId());
tenantMapper.deleteById(tenant.getId());
userMapper.deleteById(user.getId());
}
/**
@ -163,7 +156,6 @@ public class ProcessDefinitionMapperTest {
Page<ProcessDefinition> page = new Page(1,3);
IPage<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryDefineListPaging(page, "def", 101, 1010,true);
Assert.assertNotEquals(processDefinitionIPage.getTotal(), 0);
processDefinitionMapper.deleteById(processDefinition.getId());
}
/**
@ -174,7 +166,6 @@ public class ProcessDefinitionMapperTest {
ProcessDefinition processDefinition = insertOne();
List<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryAllDefinitionList(1010);
Assert.assertNotEquals(processDefinitionIPage.size(), 0);
processDefinitionMapper.deleteById(processDefinition.getId());
}
/**
@ -191,8 +182,6 @@ public class ProcessDefinitionMapperTest {
array[1] = processDefinition1.getId();
List<ProcessDefinition> processDefinitions = processDefinitionMapper.queryDefinitionListByIdList(array);
processDefinitionMapper.deleteById(processDefinition.getId());
processDefinitionMapper.deleteById(processDefinition1.getId());
Assert.assertEquals(2, processDefinitions.size());
}
@ -224,7 +213,6 @@ public class ProcessDefinitionMapperTest {
projectIds,
user.getUserType() == UserType.ADMIN_USER
);
processDefinitionMapper.deleteById(processDefinition.getId());
Assert.assertNotEquals(processDefinitions.size(), 0);
}
}

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

@ -65,7 +65,6 @@ public class ProcessInstanceMapMapperTest {
processInstanceMap.setParentProcessInstanceId(1);
int update = processInstanceMapMapper.updateById(processInstanceMap);
Assert.assertEquals(1, update);
processInstanceMapMapper.deleteById(processInstanceMap.getId());
}
/**
@ -87,7 +86,6 @@ public class ProcessInstanceMapMapperTest {
//query
List<ProcessInstanceMap> dataSources = processInstanceMapMapper.selectList(null);
Assert.assertNotEquals(dataSources.size(), 0);
processInstanceMapMapper.deleteById(processInstanceMap.getId());
}
/**
@ -99,30 +97,11 @@ public class ProcessInstanceMapMapperTest {
processInstanceMap.setParentProcessInstanceId(100);
processInstanceMapMapper.updateById(processInstanceMap);
ProcessInstanceMap map =
processInstanceMapMapper.queryByParentId(processInstanceMap.getParentProcessInstanceId(), processInstanceMap.getParentTaskInstanceId());
Assert.assertNotEquals(map, null);
processInstanceMapMapper.deleteById(processInstanceMap.getId());
}
/**
* test query by sub process instance id
*/
@Test
public void testQueryBySubProcessId() {
ProcessInstanceMap processInstanceMap = insertOne();
processInstanceMap.setProcessInstanceId(100);
processInstanceMapMapper.updateById(processInstanceMap);
ProcessInstanceMap map =
processInstanceMapMapper.queryBySubProcessId(
processInstanceMap.getProcessInstanceId() );
Assert.assertNotEquals(map, null);
processInstanceMapMapper.deleteById(processInstanceMap.getId());
}
/**
* test delete by parent process instance id
@ -140,6 +119,7 @@ public class ProcessInstanceMapMapperTest {
}
/**
*
* test query sub ids by process instance parentId
*/
@Test
@ -154,7 +134,6 @@ public class ProcessInstanceMapMapperTest {
Assert.assertNotEquals(subIds.size(), 0);
processInstanceMapMapper.deleteById(processInstanceMap.getId());
}
}

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

@ -70,7 +70,6 @@ public class ProjectMapperTest {
//update
int update = projectMapper.updateById(project);
Assert.assertEquals(update, 1);
projectMapper.deleteById(project.getId());
}
/**
@ -92,7 +91,6 @@ public class ProjectMapperTest {
//query
List<Project> projects = projectMapper.selectList(null);
Assert.assertNotEquals(projects.size(), 0);
projectMapper.deleteById(project.getId());
}
/**
@ -110,8 +108,6 @@ public class ProjectMapperTest {
projectMapper.updateById(project);
Project project1 = projectMapper.queryDetailById(project.getId());
userMapper.deleteById(user.getId());
projectMapper.deleteById(project.getId());
Assert.assertNotEquals(project1, null);
Assert.assertEquals(project1.getUserName(), user.getUserName());
}
@ -130,8 +126,6 @@ public class ProjectMapperTest {
projectMapper.updateById(project);
Project project1 = projectMapper.queryByName(project.getName());
userMapper.deleteById(user.getId());
projectMapper.deleteById(project.getId());
Assert.assertNotEquals(project1, null);
Assert.assertEquals(project1.getUserName(), user.getUserName());
}
@ -161,9 +155,6 @@ public class ProjectMapperTest {
project.getUserId(),
project.getName()
);
projectMapper.deleteById(project.getId());
projectMapper.deleteById(project1.getId());
userMapper.deleteById(user.getId());
Assert.assertNotEquals(projectIPage.getTotal(), 0);
Assert.assertNotEquals(projectIPage1.getTotal(), 0);
}
@ -177,7 +168,6 @@ public class ProjectMapperTest {
List<Project> projects = projectMapper.queryProjectCreatedByUser(project.getUserId());
projectMapper.deleteById(project.getId());
Assert.assertNotEquals(projects.size(), 0);
}
@ -191,7 +181,6 @@ public class ProjectMapperTest {
List<Project> projects = projectMapper.queryProjectCreatedByUser(project.getUserId());
projectMapper.deleteById(project.getId());
Assert.assertNotEquals(projects.size(), 0);
}
@ -206,7 +195,6 @@ public class ProjectMapperTest {
100000
);
projectMapper.deleteById(project.getId());
Assert.assertNotEquals(projects.size(), 0);
}
}

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

@ -64,7 +64,6 @@ public class ProjectUserMapperTest {
//update
int update = projectUserMapper.updateById(projectUser);
Assert.assertEquals(update, 1);
projectUserMapper.deleteById(projectUser.getId());
}
/**
@ -86,7 +85,6 @@ public class ProjectUserMapperTest {
//query
List<ProjectUser> projectUsers = projectUserMapper.selectList(null);
Assert.assertNotEquals(projectUsers.size(), 0);
projectUserMapper.deleteById(projectUser.getId());
}
/**
@ -111,6 +109,5 @@ public class ProjectUserMapperTest {
ProjectUser projectUser1 = projectUserMapper.queryProjectRelation(projectUser.getProjectId(), projectUser.getUserId());
Assert.assertNotEquals(projectUser1, null);
projectUserMapper.deleteById(projectUser.getId());
}
}

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

@ -69,7 +69,6 @@ public class QueueMapperTest {
//update
int update = queueMapper.updateById(queue);
Assert.assertEquals(1, update);
queueMapper.deleteById(queue.getId());
}
/**
@ -91,7 +90,6 @@ public class QueueMapperTest {
//query
List<Queue> queues = queueMapper.selectList(null);
Assert.assertNotEquals(queues.size(), 0);
queueMapper.deleteById(queue.getId());
}
/**
@ -110,7 +108,6 @@ public class QueueMapperTest {
queueIPage= queueMapper.queryQueuePaging(page,
queue.getQueueName());
Assert.assertNotEquals(queueIPage.getTotal(), 0);
queueMapper.deleteById(queue.getId());
}
/**
@ -125,6 +122,5 @@ public class QueueMapperTest {
queues = queueMapper.queryAllQueueList(null, queue.getQueueName());
Assert.assertNotEquals(queues.size(), 0);
queueMapper.deleteById(queue.getId());
}
}

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

@ -159,7 +159,6 @@ public class ResourceMapperTest {
//update
int update = resourceMapper.updateById(resource);
Assert.assertEquals(1, update);
resourceMapper.deleteById(resource.getId());
}
/**
@ -181,7 +180,6 @@ public class ResourceMapperTest {
//query
List<Resource> resources = resourceMapper.selectList(null);
Assert.assertNotEquals(resources.size(), 0);
resourceMapper.deleteById(resource.getId());
}
/**
@ -202,7 +200,6 @@ public class ResourceMapperTest {
);
Assert.assertNotEquals(resources.size(), 0);
resourceMapper.deleteById(resource.getId());
}
/**
@ -232,8 +229,6 @@ public class ResourceMapperTest {
resource.getType().ordinal(),
""
);
resourceMapper.deleteById(resource.getId());
resourceUserMapper.deleteById(resourcesUser.getId());
Assert.assertNotEquals(resourceIPage.getTotal(), 0);
Assert.assertNotEquals(resourceIPage1.getTotal(), 0);
@ -256,8 +251,6 @@ public class ResourceMapperTest {
List<Resource> resources1 = resourceMapper.queryAuthorizedResourceList(1110);
resourceUserMapper.deleteById(resourcesUser.getId());
resourceMapper.deleteById(resource.getId());
Assert.assertEquals(0, resources.size());
Assert.assertNotEquals(0, resources1.size());
@ -286,7 +279,6 @@ public class ResourceMapperTest {
11111
);
Assert.assertNotEquals(resources.size(), 0);
resourceMapper.deleteById(resource.getId());
}
/**
@ -316,7 +308,6 @@ public class ResourceMapperTest {
Assert.assertEquals("ut tenant code for resource", resource1);
resourceMapper.deleteById(resource.getId());
}

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

@ -67,7 +67,6 @@ public class ResourceUserMapperTest {
//update
int update = resourceUserMapper.updateById(queue);
Assert.assertEquals(1, update);
resourceUserMapper.deleteById(queue.getId());
}
/**
@ -89,7 +88,6 @@ public class ResourceUserMapperTest {
//query
List<ResourcesUser> queues = resourceUserMapper.selectList(null);
Assert.assertNotEquals(queues.size(), 0);
resourceUserMapper.deleteById(queue.getId());
}
/**

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

@ -87,7 +87,6 @@ public class ScheduleMapperTest {
//update
int update = scheduleMapper.updateById(schedule);
Assert.assertEquals(update, 1);
scheduleMapper.deleteById(schedule.getId());
}
/**
@ -109,7 +108,6 @@ public class ScheduleMapperTest {
//query
List<Schedule> schedules = scheduleMapper.selectList(null);
Assert.assertNotEquals(schedules.size(), 0);
scheduleMapper.deleteById(schedule.getId());
}
/**
@ -145,10 +143,6 @@ public class ScheduleMapperTest {
Assert.assertNotEquals(scheduleIPage.getSize(), 0);
projectMapper.deleteById(project.getId());
processDefinitionMapper.deleteById(processDefinition.getId());
userMapper.deleteById(user.getId());
scheduleMapper.deleteById(schedule.getId());
}
/**
@ -182,10 +176,6 @@ public class ScheduleMapperTest {
List<Schedule> schedules = scheduleMapper.querySchedulerListByProjectName(
project.getName()
);
projectMapper.deleteById(project.getId());
processDefinitionMapper.deleteById(processDefinition.getId());
userMapper.deleteById(user.getId());
scheduleMapper.deleteById(schedule.getId());
Assert.assertNotEquals(schedules.size(), 0);
}
@ -202,7 +192,6 @@ public class ScheduleMapperTest {
scheduleMapper.updateById(schedule);
List<Schedule> schedules= scheduleMapper.selectAllByProcessDefineArray(new int[] {schedule.getProcessDefinitionId()});
scheduleMapper.deleteById(schedule.getId());
Assert.assertNotEquals(schedules.size(), 0);
}
@ -216,7 +205,6 @@ public class ScheduleMapperTest {
scheduleMapper.updateById(schedule);
List<Schedule> schedules= scheduleMapper.queryByProcessDefinitionId(schedule.getProcessDefinitionId());
scheduleMapper.deleteById(schedule.getId());
Assert.assertNotEquals(schedules.size(), 0);
}
}

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

@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@RunWith(SpringRunner.class)
@SpringBootTest
@ -46,6 +47,7 @@ public class SessionMapperTest {
private Session insertOne(){
//insertOne
Session session = new Session();
session.setId(UUID.randomUUID().toString());
session.setLastLoginTime(new Date());
session.setUserId(11111);
sessionMapper.insert(session);
@ -63,7 +65,6 @@ public class SessionMapperTest {
//update
int update = sessionMapper.updateById(session);
Assert.assertEquals(update, 1);
sessionMapper.deleteById(session.getId());
}
/**
@ -85,7 +86,6 @@ public class SessionMapperTest {
//query
List<Session> sessions = sessionMapper.selectList(null);
Assert.assertNotEquals(sessions.size(), 0);
sessionMapper.deleteById(session.getId());
}
/**
@ -97,6 +97,5 @@ public class SessionMapperTest {
List<Session> sessions = sessionMapper.queryByUserId(session.getUserId());
Assert.assertNotEquals(sessions.size(), 0);
sessionMapper.deleteById(session.getId());
}
}

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

@ -69,7 +69,6 @@ public class TenantMapperTest {
//update
int update = tenantMapper.updateById(tenant);
Assert.assertEquals(1, update);
tenantMapper.deleteById(tenant.getId());
}
/**
@ -91,7 +90,6 @@ public class TenantMapperTest {
//query
List<Tenant> tenants = tenantMapper.selectList(null);
Assert.assertNotEquals(tenants.size(), 0);
tenantMapper.deleteById(tenant.getId());
}
/**
@ -112,7 +110,6 @@ public class TenantMapperTest {
Tenant tenant1 = tenantMapper.queryById(tenant.getId());
tenantMapper.deleteById(tenant.getId());
Assert.assertNotEquals(tenant1, null);
}
@ -125,7 +122,6 @@ public class TenantMapperTest {
Tenant tenant = insertOne();
tenant.setTenantCode("ut code");
tenantMapper.updateById(tenant);
tenantMapper.deleteById(tenant.getId());
}
/**
@ -148,8 +144,6 @@ public class TenantMapperTest {
IPage<Tenant> tenantIPage = tenantMapper.queryTenantPaging(page, tenant.getTenantName());
queueMapper.deleteById(queue.getId());
tenantMapper.deleteById(tenant.getId());
Assert.assertNotEquals(tenantIPage.getTotal(), 0);
}
}

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

@ -130,9 +130,6 @@ public class UDFUserMapperTest {
udfUser.setUdfId(2);
int update = udfUserMapper.updateById(udfUser);
Assert.assertEquals(update, 1);
udfUserMapper.deleteById(udfUser.getId());
udfFuncMapper.deleteById(udfFunc.getId());
userMapper.deleteById(user.getId());
}
@ -149,8 +146,6 @@ public class UDFUserMapperTest {
UDFUser udfUser = insertOne(user, udfFunc);
int delete = udfUserMapper.deleteById(udfUser.getId());
Assert.assertEquals(delete, 1);
userMapper.deleteById(user.getId());
udfFuncMapper.deleteById(udfFunc.getId());
}
/**
@ -163,7 +158,6 @@ public class UDFUserMapperTest {
//query
List<UDFUser> udfUserList = udfUserMapper.selectList(null);
Assert.assertNotEquals(udfUserList.size(), 0);
userMapper.deleteById(udfUser.getId());
}
/**
@ -179,8 +173,6 @@ public class UDFUserMapperTest {
UDFUser udfUser = insertOne(user, udfFunc);
int delete = udfUserMapper.deleteByUserId(user.getId());
Assert.assertEquals(delete, 1);
userMapper.deleteById(user.getId());
udfFuncMapper.deleteById(udfFunc.getId());
}
@ -197,7 +189,5 @@ public class UDFUserMapperTest {
UDFUser udfUser = insertOne(user, udfFunc);
int delete = udfUserMapper.deleteByUdfFuncId(udfFunc.getId());
Assert.assertEquals(delete, 1);
userMapper.deleteById(user.getId());
udfFuncMapper.deleteById(udfFunc.getId());
}
}

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

@ -170,7 +170,6 @@ public class UdfFuncMapperTest {
udfFunc.setUpdateTime(new Date());
//update
int update = udfFuncMapper.updateById(udfFunc);
udfFuncMapper.deleteById(udfFunc.getId());
Assert.assertEquals(update, 1);
}
@ -197,7 +196,6 @@ public class UdfFuncMapperTest {
//query
List<UdfFunc> udfFuncList = udfFuncMapper.selectList(null);
Assert.assertNotEquals(udfFuncList.size(), 0);
udfFuncMapper.deleteById(udfFunc.getId());
}
/**
@ -213,8 +211,6 @@ public class UdfFuncMapperTest {
//queryUdfByIdStr
List<UdfFunc> udfFuncList = udfFuncMapper.queryUdfByIdStr(idArray,"");
Assert.assertNotEquals(udfFuncList.size(), 0);
udfFuncMapper.deleteById(udfFunc.getId());
udfFuncMapper.deleteById(udfFunc1.getId());
}
/**
@ -229,8 +225,6 @@ public class UdfFuncMapperTest {
//queryUdfFuncPaging
Page<UdfFunc> page = new Page(1,3);
IPage<UdfFunc> udfFuncIPage = udfFuncMapper.queryUdfFuncPaging(page,user.getId(),"");
userMapper.deleteById(user.getId());
udfFuncMapper.deleteById(udfFunc.getId());
Assert.assertNotEquals(udfFuncIPage.getTotal(), 0);
}
@ -246,8 +240,6 @@ public class UdfFuncMapperTest {
UdfFunc udfFunc = insertOne(user);
//getUdfFuncByType
List<UdfFunc> udfFuncList = udfFuncMapper.getUdfFuncByType(user.getId(), udfFunc.getType().ordinal());
userMapper.deleteById(user.getId());
udfFuncMapper.deleteById(udfFunc.getId());
Assert.assertNotEquals(udfFuncList.size(), 0);
}
@ -264,10 +256,6 @@ public class UdfFuncMapperTest {
UdfFunc udfFunc1 = insertOne(user1);
UdfFunc udfFunc2 = insertOne(user2);
List<UdfFunc> udfFuncList = udfFuncMapper.queryUdfFuncExceptUserId(user1.getId());
userMapper.deleteById(user1.getId());
userMapper.deleteById(user2.getId());
udfFuncMapper.deleteById(udfFunc1.getId());
udfFuncMapper.deleteById(udfFunc2.getId());
Assert.assertNotEquals(udfFuncList.size(), 0);
}
@ -287,9 +275,6 @@ public class UdfFuncMapperTest {
UDFUser udfUser = insertOneUDFUser(user, udfFunc);
//queryAuthedUdfFunc
List<UdfFunc> udfFuncList = udfFuncMapper.queryAuthedUdfFunc(user.getId());
userMapper.deleteById(user.getId());
udfFuncMapper.deleteById(udfFunc.getId());
udfUserMapper.deleteById(udfUser.getId());
Assert.assertNotEquals(udfFuncList.size(), 0);
}

9
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UserAlertGroupMapperTest.java

@ -135,9 +135,6 @@ public class UserAlertGroupMapperTest {
int update = userAlertGroupMapper.updateById(userAlertGroup);
Assert.assertEquals(update, 1);
userAlertGroupMapper.deleteById(userAlertGroup.getId());
userMapper.deleteById(user.getId());
alertGroupMapper.deleteById(alertGroup.getId());
}
/**
@ -162,7 +159,6 @@ public class UserAlertGroupMapperTest {
//query
List<UserAlertGroup> userAlertGroupList = userAlertGroupMapper.selectList(null);
Assert.assertNotEquals(userAlertGroupList.size(), 0);
userAlertGroupMapper.deleteById(userAlertGroup.getId());
}
/**
@ -179,8 +175,6 @@ public class UserAlertGroupMapperTest {
UserAlertGroup userAlertGroup = insertOne(user,alertGroup);
int delete = userAlertGroupMapper.deleteByAlertgroupId(alertGroup.getId());
Assert.assertEquals(delete, 1);
userMapper.deleteById(user.getId());
alertGroupMapper.deleteById(alertGroup.getId());
}
/**
@ -198,8 +192,5 @@ public class UserAlertGroupMapperTest {
List<User> userList = userAlertGroupMapper.listUserByAlertgroupId(alertGroup.getId());
Assert.assertNotEquals(userList.size(), 0);
userAlertGroupMapper.deleteByAlertgroupId(alertGroup.getId());
userMapper.deleteById(user.getId());
alertGroupMapper.deleteById(alertGroup.getId());
}
}

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

@ -206,7 +206,6 @@ public class UserMapperTest {
user.setUserType(UserType.ADMIN_USER);
int update = userMapper.updateById(user);
Assert.assertEquals(update, 1);
userMapper.deleteById(user.getId());
}
/**
@ -219,7 +218,6 @@ public class UserMapperTest {
//delete
int delete = userMapper.deleteById(user.getId());
Assert.assertEquals(delete, 1);
userMapper.deleteById(user.getId());
}
/**
@ -232,7 +230,6 @@ public class UserMapperTest {
//query
List<User> userList = userMapper.selectList(null);
Assert.assertNotEquals(userList.size(), 0);
userMapper.deleteById(user.getId());
}
/**
@ -245,7 +242,6 @@ public class UserMapperTest {
//queryAllGeneralUser
List<User> userList = userMapper.queryAllGeneralUser();
Assert.assertNotEquals(userList.size(), 0);
userMapper.deleteById(user.getId());
}
/**
@ -258,7 +254,6 @@ public class UserMapperTest {
//queryByUserNameAccurately
User queryUser = userMapper.queryByUserNameAccurately(user.getUserName());
Assert.assertEquals(queryUser.getUserName(), user.getUserName());
userMapper.deleteById(user.getId());
}
/**
@ -272,7 +267,6 @@ public class UserMapperTest {
User queryUser = userMapper.queryUserByNamePassword(user.getUserName(),user.getUserPassword());
Assert.assertEquals(queryUser.getUserName(),user.getUserName());
Assert.assertEquals(queryUser.getUserPassword(),user.getUserPassword());
userMapper.deleteById(user.getId());
}
/**
@ -290,9 +284,6 @@ public class UserMapperTest {
Page<User> page = new Page(1,3);
IPage<User> userIPage = userMapper.queryUserPaging(page, user.getUserName());
Assert.assertNotEquals(userIPage.getTotal(), 0);
queueMapper.deleteById(queue.getId());
tenantMapper.deleteById(tenant.getId());
userMapper.deleteById(user.getId());
}
/**
@ -305,7 +296,6 @@ public class UserMapperTest {
//queryDetailsById
User queryUser = userMapper.queryDetailsById(user.getId());
Assert.assertEquals(queryUser,user);
userMapper.deleteById(user.getId());
}
/**
@ -322,9 +312,6 @@ public class UserMapperTest {
//queryUserListByAlertGroupId
List<User> userList = userMapper.queryUserListByAlertGroupId(userAlertGroup.getAlertgroupId());
Assert.assertNotEquals(userList.size(), 0);
userMapper.deleteById(user.getId());
alertGroupMapper.deleteById(alertGroup.getId());
userAlertGroupMapper.deleteById(userAlertGroup.getAlertgroupId());
}
@ -340,8 +327,6 @@ public class UserMapperTest {
//queryTenantCodeByUserId
User queryUser = userMapper.queryTenantCodeByUserId(user.getId());
Assert.assertEquals(queryUser,user);
userMapper.deleteById(user.getId());
tenantMapper.deleteById(tenant.getId());
}
/**
@ -356,8 +341,6 @@ public class UserMapperTest {
//queryUserByToken
User userToken = userMapper.queryUserByToken(accessToken.getToken());
Assert.assertEquals(userToken,user);
userMapper.deleteById(user.getId());
accessTokenMapper.deleteById(accessToken.getId());
}
}

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

@ -1,139 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.dao.mapper;
import org.apache.dolphinscheduler.dao.entity.WorkerGroup;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
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;
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
@Rollback(true)
public class WorkerGroupMapperTest {
@Autowired
WorkerGroupMapper workerGroupMapper;
/**
* insert
* @return WorkerGroup
*/
private WorkerGroup insertOne(){
//insertOne
WorkerGroup workerGroup = new WorkerGroup();
String name = "workerGroup3";
workerGroup.setName(name);
workerGroup.setIpList("192.168.220.154,192.168.220.188");
workerGroup.setCreateTime(new Date());
workerGroup.setUpdateTime(new Date());
workerGroupMapper.insert(workerGroup);
return workerGroup;
}
/**
* test update
*/
@Test
public void testUpdate(){
//insertOne
WorkerGroup workerGroup = insertOne();
//update
workerGroup.setName("workerGroup11");
int update = workerGroupMapper.updateById(workerGroup);
workerGroupMapper.deleteById(workerGroup.getId());
Assert.assertEquals(1, update);
}
/**
* test delete
*/
@Test
public void testDelete(){
//insertOne
WorkerGroup workerGroup = insertOne();
//delete
int delete = workerGroupMapper.deleteById(workerGroup.getId());
Assert.assertEquals(1, delete);
}
/**
* test query
*/
@Test
public void testQuery() {
//insertOne
WorkerGroup workerGroup = insertOne();
//query
List<WorkerGroup> workerGroupList = workerGroupMapper.selectList(null);
Assert.assertNotEquals(workerGroupList.size(), 0);
workerGroupMapper.deleteById(workerGroup.getId());
}
/**
* test query all worker group
*/
@Test
public void testQueryAllWorkerGroup() {
//insertOne
WorkerGroup workerGroup = insertOne();
//queryAllWorkerGroup
List<WorkerGroup> workerGroupList = workerGroupMapper.queryAllWorkerGroup();
Assert.assertNotEquals(workerGroupList.size(), 0);
workerGroupMapper.deleteById(workerGroup.getId());
}
/**
* test query work group by name
*/
@Test
public void testQueryWorkerGroupByName() {
//insertOne
WorkerGroup workerGroup = insertOne();
//queryWorkerGroupByName
List<WorkerGroup> workerGroupList = workerGroupMapper.queryWorkerGroupByName(workerGroup.getName());
Assert.assertNotEquals(workerGroupList.size(), 0);
workerGroupMapper.deleteById(workerGroup.getId());
}
/**
* test page
*/
@Test
public void testQueryListPaging() {
//insertOne
WorkerGroup workerGroup = insertOne();
//queryListPaging
Page<WorkerGroup> page = new Page(1,3);
IPage<WorkerGroup> workerGroupIPage = workerGroupMapper.queryListPaging(page, workerGroup.getName());
Assert.assertNotEquals(workerGroupIPage.getTotal(), 0);
workerGroupMapper.deleteById(workerGroup.getId());
}
}

21
pom.xml

@ -800,6 +800,27 @@
<include>**/service/zk/DefaultEnsembleProviderTest.java</include>
<include>**/service/zk/ZKServerTest.java</include>
<include>**/service/queue/TaskUpdateQueueTest.java</include>
<include>**/dao/mapper/DataSourceUserMapperTest.java</include>
<include>**/dao/mapper/ErrorCommandMapperTest.java</include>
<include>**/dao/mapper/ProcessDefinitionMapperTest.java</include>
<include>**/dao/mapper/ProcessInstanceMapMapperTest.java</include>
<include>**/dao/mapper/ProcessInstanceMapperTest.java</include>
<include>**/dao/mapper/ProjectMapperTest.java</include>
<include>**/dao/mapper/ProjectUserMapperTest.java</include>
<include>**/dao/mapper/QueueMapperTest.java</include>
<include>**/dao/mapper/ResourceMapperTest.java</include>
<include>**/dao/mapper/ResourceUserMapperTest.java</include>
<include>**/dao/mapper/ScheduleMapperTest.java</include>
<include>**/dao/mapper/SessionMapperTest.java</include>
<include>**/dao/mapper/TaskInstanceMapperTest.java</include>
<include>**/dao/mapper/TenantMapperTest.java</include>
<include>**/dao/mapper/UdfFuncMapperTest.java</include>
<include>**/dao/mapper/UDFUserMapperTest.java</include>
<include>**/dao/mapper/UserAlertGroupMapperTest.java</include>
<include>**/dao/mapper/UserMapperTest.java</include>
<include>**/dao/utils/DagHelperTest.java</include>
<include>**/dao/AlertDaoTest.java</include>
</includes>
<!-- <skip>true</skip> -->
</configuration>

Loading…
Cancel
Save