@Test public void ensureFieldsExist() { Configuration config = new Configuration(); config.setConnectionType(ConnectionType.WEB_SOCKET); config.setAuthEndpoint("http: config.setKeys(LocalKeys.generate()); config.setDsId("test"); config.setResponder(true); LocalHandshake handshake = new LocalHandshake(config); JsonObject object = handshake.toJson(); Assert.assertNotNull(object); Assert.assertFalse(object.contains("zone")); config.setZone("testZone"); handshake = new LocalHandshake(config); object = handshake.toJson(); Assert.assertTrue(object.contains("zone")); Assert.assertTrue(object.contains("publicKey")); Assert.assertTrue(object.contains("isRequester")); Assert.assertTrue(object.contains("isResponder")); }
public JsonObject toJson() { JsonObject obj = new JsonObject(); obj.put("publicKey", publicKey); if (zone != null) { obj.put("zone", zone); } obj.put("isRequester", isRequester); obj.put("isResponder", isResponder); obj.put("linkData", linkData); obj.put("version", "1.0.4"); obj.put("enableWebSocketCompression", true); return obj; }
LocalHandshake { public JsonObject toJson() { JsonObject obj = new JsonObject(); obj.put("publicKey", publicKey); if (zone != null) { obj.put("zone", zone); } obj.put("isRequester", isRequester); obj.put("isResponder", isResponder); obj.put("linkData", linkData); obj.put("version", "1.0.4"); obj.put("enableWebSocketCompression", true); return obj; } }
LocalHandshake { public JsonObject toJson() { JsonObject obj = new JsonObject(); obj.put("publicKey", publicKey); if (zone != null) { obj.put("zone", zone); } obj.put("isRequester", isRequester); obj.put("isResponder", isResponder); obj.put("linkData", linkData); obj.put("version", "1.0.4"); obj.put("enableWebSocketCompression", true); return obj; } LocalHandshake(Configuration config); }
LocalHandshake { public JsonObject toJson() { JsonObject obj = new JsonObject(); obj.put("publicKey", publicKey); if (zone != null) { obj.put("zone", zone); } obj.put("isRequester", isRequester); obj.put("isResponder", isResponder); obj.put("linkData", linkData); obj.put("version", "1.0.4"); obj.put("enableWebSocketCompression", true); return obj; } LocalHandshake(Configuration config); LocalKeys getKeys(); String getToken(); String getDsId(); boolean isRequester(); boolean isResponder(); JsonObject toJson(); }
LocalHandshake { public JsonObject toJson() { JsonObject obj = new JsonObject(); obj.put("publicKey", publicKey); if (zone != null) { obj.put("zone", zone); } obj.put("isRequester", isRequester); obj.put("isResponder", isResponder); obj.put("linkData", linkData); obj.put("version", "1.0.4"); obj.put("enableWebSocketCompression", true); return obj; } LocalHandshake(Configuration config); LocalKeys getKeys(); String getToken(); String getDsId(); boolean isRequester(); boolean isResponder(); JsonObject toJson();  }