diff options
3 files changed, 15 insertions, 3 deletions
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowVersionController.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowVersionController.java index 91995bd0..34ecb898 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowVersionController.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowVersionController.java @@ -59,7 +59,7 @@ public class WorkflowVersionController { private final WorkflowVersionManager workflowVersionManager; private Validator validator; - @InitBinder + @InitBinder("WorkflowVersion") private void initBinder(WebDataBinder binder) { binder.addValidators(validator); } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/Workflow.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/Workflow.java index 72e62778..b2fc6f59 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/Workflow.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/Workflow.java @@ -30,8 +30,8 @@ public class Workflow { private String id; @NotNull(message = "Workflow name may not be null") - @Size(min = 6, max = 30, message = "The field must be at least 6 characters, and less than 30 characters") - @Pattern(regexp = "[A-Za-z0-9_]*", message = "The field must contain only letters, digits and underscores") + @Size(max = 80, message = "Workflow name must be less than 80 characters") + @Pattern(regexp = "[A-Za-z0-9_]*", message = "Workflow name must contain only letters, digits and underscores") private String name; private String description; private Set<WorkflowVersionState> versionStates; diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java index 5e7df483..337fea79 100644 --- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java +++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java @@ -257,6 +257,18 @@ public class WorkflowControllerTest { verify(workflowManagerMock).create(reqWorkflow); } + @Test + public void shouldThrowExceptionWhenWorkflowNameInvalid() throws Exception { + + Workflow reqWorkflow = new Workflow(); + reqWorkflow.setName("Invalid workflow name %"); + MockHttpServletResponse response = mockMvc.perform( + post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER_PARAM, USER_ID).contentType(APPLICATION_JSON) + .content(GSON.toJson(reqWorkflow))).andDo(print()) + .andExpect(status().isBadRequest()).andReturn().getResponse(); + assertEquals("Workflow name must contain only letters, digits and underscores", response.getContentAsString()); + } + private List<Workflow> createWorkflows(int numOfWorkflows) { List<Workflow> workflowList = new ArrayList<>(numOfWorkflows); for (int i = 0; i < numOfWorkflows; i++) { |