From d15db10831691348f22f415aeba00cd5f771b663 Mon Sep 17 00:00:00 2001
From: Ankur Dave <ankurdave@gmail.com>
Date: Fri, 18 Oct 2013 19:43:33 -0700
Subject: [PATCH] Add a unit test for Graph.mapEdges

---
 .../scala/org/apache/spark/graph/GraphSuite.scala   | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/graph/src/test/scala/org/apache/spark/graph/GraphSuite.scala b/graph/src/test/scala/org/apache/spark/graph/GraphSuite.scala
index ff0306eaa3..b501bac2a2 100644
--- a/graph/src/test/scala/org/apache/spark/graph/GraphSuite.scala
+++ b/graph/src/test/scala/org/apache/spark/graph/GraphSuite.scala
@@ -20,6 +20,19 @@ class GraphSuite extends FunSuite with LocalSparkContext {
     }
   }
 
+  test("mapEdges") {
+    withSpark(new SparkContext("local", "test")) { sc =>
+      val n = 3
+      val star = Graph(sc.parallelize((1 to n).map(x => (0: Vid, x: Vid))))
+      val starWithEdgeAttrs = star.mapEdges(e => e.dstId)
+
+      // map(_.copy()) is a workaround for https://github.com/amplab/graphx/issues/25
+      val edges = starWithEdgeAttrs.edges.map(_.copy()).collect()
+      assert(edges.size === n)
+      assert(edges.toSet === (1 to n).map(x => Edge(0, x, x)).toSet)
+    }
+  }
+
   test("aggregateNeighbors") {
     withSpark(new SparkContext("local", "test")) { sc =>
       val n = 3
-- 
GitLab