Program: 162747
Project: 162747
Buggy source:
@Test public void testKMeans() throws Exception {
  Path tempDir=getTempDir();
  Path dataDir=tempDir.resolve("String_Node_Str");
  Path modelDir=tempDir.resolve("String_Node_Str");
  Map<String,Object> overlayConfig=new HashMap<>();
  overlayConfig.put("String_Node_Str",KMeansUpdate.class.getName());
  ConfigUtils.set(overlayConfig,"String_Node_Str",dataDir);
  ConfigUtils.set(overlayConfig,"String_Node_Str",modelDir);
  overlayConfig.put("String_Node_Str",GEN_INTERVAL_SEC);
  overlayConfig.put("String_Node_Str",NUM_CLUSTERS);
  overlayConfig.put("String_Node_Str",5);
  overlayConfig.put("String_Node_Str",NUM_FEATURES);
  overlayConfig.put("String_Node_Str","String_Node_Str");
  overlayConfig.put("String_Node_Str",EVALUATION_STRATEGY);
  Config config=ConfigUtils.overlayOn(overlayConfig,getConfig());
  startMessaging();
  List<Pair<String,String>> updates=startServerProduceConsumeTopics(config,new RandomKMeansDataGenerator(NUM_FEATURES),DATA_TO_WRITE,WRITE_INTERVAL_MSEC);
  List<Path> modelInstanceDirs=IOUtils.listFiles(modelDir,"String_Node_Str");
  int generations=modelInstanceDirs.size();
  checkIntervals(generations,DATA_TO_WRITE,WRITE_INTERVAL_MSEC,GEN_INTERVAL_SEC);
  for (  Path modelInstanceDir : modelInstanceDirs) {
    Path modelFile=modelInstanceDir.resolve(MLUpdate.MODEL_FILE_NAME);
    assertNonEmpty(modelFile);
    PMMLUtils.read(modelFile);
  }
  InputSchema schema=new InputSchema(config);
  for (  Pair<String,String> km : updates) {
    String type=km.getFirst();
    String value=km.getSecond();
    assertContains(Arrays.asList("String_Node_Str","String_Node_Str"),type);
    PMML pmml=AppPMMLUtils.readPMMLFromUpdateKeyMessage(type,value,null);
    checkHeader(pmml.getHeader());
    checkDataDictionary(schema,pmml.getDataDictionary());
    Model rootModel=pmml.getModels().get(0);
    ClusteringModel clusteringModel=(ClusteringModel)rootModel;
    assertEquals(NUM_CLUSTERS,clusteringModel.getNumberOfClusters().intValue());
    assertEquals(NUM_CLUSTERS,clusteringModel.getClusters().size());
    assertEquals(NUM_FEATURES,clusteringModel.getClusteringFields().size());
    assertEquals(ComparisonMeasure.Kind.DISTANCE,clusteringModel.getComparisonMeasure().getKind());
    assertEquals(NUM_FEATURES,clusteringModel.getClusters().get(0).getArray().getN().intValue());
    for (    Cluster cluster : clusteringModel.getClusters()) {
      assertGreater(cluster.getSize(),0);
    }
  }
}

Fixed version (ground truth):
@Test public void testKMeans() throws Exception {
  Path tempDir=getTempDir();
  Path dataDir=tempDir.resolve("String_Node_Str");
  Path modelDir=tempDir.resolve("String_Node_Str");
  Map<String,Object> overlayConfig=new HashMap<>();
  overlayConfig.put("String_Node_Str",KMeansUpdate.class.getName());
  ConfigUtils.set(overlayConfig,"String_Node_Str",dataDir);
  ConfigUtils.set(overlayConfig,"String_Node_Str",modelDir);
  overlayConfig.put("String_Node_Str",GEN_INTERVAL_SEC);
  overlayConfig.put("String_Node_Str",NUM_CLUSTERS);
  overlayConfig.put("String_Node_Str",5);
  overlayConfig.put("String_Node_Str",NUM_FEATURES);
  overlayConfig.put("String_Node_Str","String_Node_Str");
  overlayConfig.put("String_Node_Str",EVALUATION_STRATEGY);
  Config config=ConfigUtils.overlayOn(overlayConfig,getConfig());
  startMessaging();
  List<Pair<String,String>> updates=startServerProduceConsumeTopics(config,new RandomKMeansDataGenerator(NUM_FEATURES),DATA_TO_WRITE,WRITE_INTERVAL_MSEC);
  List<Path> modelInstanceDirs=IOUtils.listFiles(modelDir,"String_Node_Str");
  int generations=modelInstanceDirs.size();
  checkIntervals(generations,DATA_TO_WRITE,WRITE_INTERVAL_MSEC,GEN_INTERVAL_SEC);
  for (  Path modelInstanceDir : modelInstanceDirs) {
    Path modelFile=modelInstanceDir.resolve(MLUpdate.MODEL_FILE_NAME);
    assertNonEmpty(modelFile);
    PMMLUtils.read(modelFile);
  }
  InputSchema schema=new InputSchema(config);
  for (  Pair<String,String> km : updates) {
    String type=km.getFirst();
    String value=km.getSecond();
    assertContains(Arrays.asList("String_Node_Str","String_Node_Str"),type);
    PMML pmml=AppPMMLUtils.readPMMLFromUpdateKeyMessage(type,value,null);
    checkHeader(pmml.getHeader());
    checkDataDictionary(schema,pmml.getDataDictionary());
    Model rootModel=pmml.getModels().get(0);
    ClusteringModel clusteringModel=(ClusteringModel)rootModel;
    assertEquals(NUM_CLUSTERS,clusteringModel.getNumberOfClusters());
    assertEquals(NUM_CLUSTERS,clusteringModel.getClusters().size());
    assertEquals(NUM_FEATURES,clusteringModel.getClusteringFields().size());
    assertEquals(ComparisonMeasure.Kind.DISTANCE,clusteringModel.getComparisonMeasure().getKind());
    assertEquals(NUM_FEATURES,clusteringModel.getClusters().get(0).getArray().getN().intValue());
    for (    Cluster cluster : clusteringModel.getClusters()) {
      assertGreater(cluster.getSize(),0);
    }
  }
}