未验证 提交 5ede1711 编写于 作者: B BaoLiang 提交者: GitHub

[Fix-7654]Dependent node onChangeProjectCode error (#7672) (#7691)

* fix #7654 Dependent node onChangeProjectCode error

* fix #7654 Dependent node onChangeProjectCode error

* fix #7654 Dependent node onChangeProjectCode error

* update ut
上级 4f4cbba8
......@@ -76,6 +76,8 @@ import org.apache.dolphinscheduler.service.process.ProcessService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.mapred.TaskLog.LogName;
import org.apache.yetus.audience.InterfaceAudience.Public;
import java.io.BufferedOutputStream;
import java.io.IOException;
......@@ -1097,9 +1099,13 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, codes);
return result;
}
HashMap<Long, Project> userProjects = new HashMap(Constants.DEFAULT_HASH_MAP_SIZE);
projectMapper.queryProjectCreatedAndAuthorizedByUserId(loginUser.getId())
.forEach(userProject -> userProjects.put(userProject.getCode(), userProject));
// check processDefinition exist in project
List<ProcessDefinition> processDefinitionListInProject = processDefinitionList.stream().
filter(o -> projectCode == o.getProjectCode()).collect(Collectors.toList());
filter(o -> userProjects.containsKey(o.getProjectCode())).collect(Collectors.toList());
if (CollectionUtils.isEmpty(processDefinitionListInProject)) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, codes);
return result;
......
......@@ -543,8 +543,13 @@ public class ProcessDefinitionServiceTest {
ProcessDefinition processDefinition = getProcessDefinition();
List<ProcessDefinition> processDefinitionList = new ArrayList<>();
processDefinitionList.add(processDefinition);
Mockito.when(processDefineMapper.queryByCodes(defineCodeSet)).thenReturn(processDefinitionList);
Mockito.when(processService.genDagData(Mockito.any())).thenReturn(new DagData(processDefinition, null, null));
Project project1 = getProject(projectCode);
List<Project> projects = new ArrayList<>();
projects.add(project1);
Mockito.when(projectMapper.queryProjectCreatedAndAuthorizedByUserId(loginUser.getId())).thenReturn(projects);
Map<String, Object> successRes = processDefinitionService.getNodeListMapByDefinitionCodes(loginUser, projectCode, defineCodes);
Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS));
......
......@@ -341,6 +341,11 @@ public final class Constants {
*/
public static final int DEFAULT_ADMIN_PERMISSION = 7;
/**
* default hash map size
*/
public static final int DEFAULT_HASH_MAP_SIZE = 16;
/**
* all permissions
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册