Program: 115446
Project: 115446
Buggy source:
@Test(timeOut=APPLICATION_TEST_TIMEOUT,groups={"String_Node_Str"}) public void testApplicationBusting() throws Exception {
  TopologyHandler topologyHandler=TopologyHandler.getInstance();
  String autoscalingPolicyId="String_Node_Str";
  boolean addedScalingPolicy=restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "String_Node_Str"+ autoscalingPolicyId+ "String_Node_Str",RestConstants.AUTOSCALING_POLICIES,RestConstants.AUTOSCALING_POLICIES_NAME);
  assertTrue(addedScalingPolicy);
  boolean addedC1=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
  assertTrue(addedC1);
  boolean addedC2=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
  assertTrue(addedC2);
  boolean addedC3=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
  assertTrue(addedC3);
  boolean addedG1=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGE_GROUPS,RestConstants.CARTRIDGE_GROUPS_NAME);
  assertTrue(addedG1);
  CartridgeGroupBean beanG1=(CartridgeGroupBean)restClient.getEntity(RestConstants.CARTRIDGE_GROUPS,"String_Node_Str",CartridgeGroupBean.class,RestConstants.CARTRIDGE_GROUPS_NAME);
  assertEquals(beanG1.getName(),"String_Node_Str");
  boolean addedN1=restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.NETWORK_PARTITIONS,RestConstants.NETWORK_PARTITIONS_NAME);
  assertTrue(addedN1);
  boolean addedN2=restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.NETWORK_PARTITIONS,RestConstants.NETWORK_PARTITIONS_NAME);
  assertTrue(addedN2);
  boolean addedDep=restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.DEPLOYMENT_POLICIES,RestConstants.DEPLOYMENT_POLICIES_NAME);
  assertTrue(addedDep);
  boolean added=restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.APPLICATIONS,RestConstants.APPLICATIONS_NAME);
  assertTrue(added);
  ApplicationBean bean=(ApplicationBean)restClient.getEntity(RestConstants.APPLICATIONS,"String_Node_Str",ApplicationBean.class,RestConstants.APPLICATIONS_NAME);
  assertEquals(bean.getApplicationId(),"String_Node_Str");
  boolean addAppPolicy=restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.APPLICATION_POLICIES,RestConstants.APPLICATION_POLICIES_NAME);
  assertTrue(addAppPolicy);
  ApplicationPolicyBean policyBean=(ApplicationPolicyBean)restClient.getEntity(RestConstants.APPLICATION_POLICIES,"String_Node_Str",ApplicationPolicyBean.class,RestConstants.APPLICATION_POLICIES_NAME);
  String resourcePath=RestConstants.APPLICATIONS + "String_Node_Str" + "String_Node_Str"+ RestConstants.APPLICATIONS_DEPLOY+ "String_Node_Str"+ "String_Node_Str";
  boolean deployed=restClient.deployEntity(resourcePath,RestConstants.APPLICATIONS_NAME);
  assertTrue(deployed);
  topologyHandler.assertApplicationStatus(bean.getApplicationId(),ApplicationStatus.Active);
  topologyHandler.assertGroupActivation(bean.getApplicationId());
  topologyHandler.assertClusterActivation(bean.getApplicationId());
  boolean removedGroup=restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS,"String_Node_Str",RestConstants.CARTRIDGE_GROUPS_NAME);
  assertFalse(removedGroup);
  boolean removedAuto=restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,autoscalingPolicyId,RestConstants.AUTOSCALING_POLICIES_NAME);
  assertFalse(removedAuto);
  boolean removedNet=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
  assertFalse(removedNet);
  boolean removedDep=restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,"String_Node_Str",RestConstants.DEPLOYMENT_POLICIES_NAME);
  assertFalse(removedDep);
  String resourcePathUndeploy=RestConstants.APPLICATIONS + "String_Node_Str" + "String_Node_Str"+ RestConstants.APPLICATIONS_UNDEPLOY;
  boolean unDeployed=restClient.undeployEntity(resourcePathUndeploy,RestConstants.APPLICATIONS_NAME);
  assertTrue(unDeployed);
  boolean undeploy=topologyHandler.assertApplicationUndeploy("String_Node_Str");
  if (!undeploy) {
    log.info("String_Node_Str" + "String_Node_Str");
    restClient.undeployEntity(RestConstants.APPLICATIONS + "String_Node_Str" + "String_Node_Str"+ RestConstants.APPLICATIONS_UNDEPLOY+ "String_Node_Str",RestConstants.APPLICATIONS);
    boolean forceUndeployed=topologyHandler.assertApplicationUndeploy("String_Node_Str");
    assertEquals(String.format("String_Node_Str","String_Node_Str"),forceUndeployed);
  }
  boolean removed=restClient.removeEntity(RestConstants.APPLICATIONS,"String_Node_Str",RestConstants.APPLICATIONS_NAME);
  assertTrue(removed);
  ApplicationBean beanRemoved=(ApplicationBean)restClient.getEntity(RestConstants.APPLICATIONS,"String_Node_Str",ApplicationBean.class,RestConstants.APPLICATIONS_NAME);
  assertNull(beanRemoved);
  removedGroup=restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS,"String_Node_Str",RestConstants.CARTRIDGE_GROUPS_NAME);
  assertTrue(removedGroup);
  boolean removedC1=restClient.removeEntity(RestConstants.CARTRIDGES,"String_Node_Str",RestConstants.CARTRIDGES_NAME);
  assertTrue(removedC1);
  boolean removedC2=restClient.removeEntity(RestConstants.CARTRIDGES,"String_Node_Str",RestConstants.CARTRIDGES_NAME);
  assertTrue(removedC2);
  boolean removedC3=restClient.removeEntity(RestConstants.CARTRIDGES,"String_Node_Str",RestConstants.CARTRIDGES_NAME);
  assertTrue(removedC3);
  removedAuto=restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,autoscalingPolicyId,RestConstants.AUTOSCALING_POLICIES_NAME);
  assertTrue(removedAuto);
  removedDep=restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,"String_Node_Str",RestConstants.DEPLOYMENT_POLICIES_NAME);
  assertTrue(removedDep);
  removedNet=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
  assertFalse(removedNet);
  boolean removedN2=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
  assertFalse(removedN2);
  boolean removeAppPolicy=restClient.removeEntity(RestConstants.APPLICATION_POLICIES,"String_Node_Str",RestConstants.APPLICATION_POLICIES_NAME);
  assertTrue(removeAppPolicy);
  removedNet=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
  assertTrue(removedNet);
  removedN2=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
  assertTrue(removedN2);
}

