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