Program: 115448
Project: 115448
Buggy source:
@Test(timeOut=APPLICATION_TEST_TIMEOUT,groups={"String_Node_Str"}) public void testDeployApplication() 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);
  assertEquals(addedScalingPolicy,true);
  boolean addedC1=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
  assertEquals(addedC1,true);
  boolean addedC2=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
  assertEquals(addedC2,true);
  boolean addedC3=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
  assertEquals(addedC3,true);
  boolean addedG1=restClient.addEntity(RESOURCES_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(RESOURCES_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(RESOURCES_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(RESOURCES_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(RESOURCES_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(RESOURCES_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.assertApplicationStatus(bean.getApplicationId(),ApplicationStatus.Active);
  topologyHandler.assertGroupActivation(bean.getApplicationId());
  topologyHandler.assertClusterActivation(bean.getApplicationId());
  boolean updated=restClient.updateEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.APPLICATIONS,RestConstants.APPLICATIONS_NAME);
  assertEquals(updated,true);
  ApplicationBean updatedBean=(ApplicationBean)restClient.getEntity(RestConstants.APPLICATIONS,"String_Node_Str",ApplicationBean.class,RestConstants.APPLICATIONS_NAME);
  assertEquals(updatedBean.getApplicationId(),"String_Node_Str");
  Application application=ApplicationManager.getApplications().getApplication(bean.getApplicationId());
  Group group=application.getGroupRecursively("String_Node_Str");
  assertEquals(group.getGroupMaxInstances(),3);
  assertEquals(group.getGroupMinInstances(),2);
  log.info("String_Node_Str" + bean.getApplicationId() + "String_Node_Str"+ group.getUniqueIdentifier());
  ClusterDataHolder clusterDataHolder=application.getClusterDataHolderRecursivelyByAlias("String_Node_Str");
  assertEquals(clusterDataHolder.getMaxInstances(),3);
  assertEquals(clusterDataHolder.getMinInstances(),2);
  log.info("String_Node_Str" + bean.getApplicationId() + "String_Node_Str"+ clusterDataHolder.getClusterId());
  topologyHandler.assertGroupInstanceCount(bean.getApplicationId(),"String_Node_Str",2);
  topologyHandler.assertClusterMinMemberCount(bean.getApplicationId(),2);
  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.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,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);
}

Fixed version (ground truth):
@Test(timeOut=APPLICATION_TEST_TIMEOUT,groups={"String_Node_Str"}) public void testDeployApplication() 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);
  assertEquals(addedScalingPolicy,true);
  boolean addedC1=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
  assertEquals(addedC1,true);
  boolean addedC2=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
  assertEquals(addedC2,true);
  boolean addedC3=restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.CARTRIDGES,RestConstants.CARTRIDGES_NAME);
  assertEquals(addedC3,true);
  boolean addedG1=restClient.addEntity(RESOURCES_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(RESOURCES_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(RESOURCES_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(RESOURCES_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(RESOURCES_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(RESOURCES_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.assertApplicationStatus(bean.getApplicationId(),ApplicationStatus.Active);
  topologyHandler.assertGroupActivation(bean.getApplicationId());
  topologyHandler.assertClusterActivation(bean.getApplicationId());
  boolean updated=restClient.updateEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "String_Node_Str"+ "String_Node_Str",RestConstants.APPLICATIONS,RestConstants.APPLICATIONS_NAME);
  assertEquals(updated,true);
  ApplicationBean updatedBean=(ApplicationBean)restClient.getEntity(RestConstants.APPLICATIONS,"String_Node_Str",ApplicationBean.class,RestConstants.APPLICATIONS_NAME);
  assertEquals(updatedBean.getApplicationId(),"String_Node_Str");
  Application application=ApplicationManager.getApplications().getApplication(bean.getApplicationId());
  Group group=application.getGroupRecursively("String_Node_Str");
  assertEquals(group.getGroupMaxInstances(),3);
  assertEquals(group.getGroupMinInstances(),2);
  log.info("String_Node_Str" + bean.getApplicationId() + "String_Node_Str"+ group.getUniqueIdentifier());
  ClusterDataHolder clusterDataHolder=application.getClusterDataHolderRecursivelyByAlias("String_Node_Str");
  assertEquals(clusterDataHolder.getMaxInstances(),3);
  assertEquals(clusterDataHolder.getMinInstances(),2);
  log.info("String_Node_Str" + bean.getApplicationId() + "String_Node_Str"+ clusterDataHolder.getClusterId());
  topologyHandler.assertGroupInstanceCount(bean.getApplicationId(),"String_Node_Str",2);
  topologyHandler.assertClusterMinMemberCount(bean.getApplicationId(),2);
  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.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);
  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);
}