Fixed version (ground truth):
@Test(timeOut=APPLICATION_TEST_TIMEOUT,groups={"String_Node_Str"}) public void testApplicationBusting() throws Exception {
  TopologyHandler topologyHandler=TopologyHandler.getInstance();
  String autoscalingPolicyId="String_Node_Str";
  boolean addedScalingPolicy=restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "String_Node_Str"+ autoscalingPolicyId+ "String_Node_Str",RestConstants.AUTOSCALING_POLICIES,RestConstants.AUTOSCALING_POLICIES_NAME);
  assertTrue(addedScalingPolicy);
  boolean addedC1=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
  assertTrue(addedC1);
  boolean addedC2=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
  assertTrue(addedC2);
  boolean addedC3=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
  assertTrue(addedC3);
  boolean addedG1=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGE_GROUPS,RestConstants.CARTRIDGE_GROUPS_NAME);
  assertTrue(addedG1);
  CartridgeGroupBean beanG1=(CartridgeGroupBean)restClient.getEntity(RestConstants.CARTRIDGE_GROUPS,"String_Node_Str",CartridgeGroupBean.class,RestConstants.CARTRIDGE_GROUPS_NAME);
  assertEquals(beanG1.getName(),"String_Node_Str");
  boolean addedN1=restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.NETWORK_PARTITIONS,RestConstants.NETWORK_PARTITIONS_NAME);
  assertTrue(addedN1);
  boolean addedN2=restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.NETWORK_PARTITIONS,RestConstants.NETWORK_PARTITIONS_NAME);
  assertTrue(addedN2);
  boolean addedDep=restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.DEPLOYMENT_POLICIES,RestConstants.DEPLOYMENT_POLICIES_NAME);
  assertTrue(addedDep);
  boolean added=restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.APPLICATIONS,RestConstants.APPLICATIONS_NAME);
  assertTrue(added);
  ApplicationBean bean=(ApplicationBean)restClient.getEntity(RestConstants.APPLICATIONS,"String_Node_Str",ApplicationBean.class,RestConstants.APPLICATIONS_NAME);
  assertEquals(bean.getApplicationId(),"String_Node_Str");
  boolean addAppPolicy=restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.APPLICATION_POLICIES,RestConstants.APPLICATION_POLICIES_NAME);
  assertTrue(addAppPolicy);
  ApplicationPolicyBean policyBean=(ApplicationPolicyBean)restClient.getEntity(RestConstants.APPLICATION_POLICIES,"String_Node_Str",ApplicationPolicyBean.class,RestConstants.APPLICATION_POLICIES_NAME);
  String resourcePath=RestConstants.APPLICATIONS + "String_Node_Str" + "String_Node_Str"+ RestConstants.APPLICATIONS_DEPLOY+ "String_Node_Str"+ "String_Node_Str";
  boolean deployed=restClient.deployEntity(resourcePath,RestConstants.APPLICATIONS_NAME);
  assertTrue(deployed);
  topologyHandler.assertApplicationStatus(bean.getApplicationId(),ApplicationStatus.Active);
  topologyHandler.assertGroupActivation(bean.getApplicationId());
  topologyHandler.assertClusterActivation(bean.getApplicationId());
  boolean removedGroup=restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS,"String_Node_Str",RestConstants.CARTRIDGE_GROUPS_NAME);
  assertFalse(removedGroup);
  boolean removedAuto=restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,autoscalingPolicyId,RestConstants.AUTOSCALING_POLICIES_NAME);
  assertFalse(removedAuto);
  boolean removedNet=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
  assertFalse(removedNet);
  boolean removedDep=restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,"String_Node_Str",RestConstants.DEPLOYMENT_POLICIES_NAME);
  assertFalse(removedDep);
  String resourcePathUndeploy=RestConstants.APPLICATIONS + "String_Node_Str" + "String_Node_Str"+ RestConstants.APPLICATIONS_UNDEPLOY;
  boolean unDeployed=restClient.undeployEntity(resourcePathUndeploy,RestConstants.APPLICATIONS_NAME);
  assertTrue(unDeployed);
  boolean undeploy=topologyHandler.assertApplicationUndeploy("String_Node_Str");
  if (!undeploy) {
    log.info("String_Node_Str" + "String_Node_Str");
    restClient.undeployEntity(RestConstants.APPLICATIONS + "String_Node_Str" + "String_Node_Str"+ RestConstants.APPLICATIONS_UNDEPLOY+ "String_Node_Str",RestConstants.APPLICATIONS);
    boolean forceUndeployed=topologyHandler.assertApplicationUndeploy("String_Node_Str");
    assertTrue(String.format("String_Node_Str","String_Node_Str"),forceUndeployed);
  }
  boolean removed=restClient.removeEntity(RestConstants.APPLICATIONS,"String_Node_Str",RestConstants.APPLICATIONS_NAME);
  assertTrue(removed);
  ApplicationBean beanRemoved=(ApplicationBean)restClient.getEntity(RestConstants.APPLICATIONS,"String_Node_Str",ApplicationBean.class,RestConstants.APPLICATIONS_NAME);
  assertNull(beanRemoved);
  removedGroup=restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS,"String_Node_Str",RestConstants.CARTRIDGE_GROUPS_NAME);
  assertTrue(removedGroup);
  boolean removedC1=restClient.removeEntity(RestConstants.CARTRIDGES,"String_Node_Str",RestConstants.CARTRIDGES_NAME);
  assertTrue(removedC1);
  boolean removedC2=restClient.removeEntity(RestConstants.CARTRIDGES,"String_Node_Str",RestConstants.CARTRIDGES_NAME);
  assertTrue(removedC2);
  boolean removedC3=restClient.removeEntity(RestConstants.CARTRIDGES,"String_Node_Str",RestConstants.CARTRIDGES_NAME);
  assertTrue(removedC3);
  removedAuto=restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,autoscalingPolicyId,RestConstants.AUTOSCALING_POLICIES_NAME);
  assertTrue(removedAuto);
  removedDep=restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,"String_Node_Str",RestConstants.DEPLOYMENT_POLICIES_NAME);
  assertTrue(removedDep);
  removedNet=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
  assertFalse(removedNet);
  boolean removedN2=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
  assertFalse(removedN2);
  boolean removeAppPolicy=restClient.removeEntity(RestConstants.APPLICATION_POLICIES,"String_Node_Str",RestConstants.APPLICATION_POLICIES_NAME);
  assertTrue(removeAppPolicy);
  removedNet=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
  assertTrue(removedNet);
  removedN2=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
  assertTrue(removedN2);
}