Program: 162748
Project: 162748
Buggy source:
@Test public void testKMeansSpeed() throws Exception {
  Map<String,Object> overlayConfig=new HashMap<>();
  overlayConfig.put("String_Node_Str",KMeansSpeedModelManager.class.getName());
  overlayConfig.put("String_Node_Str",6);
  overlayConfig.put("String_Node_Str","String_Node_Str");
  overlayConfig.put("String_Node_Str","String_Node_Str");
  Config config=ConfigUtils.overlayOn(overlayConfig,getConfig());
  startMessaging();
  List<Pair<String,String>> updates=startServerProduceConsumeTopics(config,new MockKMeansInputGenerator(),new MockKMeansModelGenerator(),300,1);
  updates.forEach(update -> log.info("String_Node_Str",update));
  int numUpdates=updates.size();
  assertGreaterOrEqual(updates.size(),NUM_CLUSTERS + 1);
  assertEquals("String_Node_Str",updates.get(0).getFirst());
  PMML pmml=PMMLUtils.fromString(updates.get(0).getSecond());
  Model model=pmml.getModels().get(0);
  assertInstanceOf(model,ClusteringModel.class);
  ClusteringModel clusteringModel=(ClusteringModel)model;
  assertEquals(NUM_CLUSTERS,clusteringModel.getNumberOfClusters().intValue());
  List<Cluster> clusters=clusteringModel.getClusters();
  Map<Integer,ClusterInfo> clusterInfos=new HashMap<>();
  for (int i=1; i < numUpdates; i++) {
    Pair<String,String> update=updates.get(i);
    assertEquals("String_Node_Str",update.getFirst());
    List<?> fields=TextUtils.readJSON(update.getSecond(),List.class);
    int clusterID=(Integer)fields.get(0);
    double[] updatedCenter=TextUtils.convertViaJSON(fields.get(1),double[].class);
    int updatedClusterSize=(Integer)fields.get(2);
    clusterInfos.put(clusterID,new ClusterInfo(clusterID,updatedCenter,updatedClusterSize));
  }
  assertEquals(3,clusterInfos.size());
  for (  ClusterInfo clusterInfo : clusterInfos.values()) {
    int id=clusterInfo.getID();
    Cluster cluster=clusters.get(id);
    String[] tokens=TextUtils.parseDelimited(cluster.getArray().getValue(),' ');
    double[] modelCenter=VectorMath.parseVector(tokens);
    double[] updatedCenter=clusterInfo.getCenter();
    assertEquals(tokens.length,modelCenter.length);
    assertFalse(Arrays.equals(modelCenter,updatedCenter));
    assertArrayEquals(updatedCenter,MockKMeansInputGenerator.UPDATE_POINTS[id],0.1);
    long updatedClusterSize=clusterInfo.getCount();
    assertGreater(updatedClusterSize,cluster.getSize());
    assertEquals(100 + cluster.getSize(),updatedClusterSize);
  }
}

Fixed version (ground truth):
@Test public void testKMeansSpeed() throws Exception {
  Map<String,Object> overlayConfig=new HashMap<>();
  overlayConfig.put("String_Node_Str",KMeansSpeedModelManager.class.getName());
  overlayConfig.put("String_Node_Str",6);
  overlayConfig.put("String_Node_Str","String_Node_Str");
  overlayConfig.put("String_Node_Str","String_Node_Str");
  Config config=ConfigUtils.overlayOn(overlayConfig,getConfig());
  startMessaging();
  List<Pair<String,String>> updates=startServerProduceConsumeTopics(config,new MockKMeansInputGenerator(),new MockKMeansModelGenerator(),300,1);
  updates.forEach(update -> log.info("String_Node_Str",update));
  int numUpdates=updates.size();
  assertGreaterOrEqual(updates.size(),NUM_CLUSTERS + 1);
  assertEquals("String_Node_Str",updates.get(0).getFirst());
  PMML pmml=PMMLUtils.fromString(updates.get(0).getSecond());
  Model model=pmml.getModels().get(0);
  assertInstanceOf(model,ClusteringModel.class);
  ClusteringModel clusteringModel=(ClusteringModel)model;
  assertEquals(NUM_CLUSTERS,clusteringModel.getNumberOfClusters());
  List<Cluster> clusters=clusteringModel.getClusters();
  Map<Integer,ClusterInfo> clusterInfos=new HashMap<>();
  for (int i=1; i < numUpdates; i++) {
    Pair<String,String> update=updates.get(i);
    assertEquals("String_Node_Str",update.getFirst());
    List<?> fields=TextUtils.readJSON(update.getSecond(),List.class);
    int clusterID=(Integer)fields.get(0);
    double[] updatedCenter=TextUtils.convertViaJSON(fields.get(1),double[].class);
    int updatedClusterSize=(Integer)fields.get(2);
    clusterInfos.put(clusterID,new ClusterInfo(clusterID,updatedCenter,updatedClusterSize));
  }
  assertEquals(3,clusterInfos.size());
  for (  ClusterInfo clusterInfo : clusterInfos.values()) {
    int id=clusterInfo.getID();
    Cluster cluster=clusters.get(id);
    String[] tokens=TextUtils.parseDelimited(cluster.getArray().getValue(),' ');
    double[] modelCenter=VectorMath.parseVector(tokens);
    double[] updatedCenter=clusterInfo.getCenter();
    assertEquals(tokens.length,modelCenter.length);
    assertFalse(Arrays.equals(modelCenter,updatedCenter));
    assertArrayEquals(updatedCenter,MockKMeansInputGenerator.UPDATE_POINTS[id],0.1);
    long updatedClusterSize=clusterInfo.getCount();
    assertGreater(updatedClusterSize,cluster.getSize());
    assertEquals(100 + cluster.getSize(),updatedClusterSize);
  }
}