Program: 174777
Project: 174777
Buggy source:
public void testWorkflowDefinitionsGet() throws Exception {
  Response response=sendRequest(new GetRequest(URL_WORKFLOW_DEFINITIONS),200);
  assertEquals(Status.STATUS_OK,response.getStatus());
  JSONObject json=new JSONObject(response.getContentAsString());
  JSONArray results=json.getJSONArray("String_Node_Str");
  assertNotNull(results);
  assertTrue(results.length() > 0);
  boolean adhocWorkflowPresent=false;
  for (int i=0; i < results.length(); i++) {
    JSONObject workflowDefinitionJSON=results.getJSONObject(i);
    assertTrue(workflowDefinitionJSON.has("String_Node_Str"));
    assertTrue(workflowDefinitionJSON.getString("String_Node_Str").length() > 0);
    assertTrue(workflowDefinitionJSON.has("String_Node_Str"));
    String url=workflowDefinitionJSON.getString("String_Node_Str");
    assertTrue(url.length() > 0);
    assertTrue(url.startsWith("String_Node_Str"));
    assertTrue(workflowDefinitionJSON.has("String_Node_Str"));
    assertTrue(workflowDefinitionJSON.getString("String_Node_Str").length() > 0);
    assertTrue(workflowDefinitionJSON.has("String_Node_Str"));
    assertTrue(workflowDefinitionJSON.getString("String_Node_Str").length() > 0);
    assertTrue(workflowDefinitionJSON.has("String_Node_Str"));
    assertTrue(workflowDefinitionJSON.getString("String_Node_Str").length() > 0);
    if (getAdhocWorkflowDefinitionName().equals(workflowDefinitionJSON.getString("String_Node_Str"))) {
      adhocWorkflowPresent=true;
    }
  }
  assertTrue("String_Node_Str",adhocWorkflowPresent);
  String exclude=getAdhocWorkflowDefinitionName();
  response=sendRequest(new GetRequest(URL_WORKFLOW_DEFINITIONS + "String_Node_Str" + exclude),200);
  assertEquals(Status.STATUS_OK,response.getStatus());
  json=new JSONObject(response.getContentAsString());
  results=json.getJSONArray("String_Node_Str");
  assertNotNull(results);
  adhocWorkflowPresent=false;
  for (int i=0; i < results.length(); i++) {
    JSONObject workflowDefinitionJSON=results.getJSONObject(i);
    String name=workflowDefinitionJSON.getString("String_Node_Str");
    if (exclude.equals(name)) {
      adhocWorkflowPresent=true;
      break;
    }
  }
  assertFalse("String_Node_Str",adhocWorkflowPresent);
  exclude=getAdhocWorkflowDefinitionName() + "String_Node_Str";
  response=sendRequest(new GetRequest(URL_WORKFLOW_DEFINITIONS + "String_Node_Str" + exclude),200);
  assertEquals(Status.STATUS_OK,response.getStatus());
  json=new JSONObject(response.getContentAsString());
  results=json.getJSONArray("String_Node_Str");
  assertNotNull(results);
  adhocWorkflowPresent=false;
  boolean wcmWorkflowsPresent=false;
  for (int i=0; i < results.length(); i++) {
    JSONObject workflowDefinitionJSON=results.getJSONObject(i);
    String name=workflowDefinitionJSON.getString("String_Node_Str");
    if (name.equals(getAdhocWorkflowDefinitionName())) {
      adhocWorkflowPresent=true;
    }
    if (name.startsWith("String_Node_Str")) {
      wcmWorkflowsPresent=true;
    }
  }
  assertFalse("String_Node_Str",adhocWorkflowPresent);
  assertFalse("String_Node_Str",wcmWorkflowsPresent);
}

Fixed version (ground truth):
public void testWorkflowDefinitionsGet() throws Exception {
  Response response=sendRequest(new GetRequest(URL_WORKFLOW_DEFINITIONS),200);
  assertEquals(Status.STATUS_OK,response.getStatus());
  JSONObject json=new JSONObject(response.getContentAsString());
  JSONArray results=json.getJSONArray("String_Node_Str");
  assertNotNull(results);
  assertTrue(results.length() > 0);
  boolean adhocWorkflowPresent=false;
  for (int i=0; i < results.length(); i++) {
    JSONObject workflowDefinitionJSON=results.getJSONObject(i);
    assertTrue(workflowDefinitionJSON.has("String_Node_Str"));
    assertTrue(workflowDefinitionJSON.getString("String_Node_Str").length() > 0);
    assertTrue(workflowDefinitionJSON.has("String_Node_Str"));
    String url=workflowDefinitionJSON.getString("String_Node_Str");
    assertTrue(url.length() > 0);
    assertTrue(url.startsWith("String_Node_Str"));
    assertTrue(workflowDefinitionJSON.has("String_Node_Str"));
    assertTrue(workflowDefinitionJSON.getString("String_Node_Str").length() > 0);
    assertTrue(workflowDefinitionJSON.has("String_Node_Str"));
    String title=workflowDefinitionJSON.getString("String_Node_Str");
    assertTrue(title.length() > 0);
    assertTrue(workflowDefinitionJSON.has("String_Node_Str"));
    String description=workflowDefinitionJSON.getString("String_Node_Str");
    assertTrue(description.length() > 0);
    if (getAdhocWorkflowDefinitionName().equals(workflowDefinitionJSON.getString("String_Node_Str"))) {
      assertEquals(getAdhocWorkflowDefinitionTitle(),title);
      assertEquals(getAdhocWorkflowDefinitionDescription(),description);
      adhocWorkflowPresent=true;
    }
  }
  assertTrue("String_Node_Str",adhocWorkflowPresent);
  String exclude=getAdhocWorkflowDefinitionName();
  response=sendRequest(new GetRequest(URL_WORKFLOW_DEFINITIONS + "String_Node_Str" + exclude),200);
  assertEquals(Status.STATUS_OK,response.getStatus());
  json=new JSONObject(response.getContentAsString());
  results=json.getJSONArray("String_Node_Str");
  assertNotNull(results);
  adhocWorkflowPresent=false;
  for (int i=0; i < results.length(); i++) {
    JSONObject workflowDefinitionJSON=results.getJSONObject(i);
    String name=workflowDefinitionJSON.getString("String_Node_Str");
    if (exclude.equals(name)) {
      adhocWorkflowPresent=true;
      break;
    }
  }
  assertFalse("String_Node_Str",adhocWorkflowPresent);
  exclude=getAdhocWorkflowDefinitionName() + "String_Node_Str";
  response=sendRequest(new GetRequest(URL_WORKFLOW_DEFINITIONS + "String_Node_Str" + exclude),200);
  assertEquals(Status.STATUS_OK,response.getStatus());
  json=new JSONObject(response.getContentAsString());
  results=json.getJSONArray("String_Node_Str");
  assertNotNull(results);
  adhocWorkflowPresent=false;
  boolean wcmWorkflowsPresent=false;
  for (int i=0; i < results.length(); i++) {
    JSONObject workflowDefinitionJSON=results.getJSONObject(i);
    String name=workflowDefinitionJSON.getString("String_Node_Str");
    if (name.equals(getAdhocWorkflowDefinitionName())) {
      adhocWorkflowPresent=true;
    }
    if (name.startsWith("String_Node_Str")) {
      wcmWorkflowsPresent=true;
    }
  }
  assertFalse("String_Node_Str",adhocWorkflowPresent);
  assertFalse("String_Node_Str",wcmWorkflowsPresent);
}