@Test public void testGSONMessageSpace() throws Exception { SpaceCard spaceCard = new SpaceCard(); spaceCard.setSpaceID("id"); spaceCard.setDescription("descrizione"); spaceCard.setPeerCoordinatorID("coord{ }&)?id"); spaceCard.setPeeringChannel("canale"); spaceCard.setPeeringChannelName("nome canaèle"); spaceCard.setProfile("profilo"); spaceCard.setRetry(10); ChannelDescriptor chd = new ChannelDescriptor("1339517729177690537L", "nome!", "http: List<org.universAAL.middleware.interfaces.ChannelDescriptor> brokerChannels = new ArrayList<org.universAAL.middleware.interfaces.ChannelDescriptor>(); brokerChannels.add(chd); SpaceDescriptor spaceDescriptor = new SpaceDescriptor(spaceCard, brokerChannels); PeerCard deployManager = new PeerCard(PeerRole.PEER, "stringa1", "stringa2"); spaceDescriptor.setDeployManager(deployManager); SpaceMessage original = new SpaceMessage(spaceDescriptor, SpaceMessageTypes.CONNECT); String serializedMessage = GsonParserBuilder.getInstance().toJson(original); SpaceMessage decodedMessage = GsonParserBuilder.getInstance().fromJson(serializedMessage, SpaceMessage.class); System.out.println(original.toString()); System.out.println(serializedMessage.toString()); System.out.println(decodedMessage.toString()); assertEquals(original.toString(), decodedMessage.toString()); }
public String toString() { String serializedMessage = null; try { serializedMessage = GsonParserBuilder.getInstance().toJson(this); } catch (Exception e) { e.printStackTrace(); } return serializedMessage; }
SpaceMessage implements BrokerMessage { public String toString() { String serializedMessage = null; try { serializedMessage = GsonParserBuilder.getInstance().toJson(this); } catch (Exception e) { e.printStackTrace(); } return serializedMessage; } }
SpaceMessage implements BrokerMessage { public String toString() { String serializedMessage = null; try { serializedMessage = GsonParserBuilder.getInstance().toJson(this); } catch (Exception e) { e.printStackTrace(); } return serializedMessage; } SpaceMessage();  SpaceMessage(SpaceDescriptor spaceDescriptor, SpaceMessageTypes type); }
SpaceMessage implements BrokerMessage { public String toString() { String serializedMessage = null; try { serializedMessage = GsonParserBuilder.getInstance().toJson(this); } catch (Exception e) { e.printStackTrace(); } return serializedMessage; } SpaceMessage();  SpaceMessage(SpaceDescriptor spaceDescriptor, SpaceMessageTypes type); SpaceDescriptor getSpaceDescriptor(); void setSpaceDescriptor(SpaceDescriptor spaceDescriptor); SpaceMessageTypes getMessageType(); String toString(); BrokerMessageTypes getMType(); PeerCard[] getReceivers(); }
SpaceMessage implements BrokerMessage { public String toString() { String serializedMessage = null; try { serializedMessage = GsonParserBuilder.getInstance().toJson(this); } catch (Exception e) { e.printStackTrace(); } return serializedMessage; } SpaceMessage();  SpaceMessage(SpaceDescriptor spaceDescriptor, SpaceMessageTypes type); SpaceDescriptor getSpaceDescriptor(); void setSpaceDescriptor(SpaceDescriptor spaceDescriptor); SpaceMessageTypes getMessageType(); String toString(); BrokerMessageTypes getMType(); PeerCard[] getReceivers();  }