Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | package org.mozilla.gecko.background.sync.helpers; |
michael@0 | 5 | |
michael@0 | 6 | import static junit.framework.Assert.assertEquals; |
michael@0 | 7 | import static junit.framework.Assert.assertNotNull; |
michael@0 | 8 | import junit.framework.AssertionFailedError; |
michael@0 | 9 | |
michael@0 | 10 | public class ExpectStoredDelegate extends DefaultStoreDelegate { |
michael@0 | 11 | String expectedGUID; |
michael@0 | 12 | String storedGuid; |
michael@0 | 13 | |
michael@0 | 14 | public ExpectStoredDelegate(String guid) { |
michael@0 | 15 | this.expectedGUID = guid; |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | @Override |
michael@0 | 19 | public synchronized void onStoreCompleted(long storeEnd) { |
michael@0 | 20 | try { |
michael@0 | 21 | assertNotNull(storedGuid); |
michael@0 | 22 | performNotify(); |
michael@0 | 23 | } catch (AssertionFailedError e) { |
michael@0 | 24 | performNotify("GUID " + this.expectedGUID + " was not stored", e); |
michael@0 | 25 | } |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | @Override |
michael@0 | 29 | public synchronized void onRecordStoreSucceeded(String guid) { |
michael@0 | 30 | this.storedGuid = guid; |
michael@0 | 31 | try { |
michael@0 | 32 | if (this.expectedGUID != null) { |
michael@0 | 33 | assertEquals(this.expectedGUID, guid); |
michael@0 | 34 | } |
michael@0 | 35 | } catch (AssertionFailedError e) { |
michael@0 | 36 | performNotify(e); |
michael@0 | 37 | } |
michael@0 | 38 | } |
michael@0 | 39 | } |