mobile/android/tests/background/junit3/src/sync/helpers/ExpectManyStoredDelegate.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 package org.mozilla.gecko.background.sync.helpers;
     6 import static junit.framework.Assert.assertEquals;
     7 import static junit.framework.Assert.assertTrue;
     9 import java.util.HashSet;
    10 import java.util.concurrent.atomic.AtomicLong;
    12 import junit.framework.AssertionFailedError;
    14 import org.mozilla.gecko.sync.repositories.domain.Record;
    16 public class ExpectManyStoredDelegate extends DefaultStoreDelegate {
    17   HashSet<String> expectedGUIDs;
    18   AtomicLong stored;
    20   public ExpectManyStoredDelegate(Record[] records) {
    21     HashSet<String> s = new HashSet<String>();
    22     for (Record record : records) {
    23       s.add(record.guid);
    24     }
    25     expectedGUIDs = s;
    26     stored = new AtomicLong(0);
    27   }
    29   @Override
    30   public void onStoreCompleted(long storeEnd) {
    31     try {
    32       assertEquals(expectedGUIDs.size(), stored.get());
    33       performNotify();
    34     } catch (AssertionFailedError e) {
    35       performNotify(e);
    36     }
    37   }
    39   @Override
    40   public void onRecordStoreSucceeded(String guid) {
    41     try {
    42       assertTrue(expectedGUIDs.contains(guid));
    43     } catch (AssertionFailedError e) {
    44       performNotify(e);
    45     }
    46     stored.incrementAndGet();
    47   }
    48 }

mercurial