Program: 7265
Project: 7265
Buggy source:
@Test public void testPreferences() throws Exception {
  Id.Namespace invalidNamespace=Id.Namespace.from("String_Node_Str");
  namespaceClient.create(new NamespaceMeta.Builder().setId(invalidNamespace.getId()).build());
  Map<String,String> propMap=client.getInstancePreferences();
  Assert.assertEquals(ImmutableMap.<String,String>of(),propMap);
  propMap.put("String_Node_Str","String_Node_Str");
  client.setInstancePreferences(propMap);
  Assert.assertEquals(propMap,client.getInstancePreferences());
  File jarFile=createAppJarFile(FakeApp.class);
  appClient.deploy(jarFile);
  propMap.put("String_Node_Str","String_Node_Str");
  client.setNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,propMap);
  Assert.assertEquals(propMap,client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,true));
  Assert.assertEquals(propMap,client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,false));
  Assert.assertTrue(client.getNamespacePreferences(invalidNamespace,false).isEmpty());
  Assert.assertEquals("String_Node_Str",client.getNamespacePreferences(invalidNamespace,true).get("String_Node_Str"));
  client.deleteNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID);
  propMap.put("String_Node_Str","String_Node_Str");
  Assert.assertEquals(propMap,client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,true));
  Assert.assertEquals(ImmutableMap.<String,String>of(),client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,false));
  propMap.put("String_Node_Str","String_Node_Str");
  client.setNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,propMap);
  Assert.assertEquals(propMap,client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,true));
  Assert.assertEquals(propMap,client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,false));
  propMap.put("String_Node_Str","String_Node_Str");
  client.setApplicationPreferences(FakeApp.ID,propMap);
  Assert.assertEquals(propMap,client.getApplicationPreferences(FakeApp.ID,true));
  Assert.assertEquals(propMap,client.getApplicationPreferences(FakeApp.ID,false));
  propMap.put("String_Node_Str","String_Node_Str");
  client.setProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),propMap);
  Assert.assertEquals(propMap,client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),true));
  Assert.assertEquals(propMap,client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),false));
  client.deleteProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0));
  propMap.put("String_Node_Str","String_Node_Str");
  Assert.assertTrue(client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),false).isEmpty());
  Assert.assertEquals(propMap,client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),true));
  client.deleteApplicationPreferences(FakeApp.ID);
  propMap.put("String_Node_Str","String_Node_Str");
  Assert.assertTrue(client.getApplicationPreferences(FakeApp.ID,false).isEmpty());
  Assert.assertEquals(propMap,client.getApplicationPreferences(FakeApp.ID,true));
  Assert.assertEquals(propMap,client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),true));
  client.deleteNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID);
  propMap.put("String_Node_Str","String_Node_Str");
  Assert.assertTrue(client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,false).isEmpty());
  Assert.assertEquals(propMap,client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,true));
  Assert.assertEquals(propMap,client.getApplicationPreferences(FakeApp.ID,true));
  Assert.assertEquals(propMap,client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),true));
  client.deleteInstancePreferences();
  propMap.clear();
  Assert.assertEquals(propMap,client.getInstancePreferences());
  Assert.assertEquals(propMap,client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,true));
  Assert.assertEquals(propMap,client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,true));
  Assert.assertEquals(propMap,client.getApplicationPreferences(FakeApp.ID,true));
  Assert.assertEquals(propMap,client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),true));
  propMap.put("String_Node_Str","String_Node_Str");
  client.setApplicationPreferences(FakeApp.ID,propMap);
  Assert.assertEquals(propMap,client.getApplicationPreferences(FakeApp.ID,false));
  propMap.put("String_Node_Str","String_Node_Str");
  client.setProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),propMap);
  Assert.assertEquals(propMap,client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),false));
  appClient.delete(FakeApp.ID.getId());
  appClient.deploy(jarFile);
  propMap.clear();
  Assert.assertEquals(propMap,client.getApplicationPreferences(FakeApp.ID,false));
  Assert.assertEquals(propMap,client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),false));
  appClient.delete(FakeApp.ID.getId());
  namespaceClient.delete(invalidNamespace.getId());
}

