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);
}
use of org.springframework.test.web.servlet.MvcResult in project open-kilda by telstra.
the class FlowControllerTest method deleteFlow.
@Test
@WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE)
public void deleteFlow() throws Exception {
MvcResult result = mockMvc.perform(delete("/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);
}
use of org.springframework.test.web.servlet.MvcResult in project open-kilda by telstra.
the class FlowControllerTest method getFlows.
@Test
@WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE)
public void getFlows() throws Exception {
MvcResult result = mockMvc.perform(get("/flows", TestMessageMock.FLOW_ID).header(CORRELATION_ID, testCorrelationId()).contentType(APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)).andReturn();
List<FlowPayload> response = MAPPER.readValue(result.getResponse().getContentAsString(), new TypeReference<List<FlowPayload>>() {
});
assertEquals(Collections.singletonList(TestMessageMock.flow), response);
}
use of org.springframework.test.web.servlet.MvcResult in project open-kilda by telstra.
the class SwitchControllerTest method shouldDeleteSwitchRules.
@Test
@WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE)
public void shouldDeleteSwitchRules() throws Exception {
// given TestMessageMock as kafka topic mocks
// when
MvcResult result = mockMvc.perform(delete("/switches/{switch-id}/rules", TEST_SWITCH_ID).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();
Long[] response = MAPPER.readValue(result.getResponse().getContentAsString(), Long[].class);
assertEquals(TEST_SWITCH_RULE_COOKIE, (long) response[0]);
}
Aggregations