michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: package org.mozilla.gecko.background.sync.helpers; michael@0: michael@0: import static junit.framework.Assert.assertEquals; michael@0: import static junit.framework.Assert.assertFalse; michael@0: michael@0: import java.util.Arrays; michael@0: import java.util.HashSet; michael@0: import java.util.Set; michael@0: michael@0: import junit.framework.AssertionFailedError; michael@0: michael@0: public class ExpectGuidsSinceDelegate extends DefaultGuidsSinceDelegate { michael@0: private String[] expected; michael@0: public Set ignore = new HashSet(); michael@0: michael@0: public ExpectGuidsSinceDelegate(String[] guids) { michael@0: expected = guids; michael@0: Arrays.sort(expected); michael@0: } michael@0: michael@0: @Override michael@0: public void onGuidsSinceSucceeded(String[] guids) { michael@0: AssertionFailedError err = null; michael@0: try { michael@0: int notIgnored = 0; michael@0: for (String guid : guids) { michael@0: if (!ignore.contains(guid)) { michael@0: notIgnored++; michael@0: assertFalse(-1 == Arrays.binarySearch(this.expected, guid)); michael@0: } michael@0: } michael@0: assertEquals(this.expected.length, notIgnored); michael@0: } catch (AssertionFailedError e) { michael@0: err = e; michael@0: } michael@0: performNotify(err); michael@0: } michael@0: }