@MediumTest public void testPeriodics() throws Exception {
  final Account account1=new Account("a@example.com","example.type");
  final Account account2=new Account("b@example.com","example.type.2");
  final String authority="testprovider";
  final Bundle extras1=new Bundle();
  extras1.putString("a","1");
  final Bundle extras2=new Bundle();
  extras2.putString("a","2");
  final int period1=200;
  final int period2=1000;
  PeriodicSync sync1=new PeriodicSync(account1,authority,extras1,period1);
  PeriodicSync sync2=new PeriodicSync(account1,authority,extras2,period1);
  PeriodicSync sync3=new PeriodicSync(account1,authority,extras2,period2);
  PeriodicSync sync4=new PeriodicSync(account2,authority,extras2,period2);
  MockContentResolver mockResolver=new MockContentResolver();
  SyncStorageEngine engine=SyncStorageEngine.newTestInstance(new TestContext(mockResolver,getContext()));
  removePeriodicSyncs(engine,account1,0,authority);
  removePeriodicSyncs(engine,account2,0,authority);
  removePeriodicSyncs(engine,account1,1,authority);
  engine.addPeriodicSync(sync1.account,0,sync1.authority,sync1.extras,sync1.period);
  engine.addPeriodicSync(sync2.account,0,sync2.authority,sync2.extras,sync2.period);
  engine.addPeriodicSync(sync3.account,0,sync3.authority,sync3.extras,sync3.period);
  engine.addPeriodicSync(sync4.account,0,sync4.authority,sync4.extras,sync4.period);
  engine.addPeriodicSync(sync2.account,1,sync2.authority,sync2.extras,sync2.period);
  List<PeriodicSync> syncs=engine.getPeriodicSyncs(account1,0,authority);
  assertEquals(2,syncs.size());
  assertEquals(sync1,syncs.get(0));
  assertEquals(sync3,syncs.get(1));
  engine.removePeriodicSync(sync1.account,0,sync1.authority,sync1.extras);
  syncs=engine.getPeriodicSyncs(account1,0,authority);
  assertEquals(1,syncs.size());
  assertEquals(sync3,syncs.get(0));
  syncs=engine.getPeriodicSyncs(account2,0,authority);
  assertEquals(1,syncs.size());
  assertEquals(sync4,syncs.get(0));
  syncs=engine.getPeriodicSyncs(sync2.account,1,sync2.authority);
  assertEquals(1,syncs.size());
  assertEquals(sync2,syncs.get(0));
}

@ MediumTest public void testPeriodics ( ) throws Exception { final Account account1 = new Account ( "a@example.com" , "example.type" ) ; final Account account2 = new Account ( "b@example.com" , "example.type.2" ) ; final String authority = "testprovider" ; final Bundle extras1 = new Bundle ( ) ; extras1 . putString ( "a" , "1" ) ; final Bundle extras2 = new Bundle ( ) ; extras2 . putString ( "a" , "2" ) ; final int period1 = 200 ; final int period2 = 1000 ; PeriodicSync sync1 = new PeriodicSync ( account1 , authority , extras1 , period1 ) ; PeriodicSync sync2 = new PeriodicSync ( account1 , authority , extras2 , period1 ) ; PeriodicSync sync3 = new PeriodicSync ( account1 , authority , extras2 , period2 ) ; PeriodicSync sync4 = new PeriodicSync ( account2 , authority , extras2 , period2 ) ; MockContentResolver mockResolver = new MockContentResolver ( ) ; SyncStorageEngine engine = SyncStorageEngine . newTestInstance ( new TestContext ( mockResolver , getContext ( ) ) ) ; removePeriodicSyncs ( engine , account1 , 0 , authority ) ; removePeriodicSyncs ( engine , account2 , 0 , authority ) ; removePeriodicSyncs ( engine , account1 , 1 , authority ) ; engine . addPeriodicSync ( sync1 . account , 0 , sync1 . authority , sync1 . extras , sync1 . period ) ; engine . addPeriodicSync ( sync2 . account , 0 , sync2 . authority , sync2 . extras , sync2 . period ) ; engine . addPeriodicSync ( sync3 . account , 0 , sync3 . authority , sync3 . extras , sync3 . period ) ; engine . addPeriodicSync ( sync4 . account , 0 , sync4 . authority , sync4 . extras , sync4 . period ) ; engine . addPeriodicSync ( sync2 . account , 1 , sync2 . authority , sync2 . extras , sync2 . period ) ; List < PeriodicSync > syncs = engine . getPeriodicSyncs ( account1 , 0 , authority ) ; assertEquals ( 2 , syncs . size ( ) ) ; assertEquals ( sync1 , syncs . get ( 0 ) ) ; assertEquals ( sync3 , syncs . get ( 1 ) ) ; engine . removePeriodicSync ( sync1 . account , 0 , sync1 . authority , sync1 . extras ) ; syncs = engine . getPeriodicSyncs ( account1 , 0 , authority ) ; assertEquals ( 1 , syncs . size ( ) ) ; assertEquals ( sync3 , syncs . get ( 0 ) ) ; syncs = engine . getPeriodicSyncs ( account2 , 0 , authority ) ; assertEquals ( 1 , syncs . size ( ) ) ; assertEquals ( sync4 , syncs . get ( 0 ) ) ; syncs = engine . getPeriodicSyncs ( sync2 . account , 1 , sync2 . authority ) ; assertEquals ( 1 , syncs . size ( ) ) ; assertEquals ( sync2 , syncs . get ( 0 ) ) ; }
test that we can create , remove and retrieve periodic syncs
