use of org.springframework.test.web.servlet.MvcResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestGroupingsRestController method mapGroupingAssignment.
private GroupingAssignment mapGroupingAssignment() throws Exception {
ObjectMapper objectMapper = new ObjectMapper();
MvcResult result = mockMvc.perform(get("/api/groupings/groupingAssignment").with(csrf())).andExpect(status().isOk()).andReturn();
return objectMapper.readValue(result.getResponse().getContentAsByteArray(), GroupingAssignment.class);
}
use of org.springframework.test.web.servlet.MvcResult in project open-kilda by telstra.
the class FlowControllerTest method pathFlow.
@Test
@WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE)
public void pathFlow() throws Exception {
MvcResult result = mockMvc.perform(get("/flows/path/{flow-id}", TestMessageMock.FLOW_ID).header(CORRELATION_ID, testCorrelationId()).contentType(APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)).andReturn();
FlowPathPayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowPathPayload.class);
assertEquals(TestMessageMock.flowPath, response);
}
use of org.springframework.test.web.servlet.MvcResult in project open-kilda by telstra.
the class FlowControllerTest method deleteFlows.
@Test
@WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE)
public void deleteFlows() throws Exception {
MvcResult result = mockMvc.perform(delete("/flows").header(CORRELATION_ID, testCorrelationId()).header(EXTRA_AUTH, System.currentTimeMillis() - TimeUnit.SECONDS.toMillis(119)).contentType(APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)).andReturn();
FlowPayload[] response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowPayload[].class);
assertEquals(TestMessageMock.flow, response[0]);
}
use of org.springframework.test.web.servlet.MvcResult in project open-kilda by telstra.
the class FlowControllerTest method statusFlow.
@Test
@WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE)
public void statusFlow() throws Exception {
MvcResult result = mockMvc.perform(get("/flows/status/{flow-id}", TestMessageMock.FLOW_ID).header(CORRELATION_ID, testCorrelationId()).contentType(APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)).andReturn();
FlowIdStatusPayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowIdStatusPayload.class);
assertEquals(TestMessageMock.flowStatus, response);
}
use of org.springframework.test.web.servlet.MvcResult in project open-kilda by telstra.
the class FlowControllerTest method getFlow.
@Test
@WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE)
public void getFlow() throws Exception {
MvcResult result = mockMvc.perform(get("/flows/{flow-id}", TestMessageMock.FLOW_ID).header(CORRELATION_ID, testCorrelationId()).contentType(APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)).andReturn();
FlowPayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowPayload.class);
assertEquals(TestMessageMock.flow, response);
}
Aggregations