Get and update workflow version state
[sdc/sdc-workflow-designer.git] / workflow-designer-be / src / test / java / org / onap / sdc / workflow / api / WorkflowControllerTest.java
index d23d3f9..69b25b0 100644 (file)
@@ -8,6 +8,7 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.onap.sdc.workflow.TestUtil.createWorkflow;
+import static org.onap.sdc.workflow.api.RestConstants.USER_ID_HEADER_PARAM;
 import static org.springframework.http.MediaType.APPLICATION_JSON;
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
@@ -25,7 +26,6 @@ import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.sdc.workflow.RestPath;
-import org.onap.sdc.workflow.api.impl.WorkflowControllerImpl;
 import org.onap.sdc.workflow.persistence.types.Workflow;
 import org.onap.sdc.workflow.services.WorkflowManager;
 import org.openecomp.sdc.versioning.types.Item;
@@ -42,13 +42,12 @@ public class WorkflowControllerTest {
             "Missing request header '%s' for method parameter of type String";
     private static final String USER_ID = "userId";
     private static final Gson GSON = new Gson();
-    public static final String USER_ID_HEADER = "USER_ID";
 
     private MockMvc mockMvc;
 
 
     @InjectMocks
-    private WorkflowControllerImpl workflowController;
+    private WorkflowController workflowController;
 
     @Mock
     private WorkflowManager workflowManagerMock;
@@ -73,7 +72,7 @@ public class WorkflowControllerTest {
         Workflow workflowMock = createWorkflow(1, true);
         doReturn(workflowMock).when(workflowManagerMock).get(any(Workflow.class));
         mockMvc.perform(
-                get(RestPath.getWorkflowPath(workflowMock.getId())).header(RestConstants.USER_ID_HEADER_PARAM, USER_ID)
+                get(RestPath.getWorkflowPath(workflowMock.getId())).header(USER_ID_HEADER_PARAM, USER_ID)
                                                                    .contentType(APPLICATION_JSON)).andDo(print())
                .andExpect(status().isOk()).andExpect(jsonPath("$.id", is(workflowMock.getId())))
                .andExpect(jsonPath("$.name", is(workflowMock.getName())));
@@ -84,7 +83,7 @@ public class WorkflowControllerTest {
         MockHttpServletResponse response =
                 mockMvc.perform(get(RestPath.getWorkflowsPath()).contentType(APPLICATION_JSON)).andDo(print())
                        .andExpect(status().isBadRequest()).andExpect(status().is(400)).andReturn().getResponse();
-        assertEquals(String.format(MISSING_REQUEST_HEADER_ERRROR_FORMAT, USER_ID_HEADER), response.getErrorMessage());
+        assertEquals(String.format(MISSING_REQUEST_HEADER_ERRROR_FORMAT, USER_ID_HEADER_PARAM), response.getErrorMessage());
     }
 
     @Test
@@ -93,7 +92,7 @@ public class WorkflowControllerTest {
         List<Workflow> workflowMocks = createWorkflows(numOfWorkflows);
         doReturn(workflowMocks).when(workflowManagerMock).list();
         mockMvc.perform(
-                get(RestPath.getWorkflowsPath()).header(RestConstants.USER_ID_HEADER_PARAM, USER_ID).contentType(APPLICATION_JSON))
+                get(RestPath.getWorkflowsPath()).header(USER_ID_HEADER_PARAM, USER_ID).contentType(APPLICATION_JSON))
                .andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$.results", hasSize(numOfWorkflows)));
     }
 
@@ -103,7 +102,7 @@ public class WorkflowControllerTest {
         item.setId("abc");
         Workflow reqWorkflow = createWorkflow(1, false);
         mockMvc.perform(
-                post(RestPath.getWorkflowsPath()).header(RestConstants.USER_ID_HEADER_PARAM, USER_ID).contentType(APPLICATION_JSON)
+                post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER_PARAM, USER_ID).contentType(APPLICATION_JSON)
                                                  .content(GSON.toJson(reqWorkflow))).andDo(print()).andExpect(status().isCreated())
                .andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
         verify(workflowManagerMock, times(1)).create(reqWorkflow);