Buggy code:
@ RunWith ( TestRunner . class ) public class TestGlobalSession { private int TEST_PORT = HTTPServerTestHelper . getTestPort ( ) ; private final String TEST_CLUSTER_URL = "http:////localhost:" + ( TEST_PORT ) ; private final String TEST_USERNAME = "johndoe" ; private final String TEST_PASSWORD = "password" ; private final String TEST_SYNC_KEY = "abcdeabcdeabcdeabcdeabcdea" ; private final long TEST_BACKOFF_IN_SECONDS = 2401 ; public static WaitHelper getTestWaiter ( ) { } @ Test public void testGetSyncStagesBy ( ) throws IOException , IllegalArgumentException , ParseException , NonObjectJSONException , SyncConfigurationException , CryptoException , NoSuchStageException { } @ Test public void testBackoffCalledByHandleHTTPError ( ) { } @ Test public void testSuccessCalledAfterStages ( ) { } @ Test public void testBackoffCalledInStages ( ) { } private HTTPServerTestHelper data = new HTTPServerTestHelper ( ) ; @ SuppressWarnings ( "static-method" ) @ Before public void setUp ( ) { } public void doRequest ( ) { } public MockGlobalSessionCallback doTestSuccess ( final boolean stageShouldBackoff , final boolean stageShouldAdvance ) throws IOException , IllegalArgumentException , ParseException , NonObjectJSONException , SyncConfigurationException , CryptoException { } @ Test public void testOnSuccessBackoffAdvanced ( ) throws IOException , IllegalArgumentException , ParseException , NonObjectJSONException , SyncConfigurationException , CryptoException { } @ Test public void testOnSuccessBackoffAborted ( ) throws IOException , IllegalArgumentException , ParseException , NonObjectJSONException , SyncConfigurationException , CryptoException { } @ Test public void testOnSuccessNoBackoffAdvanced ( ) throws IOException , IllegalArgumentException , ParseException , NonObjectJSONException , SyncConfigurationException , CryptoException { } @ Test public void testOnSuccessNoBackoffAborted ( ) throws IOException , IllegalArgumentException , ParseException , NonObjectJSONException , SyncConfigurationException , CryptoException { } @ Test public void testGenerateNewMetaGlobalNonePersisted ( ) throws Exception { } @ Test public void testGenerateNewMetaGlobalSomePersisted ( ) throws Exception { } @ Test public void testUploadUpdatedMetaGlobal ( ) throws Exception { final MockGlobalSessionCallback callback = new MockGlobalSessionCallback ( ) ; final GlobalSession session = MockPrefsGlobalSession . getSession ( TEST_USERNAME , TEST_PASSWORD , new KeyBundle ( TEST_USERNAME , TEST_SYNC_KEY ) , callback , null , null ) ; session . config . metaGlobal = session . generateNewMetaGlobal ( ) ; session . enginesToUpdate . clear ( ) ; String [ ] origEngines = new String [ ] { "bookmarks" , "clients" , "forms" , "history" , "tabs" , "new-engine" } ; ExtendedJSONObject origEnginesJSONObject = new ExtendedJSONObject ( ) ; for ( String engineName : origEngines ) { EngineSettings mockEngineSettings = new EngineSettings ( Utils . generateGuid ( ) , Integer . valueOf ( 0 ) ) ; <START_BUG> origEnginesJSONObject . put ( engineName , mockEngineSettings ) ; <END_BUG> } session . config . metaGlobal . setEngines ( origEnginesJSONObject ) ; String [ ] toRemove = new String [ ] { "bookmarks" , "tabs" } ; for ( String name : toRemove ) { session . removeEngineFromMetaGlobal ( name ) ; } String [ ] toAdd = new String [ ] { "passwords" } ; for ( String name : toAdd ) { String syncId = Utils . generateGuid ( ) ; session . recordForMetaGlobalUpdate ( name , new EngineSettings ( syncId , Integer . valueOf ( 1 ) ) ) ; } session . uploadUpdatedMetaGlobal ( ) ; Set < String > expected = new HashSet < String > ( ) ; for ( String name : origEngines ) { expected . add ( name ) ; } for ( String name : toRemove ) { expected . remove ( name ) ; } for ( String name : toAdd ) { expected . add ( name ) ; } assertEquals ( expected , session . config . metaGlobal . getEnabledEngineNames ( ) ) ; } public void testStageAdvance ( ) { } }

Fix:
origEnginesJSONObject . put ( engineName , mockEngineSettings . toJSONObject ( ) ) ;