Program: 115483
Project: 115483
Buggy source:
@Test public void testTerminationBehavior(){
  try {
    log.info("String_Node_Str");
    String autoscalingPolicyId="String_Node_Str";
    TopologyHandler topologyHandler=TopologyHandler.getInstance();
    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 addedC5=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
    assertTrue(addedC5);
    boolean addedC6=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
    assertTrue(addedC6);
    boolean addedC7=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
    assertTrue(addedC7);
    boolean addedC8=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
    assertTrue(addedC8);
    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);
    boolean addedG2=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGE_GROUPS,RestConstants.CARTRIDGE_GROUPS_NAME);
    assertTrue(addedG2);
    boolean addedG3=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGE_GROUPS,RestConstants.CARTRIDGE_GROUPS_NAME);
    assertTrue(addedG3);
    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 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);
    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);
    String groupId=topologyHandler.generateId(bean.getApplicationId(),"String_Node_Str",bean.getApplicationId() + "String_Node_Str");
    String clusterIdC3=topologyHandler.getClusterIdFromAlias(bean.getApplicationId(),"String_Node_Str");
    String clusterIdC4=topologyHandler.getClusterIdFromAlias(bean.getApplicationId(),"String_Node_Str");
    String clusterIdC2=topologyHandler.getClusterIdFromAlias(bean.getApplicationId(),"String_Node_Str");
    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);
    boolean removedC4=restClient.removeEntity(RestConstants.CARTRIDGES,"String_Node_Str",RestConstants.CARTRIDGES_NAME);
    assertTrue(removedC4);
    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 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);
    log.info("String_Node_Str");
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    assertTrue("String_Node_Str",false);
  }
}

Fixed version (ground truth):
@Test public void testTerminationBehavior(){
  try {
    log.info("String_Node_Str");
    String autoscalingPolicyId="String_Node_Str";
    TopologyHandler topologyHandler=TopologyHandler.getInstance();
    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 addedC5=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
    assertTrue(addedC5);
    boolean addedC6=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
    assertTrue(addedC6);
    boolean addedC7=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
    assertTrue(addedC7);
    boolean addedC8=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
    assertTrue(addedC8);
    boolean addedG2=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGE_GROUPS,RestConstants.CARTRIDGE_GROUPS_NAME);
    assertTrue(addedG2);
    boolean addedG3=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGE_GROUPS,RestConstants.CARTRIDGE_GROUPS_NAME);
    assertTrue(addedG3);
    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 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);
    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);
    String group6=topologyHandler.generateId(bean.getApplicationId(),"String_Node_Str",bean.getApplicationId() + "String_Node_Str");
    String group8=topologyHandler.generateId(bean.getApplicationId(),"String_Node_Str",bean.getApplicationId() + "String_Node_Str");
    String lb=topologyHandler.getClusterIdFromAlias(bean.getApplicationId(),"String_Node_Str");
    String tomcat=topologyHandler.getClusterIdFromAlias(bean.getApplicationId(),"String_Node_Str");
    assertCreationOfNodes(lb,tomcat);
    assertCreationOfNodes(tomcat,group6);
    assertCreationOfNodesInParallel(group6,group8);
    assertCreationOfNodes(tomcat,group8);
    String group7=topologyHandler.generateId(bean.getApplicationId(),"String_Node_Str",bean.getApplicationId() + "String_Node_Str");
    String groupTom2=topologyHandler.generateId(bean.getApplicationId(),"String_Node_Str",bean.getApplicationId() + "String_Node_Str");
    assertCreationOfNodesInParallel(group7,groupTom2);
    String group7Tomcat=topologyHandler.getClusterIdFromAlias(bean.getApplicationId(),"String_Node_Str");
    String group7Tomcat1=topologyHandler.getClusterIdFromAlias(bean.getApplicationId(),"String_Node_Str");
    assertCreationOfNodes(group7Tomcat,group7Tomcat1);
    String groupTom2Tomcat2=topologyHandler.getClusterIdFromAlias(bean.getApplicationId(),"String_Node_Str");
    String groupTom2Tomcat3=topologyHandler.getClusterIdFromAlias(bean.getApplicationId(),"String_Node_Str");
    assertCreationOfNodes(groupTom2Tomcat2,groupTom2Tomcat3);
    String group8Tomcat2=topologyHandler.getClusterIdFromAlias(bean.getApplicationId(),"String_Node_Str");
    String group8Tomcat=topologyHandler.getClusterIdFromAlias(bean.getApplicationId(),"String_Node_Str");
    assertCreationOfNodesInParallel(group8Tomcat2,group8Tomcat);
    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);
    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);
    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);
    boolean removedC4=restClient.removeEntity(RestConstants.CARTRIDGES,"String_Node_Str",RestConstants.CARTRIDGES_NAME);
    assertTrue(removedC4);
    boolean removedC5=restClient.removeEntity(RestConstants.CARTRIDGES,"String_Node_Str",RestConstants.CARTRIDGES_NAME);
    assertTrue(removedC5);
    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 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);
    log.info("String_Node_Str");
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    assertTrue("String_Node_Str",false);
  }
}