diff options
author | ayalaben <ayala.benzvi@amdocs.com> | 2018-08-16 11:08:21 +0300 |
---|---|---|
committer | ayalaben <ayala.benzvi@amdocs.com> | 2018-08-16 11:08:21 +0300 |
commit | 1c519a911f04a03d066b123d011e37902b0941fc (patch) | |
tree | f44307689ef86bb59179ceb4287090c88f3a774f /workflow-designer-be/src/test | |
parent | e131bf1bb08a3ebe81522ae90a3ce60e72cc865b (diff) |
Workflow name validation
Change-Id: I6ff7175b84f32deb5e66ce9a3597bb2e32c12e70
Issue-ID: SDC-1654
Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
Diffstat (limited to 'workflow-designer-be/src/test')
-rw-r--r-- | workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java | 30 |
1 files changed, 30 insertions, 0 deletions
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 a748dd5f..da452125 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 @@ -201,6 +201,36 @@ public class WorkflowControllerTest { jsonPath("$.message", is("Workflow name must contain only letters, digits and underscores"))); } + @Test + public void shouldThrowExceptionWhenWorkflowNameBlank() throws Exception { + Workflow reqWorkflow = new Workflow(); + reqWorkflow.setName(" "); + mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON) + .content(JsonUtil.object2Json(reqWorkflow))).andDo(print()) + .andExpect(status().isBadRequest()).andExpect( + jsonPath("$.message", is("Workflow name may not be blank"))); + } + + @Test + public void shouldThrowExceptionWhenWorkflowNameNull() throws Exception { + Workflow reqWorkflow = new Workflow(); + reqWorkflow.setName(null); + mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON) + .content(JsonUtil.object2Json(reqWorkflow))).andDo(print()) + .andExpect(status().isBadRequest()).andExpect( + jsonPath("$.message", is("Workflow name may not be blank"))); + } + + @Test + public void shouldThrowExceptionWhenWorkflowNameEmptyString() throws Exception { + Workflow reqWorkflow = new Workflow(); + reqWorkflow.setName(""); + mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON) + .content(JsonUtil.object2Json(reqWorkflow))).andDo(print()) + .andExpect(status().isBadRequest()).andExpect( + jsonPath("$.message", is("Workflow name may not be blank"))); + } + private void mockManagerList3() { doReturn(new Page<>(Arrays.asList(createWorkflow(1, true), createWorkflow(2, true), createWorkflow(3, true)), new PagingRequest(DEFAULT_OFFSET, DEFAULT_LIMIT), 3)).when(workflowManagerMock).list(any(), any()); |