public void shouldReturnErrorWhenMissingUserIdInGetReqHeader() throws Exception {
Workflow workflowMock = createWorkflow(1, true);
mockMvc.perform(get(RestPath.getWorkflowPath(workflowMock.getId())).contentType(APPLICATION_JSON))
- .andDo(print()).andExpect(status().isBadRequest())
+ .andExpect(status().isBadRequest())
.andExpect(jsonPath("$.message", is(MISSING_USER_HEADER_ERROR)));
}
doReturn(workflowMock).when(workflowManagerMock).get(any(Workflow.class));
mockMvc.perform(get(RestPath.getWorkflowPath(workflowMock.getId())).header(USER_ID_HEADER, USER_ID)
.contentType(APPLICATION_JSON))
- .andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$.id", is(workflowMock.getId())))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.id", is(workflowMock.getId())))
.andExpect(jsonPath("$.name", is(workflowMock.getName())));
}
@Test
public void shouldReturnErrorWhenMissingUserIdInListReqHeader() throws Exception {
- mockMvc.perform(get(RestPath.getWorkflowsPath()).contentType(APPLICATION_JSON)).andDo(print())
+ mockMvc.perform(get(RestPath.getWorkflowsPath()).contentType(APPLICATION_JSON))
.andExpect(status().isBadRequest()).andExpect(jsonPath("$.message", is(MISSING_USER_HEADER_ERROR)));
}
mockManagerList3();
ResultActions result = mockMvc.perform(
get(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON))
- .andDo(print()).andExpect(status().isOk())
+ .andExpect(status().isOk())
.andExpect(jsonPath("$.items", hasSize(3)));
for (int i = 0; i < 3; i++) {
result.andExpect(jsonPath(String.format("$.items[%s].id", i), is(String.valueOf(i + 1))));
public void listWhenPagingAndSortingAreSet() throws Exception {
mockManagerList3();
mockMvc.perform(get(RestPath.getWorkflowsPathAllQueryParams(DEFAULT_SORT_VALUE, "2", "1"))
- .header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON)).andDo(print())
+ .header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$.items", hasSize(3)));
verify(workflowManagerMock).list(any(), any(), requestSpecArg.capture());
assertRequestSpec(requestSpecArg.getValue(), 1, 2, Collections.singletonList(new Sort("name", true)));
public void shouldReturnResultsWithDefaultWhenLimitIsNegative() throws Exception {
mockManagerList3();
mockMvc.perform(get(RestPath.getWorkflowsPathAllQueryParams(DEFAULT_SORT_VALUE, "-2", "1"))
- .header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON)).andDo(print())
+ .header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$.items", hasSize(3)));
verify(workflowManagerMock).list(any(), any(), requestSpecArg.capture());
assertRequestSpec(requestSpecArg.getValue(), 1, DEFAULT_LIMIT,
public void shouldFallbackOnDefaultOffsetWhenOffsetIsNegative() throws Exception {
mockManagerList3();
mockMvc.perform(get(RestPath.getWorkflowsPathAllQueryParams(DEFAULT_SORT_VALUE, "2", "-1"))
- .header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON)).andDo(print())
+ .header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$.items", hasSize(3)));
verify(workflowManagerMock).list(any(), any(), requestSpecArg.capture());
assertRequestSpec(requestSpecArg.getValue(), DEFAULT_OFFSET, 2,
public void shouldFallbackOnDefaultLimitWhenLimitIsNotAnInteger() throws Exception {
mockManagerList3();
mockMvc.perform(get(RestPath.getWorkflowsPathAllQueryParams(DEFAULT_SORT_VALUE, "abc", "0"))
- .header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON)).andDo(print())
+ .header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$.items", hasSize(3)));
verify(workflowManagerMock).list(any(), any(), requestSpecArg.capture());
assertRequestSpec(requestSpecArg.getValue(), 0, DEFAULT_LIMIT,
public void shouldFallbackOnDefaultOffsetWhenOffsetIsNotAnInteger() throws Exception {
mockManagerList3();
mockMvc.perform(get(RestPath.getWorkflowsPathAllQueryParams(DEFAULT_SORT_VALUE, "2", "abc"))
- .header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON)).andDo(print())
+ .header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON))
.andExpect(jsonPath("$.items", hasSize(3)));
verify(workflowManagerMock).list(any(), any(), requestSpecArg.capture());
assertRequestSpec(requestSpecArg.getValue(), DEFAULT_OFFSET, 2,
public void shouldReturnDefaultLimitOffsetAppliedWorkflowsWhenLimitIsNotSpecified() throws Exception {
mockManagerList3();
mockMvc.perform(get(RestPath.getWorkflowsPathNoSortAndLimit("1")).header(USER_ID_HEADER, USER_ID)
- .contentType(APPLICATION_JSON)).andDo(print())
+ .contentType(APPLICATION_JSON))
.andExpect(jsonPath("$.items", hasSize(3)));
verify(workflowManagerMock).list(any(), any(), requestSpecArg.capture());
assertRequestSpec(requestSpecArg.getValue(), 1, DEFAULT_LIMIT, Collections.emptyList());
public void shouldReturnDefaultOffsetAppliedWorkflowsWhenOffsetIsNotSpecified() throws Exception {
mockManagerList3();
mockMvc.perform(get(RestPath.getWorkflowsPathNoSortAndOffset("1")).header(USER_ID_HEADER, USER_ID)
- .contentType(APPLICATION_JSON)).andDo(print())
+ .contentType(APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$.items", hasSize(3)));
verify(workflowManagerMock).list(any(), any(), requestSpecArg.capture());
assertRequestSpec(requestSpecArg.getValue(), DEFAULT_OFFSET, 1, Collections.emptyList());
item.setId(new Id("abc"));
Workflow reqWorkflow = createWorkflow(1, false);
mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON)
- .content(JsonUtil.object2Json(reqWorkflow))).andDo(print())
+ .content(JsonUtil.object2Json(reqWorkflow)))
.andExpect(status().isCreated());
verify(workflowManagerMock).create(reqWorkflow);
}
Workflow reqWorkflow = new Workflow();
reqWorkflow.setName("Invalid workflow name %");
mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON)
- .content(JsonUtil.object2Json(reqWorkflow))).andDo(print())
+ .content(JsonUtil.object2Json(reqWorkflow)))
.andExpect(status().isBadRequest()).andExpect(
jsonPath("$.message", is("Workflow name must contain only letters, digits and underscores.")));
}
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())
+ .content(JsonUtil.object2Json(reqWorkflow)))
.andExpect(status().isBadRequest());
}
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())
+ .content(JsonUtil.object2Json(reqWorkflow)))
.andExpect(status().isBadRequest());
}
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())
+ .content(JsonUtil.object2Json(reqWorkflow)))
.andExpect(status().isBadRequest());
}
Workflow reqWorkflow = new Workflow();
reqWorkflow.setName("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON)
- .content(JsonUtil.object2Json(reqWorkflow))).andDo(print()).andExpect(
+ .content(JsonUtil.object2Json(reqWorkflow))).andExpect(
status().isBadRequest()).andExpect(jsonPath("$.message", is(
"Workflow name must be at least " + MIN_LENGTH
+ " characters, and no more than " + MAX_LENGTH
Workflow reqWorkflow = new Workflow();
reqWorkflow.setName("AAA");
mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON)
- .content(JsonUtil.object2Json(reqWorkflow))).andDo(print()).andExpect(
+ .content(JsonUtil.object2Json(reqWorkflow))).andExpect(
status().isBadRequest()).andExpect(jsonPath("$.message",
is("Workflow name must be at least " + MIN_LENGTH + " characters, and no more than "
+ MAX_LENGTH + " characters.")));