use of org.openkilda.messaging.payload.flow.FlowPayload 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.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.
the class FlowUtils method putFlow.
/**
* Creates flow through Northbound service.
*
* @param payload flow JSON data
* @return The JSON document of the created flow
*/
public static FlowPayload putFlow(final FlowPayload payload) {
System.out.println("\n==> Northbound Create Flow");
long current = System.currentTimeMillis();
Client client = clientFactory();
Response response = client.target(northboundEndpoint).path("/api/v1/flows").request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, authHeaderValue).header(Utils.CORRELATION_ID, String.valueOf(System.currentTimeMillis())).put(Entity.json(payload));
System.out.println(format("===> Request Payload = %s", Entity.json(payload).getEntity()));
System.out.println(format("===> Response = %s", response.toString()));
System.out.println(format("===> Northbound Create Flow Time: %,.3f", getTimeDuration(current)));
int responseCode = response.getStatus();
if (responseCode == 200) {
FlowPayload flow = response.readEntity(FlowPayload.class);
System.out.println(format("====> Northbound Create Flow = %s", flow));
return flow;
} else {
System.out.println(format("====> Error: Northbound Create Flow = %s", response.readEntity(MessageError.class)));
return null;
}
}
use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.
the class FlowUtils method getFlowDump.
/**
* Gets flows dump through Northbound service.
*
* @return The JSON document of the dump flows
*/
public static List<FlowPayload> getFlowDump() {
System.out.println("\n==> Northbound Get Flow Dump");
long current = System.currentTimeMillis();
Client client = clientFactory();
Response response = client.target(northboundEndpoint).path("/api/v1/flows").request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, authHeaderValue).header(Utils.CORRELATION_ID, String.valueOf(System.currentTimeMillis())).get();
System.out.println(format("===> Response = %s", response.toString()));
System.out.println(format("===> Northbound Get Flow Dump Time: %,.3f", getTimeDuration(current)));
int responseCode = response.getStatus();
if (responseCode == 200) {
List<FlowPayload> flows = response.readEntity(new GenericType<List<FlowPayload>>() {
});
System.out.println(format("====> Northbound Get Flow Dump = %d", flows.size()));
return flows;
} else {
System.out.println(format("====> Error: Northbound Get Flow Dump = %s", response.readEntity(MessageError.class)));
return Collections.emptyList();
}
}
use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.
the class FlowUtils method deleteFlow.
/**
* Deletes flow through Northbound service.
*
* @param flowId flow id
* @return The JSON document of the specified flow
*/
public static FlowPayload deleteFlow(final String flowId) {
System.out.println("\n==> Northbound Delete Flow");
long current = System.currentTimeMillis();
Client client = clientFactory();
Response response = client.target(northboundEndpoint).path("/api/v1/flows").path("{flowid}").resolveTemplate("flowid", flowId).request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, authHeaderValue).header(Utils.CORRELATION_ID, String.valueOf(System.currentTimeMillis())).delete();
System.out.println(format("===> Response = %s", response.toString()));
System.out.println(format("===> Northbound Delete Flow Time: %,.3f", getTimeDuration(current)));
int responseCode = response.getStatus();
if (responseCode == 200) {
FlowPayload flow = response.readEntity(FlowPayload.class);
System.out.println(format("====> Northbound Delete Flow = %s", flow));
return flow;
} else {
System.out.println(format("====> Error: Northbound Delete Flow = %s", response.readEntity(MessageError.class)));
return null;
}
}
use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.
the class FlowServiceImplTest method deleteFlow.
@Test
public void deleteFlow() throws Exception {
FlowEndpointPayload firstEndpoint = new FlowEndpointPayload(srcSwitchId, 10, 100);
FlowEndpointPayload secondEndpoint = new FlowEndpointPayload(dstSwitchId, 20, 100);
FlowPayload flowPayload = new FlowPayload(flowId, 0L, secondEndpoint, firstEndpoint, 10000L, "", "", OutputVlanType.NONE);
FlowIdStatusPayload flowIdStatusPayload = new FlowIdStatusPayload(flowId);
flowService.createFlow(flowPayload, DEFAULT_CORRELATION_ID);
flowService.deleteFlow(flowIdStatusPayload, DEFAULT_CORRELATION_ID);
Set<Flow> flows = flowRepository.findByFlowId(flowId);
assertNotNull(flows);
assertTrue(flows.isEmpty());
}
Aggregations