+ private static ProvData setUpProvData() throws IOException {
+ JSONObject provData = new JSONObject();
+ createValidFeed(provData);
+ createValidSubscription(provData);
+ createValidParameters(provData);
+ createValidIngressValues(provData);
+ createValidEgressValues(provData);
+ createValidRoutingValues(provData);
+ Reader reader = new StringReader(provData.toString());
+ return new ProvData(reader);
+ }
+
+ private static void createValidFeed(JSONObject provData) {
+ JSONArray feeds = new JSONArray();
+ JSONObject feed = new JSONObject();
+ JSONObject auth = new JSONObject();
+ JSONArray endpointIds = new JSONArray();
+ JSONArray endpointAddrs = new JSONArray();
+ JSONObject endpointId = new JSONObject();
+ feed.put("feedid", "1");
+ feed.put("name", "Feed1");
+ feed.put("version", "m1.0");
+ feed.put("suspend", false);
+ feed.put("deleted", false);
+ endpointId.put("id", "user1");
+ endpointId.put("password", "password1");
+ endpointIds.put(endpointId);
+ auth.put("endpoint_ids", endpointIds);
+ endpointAddrs.put("172.0.0.1");
+ auth.put("endpoint_addrs", endpointAddrs);
+ feed.put("authorization", auth);
+ feed.put("aaf_instance", "legacy");
+ feeds.put(feed);
+ provData.put("feeds", feeds);
+ }
+
+ private static void createValidSubscription(JSONObject provData) {
+ JSONArray subscriptions = new JSONArray();
+ JSONObject subscription = new JSONObject();
+ JSONObject delivery = new JSONObject();
+ subscription.put("subid", "1");
+ subscription.put("feedid", "1");
+ subscription.put("suspend", false);
+ subscription.put("metadataOnly", false);
+ delivery.put("url", "https://172.0.0.2");
+ delivery.put("user", "user1");
+ delivery.put("password", "password1");
+ delivery.put("use100", true);
+ subscription.put("delivery", delivery);
+ subscription.put("privilegedSubscriber", false);
+ subscription.put("follow_redirect", false);
+ subscription.put("decompress", false);
+ subscriptions.put(subscription);
+ provData.put("subscriptions", subscriptions);
+ }
+
+ private static void createValidParameters(JSONObject provData) {
+ JSONObject parameters = new JSONObject();
+ JSONArray nodes = new JSONArray();
+ parameters.put("PROV_NAME", "prov.datarouternew.com");
+ parameters.put("DELIVERY_INIT_RETRY_INTERVAL", "10");
+ parameters.put("DELIVERY_MAX_AGE", "86400");
+ parameters.put("PROV_DOMAIN", "");
+ nodes.put("172.0.0.4");
+ parameters.put("NODES", nodes);
+ provData.put("parameters", parameters);
+ }
+
+ private static void createValidIngressValues(JSONObject provData) {
+ JSONArray ingresses = new JSONArray();
+ JSONObject ingress = new JSONObject();
+ ingress.put("feedid", "1");
+ ingress.put("subnet", "");
+ ingress.put("user", "");
+ ingress.put("node", "172.0.0.4");
+ ingresses.put(ingress);
+ provData.put("ingress", ingresses);
+ }
+
+ private static void createValidEgressValues(JSONObject provData) {
+ JSONObject egress = new JSONObject();
+ egress.put("subid", "1");
+ egress.put("nodeid", "172.0.0.4");
+ provData.put("egress", egress);
+ }
+
+ private static void createValidRoutingValues(JSONObject provData) {
+ JSONArray routings = new JSONArray();
+ JSONObject routing = new JSONObject();
+ routing.put("from", "prov.datarouternew.com");
+ routing.put("to", "172.0.0.4");
+ routing.put("via", "172.100.0.1");
+ routings.put(routing);
+ provData.put("routing", routings);
+ }
+