Program: 48325
Project: 48325
Buggy source:
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Test(groups={"String_Node_Str"}) public void testClusterConfigWithExternalHDFS() throws Exception {
  String[] hdfsArray=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  ClusterCreate spec=new ClusterCreate();
  spec.setName("String_Node_Str");
  List<String> rps=new ArrayList<String>();
  rps.add("String_Node_Str");
  spec.setRpNames(rps);
  spec.setNetworkConfig(createNetConfigs());
  spec.setDistro("String_Node_Str");
  spec.setDistroVendor(Constants.DEFAULT_VENDOR);
  spec.setExternalHDFS(hdfsArray[0]);
  String clusterConfigJson="String_Node_Str" + hdfsArray[1] + "String_Node_Str";
  Map clusterConfig=(new Gson()).fromJson(clusterConfigJson,Map.class);
  spec.setConfiguration((Map<String,Object>)(clusterConfig.get("String_Node_Str")));
  NodeGroupCreate ng0=new NodeGroupCreate();
  List<String> computerMasterRoles=new ArrayList<String>();
  computerMasterRoles.add("String_Node_Str");
  ng0.setRoles(computerMasterRoles);
  ng0.setName("String_Node_Str");
  ng0.setInstanceNum(1);
  ng0.setInstanceType(InstanceType.LARGE);
  String ng0ConfigJson="String_Node_Str" + hdfsArray[2] + "String_Node_Str";
  Map ng0Config=(new Gson()).fromJson(ng0ConfigJson,Map.class);
  ng0.setConfiguration((Map<String,Object>)(ng0Config.get("String_Node_Str")));
  NodeGroupCreate ng1=new NodeGroupCreate();
  List<String> computeWorkerRoles=new ArrayList<String>();
  computeWorkerRoles.add("String_Node_Str");
  ng1.setRoles(computeWorkerRoles);
  ng1.setName("String_Node_Str");
  ng1.setInstanceNum(4);
  ng1.setInstanceType(InstanceType.MEDIUM);
  StorageRead storage=new StorageRead();
  storage.setType("String_Node_Str");
  storage.setSizeGB(10);
  ng1.setStorage(storage);
  String ng1ConfigJson="String_Node_Str" + hdfsArray[3] + "String_Node_Str";
  Map ng1Config=(new Gson()).fromJson(ng1ConfigJson,Map.class);
  ng1.setConfiguration((Map<String,Object>)(ng1Config.get("String_Node_Str")));
  NodeGroupCreate ng2=new NodeGroupCreate();
  ng2.setRoles(computeWorkerRoles);
  ng2.setName("String_Node_Str");
  ng2.setInstanceNum(2);
  ng2.setInstanceType(InstanceType.MEDIUM);
  StorageRead storageCompute=new StorageRead();
  storageCompute.setType("String_Node_Str");
  storageCompute.setSizeGB(10);
  ng2.setStorage(storageCompute);
  NodeGroupCreate[] ngs=new NodeGroupCreate[]{ng0,ng1,ng2};
  spec.setNodeGroups(ngs);
  spec=ClusterSpecFactory.getCustomizedSpec(spec,null);
  clusterConfigMgr.createClusterConfig(spec);
  ClusterEntity cluster=clusterEntityMgr.findClusterById(1l);
  List<ClusterEntity> cs=clusterEntityMgr.findAllClusters();
  for (  ClusterEntity c : cs) {
    System.out.println(c.getId());
  }
  cluster=clusterEntityMgr.findByName("String_Node_Str");
  Assert.assertTrue(cluster != null);
  Assert.assertEquals(cluster.getAdvancedProperties(),"String_Node_Str");
  ClusterRead clusterRead=clusterEntityMgr.toClusterRead("String_Node_Str");
  Assert.assertEquals(clusterRead.getExternalHDFS(),"String_Node_Str");
  ClusterCreate attrs=clusterConfigMgr.getClusterConfig("String_Node_Str");
  String manifest=gson.toJson(attrs);
  System.out.println(manifest);
  Assert.assertTrue(Pattern.compile("String_Node_Str" + hdfsArray[0] + "String_Node_Str").matcher(manifest).matches(),"String_Node_Str");
  Assert.assertTrue(manifest.indexOf(hdfsArray[1]) == -1,"String_Node_Str");
  Assert.assertTrue(manifest.indexOf(hdfsArray[2]) == -1,"String_Node_Str");
  Assert.assertTrue(manifest.indexOf(hdfsArray[3]) == -1,"String_Node_Str");
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Test(groups={"String_Node_Str"}) public void testClusterConfigWithExternalHDFS() throws Exception {
  String[] hdfsArray=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  ClusterCreate spec=new ClusterCreate();
  spec.setName("String_Node_Str");
  List<String> rps=new ArrayList<String>();
  rps.add("String_Node_Str");
  spec.setRpNames(rps);
  spec.setNetworkConfig(createNetConfigs());
  spec.setDistro("String_Node_Str");
  spec.setDistroVendor(Constants.DEFAULT_VENDOR);
  spec.setExternalHDFS(hdfsArray[0]);
  String clusterConfigJson="String_Node_Str" + hdfsArray[1] + "String_Node_Str";
  Map clusterConfig=(new Gson()).fromJson(clusterConfigJson,Map.class);
  spec.setConfiguration((Map<String,Object>)(clusterConfig.get("String_Node_Str")));
  NodeGroupCreate ng0=new NodeGroupCreate();
  List<String> computerMasterRoles=new ArrayList<String>();
  computerMasterRoles.add("String_Node_Str");
  ng0.setRoles(computerMasterRoles);
  ng0.setName("String_Node_Str");
  ng0.setInstanceNum(1);
  ng0.setInstanceType(InstanceType.LARGE);
  String ng0ConfigJson="String_Node_Str" + hdfsArray[2] + "String_Node_Str";
  Map ng0Config=(new Gson()).fromJson(ng0ConfigJson,Map.class);
  ng0.setConfiguration((Map<String,Object>)(ng0Config.get("String_Node_Str")));
  NodeGroupCreate ng1=new NodeGroupCreate();
  List<String> computeWorkerRoles=new ArrayList<String>();
  computeWorkerRoles.add("String_Node_Str");
  ng1.setRoles(computeWorkerRoles);
  ng1.setName("String_Node_Str");
  ng1.setInstanceNum(4);
  ng1.setInstanceType(InstanceType.MEDIUM);
  StorageRead storage=new StorageRead();
  storage.setType("String_Node_Str");
  storage.setSizeGB(10);
  ng1.setStorage(storage);
  String ng1ConfigJson="String_Node_Str" + hdfsArray[3] + "String_Node_Str";
  Map ng1Config=(new Gson()).fromJson(ng1ConfigJson,Map.class);
  ng1.setConfiguration((Map<String,Object>)(ng1Config.get("String_Node_Str")));
  NodeGroupCreate ng2=new NodeGroupCreate();
  ng2.setRoles(computeWorkerRoles);
  ng2.setName("String_Node_Str");
  ng2.setInstanceNum(2);
  ng2.setInstanceType(InstanceType.MEDIUM);
  StorageRead storageCompute=new StorageRead();
  storageCompute.setType("String_Node_Str");
  storageCompute.setSizeGB(10);
  ng2.setStorage(storageCompute);
  NodeGroupCreate[] ngs=new NodeGroupCreate[]{ng0,ng1,ng2};
  spec.setNodeGroups(ngs);
  spec=ClusterSpecFactory.getCustomizedSpec(spec,null);
  clusterConfigMgr.createClusterConfig(spec);
  ClusterEntity cluster=clusterEntityMgr.findClusterById(1l);
  List<ClusterEntity> cs=clusterEntityMgr.findAllClusters();
  for (  ClusterEntity c : cs) {
    System.out.println(c.getId());
  }
  cluster=clusterEntityMgr.findByName("String_Node_Str");
  Assert.assertTrue(cluster != null);
  Assert.assertEquals(cluster.getAdvancedProperties(),"String_Node_Str");
  ClusterRead clusterRead=clusterEntityMgr.toClusterRead("String_Node_Str",true);
  Assert.assertEquals(clusterRead.getExternalHDFS(),"String_Node_Str");
  ClusterCreate attrs=clusterConfigMgr.getClusterConfig("String_Node_Str");
  String manifest=gson.toJson(attrs);
  System.out.println(manifest);
  Assert.assertTrue(Pattern.compile("String_Node_Str" + hdfsArray[0] + "String_Node_Str").matcher(manifest).matches(),"String_Node_Str");
  Assert.assertTrue(manifest.indexOf(hdfsArray[1]) == -1,"String_Node_Str");
  Assert.assertTrue(manifest.indexOf(hdfsArray[2]) == -1,"String_Node_Str");
  Assert.assertTrue(manifest.indexOf(hdfsArray[3]) == -1,"String_Node_Str");
}