use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.
the class AbstractSerializerTest method flowCreateRequestTest.
@Test
public void flowCreateRequestTest() throws IOException, ClassNotFoundException {
FlowCreateRequest data = new FlowCreateRequest(flowModel);
System.out.println(data);
CommandMessage command = new CommandMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
serialize(command);
Message message = (Message) deserialize();
assertTrue(message instanceof CommandMessage);
CommandMessage resultCommand = (CommandMessage) message;
assertTrue(resultCommand.getData() instanceof FlowCreateRequest);
FlowCreateRequest resultData = (FlowCreateRequest) resultCommand.getData();
System.out.println(resultData);
assertEquals(data, resultData);
assertEquals(data.hashCode(), resultData.hashCode());
assertEquals(flowModel.hashCode(), resultData.getPayload().hashCode());
}
use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.
the class AbstractSerializerTest method flowUpdateRequestTest.
@Test
public void flowUpdateRequestTest() throws IOException, ClassNotFoundException {
FlowUpdateRequest data = new FlowUpdateRequest(flowModel);
System.out.println(data);
CommandMessage command = new CommandMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
serialize(command);
Message message = (Message) deserialize();
assertTrue(message instanceof CommandMessage);
CommandMessage resultCommand = (CommandMessage) message;
assertTrue(resultCommand.getData() instanceof FlowUpdateRequest);
FlowUpdateRequest resultData = (FlowUpdateRequest) resultCommand.getData();
System.out.println(resultData);
assertEquals(data, resultData);
assertEquals(data.hashCode(), resultData.hashCode());
assertEquals(flowModel.hashCode(), resultData.getPayload().hashCode());
}
use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.
the class AbstractSerializerTest method flowDeleteRequestTest.
@Test
public void flowDeleteRequestTest() throws IOException, ClassNotFoundException {
Flow deleteFlow = new Flow();
deleteFlow.setFlowId(flowName);
FlowDeleteRequest data = new FlowDeleteRequest(deleteFlow);
System.out.println(data);
CommandMessage command = new CommandMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
serialize(command);
Message message = (Message) deserialize();
assertTrue(message instanceof CommandMessage);
CommandMessage resultCommand = (CommandMessage) message;
assertTrue(resultCommand.getData() instanceof FlowDeleteRequest);
FlowDeleteRequest resultData = (FlowDeleteRequest) resultCommand.getData();
System.out.println(resultData);
assertEquals(data, resultData);
assertEquals(data.hashCode(), resultData.hashCode());
assertEquals(deleteFlow.hashCode(), resultData.getPayload().hashCode());
}
use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.
the class FlowServiceImpl method updateFlow.
/**
* {@inheritDoc}
*/
@Override
public FlowPayload updateFlow(final FlowPayload flow, final String correlationId) {
LOGGER.debug("Update flow: {}={}", CORRELATION_ID, correlationId);
FlowUpdateRequest data = new FlowUpdateRequest(Converter.buildFlowByFlowPayload(flow));
CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
messageConsumer.clear();
messageProducer.send(topic, request);
Message message = (Message) messageConsumer.poll(correlationId);
FlowResponse response = (FlowResponse) validateInfoMessage(request, message, correlationId);
return Converter.buildFlowPayloadByFlow(response.getPayload());
}
use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.
the class FlowServiceImpl method pathFlow.
/**
* {@inheritDoc}
*/
@Override
public FlowPathPayload pathFlow(final String id, final String correlationId) {
LOGGER.debug("Flow path: {}={}", CORRELATION_ID, correlationId);
FlowPathRequest data = new FlowPathRequest(new FlowIdStatusPayload(id, null));
CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
messageConsumer.clear();
messageProducer.send(topic, request);
Message message = (Message) messageConsumer.poll(correlationId);
FlowPathResponse response = (FlowPathResponse) validateInfoMessage(request, message, correlationId);
return Converter.buildFlowPathPayloadByFlowPath(id, response.getPayload());
}
Aggregations