@@ -0,0 +1,1418 @@
+package org.deeplearning4j.spark.util;%0A%0Aimport org.apache.spark.api.java.JavaPairRDD;%0Aimport org.apache.spark.api.java.JavaRDD;%0Aimport org.deeplearning4j.spark.BaseSparkTest;%0Aimport org.deeplearning4j.spark.api.Repartition;%0Aimport org.junit.Test;%0Aimport scala.Tuple2;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport static junit.framework.TestCase.assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertTrue;%0A%0A/**%0A * Created by Alex on 03/07/2016.%0A */%0Apublic class TestRepartitioning extends BaseSparkTest%7B%0A%0A    @Test%0A    public void testRepartitioning()%7B%0A        List%3CString%3E list = new ArrayList%3C%3E();%0A        for( int i=0; i%3C1000; i++ )%7B%0A            list.add(String.valueOf(i));%0A        %7D%0A%0A        JavaRDD%3CString%3E rdd = sc.parallelize(list);%0A        rdd = rdd.repartition(200);%0A%0A        JavaRDD%3CString%3E rdd2 = SparkUtils.repartitionBalanceIfRequired(rdd, Repartition.Always, 100, 10);%0A        assertFalse(rdd == rdd2);   //Should be different objects due to repartitioning%0A%0A        assertEquals(10, rdd2.partitions().size());%0A        for( int i=0; i%3C10; i++ )%7B%0A            List%3CString%3E partition = rdd2.collectPartitions(new int%5B%5D%7Bi%7D)%5B0%5D;%0A            System.out.println(%22Partition %22 + i + %22 size: %22 + partition.size());%0A            assertEquals(100, partition.size());    //Should be exactly 100, for the util method (but NOT spark .repartition)%0A        %7D%0A    %7D%0A%7D%0A

Add test for repartitioning