Program: 7055
Project: 7055
Buggy source:
private void testAdapterLifeCycle(String namespaceId,String templateId,String adapterName,AdapterConfig adapterConfig) throws Exception {
  String deleteURL=getVersionedAPIPath("String_Node_Str" + templateId,Constants.Gateway.API_VERSION_3_TOKEN,namespaceId);
  HttpResponse response=createAdapter(namespaceId,adapterName,adapterConfig);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  response=createAdapter(namespaceId,adapterName,adapterConfig);
  Assert.assertEquals(409,response.getStatusLine().getStatusCode());
  response=listAdapters(namespaceId);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  List<AdapterDetail> list=readResponse(response,ADAPTER_SPEC_LIST_TYPE);
  Assert.assertEquals(1,list.size());
  checkIsExpected(adapterConfig,list.get(0));
  response=getAdapter(namespaceId,adapterName);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  AdapterDetail receivedAdapterConfig=readResponse(response,AdapterDetail.class);
  checkIsExpected(adapterConfig,receivedAdapterConfig);
  List<JsonObject> deployedApps=getAppList(namespaceId);
  Assert.assertEquals(1,deployedApps.size());
  JsonObject deployedApp=deployedApps.get(0);
  Assert.assertEquals(templateId,deployedApp.get("String_Node_Str").getAsString());
  String status=getAdapterStatus(Id.Adapter.from(namespaceId,adapterName));
  Assert.assertEquals("String_Node_Str",status);
  response=startStopAdapter(namespaceId,adapterName,"String_Node_Str");
  Assert.assertEquals(409,response.getStatusLine().getStatusCode());
  response=startStopAdapter(namespaceId,adapterName,"String_Node_Str");
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  status=getAdapterStatus(Id.Adapter.from(namespaceId,adapterName));
  Assert.assertEquals("String_Node_Str",status);
  deleteApplication(1,deleteURL,403);
  response=deleteAdapter(namespaceId,adapterName);
  Assert.assertEquals(403,response.getStatusLine().getStatusCode());
  response=startStopAdapter(namespaceId,adapterName,"String_Node_Str");
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  deleteApplication(1,deleteURL,403);
  response=deleteAdapter(namespaceId,adapterName);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  response=getAdapter(namespaceId,adapterName);
  Assert.assertEquals(404,response.getStatusLine().getStatusCode());
  deleteApplication(60,deleteURL,404);
  deployedApps=getAppList(namespaceId);
  Assert.assertTrue(deployedApps.isEmpty());
  response=createAdapter(namespaceId,adapterName,adapterConfig);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  response=deleteAdapter(namespaceId,adapterName);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  deleteApplication(60,deleteURL,404);
  deployedApps=getAppList(namespaceId);
  Assert.assertTrue(deployedApps.isEmpty());
}

Fixed version (ground truth):
private void testAdapterLifeCycle(String namespaceId,String templateId,String adapterName,AdapterConfig adapterConfig) throws Exception {
  String deleteURL=getVersionedAPIPath("String_Node_Str" + templateId,Constants.Gateway.API_VERSION_3_TOKEN,namespaceId);
  HttpResponse response=createAdapter(namespaceId,adapterName,adapterConfig);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  response=createAdapter(namespaceId,adapterName,adapterConfig);
  Assert.assertEquals(409,response.getStatusLine().getStatusCode());
  response=listAdapters(namespaceId);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  List<AdapterDetail> list=readResponse(response,ADAPTER_SPEC_LIST_TYPE);
  Assert.assertEquals(1,list.size());
  checkIsExpected(adapterConfig,list.get(0));
  response=getAdapter(namespaceId,adapterName);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  AdapterDetail receivedAdapterConfig=readResponse(response,AdapterDetail.class);
  checkIsExpected(adapterConfig,receivedAdapterConfig);
  List<JsonObject> deployedApps=getAppList(namespaceId);
  Assert.assertEquals(1,deployedApps.size());
  JsonObject deployedApp=deployedApps.get(0);
  Assert.assertEquals(templateId,deployedApp.get("String_Node_Str").getAsString());
  String status=getAdapterStatus(Id.Adapter.from(namespaceId,adapterName));
  Assert.assertEquals("String_Node_Str",status);
  response=startStopAdapter(namespaceId,adapterName,"String_Node_Str");
  Assert.assertEquals(409,response.getStatusLine().getStatusCode());
  response=startStopAdapter(namespaceId,adapterName,"String_Node_Str");
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  status=getAdapterStatus(Id.Adapter.from(namespaceId,adapterName));
  Assert.assertEquals("String_Node_Str",status);
  deleteApplication(1,deleteURL,403);
  response=deleteAdapter(namespaceId,adapterName);
  Assert.assertEquals(409,response.getStatusLine().getStatusCode());
  response=startStopAdapter(namespaceId,adapterName,"String_Node_Str");
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  deleteApplication(1,deleteURL,403);
  response=deleteAdapter(namespaceId,adapterName);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  response=getAdapter(namespaceId,adapterName);
  Assert.assertEquals(404,response.getStatusLine().getStatusCode());
  deleteApplication(60,deleteURL,404);
  deployedApps=getAppList(namespaceId);
  Assert.assertTrue(deployedApps.isEmpty());
  response=createAdapter(namespaceId,adapterName,adapterConfig);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  response=deleteAdapter(namespaceId,adapterName);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  deleteApplication(60,deleteURL,404);
  deployedApps=getAppList(namespaceId);
  Assert.assertTrue(deployedApps.isEmpty());
}