Program: 7056
Project: 7056
Buggy source:
@Test public void testDeleteDatasetsOnly() throws Exception {
  CConfiguration cConf=getInjector().getInstance(CConfiguration.class);
  assertResponseCode(200,createNamespace(NAME));
  assertResponseCode(200,getNamespace(NAME));
  NamespacedLocationFactory namespacedLocationFactory=getInjector().getInstance(NamespacedLocationFactory.class);
  Location nsLocation=namespacedLocationFactory.get(Id.Namespace.from(NAME));
  Assert.assertTrue(nsLocation.exists());
  DatasetFramework dsFramework=getInjector().getInstance(DatasetFramework.class);
  deploy(AppWithServices.class,Constants.Gateway.API_VERSION_3_TOKEN,NAME);
  deploy(AppWithDataset.class,Constants.Gateway.API_VERSION_3_TOKEN,NAME);
  Id.DatasetInstance myDataset=Id.DatasetInstance.from(NAME,"String_Node_Str");
  Assert.assertTrue(dsFramework.hasInstance(myDataset));
  Id.Program program=Id.Program.from(NAME_ID,"String_Node_Str",ProgramType.SERVICE,"String_Node_Str");
  startProgram(program);
  boolean resetEnabled=cConf.getBoolean(Constants.Dangerous.UNRECOVERABLE_RESET);
  cConf.setBoolean(Constants.Dangerous.UNRECOVERABLE_RESET,false);
  assertResponseCode(403,deleteNamespaceData(NAME));
  Assert.assertTrue(nsLocation.exists());
  cConf.setBoolean(Constants.Dangerous.UNRECOVERABLE_RESET,resetEnabled);
  assertResponseCode(409,deleteNamespace(NAME));
  Assert.assertTrue(nsLocation.exists());
  stopProgram(program);
  assertResponseCode(200,deleteNamespaceData(NAME));
  Assert.assertTrue(nsLocation.exists());
  Assert.assertTrue(getAppList(NAME).size() == 2);
  Assert.assertTrue(getAppDetails(NAME,"String_Node_Str").get("String_Node_Str").getAsString().equals("String_Node_Str"));
  Assert.assertTrue(getAppDetails(NAME,"String_Node_Str").get("String_Node_Str").getAsString().equals("String_Node_Str"));
  assertResponseCode(200,getNamespace(NAME));
  Assert.assertFalse(dsFramework.hasInstance(myDataset));
  assertResponseCode(200,deleteNamespace(NAME));
  assertResponseCode(404,getNamespace(NAME));
}

Fixed version (ground truth):
@Test public void testDeleteDatasetsOnly() throws Exception {
  CConfiguration cConf=getInjector().getInstance(CConfiguration.class);
  assertResponseCode(200,createNamespace(NAME));
  assertResponseCode(200,getNamespace(NAME));
  NamespacedLocationFactory namespacedLocationFactory=getInjector().getInstance(NamespacedLocationFactory.class);
  Location nsLocation=namespacedLocationFactory.get(Id.Namespace.from(NAME));
  Assert.assertTrue(nsLocation.exists());
  DatasetFramework dsFramework=getInjector().getInstance(DatasetFramework.class);
  deploy(AppWithServices.class,Constants.Gateway.API_VERSION_3_TOKEN,NAME);
  deploy(AppWithDataset.class,Constants.Gateway.API_VERSION_3_TOKEN,NAME);
  Id.DatasetInstance myDataset=Id.DatasetInstance.from(NAME,"String_Node_Str");
  Assert.assertTrue(dsFramework.hasInstance(myDataset));
  Id.Program program=Id.Program.from(NAME_ID,"String_Node_Str",ProgramType.SERVICE,"String_Node_Str");
  startProgram(program);
  boolean resetEnabled=cConf.getBoolean(Constants.Dangerous.UNRECOVERABLE_RESET);
  cConf.setBoolean(Constants.Dangerous.UNRECOVERABLE_RESET,false);
  assertResponseCode(403,deleteNamespaceData(NAME));
  Assert.assertTrue(nsLocation.exists());
  cConf.setBoolean(Constants.Dangerous.UNRECOVERABLE_RESET,resetEnabled);
  assertResponseCode(409,deleteNamespaceData(NAME));
  Assert.assertTrue(nsLocation.exists());
  stopProgram(program);
  assertResponseCode(200,deleteNamespaceData(NAME));
  Assert.assertTrue(nsLocation.exists());
  Assert.assertTrue(getAppList(NAME).size() == 2);
  Assert.assertTrue(getAppDetails(NAME,"String_Node_Str").get("String_Node_Str").getAsString().equals("String_Node_Str"));
  Assert.assertTrue(getAppDetails(NAME,"String_Node_Str").get("String_Node_Str").getAsString().equals("String_Node_Str"));
  assertResponseCode(200,getNamespace(NAME));
  Assert.assertFalse(dsFramework.hasInstance(myDataset));
  assertResponseCode(200,deleteNamespace(NAME));
  assertResponseCode(404,getNamespace(NAME));
}