Browse Source
* Modify Project and ProjectUser Mapper * Modify Project and ProjectUser Mapper * project_code is bigint(20) * modify ERROR name * modify saveProcessDefine, remove the duplicate code with createTaskAndRelation * modify import/export processdefinition, add genProcessData * fix ut and bug * code style * repalce project_id with code * conflicts solve * conflicts solve * conflicts solve * bugfix * modify listResources mothod and remove getResourceIds mothod * 1 * conflicts solve * modify listResources mothod and remove getResourceIds mothod * modify listResources mothod and remove getResourceIds mothod * replace processDefinitionVersion with processDefinitionLog * codestyle * codestyle * add mapper module ut * codestylepull/3/MERGE
Simon
4 years ago
committed by
GitHub
9 changed files with 361 additions and 23 deletions
@ -0,0 +1,174 @@
|
||||
/* |
||||
* 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.common.enums.UserType; |
||||
import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog; |
||||
import org.apache.dolphinscheduler.dao.entity.Project; |
||||
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.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 com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
||||
@RunWith(SpringRunner.class) |
||||
@SpringBootTest |
||||
@Transactional |
||||
@Rollback(true) |
||||
public class ProcessDefinitionLogMapperTest { |
||||
@Autowired |
||||
ProcessDefinitionMapper processDefinitionMapper; |
||||
|
||||
@Autowired |
||||
UserMapper userMapper; |
||||
|
||||
@Autowired |
||||
QueueMapper queueMapper; |
||||
|
||||
@Autowired |
||||
TenantMapper tenantMapper; |
||||
|
||||
@Autowired |
||||
ProjectMapper projectMapper; |
||||
|
||||
@Autowired |
||||
ProcessDefinitionLogMapper processDefinitionLogMapper; |
||||
|
||||
/** |
||||
* insert |
||||
* |
||||
* @return ProcessDefinition |
||||
*/ |
||||
private ProcessDefinitionLog insertOne() { |
||||
//insertOne
|
||||
ProcessDefinitionLog processDefinitionLog = new ProcessDefinitionLog(); |
||||
processDefinitionLog.setCode(1L); |
||||
processDefinitionLog.setName("def 1"); |
||||
processDefinitionLog.setProjectCode(1L); |
||||
processDefinitionLog.setUserId(101); |
||||
processDefinitionLog.setVersion(1); |
||||
processDefinitionLog.setUpdateTime(new Date()); |
||||
processDefinitionLog.setCreateTime(new Date()); |
||||
processDefinitionLogMapper.insert(processDefinitionLog); |
||||
return processDefinitionLog; |
||||
} |
||||
|
||||
/** |
||||
* insert |
||||
* |
||||
* @return ProcessDefinition |
||||
*/ |
||||
private ProcessDefinitionLog insertTwo() { |
||||
//insertOne
|
||||
ProcessDefinitionLog processDefinitionLog = new ProcessDefinitionLog(); |
||||
processDefinitionLog.setCode(1L); |
||||
processDefinitionLog.setName("def 2"); |
||||
processDefinitionLog.setProjectCode(1L); |
||||
processDefinitionLog.setUserId(101); |
||||
processDefinitionLog.setVersion(2); |
||||
|
||||
processDefinitionLog.setUpdateTime(new Date()); |
||||
processDefinitionLog.setCreateTime(new Date()); |
||||
processDefinitionLogMapper.insert(processDefinitionLog); |
||||
return processDefinitionLog; |
||||
} |
||||
|
||||
@Test |
||||
public void testInsert() { |
||||
ProcessDefinitionLog processDefinitionLog = insertOne(); |
||||
Assert.assertNotEquals(processDefinitionLog.getId(), 0); |
||||
} |
||||
|
||||
@Test |
||||
public void testQueryByDefinitionName() { |
||||
ProcessDefinitionLog processDefinitionLog = insertOne(); |
||||
Project project = new Project(); |
||||
project.setCode(1L); |
||||
project.setName("ut project"); |
||||
project.setUserId(101); |
||||
project.setCreateTime(new Date()); |
||||
projectMapper.insert(project); |
||||
|
||||
User user = new User(); |
||||
user.setUserName("hello"); |
||||
user.setUserPassword("pwd"); |
||||
user.setUserType(UserType.GENERAL_USER); |
||||
user.setId(101); |
||||
userMapper.insert(user); |
||||
|
||||
List<ProcessDefinitionLog> processDefinitionLogs = processDefinitionLogMapper |
||||
.queryByDefinitionName(1L, "def 1"); |
||||
Assert.assertEquals(0, processDefinitionLogs.size()); |
||||
|
||||
} |
||||
|
||||
@Test |
||||
public void testQueryByDefinitionCode() { |
||||
ProcessDefinitionLog processDefinitionLog = insertOne(); |
||||
|
||||
List<ProcessDefinitionLog> processDefinitionLogs = processDefinitionLogMapper |
||||
.queryByDefinitionCode(1L); |
||||
Assert.assertNotEquals(0, processDefinitionLogs.size()); |
||||
} |
||||
|
||||
@Test |
||||
public void testQueryByDefinitionCodeAndVersion() { |
||||
ProcessDefinitionLog processDefinitionLog = insertOne(); |
||||
|
||||
ProcessDefinitionLog processDefinitionLogs = processDefinitionLogMapper |
||||
.queryByDefinitionCodeAndVersion(1L, 1); |
||||
Assert.assertNotEquals(null, processDefinitionLogs); |
||||
} |
||||
|
||||
@Test |
||||
public void testQueryMaxVersionForDefinition() { |
||||
ProcessDefinitionLog processDefinitionLog = insertOne(); |
||||
ProcessDefinitionLog processDefinitionLog1 = insertTwo(); |
||||
|
||||
int version = processDefinitionLogMapper.queryMaxVersionForDefinition(1L); |
||||
Assert.assertEquals(2, version); |
||||
} |
||||
|
||||
@Test |
||||
public void testQueryProcessDefinitionVersionsPaging() { |
||||
ProcessDefinitionLog processDefinitionLog = insertOne(); |
||||
Page<ProcessDefinitionLog> page = new Page(1, 3); |
||||
IPage<ProcessDefinitionLog> processDefinitionLogs = processDefinitionLogMapper.queryProcessDefinitionVersionsPaging(page, 1L); |
||||
Assert.assertNotEquals(processDefinitionLogs.getTotal(), 0); |
||||
} |
||||
|
||||
@Test |
||||
public void testDeleteByProcessDefinitionCodeAndVersion() { |
||||
ProcessDefinitionLog processDefinitionLog = insertOne(); |
||||
Page<ProcessDefinitionLog> page = new Page(1, 3); |
||||
int processDefinitionLogs = processDefinitionLogMapper.deleteByProcessDefinitionCodeAndVersion(1L, 1); |
||||
Assert.assertNotEquals(processDefinitionLogs, 0); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,71 @@
|
||||
/* |
||||
* 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.ProcessTaskRelationLog; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
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; |
||||
|
||||
@RunWith(SpringRunner.class) |
||||
@SpringBootTest |
||||
@Transactional |
||||
@Rollback(true) |
||||
public class ProcessTaskRelationLogMapperTest { |
||||
|
||||
@Autowired |
||||
ProcessTaskRelationLogMapper processTaskRelationLogMapper; |
||||
|
||||
/** |
||||
* insert |
||||
* |
||||
* @return ProcessDefinition |
||||
*/ |
||||
private ProcessTaskRelationLog insertOne() { |
||||
//insertOne
|
||||
ProcessTaskRelationLog processTaskRelationLog = new ProcessTaskRelationLog(); |
||||
processTaskRelationLog.setName("def 1"); |
||||
processTaskRelationLog.setProcessDefinitionVersion(1); |
||||
processTaskRelationLog.setProjectCode(1L); |
||||
processTaskRelationLog.setProcessDefinitionCode(1L); |
||||
processTaskRelationLog.setPostTaskCode(3L); |
||||
processTaskRelationLog.setPreTaskCode(2L); |
||||
processTaskRelationLog.setUpdateTime(new Date()); |
||||
processTaskRelationLog.setCreateTime(new Date()); |
||||
processTaskRelationLogMapper.insert(processTaskRelationLog); |
||||
return processTaskRelationLog; |
||||
} |
||||
|
||||
@Test |
||||
public void testQueryByProcessCodeAndVersion() { |
||||
ProcessTaskRelationLog processTaskRelationLog = insertOne(); |
||||
List<ProcessTaskRelationLog> processTaskRelationLogs = processTaskRelationLogMapper |
||||
.queryByProcessCodeAndVersion(1L, 1); |
||||
Assert.assertNotEquals(processTaskRelationLogs.size(), 0); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,94 @@
|
||||
/* |
||||
* 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.ProcessTaskRelation; |
||||
|
||||
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.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; |
||||
|
||||
@RunWith(SpringRunner.class) |
||||
@SpringBootTest |
||||
@Transactional |
||||
@Rollback(true) |
||||
public class ProcessTaskRelationMapperTest { |
||||
|
||||
@Autowired |
||||
ProcessTaskRelationMapper processTaskRelationMapper; |
||||
|
||||
/** |
||||
* insert |
||||
* |
||||
* @return ProcessDefinition |
||||
*/ |
||||
private ProcessTaskRelation insertOne() { |
||||
//insertOne
|
||||
ProcessTaskRelation processTaskRelation = new ProcessTaskRelation(); |
||||
processTaskRelation.setName("def 1"); |
||||
|
||||
processTaskRelation.setProjectCode(1L); |
||||
processTaskRelation.setProcessDefinitionCode(1L); |
||||
processTaskRelation.setPostTaskCode(3L); |
||||
processTaskRelation.setPreTaskCode(2L); |
||||
processTaskRelation.setUpdateTime(new Date()); |
||||
processTaskRelation.setCreateTime(new Date()); |
||||
processTaskRelationMapper.insert(processTaskRelation); |
||||
return processTaskRelation; |
||||
} |
||||
|
||||
@Test |
||||
public void testQueryByProcessCode() { |
||||
ProcessTaskRelation processTaskRelation = insertOne(); |
||||
List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByProcessCode(1L, 1L); |
||||
Assert.assertNotEquals(processTaskRelations.size(), 0); |
||||
} |
||||
|
||||
@Test |
||||
public void testQueryByTaskCode() { |
||||
ProcessTaskRelation processTaskRelation = insertOne(); |
||||
List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByTaskCode(2L); |
||||
Assert.assertNotEquals(processTaskRelations.size(), 0); |
||||
} |
||||
|
||||
@Test |
||||
public void testQueryByTaskCodes() { |
||||
ProcessTaskRelation processTaskRelation = insertOne(); |
||||
|
||||
Long[] codes = Arrays.array(1L, 2L); |
||||
List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByTaskCodes(codes); |
||||
Assert.assertNotEquals(processTaskRelations.size(), 0); |
||||
} |
||||
|
||||
@Test |
||||
public void testDeleteByCode() { |
||||
ProcessTaskRelation processTaskRelation = insertOne(); |
||||
int i = processTaskRelationMapper.deleteByCode(1L, 1L); |
||||
Assert.assertNotEquals(i, 0); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue