Search in sources :

Example 6 with FlowsResponse

use of org.openkilda.messaging.info.flow.FlowsResponse in project open-kilda by telstra.

the class AbstractSerializerTest method flowsResponseTest.

@Test
public void flowsResponseTest() throws IOException, ClassNotFoundException {
    FlowsResponse data = new FlowsResponse(Collections.singletonList(flowModel));
    System.out.println(data);
    InfoMessage info = new InfoMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
    serialize(info);
    Message message = (Message) deserialize();
    assertTrue(message instanceof InfoMessage);
    InfoMessage resultInfo = (InfoMessage) message;
    assertTrue(resultInfo.getData() instanceof FlowsResponse);
    FlowsResponse resultData = (FlowsResponse) resultInfo.getData();
    System.out.println(resultData);
    assertEquals(data, resultData);
    assertEquals(data.hashCode(), resultData.hashCode());
    assertEquals(Collections.singletonList(flowModel).hashCode(), resultData.getPayload().hashCode());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowsResponse(org.openkilda.messaging.info.flow.FlowsResponse) Test(org.junit.Test)

Example 7 with FlowsResponse

use of org.openkilda.messaging.info.flow.FlowsResponse 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;
}
Also used : FlowsGetRequest(org.openkilda.messaging.command.flow.FlowsGetRequest) FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) FlowsResponse(org.openkilda.messaging.info.flow.FlowsResponse) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

InfoMessage (org.openkilda.messaging.info.InfoMessage)7 FlowsResponse (org.openkilda.messaging.info.flow.FlowsResponse)7 Test (org.junit.Test)3 Message (org.openkilda.messaging.Message)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)2 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)2 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)2 Flow (org.openkilda.messaging.model.Flow)2 FlowPayload (org.openkilda.messaging.payload.flow.FlowPayload)2 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)2 ArrayList (java.util.ArrayList)1 Ignore (org.junit.Ignore)1 FlowsGetRequest (org.openkilda.messaging.command.flow.FlowsGetRequest)1 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)1 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)1 FlowsPayload (org.openkilda.messaging.payload.flow.FlowsPayload)1 Flow (org.openkilda.topology.domain.Flow)1 HttpHeaders (org.springframework.http.HttpHeaders)1 ResponseEntity (org.springframework.http.ResponseEntity)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1