@Test public void GSONC1ontrolMessageTest() throws Exception { Gson gson = GsonParserBuilder.getInstance(); DeployMessageType type = DeployMessageType.REQUEST_TO_INSTALL_PART; byte[] bytearray = new byte[] { 4, 4, 56, 35, 64, (byte) 0xfe6, 4 }; App uapp = new App(); uapp.setAppId("10"); uapp.setApplicationProfile("ciao"); uapp.setDescription("descrizione app"); uapp.setMultipart(true); uapp.setName("nome"); uapp.setTags("tags"); VersionType tipoversione = new VersionType(); tipoversione.setBuild("stringa build"); tipoversione.setMajor(1); tipoversione.setMicro(2); tipoversione.setMinor(3); uapp.setVersion(tipoversione); ContactType contatto = new ContactType(); contatto.setCertificate("certificato"); contatto.setContactPerson("persona"); contatto.setEmail("indirizzo email"); contatto.setOrganizationName("nome Organizzazione"); contatto.setPhone("32525"); contatto.setStreetAddress("indirizzo"); contatto.setWebAddress("web address"); OtherChannel altrocanale = new OtherChannel(); altrocanale.setChannelName("nome altro canale"); altrocanale.setChannelDetails("dettagli"); contatto.setOtherChannel(altrocanale); uapp.setApplicationProvider(contatto); UAPPCard card = new UAPPCard("service id", "part id", uapp); DeployPayload payload = new DeployPayload(bytearray, card); DeployMessage sorgente = new DeployMessage(type, payload); BrokerMessage message = sorgente; String serial = gson.toJson(sorgente); BrokerMessage brokerMessage = gson.fromJson(serial, BrokerMessage.class); DeployMessage deployMessage = null; if (brokerMessage instanceof DeployMessage) { deployMessage = (DeployMessage) brokerMessage; } assertEquals(sorgente.toString(), deployMessage.toString()); }
public String toString() { String serializedMessage = null; if (parsed == null) { try { Gson gson = GsonParserBuilder.getInstance(); serializedMessage = gson.toJson(this); } catch (Exception e) { e.printStackTrace(); } } parsed = serializedMessage; return parsed; }
ControlMessage implements BrokerMessage { public String toString() { String serializedMessage = null; if (parsed == null) { try { Gson gson = GsonParserBuilder.getInstance(); serializedMessage = gson.toJson(this); } catch (Exception e) { e.printStackTrace(); } } parsed = serializedMessage; return parsed; } }
ControlMessage implements BrokerMessage { public String toString() { String serializedMessage = null; if (parsed == null) { try { Gson gson = GsonParserBuilder.getInstance(); serializedMessage = gson.toJson(this); } catch (Exception e) { e.printStackTrace(); } } parsed = serializedMessage; return parsed; } ControlMessage(SpaceDescriptor space, List<String> attributes);  ControlMessage(SpaceDescriptor space, ControlMessageType type);  ControlMessage();  ControlMessage(SpaceDescriptor space, Map<String, Serializable> filter);  ControlMessage(SpaceDescriptor space, String id, HashMap<String, Serializable> map);  ControlMessage(SpaceDescriptor space, String id, HashMap<String, Serializable> map, boolean match);  ControlMessage(SpaceDescriptor space, ControlMessageType type, String id); }
ControlMessage implements BrokerMessage { public String toString() { String serializedMessage = null; if (parsed == null) { try { Gson gson = GsonParserBuilder.getInstance(); serializedMessage = gson.toJson(this); } catch (Exception e) { e.printStackTrace(); } } parsed = serializedMessage; return parsed; } ControlMessage(SpaceDescriptor space, List<String> attributes);  ControlMessage(SpaceDescriptor space, ControlMessageType type);  ControlMessage();  ControlMessage(SpaceDescriptor space, Map<String, Serializable> filter);  ControlMessage(SpaceDescriptor space, String id, HashMap<String, Serializable> map);  ControlMessage(SpaceDescriptor space, String id, HashMap<String, Serializable> map, boolean match);  ControlMessage(SpaceDescriptor space, ControlMessageType type, String id); String toString(); boolean getMatchFilter(); ControlMessageType getMessageType(); static ControlMessage unmarshall(String message); String getTransactionId(); Map<String, Serializable> getAttributeFilter(); Map<String, Serializable> getAttributeValues(); BrokerMessageTypes getMType(); List<String> getAttributes(); PeerCard[] getReceivers(); }
ControlMessage implements BrokerMessage { public String toString() { String serializedMessage = null; if (parsed == null) { try { Gson gson = GsonParserBuilder.getInstance(); serializedMessage = gson.toJson(this); } catch (Exception e) { e.printStackTrace(); } } parsed = serializedMessage; return parsed; } ControlMessage(SpaceDescriptor space, List<String> attributes);  ControlMessage(SpaceDescriptor space, ControlMessageType type);  ControlMessage();  ControlMessage(SpaceDescriptor space, Map<String, Serializable> filter);  ControlMessage(SpaceDescriptor space, String id, HashMap<String, Serializable> map);  ControlMessage(SpaceDescriptor space, String id, HashMap<String, Serializable> map, boolean match);  ControlMessage(SpaceDescriptor space, ControlMessageType type, String id); String toString(); boolean getMatchFilter(); ControlMessageType getMessageType(); static ControlMessage unmarshall(String message); String getTransactionId(); Map<String, Serializable> getAttributeFilter(); Map<String, Serializable> getAttributeValues(); BrokerMessageTypes getMType(); List<String> getAttributes(); PeerCard[] getReceivers();  }