Program: 115449
Project: 115449
Buggy source:
@Test(timeOut=APPLICATION_TEST_TIMEOUT,groups={"String_Node_Str","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 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 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.assertClusterActivation(bean.getApplicationId());
  assertClusterWithRoundRobinAlgorithm(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.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(forceUndeployed,true,String.format("String_Node_Str","String_Node_Str"));
  }
  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 removedC1=restClient.removeEntity(RestConstants.CARTRIDGES,"String_Node_Str",RestConstants.CARTRIDGES_NAME);
  assertEquals(removedC1,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 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);
}

Fixed version (ground truth):
@Test(timeOut=APPLICATION_TEST_TIMEOUT,groups={"String_Node_Str","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 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 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.assertClusterActivation(bean.getApplicationId());
  assertClusterWithRoundRobinAlgorithm(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.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);
  boolean removedC1=restClient.removeEntity(RestConstants.CARTRIDGES,"String_Node_Str",RestConstants.CARTRIDGES_NAME);
  assertEquals(removedC1,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 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);
}