use of org.openkilda.messaging.info.InfoMessage in project open-kilda by telstra.
the class AbstractSerializerTest method flowResponseTest.
@Test
public void flowResponseTest() throws IOException, ClassNotFoundException {
FlowResponse data = new FlowResponse(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 FlowResponse);
FlowResponse resultData = (FlowResponse) resultInfo.getData();
System.out.println(resultData);
assertEquals(data, resultData);
assertEquals(data.hashCode(), resultData.hashCode());
assertEquals(flowModel.hashCode(), resultData.getPayload().hashCode());
}
use of org.openkilda.messaging.info.InfoMessage in project open-kilda by telstra.
the class AbstractSerializerTest method dumpNetworkResponseTest.
@Test
public void dumpNetworkResponseTest() throws IOException, ClassNotFoundException {
NetworkInfoData data = new NetworkInfoData(requester, new HashSet<>(Arrays.asList(sw1, sw2)), new HashSet<>(), Collections.singleton(isl), Collections.singleton(new ImmutablePair<>(flowModel, flowModel)));
System.out.println(data);
InfoMessage info = new InfoMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
info.setData(data);
serialize(info);
Message message = (Message) deserialize();
assertTrue(message instanceof InfoMessage);
InfoMessage resultInfo = (InfoMessage) message;
assertTrue(resultInfo.getData() != null);
NetworkInfoData resultData = (NetworkInfoData) resultInfo.getData();
System.out.println(resultData);
assertEquals(data, resultData);
assertEquals(data.hashCode(), resultData.hashCode());
}
use of org.openkilda.messaging.info.InfoMessage in project open-kilda by telstra.
the class AbstractSerializerTest method flowStatusResponseTest.
@Test
public void flowStatusResponseTest() throws IOException, ClassNotFoundException {
FlowStatusResponse data = new FlowStatusResponse(flowIdStatusResponse);
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 FlowStatusResponse);
FlowStatusResponse resultData = (FlowStatusResponse) resultInfo.getData();
System.out.println(resultData);
assertEquals(data, resultData);
assertEquals(data.hashCode(), resultData.hashCode());
assertEquals(flowIdStatusResponse.hashCode(), resultData.getPayload().hashCode());
}
use of org.openkilda.messaging.info.InfoMessage 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());
}
use of org.openkilda.messaging.info.InfoMessage in project open-kilda by telstra.
the class FlowStatusResponseTest method testJsonSerialization.
@Test
public void testJsonSerialization() throws IOException {
/*
* Start with serializing to JSON.
* Then re-populate from JSON.
*/
InfoMessage msg = new InfoMessage(new FlowStatusResponse(new FlowIdStatusPayload("FLOW", FlowState.UP)), 10L, "CORRELATION", Destination.NORTHBOUND);
InfoMessage fromJson = MAPPER.readValue(json, InfoMessage.class);
FlowStatusResponse fsrJson = (FlowStatusResponse) fromJson.getData();
FlowStatusResponse fsrObj = (FlowStatusResponse) msg.getData();
Assert.assertEquals(fsrJson.getPayload().getId(), fsrObj.getPayload().getId());
Assert.assertEquals(fsrJson.getPayload().getStatus(), fsrObj.getPayload().getStatus());
Assert.assertEquals(fsrJson.getPayload().getStatus(), FlowState.UP);
Assert.assertEquals(fromJson.getCorrelationId(), msg.getCorrelationId());
System.out.println("JSON: " + MAPPER.writeValueAsString(msg));
}
Aggregations