Program: 115503
Project: 115503
Buggy source:
@Test public void testDeployApplication(){
  try {
    log.info("String_Node_Str");
    String autoscalingPolicyId="String_Node_Str";
    boolean addedScalingPolicy=restClient.addEntity(TEST_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "String_Node_Str"+ autoscalingPolicyId+ "String_Node_Str",RestConstants.AUTOSCALING_POLICIES,RestConstants.AUTOSCALING_POLICIES_NAME);
    assertEquals(addedScalingPolicy,true);
    boolean addedC1=restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
    assertEquals(addedC1,true);
    boolean addedC2=restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
    assertEquals(addedC2,true);
    boolean addedC3=restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
    assertEquals(addedC3,true);
    boolean addedG1=restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGE_GROUPS,RestConstants.CARTRIDGE_GROUPS_NAME);
    assertEquals(addedG1,true);
    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(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.NETWORK_PARTITIONS,RestConstants.NETWORK_PARTITIONS_NAME);
    assertEquals(addedN1,true);
    boolean addedN2=restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.NETWORK_PARTITIONS,RestConstants.NETWORK_PARTITIONS_NAME);
    assertEquals(addedN2,true);
    boolean addedDep=restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.DEPLOYMENT_POLICIES,RestConstants.DEPLOYMENT_POLICIES_NAME);
    assertEquals(addedDep,true);
    boolean added=restClient.addEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.APPLICATIONS,RestConstants.APPLICATIONS_NAME);
    assertEquals(added,true);
    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(TEST_PATH + RestConstants.APPLICATION_POLICIES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.APPLICATION_POLICIES,RestConstants.APPLICATION_POLICIES_NAME);
    assertEquals(addAppPolicy,true);
    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);
    assertEquals(deployed,true);
    TopologyHandler.getInstance().assertApplicationActivation(bean.getApplicationId());
    TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId());
    TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
    boolean removedAuto=restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,autoscalingPolicyId,RestConstants.AUTOSCALING_POLICIES_NAME);
    assertEquals(removedAuto,false);
    boolean removedNet=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
    assertEquals(removedNet,false);
    boolean removedDep=restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,"String_Node_Str",RestConstants.DEPLOYMENT_POLICIES_NAME);
    assertEquals(removedDep,false);
    String resourcePathUndeploy=RestConstants.APPLICATIONS + "String_Node_Str" + "String_Node_Str"+ RestConstants.APPLICATIONS_UNDEPLOY;
    boolean unDeployed=restClient.undeployEntity(resourcePathUndeploy,RestConstants.APPLICATIONS_NAME);
    assertEquals(unDeployed,true);
    boolean undeploy=TopologyHandler.getInstance().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.getInstance().assertApplicationUndeploy("String_Node_Str");
      assertEquals(String.format("String_Node_Str","String_Node_Str"),forceUndeployed,true);
    }
    boolean removed=restClient.removeEntity(RestConstants.APPLICATIONS,"String_Node_Str",RestConstants.APPLICATIONS_NAME);
    assertEquals(removed,true);
    ApplicationBean beanRemoved=(ApplicationBean)restClient.getEntity(RestConstants.APPLICATIONS,"String_Node_Str",ApplicationBean.class,RestConstants.APPLICATIONS_NAME);
    assertEquals(beanRemoved,null);
    boolean removedGroup=restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS,"String_Node_Str",RestConstants.CARTRIDGE_GROUPS_NAME);
    assertEquals(removedGroup,true);
    boolean removedC1=restClient.removeEntity(RestConstants.CARTRIDGES,"String_Node_Str",RestConstants.CARTRIDGES_NAME);
    assertEquals(removedC1,true);
    boolean removedC2=restClient.removeEntity(RestConstants.CARTRIDGES,"String_Node_Str",RestConstants.CARTRIDGES_NAME);
    assertEquals(removedC2,true);
    boolean removedC3=restClient.removeEntity(RestConstants.CARTRIDGES,"String_Node_Str",RestConstants.CARTRIDGES_NAME);
    assertEquals(removedC3,true);
    removedAuto=restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,autoscalingPolicyId,RestConstants.AUTOSCALING_POLICIES_NAME);
    assertEquals(removedAuto,true);
    removedDep=restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,"String_Node_Str",RestConstants.DEPLOYMENT_POLICIES_NAME);
    assertEquals(removedDep,true);
    removedNet=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
    assertEquals(removedNet,false);
    boolean removedN2=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
    assertEquals(removedN2,false);
    boolean removeAppPolicy=restClient.removeEntity(RestConstants.APPLICATION_POLICIES,"String_Node_Str",RestConstants.APPLICATION_POLICIES_NAME);
    assertEquals(removeAppPolicy,true);
    removedNet=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
    assertEquals(removedNet,true);
    removedN2=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
    assertEquals(removedN2,true);
    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 testDeployApplication(){
  try {
    log.info("String_Node_Str");
    String autoscalingPolicyId="String_Node_Str";
    boolean addedScalingPolicy=restClient.addEntity(TEST_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "String_Node_Str"+ autoscalingPolicyId+ "String_Node_Str",RestConstants.AUTOSCALING_POLICIES,RestConstants.AUTOSCALING_POLICIES_NAME);
    assertEquals(addedScalingPolicy,true);
    boolean addedC1=restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
    assertEquals(addedC1,true);
    boolean addedC2=restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
    assertEquals(addedC2,true);
    boolean addedC3=restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
    assertEquals(addedC3,true);
    boolean addedG1=restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGE_GROUPS,RestConstants.CARTRIDGE_GROUPS_NAME);
    assertEquals(addedG1,true);
    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(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.NETWORK_PARTITIONS,RestConstants.NETWORK_PARTITIONS_NAME);
    assertEquals(addedN1,true);
    boolean addedN2=restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.NETWORK_PARTITIONS,RestConstants.NETWORK_PARTITIONS_NAME);
    assertEquals(addedN2,true);
    boolean addedDep=restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.DEPLOYMENT_POLICIES,RestConstants.DEPLOYMENT_POLICIES_NAME);
    assertEquals(addedDep,true);
    boolean added=restClient.addEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.APPLICATIONS,RestConstants.APPLICATIONS_NAME);
    assertEquals(added,true);
    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(TEST_PATH + RestConstants.APPLICATION_POLICIES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.APPLICATION_POLICIES,RestConstants.APPLICATION_POLICIES_NAME);
    assertEquals(addAppPolicy,true);
    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);
    assertEquals(deployed,true);
    TopologyHandler.getInstance().assertApplicationActivation(bean.getApplicationId());
    TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId());
    TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
    boolean removedGroup=restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS,"String_Node_Str",RestConstants.CARTRIDGE_GROUPS_NAME);
    assertEquals(removedGroup,false);
    boolean removedAuto=restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,autoscalingPolicyId,RestConstants.AUTOSCALING_POLICIES_NAME);
    assertEquals(removedAuto,false);
    boolean removedNet=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
    assertEquals(removedNet,false);
    boolean removedDep=restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,"String_Node_Str",RestConstants.DEPLOYMENT_POLICIES_NAME);
    assertEquals(removedDep,false);
    String resourcePathUndeploy=RestConstants.APPLICATIONS + "String_Node_Str" + "String_Node_Str"+ RestConstants.APPLICATIONS_UNDEPLOY;
    boolean unDeployed=restClient.undeployEntity(resourcePathUndeploy,RestConstants.APPLICATIONS_NAME);
    assertEquals(unDeployed,true);
    boolean undeploy=TopologyHandler.getInstance().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.getInstance().assertApplicationUndeploy("String_Node_Str");
      assertEquals(String.format("String_Node_Str","String_Node_Str"),forceUndeployed,true);
    }
    boolean removed=restClient.removeEntity(RestConstants.APPLICATIONS,"String_Node_Str",RestConstants.APPLICATIONS_NAME);
    assertEquals(removed,true);
    ApplicationBean beanRemoved=(ApplicationBean)restClient.getEntity(RestConstants.APPLICATIONS,"String_Node_Str",ApplicationBean.class,RestConstants.APPLICATIONS_NAME);
    assertEquals(beanRemoved,null);
    removedGroup=restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS,"String_Node_Str",RestConstants.CARTRIDGE_GROUPS_NAME);
    assertEquals(removedGroup,true);
    boolean removedC1=restClient.removeEntity(RestConstants.CARTRIDGES,"String_Node_Str",RestConstants.CARTRIDGES_NAME);
    assertEquals(removedC1,true);
    boolean removedC2=restClient.removeEntity(RestConstants.CARTRIDGES,"String_Node_Str",RestConstants.CARTRIDGES_NAME);
    assertEquals(removedC2,true);
    boolean removedC3=restClient.removeEntity(RestConstants.CARTRIDGES,"String_Node_Str",RestConstants.CARTRIDGES_NAME);
    assertEquals(removedC3,true);
    removedAuto=restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,autoscalingPolicyId,RestConstants.AUTOSCALING_POLICIES_NAME);
    assertEquals(removedAuto,true);
    removedDep=restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,"String_Node_Str",RestConstants.DEPLOYMENT_POLICIES_NAME);
    assertEquals(removedDep,true);
    removedNet=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
    assertEquals(removedNet,false);
    boolean removedN2=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
    assertEquals(removedN2,false);
    boolean removeAppPolicy=restClient.removeEntity(RestConstants.APPLICATION_POLICIES,"String_Node_Str",RestConstants.APPLICATION_POLICIES_NAME);
    assertEquals(removeAppPolicy,true);
    removedNet=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
    assertEquals(removedNet,true);
    removedN2=restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,"String_Node_Str",RestConstants.NETWORK_PARTITIONS_NAME);
    assertEquals(removedN2,true);
    log.info("String_Node_Str");
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    assertTrue("String_Node_Str",false);
  }
}