List of usage examples for org.apache.commons.collections CollectionUtils union
public static Collection union(final Collection a, final Collection b)
From source file:org.pentaho.test.platform.repository.subscription.SubscriptionRepositoryHelperTest.java
/** * verify that the expected items are in the schedule's content list, delete the last schedule * and verify that the content list is clean up. *//* www. j a v a2 s . c o m*/ public void verifyContentList() { ISubscriptionRepository subscriptionRepository = PentahoSystem.get(ISubscriptionRepository.class, session); List<ISubscribeContent> endContentList = subscriptionRepository.getAllContent(); PentahoSystem.systemExitPoint(); // lists are both detached, and modification of lists should not effect persistent store // create a set of the actionRefs that were added to the final schedule (for fast lookup) Set<String> actionRefEditSet = new HashSet<String>(); for (String actionRef : actionRefsEdit) { actionRefEditSet.add(actionRef); } Set<String> actionRefStartSet = new HashSet<String>(); for (ISubscribeContent content : startContentList) { actionRefStartSet.add(content.getActionReference()); } Set<String> actionRefEndSet = new HashSet<String>(); for (ISubscribeContent content : endContentList) { actionRefEndSet.add(content.getActionReference()); } assertTrue("Content list does not contain expected content.", CollectionUtils .isEqualCollection(CollectionUtils.union(actionRefEditSet, actionRefStartSet), actionRefEndSet)); // assertTrue( "", CollectionUtils.xx() ); // assertTrue( "", CollectionUtils.xx() ); // assertTrue( "", CollectionUtils.xx() ); // do the final delete int ii = scheduleNames.length - 1; String name = scheduleNames[ii] + "-cron"; //$NON-NLS-1$ System.out.println("deleting: " + name); //$NON-NLS-1$ try { subscriptionRepository = PentahoSystem.get(ISubscriptionRepository.class, session); ISchedule schedule = subscriptionRepository.getScheduleByScheduleReference(name); //$NON-NLS-1$ if (null != schedule) { SubscriptionRepositoryHelper.deleteScheduleContentAndSubscription(subscriptionRepository, schedule); } PentahoSystem.systemExitPoint(); } catch (Exception e) { assertTrue("Failed in call to deleteScheduleContentAndSubscription: " //$NON-NLS-1$ + name + " " + e.getMessage(), false); //$NON-NLS-1$ } // we have now removed our last schedule, so associated content should be clean up. Let's see... subscriptionRepository = PentahoSystem.get(ISubscriptionRepository.class, session); endContentList = subscriptionRepository.getAllContent(); PentahoSystem.systemExitPoint(); actionRefEndSet = new HashSet<String>(); for (ISubscribeContent content : endContentList) { actionRefEndSet.add(content.getActionReference()); } assertTrue("Content list does not contain expected content.", CollectionUtils.isEqualCollection(actionRefStartSet, actionRefEndSet)); }
From source file:org.sonar.server.issue.AddTagsAction.java
@Override @SuppressWarnings("unchecked") protected Collection<String> getTagsToSet(Context context, Collection<String> tagsFromParams) { return CollectionUtils.union(context.issue().tags(), tagsFromParams); }
From source file:org.xbmc.android.jsonrpc.generator.model.Namespace.java
@SuppressWarnings("unchecked") public static Collection<Namespace> getAll() { return CollectionUtils.union(TYPES.values(), METHODS.values()); }
From source file:ru.ksu.niimm.cll.mocassin.util.GraphMetricUtils.java
/** * this method computes Jaccard coefficient for neighbors of a given pair of * structural elements/* www . j a va 2 s .co m*/ */ public static float computeNeighborJaccard(Collection<?> iNeighbors, Collection<?> jNeighbors) { int intersection = CollectionUtils.intersection(iNeighbors, jNeighbors).size(); int union = CollectionUtils.union(iNeighbors, jNeighbors).size(); float jaccard = (float) intersection / union; return jaccard; }
From source file:scratch.joshua.jung_2_0.core.SimpleDirectedSparseGraph.java
public Collection getNeighbors(V vertex) { return CollectionUtils.union(this.getPredecessors(vertex), this.getSuccessors(vertex)); }
From source file:scratch.joshua.jung_2_0.core.SimpleDirectedSparseGraph.java
public Collection getIncidentEdges(V vertex) { return CollectionUtils.union(this.getInEdges(vertex), this.getOutEdges(vertex)); }
From source file:test.edu.uci.ics.jung.algorithms.cluster.TestWeakComponentClusterer.java
public void testComponentHasIsolate() { Graph graph = getGraph();//from w ww. j av a 2 s .c om GraphUtils.addVertices(graph, 5); Indexer id = Indexer.getIndexer(graph); GraphUtils.addEdge(graph, (Vertex) id.getVertex(0), (Vertex) id.getVertex(1)); GraphUtils.addEdge(graph, (Vertex) id.getVertex(0), (Vertex) id.getVertex(2)); GraphUtils.addEdge(graph, (Vertex) id.getVertex(2), (Vertex) id.getVertex(3)); WeakComponentClusterer wcSearch = new WeakComponentClusterer(); ClusterSet componentList = wcSearch.extract(graph); Assert.assertEquals(componentList.size(), 2); Set z = componentList.getCluster(0); Set z1 = componentList.getCluster(1); assertFalse(CollectionUtils.containsAny(z, z1)); assertEquals(graph.getVertices(), new HashSet(CollectionUtils.union(z, z1))); }
From source file:test.edu.uci.ics.jung.algorithms.cluster.TestWeakComponentClusterer.java
public void testComponentAllIsolates() { Graph graph = getGraph();/* w ww.j av a 2s. c o m*/ GraphUtils.addVertices(graph, 2); WeakComponentClusterer wcSearch = new WeakComponentClusterer(); ClusterSet componentList = wcSearch.extract(graph); Assert.assertEquals(componentList.size(), 2); Set z = componentList.getCluster(0); Set z1 = componentList.getCluster(1); assertFalse(CollectionUtils.containsAny(z, z1)); assertEquals(graph.getVertices(), new HashSet(CollectionUtils.union(z, z1))); }
From source file:test.edu.uci.ics.jung.algorithms.cluster.TestWeakComponentClusterer.java
public void testExtractTwoComponents() { Graph graph = getGraph();/*from w w w. j ava 2 s . c o m*/ GraphUtils.addVertices(graph, 5); Indexer id = Indexer.getIndexer(graph); GraphUtils.addEdge(graph, (Vertex) id.getVertex(0), (Vertex) id.getVertex(1)); GraphUtils.addEdge(graph, (Vertex) id.getVertex(0), (Vertex) id.getVertex(2)); GraphUtils.addEdge(graph, (Vertex) id.getVertex(3), (Vertex) id.getVertex(4)); WeakComponentClusterer wcSearch = new WeakComponentClusterer(); ClusterSet componentList = wcSearch.extract(graph); Assert.assertEquals(componentList.size(), 2); Set z = componentList.getCluster(0); Set z1 = componentList.getCluster(1); assertFalse(CollectionUtils.containsAny(z, z1)); assertEquals(graph.getVertices(), new HashSet(CollectionUtils.union(z, z1))); }