Buggy code:
public class KMeansPlusPlusClustererTest { @ Test public void dimension2 ( ) { KMeansPlusPlusClusterer < EuclideanIntegerPoint > transformer = new KMeansPlusPlusClusterer < EuclideanIntegerPoint > ( new Random ( 1746432956321L ) ) ; EuclideanIntegerPoint [ ] points = new EuclideanIntegerPoint [ ] { new EuclideanIntegerPoint ( new int [ ] { - 15 , 3 } ) , new EuclideanIntegerPoint ( new int [ ] { - 15 , 4 } ) , new EuclideanIntegerPoint ( new int [ ] { - 15 , 5 } ) , new EuclideanIntegerPoint ( new int [ ] { - 14 , 3 } ) , new EuclideanIntegerPoint ( new int [ ] { - 14 , 5 } ) , new EuclideanIntegerPoint ( new int [ ] { - 13 , 3 } ) , new EuclideanIntegerPoint ( new int [ ] { - 13 , 4 } ) , new EuclideanIntegerPoint ( new int [ ] { - 13 , 5 } ) , new EuclideanIntegerPoint ( new int [ ] { - 1 , 0 } ) , new EuclideanIntegerPoint ( new int [ ] { - 1 , - 1 } ) , new EuclideanIntegerPoint ( new int [ ] { 0 , - 1 } ) , new EuclideanIntegerPoint ( new int [ ] { 1 , - 1 } ) , new EuclideanIntegerPoint ( new int [ ] { 1 , - 2 } ) , new EuclideanIntegerPoint ( new int [ ] { 13 , 3 } ) , new EuclideanIntegerPoint ( new int [ ] { 13 , 4 } ) , new EuclideanIntegerPoint ( new int [ ] { 14 , 4 } ) , new EuclideanIntegerPoint ( new int [ ] { 14 , 7 } ) , new EuclideanIntegerPoint ( new int [ ] { 16 , 5 } ) , new EuclideanIntegerPoint ( new int [ ] { 16 , 6 } ) , new EuclideanIntegerPoint ( new int [ ] { 17 , 4 } ) , new EuclideanIntegerPoint ( new int [ ] { 17 , 7 } ) } ; <START_BUG> List < Cluster < EuclideanIntegerPoint > > clusters = transformer . cluster ( Arrays . asList ( points ) , 3 , 10 ) ; <END_BUG> Assert . assertEquals ( 3 , clusters . size ( ) ) ; boolean cluster1Found = false ; boolean cluster2Found = false ; boolean cluster3Found = false ; for ( Cluster < EuclideanIntegerPoint > cluster : clusters ) { int [ ] center = cluster . getCenter ( ) . getPoint ( ) ; if ( ( center [ 0 ] ) < 0 ) { cluster1Found = true ; Assert . assertEquals ( 8 , cluster . getPoints ( ) . size ( ) ) ; Assert . assertEquals ( ( - 14 ) , center [ 0 ] ) ; Assert . assertEquals ( 4 , center [ 1 ] ) ; } else if ( ( center [ 1 ] ) < 0 ) { cluster2Found = true ; Assert . assertEquals ( 5 , cluster . getPoints ( ) . size ( ) ) ; Assert . assertEquals ( 0 , center [ 0 ] ) ; Assert . assertEquals ( ( - 1 ) , center [ 1 ] ) ; } else { cluster3Found = true ; Assert . assertEquals ( 8 , cluster . getPoints ( ) . size ( ) ) ; Assert . assertEquals ( 15 , center [ 0 ] ) ; Assert . assertEquals ( 5 , center [ 1 ] ) ; } } Assert . assertTrue ( cluster1Found ) ; Assert . assertTrue ( cluster2Found ) ; Assert . assertTrue ( cluster3Found ) ; } @ Test public void testPerformClusterAnalysisDegenerate ( ) { } @ Test public void testCertainSpace ( ) { } private class CloseIntegerPoint implements Clusterable < KMeansPlusPlusClustererTest . CloseIntegerPoint > { public CloseIntegerPoint ( EuclideanIntegerPoint point ) { } public double distanceFrom ( KMeansPlusPlusClustererTest . CloseIntegerPoint p ) { } public KMeansPlusPlusClustererTest . CloseIntegerPoint centroidOf ( Collection < KMeansPlusPlusClustererTest . CloseIntegerPoint > p ) { } @ Override public boolean equals ( Object o ) { } @ Override public int hashCode ( ) { } private EuclideanIntegerPoint euclideanPoint ; } @ Test public void testSmallDistances ( ) { } @ Test ( expected = NumberIsTooSmallException . class ) public void testPerformClusterAnalysisToManyClusters ( ) { } }

Fix:
List < Cluster < EuclideanIntegerPoint > > clusters = transformer . cluster ( Arrays . asList ( points ) , 3 , 5 , 10 ) ;