@Test public void BrokerMessageTest() throws Exception { 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); System.out.println(sorgente.toString()); String serializedMessage = GsonParserBuilder.getInstance().toJson(sorgente); String destinazione = GsonParserBuilder.getInstance().fromJson(serializedMessage, BrokerMessage.class) .toString(); System.out.println(serializedMessage.toString()); System.out.println(destinazione.toString()); assertEquals(sorgente.toString(), destinazione.toString()); }
public String toString() { String serializedMessage = null; try { Gson gson = GsonParserBuilder.getInstance(); serializedMessage = gson.toJson(this); } catch (Exception e) { e.printStackTrace(); } return serializedMessage; }
DeployMessage implements BrokerMessage { public String toString() { String serializedMessage = null; try { Gson gson = GsonParserBuilder.getInstance(); serializedMessage = gson.toJson(this); } catch (Exception e) { e.printStackTrace(); } return serializedMessage; } }
DeployMessage implements BrokerMessage { public String toString() { String serializedMessage = null; try { Gson gson = GsonParserBuilder.getInstance(); serializedMessage = gson.toJson(this); } catch (Exception e) { e.printStackTrace(); } return serializedMessage; } DeployMessage(DeployMessageType messageType, DeployPayload payload);  DeployMessage(); }
DeployMessage implements BrokerMessage { public String toString() { String serializedMessage = null; try { Gson gson = GsonParserBuilder.getInstance(); serializedMessage = gson.toJson(this); } catch (Exception e) { e.printStackTrace(); } return serializedMessage; } DeployMessage(DeployMessageType messageType, DeployPayload payload);  DeployMessage(); DeployMessageType getMessageType(); void setMessageType(DeployMessageType messageType); String toString(); DeployPayload getPayload(); BrokerMessageTypes getMType(); PeerCard[] getReceivers(); }
DeployMessage implements BrokerMessage { public String toString() { String serializedMessage = null; try { Gson gson = GsonParserBuilder.getInstance(); serializedMessage = gson.toJson(this); } catch (Exception e) { e.printStackTrace(); } return serializedMessage; } DeployMessage(DeployMessageType messageType, DeployPayload payload);  DeployMessage(); DeployMessageType getMessageType(); void setMessageType(DeployMessageType messageType); String toString(); DeployPayload getPayload(); BrokerMessageTypes getMType(); PeerCard[] getReceivers(); public BrokerMessageTypes mType; }