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.
API to validate a workflow definition
- Loading branch information
1 parent
ed638cd
commit e841f73
Showing
9 changed files
with
114 additions
and
10 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
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
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 |
---|---|---|
|
@@ -298,6 +298,22 @@ public void testRegisterWorkflowDefNoName() { | |
fail("metadataService.registerWorkflowDef did not throw ConstraintViolationException !"); | ||
} | ||
|
||
@Test(expected = ConstraintViolationException.class) | ||
public void testValidateWorkflowDefNoName() { | ||
try { | ||
WorkflowDef workflowDef = new WorkflowDef(); | ||
metadataService.validateWorkflowDef(workflowDef); | ||
} catch (ConstraintViolationException ex) { | ||
assertEquals(3, ex.getConstraintViolations().size()); | ||
Set<String> messages = getConstraintViolationMessages(ex.getConstraintViolations()); | ||
assertTrue(messages.contains("WorkflowDef name cannot be null or empty")); | ||
assertTrue(messages.contains("WorkflowTask list cannot be empty")); | ||
assertTrue(messages.contains("ownerEmail cannot be empty")); | ||
throw ex; | ||
} | ||
fail("metadataService.validateWorkflowDef did not throw ConstraintViolationException !"); | ||
} | ||
|
||
@Test(expected = ConstraintViolationException.class) | ||
public void testRegisterWorkflowDefInvalidName() { | ||
try { | ||
|
@@ -318,6 +334,26 @@ public void testRegisterWorkflowDefInvalidName() { | |
fail("metadataService.registerWorkflowDef did not throw ConstraintViolationException !"); | ||
} | ||
|
||
@Test(expected = ConstraintViolationException.class) | ||
public void testValidateWorkflowDefInvalidName() { | ||
try { | ||
WorkflowDef workflowDef = new WorkflowDef(); | ||
workflowDef.setName("invalid:name"); | ||
workflowDef.setOwnerEmail("inavlid-email"); | ||
metadataService.validateWorkflowDef(workflowDef); | ||
} catch (ConstraintViolationException ex) { | ||
assertEquals(3, ex.getConstraintViolations().size()); | ||
Set<String> messages = getConstraintViolationMessages(ex.getConstraintViolations()); | ||
assertTrue(messages.contains("WorkflowTask list cannot be empty")); | ||
assertTrue( | ||
messages.contains( | ||
"Workflow name cannot contain the following set of characters: ':'")); | ||
assertTrue(messages.contains("ownerEmail should be valid email address")); | ||
throw ex; | ||
} | ||
fail("metadataService.validateWorkflowDef did not throw ConstraintViolationException !"); | ||
} | ||
|
||
@Test | ||
public void testRegisterWorkflowDef() { | ||
WorkflowDef workflowDef = new WorkflowDef(); | ||
|
@@ -336,6 +372,24 @@ public void testRegisterWorkflowDef() { | |
assertEquals(2, workflowDef.getSchemaVersion()); | ||
} | ||
|
||
@Test | ||
public void testValidateWorkflowDef() { | ||
WorkflowDef workflowDef = new WorkflowDef(); | ||
workflowDef.setName("somename"); | ||
workflowDef.setSchemaVersion(2); | ||
workflowDef.setOwnerEmail("[email protected]"); | ||
List<WorkflowTask> tasks = new ArrayList<>(); | ||
WorkflowTask workflowTask = new WorkflowTask(); | ||
workflowTask.setTaskReferenceName("hello"); | ||
workflowTask.setName("hello"); | ||
tasks.add(workflowTask); | ||
workflowDef.setTasks(tasks); | ||
when(metadataDAO.getTaskDef(any())).thenReturn(new TaskDef()); | ||
metadataService.validateWorkflowDef(workflowDef); | ||
verify(metadataDAO, times(1)).createWorkflowDef(workflowDef); | ||
assertEquals(2, workflowDef.getSchemaVersion()); | ||
} | ||
|
||
@Test(expected = ConstraintViolationException.class) | ||
public void testUnregisterWorkflowDefNoName() { | ||
try { | ||
|
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
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