michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: package org.mozilla.gecko.background.sync.helpers; michael@0: michael@0: import static junit.framework.Assert.assertEquals; michael@0: import static junit.framework.Assert.assertNotNull; michael@0: import junit.framework.AssertionFailedError; michael@0: michael@0: public class ExpectStoredDelegate extends DefaultStoreDelegate { michael@0: String expectedGUID; michael@0: String storedGuid; michael@0: michael@0: public ExpectStoredDelegate(String guid) { michael@0: this.expectedGUID = guid; michael@0: } michael@0: michael@0: @Override michael@0: public synchronized void onStoreCompleted(long storeEnd) { michael@0: try { michael@0: assertNotNull(storedGuid); michael@0: performNotify(); michael@0: } catch (AssertionFailedError e) { michael@0: performNotify("GUID " + this.expectedGUID + " was not stored", e); michael@0: } michael@0: } michael@0: michael@0: @Override michael@0: public synchronized void onRecordStoreSucceeded(String guid) { michael@0: this.storedGuid = guid; michael@0: try { michael@0: if (this.expectedGUID != null) { michael@0: assertEquals(this.expectedGUID, guid); michael@0: } michael@0: } catch (AssertionFailedError e) { michael@0: performNotify(e); michael@0: } michael@0: } michael@0: }