This repository has been archived by the owner on Dec 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISICO-15108: javascript validation done on updating w/d (#3805)
* ISICO-15108: javascript validation done on updating w/d * ISICO-14902: NPE while checking EvaluatorType is fixed * ISICO-14902: unused variables removed * ISICO-15108: javascript validation added in the constraint violation part * ISICO-15108: getExpression() is used for switch javascript code
- Loading branch information
Showing
2 changed files
with
105 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,7 @@ | |
*/ | ||
package com.netflix.conductor.service; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.Date; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.*; | ||
|
||
import javax.validation.ConstraintViolationException; | ||
|
||
|
@@ -35,6 +29,7 @@ | |
import com.netflix.conductor.common.metadata.workflow.WorkflowDef; | ||
import com.netflix.conductor.common.metadata.workflow.WorkflowDefSummary; | ||
import com.netflix.conductor.common.metadata.workflow.WorkflowTask; | ||
import com.netflix.conductor.common.model.BulkResponse; | ||
import com.netflix.conductor.core.config.ConductorProperties; | ||
import com.netflix.conductor.core.exception.NotFoundException; | ||
import com.netflix.conductor.dao.EventHandlerDAO; | ||
|
@@ -282,6 +277,66 @@ public void testUpdateWorkflowDef() { | |
verify(metadataDAO, times(1)).updateWorkflowDef(workflowDef); | ||
} | ||
|
||
@Test(expected = ConstraintViolationException.class) | ||
public void testUpdateWorkflowDefWithCaseExpression() { | ||
WorkflowDef workflowDef = new WorkflowDef(); | ||
workflowDef.setName("somename"); | ||
workflowDef.setOwnerEmail("[email protected]"); | ||
List<WorkflowTask> tasks = new ArrayList<>(); | ||
WorkflowTask workflowTask = new WorkflowTask(); | ||
workflowTask.setTaskReferenceName("hello"); | ||
workflowTask.setName("hello"); | ||
workflowTask.setType("DECISION"); | ||
|
||
WorkflowTask caseTask = new WorkflowTask(); | ||
caseTask.setTaskReferenceName("casetrue"); | ||
caseTask.setName("casetrue"); | ||
|
||
List<WorkflowTask> caseTaskList = new ArrayList<>(); | ||
caseTaskList.add(caseTask); | ||
|
||
Map<String, List<WorkflowTask>> decisionCases = new HashMap(); | ||
decisionCases.put("true", caseTaskList); | ||
|
||
workflowTask.setDecisionCases(decisionCases); | ||
workflowTask.setCaseExpression("1 >0abcd"); | ||
tasks.add(workflowTask); | ||
workflowDef.setTasks(tasks); | ||
when(metadataDAO.getTaskDef(any())).thenReturn(new TaskDef()); | ||
BulkResponse bulkResponse = | ||
metadataService.updateWorkflowDef(Collections.singletonList(workflowDef)); | ||
} | ||
|
||
@Test(expected = ConstraintViolationException.class) | ||
public void testUpdateWorkflowDefWithJavscriptEvaluator() { | ||
WorkflowDef workflowDef = new WorkflowDef(); | ||
workflowDef.setName("somename"); | ||
workflowDef.setOwnerEmail("[email protected]"); | ||
List<WorkflowTask> tasks = new ArrayList<>(); | ||
WorkflowTask workflowTask = new WorkflowTask(); | ||
workflowTask.setTaskReferenceName("hello"); | ||
workflowTask.setName("hello"); | ||
workflowTask.setType("SWITCH"); | ||
workflowTask.setEvaluatorType("javascript"); | ||
workflowTask.setExpression("1>abcd"); | ||
WorkflowTask caseTask = new WorkflowTask(); | ||
caseTask.setTaskReferenceName("casetrue"); | ||
caseTask.setName("casetrue"); | ||
|
||
List<WorkflowTask> caseTaskList = new ArrayList<>(); | ||
caseTaskList.add(caseTask); | ||
|
||
Map<String, List<WorkflowTask>> decisionCases = new HashMap(); | ||
decisionCases.put("true", caseTaskList); | ||
|
||
workflowTask.setDecisionCases(decisionCases); | ||
tasks.add(workflowTask); | ||
workflowDef.setTasks(tasks); | ||
when(metadataDAO.getTaskDef(any())).thenReturn(new TaskDef()); | ||
BulkResponse bulkResponse = | ||
metadataService.updateWorkflowDef(Collections.singletonList(workflowDef)); | ||
} | ||
|
||
@Test(expected = ConstraintViolationException.class) | ||
public void testRegisterWorkflowDefNoName() { | ||
try { | ||
|