use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.
the class FlowServiceImpl method getFlows.
/**
* {@inheritDoc}
*/
@Override
public List<FlowPayload> getFlows(final String correlationId) {
LOGGER.debug("\n\n\nGet flows: ENTER {}={}\n", CORRELATION_ID, correlationId);
// TODO: why does FlowsGetRequest use empty FlowIdStatusPayload? Delete if not needed.
FlowsGetRequest data = new FlowsGetRequest(new FlowIdStatusPayload());
CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
messageConsumer.clear();
messageProducer.send(topic, request);
Message message = (Message) messageConsumer.poll(correlationId);
FlowsResponse response = (FlowsResponse) validateInfoMessage(request, message, correlationId);
List<FlowPayload> result = Converter.buildFlowsPayloadByFlows(response.getPayload());
logger.debug("\nGet flows: EXIT {}={}, num_flows {}\n\n\n", CORRELATION_ID, correlationId, result.size());
return result;
}
use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.
the class FlowServiceImpl method deleteFlows.
/**
* {@inheritDoc}
*/
@Override
public List<FlowPayload> deleteFlows(final String correlationId) {
LOGGER.debug("\n\nDELETE ALL FLOWS: ENTER {}={}\n", CORRELATION_ID, correlationId);
ArrayList<FlowPayload> result = new ArrayList<>();
// TODO: Need a getFlowIDs .. since that is all we need
List<FlowPayload> flows = this.getFlows(correlationId + "-GET");
messageConsumer.clear();
// Send all the requests first
ArrayList<CommandMessage> requests = new ArrayList<>();
for (int i = 0; i < flows.size(); i++) {
String cid = correlationId + "-" + i;
FlowPayload flow = flows.get(i);
requests.add(_sendDeleteFlow(flow.getId(), cid));
}
// Now wait for the responses.
for (int i = 0; i < flows.size(); i++) {
String cid = correlationId + "-" + i;
result.add(_deleteFlowRespone(cid, requests.get(i)));
}
LOGGER.debug("\n\nDELETE ALL FLOWS: EXIT {}={}\n", CORRELATION_ID, correlationId);
return result;
}
use of org.openkilda.messaging.payload.flow.FlowPayload 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 result = mockMvc.perform(put("/flows").header(CORRELATION_ID, testCorrelationId()).contentType(APPLICATION_JSON_VALUE).content(MAPPER.writeValueAsString(TestMessageMock.flow))).andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)).andReturn();
System.out.println("RESPONSE: " + result.getResponse().getContentAsString());
FlowPayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowPayload.class);
assertEquals(TestMessageMock.flow, response);
}
use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.
the class FlowControllerTest method updateFlow.
@Test
@WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE)
public void updateFlow() throws Exception {
MvcResult result = mockMvc.perform(put("/flows/{flow-id}", TestMessageMock.FLOW_ID).header(CORRELATION_ID, testCorrelationId()).contentType(APPLICATION_JSON_VALUE).content(MAPPER.writeValueAsString(TestMessageMock.flow))).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.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.
the class FlowCrudSteps method eachFlowCanNotBeReadFromTopologyEngine.
@And("^each flow can not be read from TopologyEngine$")
public void eachFlowCanNotBeReadFromTopologyEngine() {
for (FlowPayload flow : flows) {
ImmutablePair<Flow, Flow> result = Failsafe.with(retryPolicy.abortIf(Objects::isNull)).get(() -> topologyEngineService.getFlow(flow.getId()));
assertNull(format("The flow '%s' exists.", flow.getId()), result);
}
}
Aggregations