Fixed version (ground truth):
@Test public void testPreferences() throws Exception {
  Id.Namespace invalidNamespace=Id.Namespace.from("String_Node_Str");
  namespaceClient.create(new NamespaceMeta.Builder().setId(invalidNamespace.getId()).build());
  Map<String,String> propMap=client.getInstancePreferences();
  Assert.assertEquals(ImmutableMap.<String,String>of(),propMap);
  propMap.put("String_Node_Str","String_Node_Str");
  client.setInstancePreferences(propMap);
  Assert.assertEquals(propMap,client.getInstancePreferences());
  File jarFile=createAppJarFile(FakeApp.class);
  appClient.deploy(jarFile);
  propMap.put("String_Node_Str","String_Node_Str");
  client.setNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,propMap);
  Assert.assertEquals(propMap,client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,true));
  Assert.assertEquals(propMap,client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,false));
  Assert.assertTrue(client.getNamespacePreferences(invalidNamespace,false).isEmpty());
  Assert.assertEquals("String_Node_Str",client.getNamespacePreferences(invalidNamespace,true).get("String_Node_Str"));
  client.deleteNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID);
  propMap.put("String_Node_Str","String_Node_Str");
  Assert.assertEquals(propMap,client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,true));
  Assert.assertEquals(ImmutableMap.<String,String>of(),client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,false));
  propMap.put("String_Node_Str","String_Node_Str");
  client.setNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,propMap);
  Assert.assertEquals(propMap,client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,true));
  Assert.assertEquals(propMap,client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,false));
  propMap.put("String_Node_Str","String_Node_Str");
  client.setApplicationPreferences(FakeApp.ID,propMap);
  Assert.assertEquals(propMap,client.getApplicationPreferences(FakeApp.ID,true));
  Assert.assertEquals(propMap,client.getApplicationPreferences(FakeApp.ID,false));
  propMap.put("String_Node_Str","String_Node_Str");
  client.setProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),propMap);
  Assert.assertEquals(propMap,client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),true));
  Assert.assertEquals(propMap,client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),false));
  client.deleteProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0));
  propMap.put("String_Node_Str","String_Node_Str");
  Assert.assertTrue(client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),false).isEmpty());
  Assert.assertEquals(propMap,client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),true));
  client.deleteApplicationPreferences(FakeApp.ID);
  propMap.put("String_Node_Str","String_Node_Str");
  Assert.assertTrue(client.getApplicationPreferences(FakeApp.ID,false).isEmpty());
  Assert.assertEquals(propMap,client.getApplicationPreferences(FakeApp.ID,true));
  Assert.assertEquals(propMap,client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),true));
  client.deleteNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID);
  propMap.put("String_Node_Str","String_Node_Str");
  Assert.assertTrue(client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,false).isEmpty());
  Assert.assertEquals(propMap,client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,true));
  Assert.assertEquals(propMap,client.getApplicationPreferences(FakeApp.ID,true));
  Assert.assertEquals(propMap,client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),true));
  client.deleteInstancePreferences();
  propMap.clear();
  Assert.assertEquals(propMap,client.getInstancePreferences());
  Assert.assertEquals(propMap,client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,true));
  Assert.assertEquals(propMap,client.getNamespacePreferences(Constants.DEFAULT_NAMESPACE_ID,true));
  Assert.assertEquals(propMap,client.getApplicationPreferences(FakeApp.ID,true));
  Assert.assertEquals(propMap,client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),true));
  propMap.put("String_Node_Str","String_Node_Str");
  client.setApplicationPreferences(FakeApp.ID,propMap);
  Assert.assertEquals(propMap,client.getApplicationPreferences(FakeApp.ID,false));
  propMap.put("String_Node_Str","String_Node_Str");
  client.setProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),propMap);
  Assert.assertEquals(propMap,client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),false));
  appClient.delete(FakeApp.ID.getId());
  appClient.deploy(jarFile);
  propMap.clear();
  Assert.assertEquals(propMap,client.getApplicationPreferences(FakeApp.ID,false));
  Assert.assertEquals(propMap,client.getProgramPreferences(FakeApp.ID,"String_Node_Str",FakeApp.FLOWS.get(0),false));
  appClient.delete(FakeApp.ID.getId());
  namespaceClient.delete(invalidNamespace);
}