mobile/android/tests/background/junit3/src/sync/helpers/ExpectFetchSinceDelegate.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.assertFalse;
     8 import static junit.framework.Assert.assertTrue;
    10 import java.util.Arrays;
    12 import org.mozilla.gecko.sync.repositories.domain.Record;
    14 import junit.framework.AssertionFailedError;
    16 public class ExpectFetchSinceDelegate extends DefaultFetchDelegate {
    17   private String[] expected;
    18   private long earliest;
    20   public ExpectFetchSinceDelegate(long timestamp, String[] guids) {
    21     expected = guids;
    22     earliest = timestamp;
    23     Arrays.sort(expected);
    24   }
    26   @Override
    27   public void onFetchCompleted(final long fetchEnd) {
    28     AssertionFailedError err = null;
    29     try {
    30       int countSpecials = 0;
    31       for (Record record : records) {
    32         // Check if record should be ignored.
    33         if (!ignore.contains(record.guid)) {
    34           assertFalse(-1 == Arrays.binarySearch(this.expected, record.guid));
    35         } else {
    36           countSpecials++;
    37         }
    38         // Check that record is later than timestamp-earliest.
    39         assertTrue(record.lastModified >= this.earliest);
    40       }
    41       assertEquals(this.expected.length, records.size() - countSpecials);
    42     } catch (AssertionFailedError e) {
    43       err = e;
    44     }
    45     performNotify(err);
    46   }
    47 }

mercurial