NetworkSchema implements NetworkDescriptor { @SuppressWarnings("unchecked") @Override public List<AnalyticNodeDescriptor> getPublishers() { if(nodes == null || nodes.size() < 1) { throw new IllegalStateException("Network: " + name + " was initialized with no nodes!"); } if(mainPublishers == null) { mainPublishers = new ArrayList<AnalyticNodeDescriptor>(); } int len = nodes.size(); for(int i = 0;i < len;i++) { AnalyticNodeDescriptor currCheck = nodes.get(i); boolean isPublisher = true; for(int j = 0;j < len;j++) { AnalyticNodeDescriptor iter = nodes.get(j); if(!(isPublisher = !iter.getInputNodeDescriptors().contains(currCheck))) { break; } } if(isPublisher) mainPublishers.add(currCheck); } return mainPublishers; } NetworkSchema(String name);  NetworkSchema(String name, List<AnalyticNodeDescriptor> nodes); @Override String getSpecifier(); @Override NodeType getType(); @Override String getNetworkName(); @Override void setNetworkName(String name); @SuppressWarnings("unchecked") @Override List<AnalyticNodeDescriptor> getNodeDescriptors(); @SuppressWarnings("unchecked") @Override void setNodeDescriptors(List<T> nodes); @SuppressWarnings("unchecked") @Override List<AnalyticNodeDescriptor> getPublishers(); static boolean hasNetworkByName(String networkName); static String getSchemaFilePath(); static void setSchemaFilePath(String filePath); static AnalyticNodeDescriptor lookup(String name, int timeFrames); static AnalyticNodeDescriptor lookup(SeriesSubscription subscription); static void reloadDefinitions(); static NetworkSchema getNetwork(String name); @SuppressWarnings("unchecked") static AnalyticNodeDescriptor loadDescriptor(String[] entry); static void loadAllDescriptors(); static void loadDefinitionsFile(String fileName); static void loadFromStream(InputStream stream);  }
@Test public void testGetPublishers() { NetworkSchema.setSchemaFilePath("testNetworks.txt"); NetworkSchema.reloadDefinitions(); NetworkDescriptor schema = NetworkSchema.getNetwork("PivotPoint"); assertNotNull(schema); assertEquals("PivotPoint", schema.getNetworkName()); assertEquals(8, schema.getNodeDescriptors().size()); List<AnalyticNodeDescriptor> publishers = schema.getPublishers(); assertTrue(!publishers.isEmpty()); assertEquals(7, publishers.size()); for(AnalyticNodeDescriptor and : publishers) { assertTrue(!and.getSpecifier().equals("PP_R2")); } }