Search in sources :

Example 1 with FlowResponsePayload

use of org.openkilda.messaging.payload.flow.FlowResponsePayload 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 mvcResult = mockMvc.perform(delete("/v1/flows/{flow-id}", TestMessageMock.FLOW_ID).header(CORRELATION_ID, testCorrelationId()).contentType(APPLICATION_JSON_VALUE)).andReturn();
    MvcResult result = mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_VALUE)).andReturn();
    FlowResponsePayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowResponsePayload.class);
    assertEquals(TestMessageMock.flowResponsePayload, response);
}
Also used : FlowResponsePayload(org.openkilda.messaging.payload.flow.FlowResponsePayload) MvcResult(org.springframework.test.web.servlet.MvcResult) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 2 with FlowResponsePayload

use of org.openkilda.messaging.payload.flow.FlowResponsePayload in project open-kilda by telstra.

the class FlowControllerTest method createFlow.

@Test
@WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE)
public void createFlow() throws Exception {
    MvcResult mvcResult = mockMvc.perform(put("/v1/flows").header(CORRELATION_ID, testCorrelationId()).contentType(APPLICATION_JSON_VALUE).content(MAPPER.writeValueAsString(TestMessageMock.flow))).andReturn();
    MvcResult result = mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_VALUE)).andReturn();
    System.out.println("RESPONSE: " + result.getResponse().getContentAsString());
    FlowResponsePayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowResponsePayload.class);
    assertEquals(TestMessageMock.flowResponsePayload, response);
}
Also used : FlowResponsePayload(org.openkilda.messaging.payload.flow.FlowResponsePayload) MvcResult(org.springframework.test.web.servlet.MvcResult) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 3 with FlowResponsePayload

use of org.openkilda.messaging.payload.flow.FlowResponsePayload 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 mvcResult = mockMvc.perform(delete("/v1/flows").header(CORRELATION_ID, testCorrelationId()).header(EXTRA_AUTH, System.currentTimeMillis() - TimeUnit.SECONDS.toMillis(119)).contentType(APPLICATION_JSON_VALUE)).andReturn();
    MvcResult result = mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_VALUE)).andReturn();
    FlowResponsePayload[] response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowResponsePayload[].class);
    assertEquals(TestMessageMock.flowResponsePayload, response[0]);
}
Also used : FlowResponsePayload(org.openkilda.messaging.payload.flow.FlowResponsePayload) MvcResult(org.springframework.test.web.servlet.MvcResult) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 4 with FlowResponsePayload

use of org.openkilda.messaging.payload.flow.FlowResponsePayload in project open-kilda by telstra.

the class FlowMapper method toFlowResponseOutput.

/**
 * Map {@link FlowDto} into {@link FlowResponsePayload}.
 */
public FlowResponsePayload toFlowResponseOutput(FlowDto f) {
    FlowResponsePayload result = new FlowResponsePayload();
    generatedMap(result, f);
    generatedFlowResponsePayloadMap(result, f);
    mapFlowResponseEndpoints(result, f);
    return result;
}
Also used : FlowResponsePayload(org.openkilda.messaging.payload.flow.FlowResponsePayload)

Example 5 with FlowResponsePayload

use of org.openkilda.messaging.payload.flow.FlowResponsePayload 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 mvcResult = mockMvc.perform(get("/v1/flows", TestMessageMock.FLOW_ID).header(CORRELATION_ID, testCorrelationId()).contentType(APPLICATION_JSON_VALUE)).andReturn();
    MvcResult result = mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_VALUE)).andReturn();
    List<FlowResponsePayload> response = MAPPER.readValue(result.getResponse().getContentAsString(), new TypeReference<List<FlowResponsePayload>>() {
    });
    assertEquals(Collections.singletonList(TestMessageMock.flowResponsePayload), response);
}
Also used : FlowResponsePayload(org.openkilda.messaging.payload.flow.FlowResponsePayload) List(java.util.List) MvcResult(org.springframework.test.web.servlet.MvcResult) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

FlowResponsePayload (org.openkilda.messaging.payload.flow.FlowResponsePayload)7 Test (org.junit.Test)6 WithMockUser (org.springframework.security.test.context.support.WithMockUser)6 MvcResult (org.springframework.test.web.servlet.MvcResult)6 List (java.util.List)1