You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by pt...@apache.org on 2014/03/20 22:22:44 UTC

[21/50] [abbrv] Reformat Java code to use 2 instead of 4 spaces (to match Clojure style)

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/a51c8247/test/jvm/storm/starter/tools/NthLastModifiedTimeTrackerTest.java
----------------------------------------------------------------------
diff --git a/test/jvm/storm/starter/tools/NthLastModifiedTimeTrackerTest.java b/test/jvm/storm/starter/tools/NthLastModifiedTimeTrackerTest.java
index 77f8f71..c79d382 100644
--- a/test/jvm/storm/starter/tools/NthLastModifiedTimeTrackerTest.java
+++ b/test/jvm/storm/starter/tools/NthLastModifiedTimeTrackerTest.java
@@ -1,112 +1,108 @@
 package storm.starter.tools;
 
-import static org.fest.assertions.api.Assertions.assertThat;
-
+import backtype.storm.utils.Time;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-import backtype.storm.utils.Time;
+import static org.fest.assertions.api.Assertions.assertThat;
 
 public class NthLastModifiedTimeTrackerTest {
 
-    private static final int ANY_NUM_TIMES_TO_TRACK = 3;
-    private static final int MILLIS_IN_SEC = 1000;
-
-    @DataProvider
-    public Object[][] illegalNumTimesData() {
-        return new Object[][] { { -10 }, { -3 }, { -2 }, { -1 }, { 0 } };
-    }
-
-    @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "illegalNumTimesData")
-    public void negativeOrZeroNumTimesToTrackShouldThrowIAE(int numTimesToTrack) {
-        new NthLastModifiedTimeTracker(numTimesToTrack);
-    }
-
-    @DataProvider
-    public Object[][] legalNumTimesData() {
-        return new Object[][] { { 1 }, { 2 }, { 3 }, { 20 } };
-    }
-
-    @Test(dataProvider = "legalNumTimesData")
-    public void positiveNumTimesToTrackShouldBeOk(int numTimesToTrack) {
-        new NthLastModifiedTimeTracker(numTimesToTrack);
-    }
-
-    @DataProvider
-    public Object[][] whenNotYetMarkedAsModifiedData() {
-        return new Object[][] { { 0 }, { 1 }, { 2 }, { 3 }, { 4 }, { 5 }, { 8 }, { 10 } };
+  private static final int ANY_NUM_TIMES_TO_TRACK = 3;
+  private static final int MILLIS_IN_SEC = 1000;
+
+  @DataProvider
+  public Object[][] illegalNumTimesData() {
+    return new Object[][]{ { -10 }, { -3 }, { -2 }, { -1 }, { 0 } };
+  }
+
+  @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "illegalNumTimesData")
+  public void negativeOrZeroNumTimesToTrackShouldThrowIAE(int numTimesToTrack) {
+    new NthLastModifiedTimeTracker(numTimesToTrack);
+  }
+
+  @DataProvider
+  public Object[][] legalNumTimesData() {
+    return new Object[][]{ { 1 }, { 2 }, { 3 }, { 20 } };
+  }
+
+  @Test(dataProvider = "legalNumTimesData")
+  public void positiveNumTimesToTrackShouldBeOk(int numTimesToTrack) {
+    new NthLastModifiedTimeTracker(numTimesToTrack);
+  }
+
+  @DataProvider
+  public Object[][] whenNotYetMarkedAsModifiedData() {
+    return new Object[][]{ { 0 }, { 1 }, { 2 }, { 3 }, { 4 }, { 5 }, { 8 }, { 10 } };
+  }
+
+  @Test(dataProvider = "whenNotYetMarkedAsModifiedData")
+  public void shouldReturnCorrectModifiedTimeEvenWhenNotYetMarkedAsModified(int secondsToAdvance) {
+    // given
+    Time.startSimulating();
+    NthLastModifiedTimeTracker tracker = new NthLastModifiedTimeTracker(ANY_NUM_TIMES_TO_TRACK);
+
+    // when
+    advanceSimulatedTimeBy(secondsToAdvance);
+    int seconds = tracker.secondsSinceOldestModification();
+
+    // then
+    assertThat(seconds).isEqualTo(secondsToAdvance);
+
+    // cleanup
+    Time.stopSimulating();
+  }
+
+  @DataProvider
+  public Object[][] simulatedTrackerIterations() {
+    return new Object[][]{ { 1, new int[]{ 0, 1 }, new int[]{ 0, 0 } }, { 1, new int[]{ 0, 2 }, new int[]{ 0, 0 } },
+        { 2, new int[]{ 2, 2 }, new int[]{ 2, 2 } }, { 2, new int[]{ 0, 4 }, new int[]{ 0, 4 } },
+        { 1, new int[]{ 1, 1, 1, 1, 1, 1, 1 }, new int[]{ 0, 0, 0, 0, 0, 0, 0 } },
+        { 1, new int[]{ 1, 2, 3, 4, 5, 6, 7 }, new int[]{ 0, 0, 0, 0, 0, 0, 0 } },
+        { 2, new int[]{ 1, 1, 1, 1, 1, 1, 1 }, new int[]{ 1, 1, 1, 1, 1, 1, 1 } },
+        { 2, new int[]{ 2, 2, 2, 2, 2, 2, 2 }, new int[]{ 2, 2, 2, 2, 2, 2, 2 } },
+        { 2, new int[]{ 1, 2, 3, 4, 5, 6, 7 }, new int[]{ 1, 2, 3, 4, 5, 6, 7 } },
+        { 3, new int[]{ 1, 1, 1, 1, 1, 1, 1 }, new int[]{ 1, 2, 2, 2, 2, 2, 2 } },
+        { 3, new int[]{ 1, 2, 3, 4, 5, 6, 7 }, new int[]{ 1, 3, 5, 7, 9, 11, 13 } },
+        { 3, new int[]{ 2, 2, 2, 2, 2, 2, 2 }, new int[]{ 2, 4, 4, 4, 4, 4, 4 } },
+        { 4, new int[]{ 1, 1, 1, 1, 1, 1, 1 }, new int[]{ 1, 2, 3, 3, 3, 3, 3 } },
+        { 4, new int[]{ 1, 2, 3, 4, 5, 6, 7 }, new int[]{ 1, 3, 6, 9, 12, 15, 18 } },
+        { 4, new int[]{ 2, 2, 2, 2, 2, 2, 2 }, new int[]{ 2, 4, 6, 6, 6, 6, 6 } },
+        { 5, new int[]{ 1, 1, 1, 1, 1, 1, 1 }, new int[]{ 1, 2, 3, 4, 4, 4, 4 } },
+        { 5, new int[]{ 1, 2, 3, 4, 5, 6, 7 }, new int[]{ 1, 3, 6, 10, 14, 18, 22 } },
+        { 5, new int[]{ 2, 2, 2, 2, 2, 2, 2 }, new int[]{ 2, 4, 6, 8, 8, 8, 8 } },
+        { 6, new int[]{ 1, 1, 1, 1, 1, 1, 1 }, new int[]{ 1, 2, 3, 4, 5, 5, 5 } },
+        { 6, new int[]{ 1, 2, 3, 4, 5, 6, 7 }, new int[]{ 1, 3, 6, 10, 15, 20, 25 } },
+        { 6, new int[]{ 2, 2, 2, 2, 2, 2, 2 }, new int[]{ 2, 4, 6, 8, 10, 10, 10 } },
+        { 3, new int[]{ 1, 2, 3 }, new int[]{ 1, 3, 5 } } };
+  }
+
+  @Test(dataProvider = "simulatedTrackerIterations")
+  public void shouldReturnCorrectModifiedTimeWhenMarkedAsModified(int numTimesToTrack,
+      int[] secondsToAdvancePerIteration, int[] expLastModifiedTimes) {
+    // given
+    Time.startSimulating();
+    NthLastModifiedTimeTracker tracker = new NthLastModifiedTimeTracker(numTimesToTrack);
+
+    int[] modifiedTimes = new int[expLastModifiedTimes.length];
+
+    // when
+    int i = 0;
+    for (int secondsToAdvance : secondsToAdvancePerIteration) {
+      advanceSimulatedTimeBy(secondsToAdvance);
+      tracker.markAsModified();
+      modifiedTimes[i] = tracker.secondsSinceOldestModification();
+      i++;
     }
 
-    @Test(dataProvider = "whenNotYetMarkedAsModifiedData")
-    public void shouldReturnCorrectModifiedTimeEvenWhenNotYetMarkedAsModified(int secondsToAdvance) {
-        // given
-        Time.startSimulating();
-        NthLastModifiedTimeTracker tracker = new NthLastModifiedTimeTracker(ANY_NUM_TIMES_TO_TRACK);
+    // then
+    assertThat(modifiedTimes).isEqualTo(expLastModifiedTimes);
 
-        // when
-        advanceSimulatedTimeBy(secondsToAdvance);
-        int seconds = tracker.secondsSinceOldestModification();
-
-        // then
-        assertThat(seconds).isEqualTo(secondsToAdvance);
-
-        // cleanup
-        Time.stopSimulating();
-    }
+    // cleanup
+    Time.stopSimulating();
+  }
 
-    @DataProvider
-    public Object[][] simulatedTrackerIterations() {
-        return new Object[][] {
-                { 1, new int[] { 0, 1 }, new int[] { 0, 0 } },
-                { 1, new int[] { 0, 2 }, new int[] { 0, 0 } },
-                { 2, new int[] { 2, 2 }, new int[] { 2, 2 } },
-                { 2, new int[] { 0, 4 }, new int[] { 0, 4 } },
-                { 1, new int[] { 1, 1, 1, 1, 1, 1, 1 }, new int[] { 0, 0, 0, 0, 0, 0, 0 } },
-                { 1, new int[] { 1, 2, 3, 4, 5, 6, 7 }, new int[] { 0, 0, 0, 0, 0, 0, 0 } },
-                { 2, new int[] { 1, 1, 1, 1, 1, 1, 1 }, new int[] { 1, 1, 1, 1, 1, 1, 1 } },
-                { 2, new int[] { 2, 2, 2, 2, 2, 2, 2 }, new int[] { 2, 2, 2, 2, 2, 2, 2 } },
-                { 2, new int[] { 1, 2, 3, 4, 5, 6, 7 }, new int[] { 1, 2, 3, 4, 5, 6, 7 } },
-                { 3, new int[] { 1, 1, 1, 1, 1, 1, 1 }, new int[] { 1, 2, 2, 2, 2, 2, 2 } },
-                { 3, new int[] { 1, 2, 3, 4, 5, 6, 7 }, new int[] { 1, 3, 5, 7, 9, 11, 13 } },
-                { 3, new int[] { 2, 2, 2, 2, 2, 2, 2 }, new int[] { 2, 4, 4, 4, 4, 4, 4 } },
-                { 4, new int[] { 1, 1, 1, 1, 1, 1, 1 }, new int[] { 1, 2, 3, 3, 3, 3, 3 } },
-                { 4, new int[] { 1, 2, 3, 4, 5, 6, 7 }, new int[] { 1, 3, 6, 9, 12, 15, 18 } },
-                { 4, new int[] { 2, 2, 2, 2, 2, 2, 2 }, new int[] { 2, 4, 6, 6, 6, 6, 6 } },
-                { 5, new int[] { 1, 1, 1, 1, 1, 1, 1 }, new int[] { 1, 2, 3, 4, 4, 4, 4 } },
-                { 5, new int[] { 1, 2, 3, 4, 5, 6, 7 }, new int[] { 1, 3, 6, 10, 14, 18, 22 } },
-                { 5, new int[] { 2, 2, 2, 2, 2, 2, 2 }, new int[] { 2, 4, 6, 8, 8, 8, 8 } },
-                { 6, new int[] { 1, 1, 1, 1, 1, 1, 1 }, new int[] { 1, 2, 3, 4, 5, 5, 5 } },
-                { 6, new int[] { 1, 2, 3, 4, 5, 6, 7 }, new int[] { 1, 3, 6, 10, 15, 20, 25 } },
-                { 6, new int[] { 2, 2, 2, 2, 2, 2, 2 }, new int[] { 2, 4, 6, 8, 10, 10, 10 } },
-                { 3, new int[] { 1, 2, 3 }, new int[] { 1, 3, 5 } } };
-    }
-
-    @Test(dataProvider = "simulatedTrackerIterations")
-    public void shouldReturnCorrectModifiedTimeWhenMarkedAsModified(int numTimesToTrack,
-        int[] secondsToAdvancePerIteration, int[] expLastModifiedTimes) {
-        // given
-        Time.startSimulating();
-        NthLastModifiedTimeTracker tracker = new NthLastModifiedTimeTracker(numTimesToTrack);
-
-        int[] modifiedTimes = new int[expLastModifiedTimes.length];
-
-        // when
-        int i = 0;
-        for (int secondsToAdvance : secondsToAdvancePerIteration) {
-            advanceSimulatedTimeBy(secondsToAdvance);
-            tracker.markAsModified();
-            modifiedTimes[i] = tracker.secondsSinceOldestModification();
-            i++;
-        }
-
-        // then
-        assertThat(modifiedTimes).isEqualTo(expLastModifiedTimes);
-
-        // cleanup
-        Time.stopSimulating();
-    }
-
-    private void advanceSimulatedTimeBy(int seconds) {
-        Time.advanceTime(seconds * MILLIS_IN_SEC);
-    }
+  private void advanceSimulatedTimeBy(int seconds) {
+    Time.advanceTime(seconds * MILLIS_IN_SEC);
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/a51c8247/test/jvm/storm/starter/tools/RankableObjectWithFieldsTest.java
----------------------------------------------------------------------
diff --git a/test/jvm/storm/starter/tools/RankableObjectWithFieldsTest.java b/test/jvm/storm/starter/tools/RankableObjectWithFieldsTest.java
index b2360c1..c8a14cc 100644
--- a/test/jvm/storm/starter/tools/RankableObjectWithFieldsTest.java
+++ b/test/jvm/storm/starter/tools/RankableObjectWithFieldsTest.java
@@ -1,225 +1,214 @@
 package storm.starter.tools;
 
-import static org.fest.assertions.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
+import backtype.storm.tuple.Tuple;
+import com.google.common.collect.Lists;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-import backtype.storm.tuple.Tuple;
+import java.util.ArrayList;
+import java.util.List;
 
-import com.google.common.collect.Lists;
+import static org.fest.assertions.api.Assertions.assertThat;
+import static org.mockito.Mockito.*;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
 
 public class RankableObjectWithFieldsTest {
 
-    private static final Object ANY_OBJECT = new Object();
-    private static final long ANY_COUNT = 271;
-    private static final String ANY_FIELD = "someAdditionalField";
-    private static final int GREATER_THAN = 1;
-    private static final int EQUAL_TO = 0;
-    private static final int SMALLER_THAN = -1;
-
-    @Test(expectedExceptions = IllegalArgumentException.class)
-    public void constructorWithNullObjectAndNoFieldsShouldThrowIAE() {
-        new RankableObjectWithFields(null, ANY_COUNT);
-    }
-
-    @Test(expectedExceptions = IllegalArgumentException.class)
-    public void constructorWithNullObjectAndFieldsShouldThrowIAE() {
-        Object someAdditionalField = new Object();
-        new RankableObjectWithFields(null, ANY_COUNT, someAdditionalField);
-    }
-
-    @Test(expectedExceptions = IllegalArgumentException.class)
-    public void constructorWithNegativeCountAndNoFieldsShouldThrowIAE() {
-        new RankableObjectWithFields(ANY_OBJECT, -1);
-    }
-
-    @Test(expectedExceptions = IllegalArgumentException.class)
-    public void constructorWithNegativeCountAndFieldsShouldThrowIAE() {
-        Object someAdditionalField = new Object();
-        new RankableObjectWithFields(ANY_OBJECT, -1, someAdditionalField);
-    }
-
-    @Test
-    public void shouldBeEqualToItself() {
-        RankableObjectWithFields r = new RankableObjectWithFields(ANY_OBJECT, ANY_COUNT);
-        assertThat(r).isEqualTo(r);
-    }
-
-    @DataProvider
-    public Object[][] otherClassesData() {
-        return new Object[][] {
-                { new String("foo") },
-                { new Object() },
-                { Integer.valueOf(4) },
-                { Lists.newArrayList(7, 8, 9) } };
-    }
-
-    @Test(dataProvider = "otherClassesData")
-    public void shouldNotBeEqualToInstancesOfOtherClasses(Object notARankable) {
-        RankableObjectWithFields r = new RankableObjectWithFields(ANY_OBJECT, ANY_COUNT);
-        assertFalse(r.equals(notARankable), r + " is equal to " + notARankable + " but it should not be");
-    }
-
-    @DataProvider
-    public Object[][] falseDuplicatesData() {
-        return new Object[][] {
-                { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("foo", 1) },
-                { new RankableObjectWithFields("foo", 1), new RankableObjectWithFields("Foo", 1) },
-                { new RankableObjectWithFields("foo", 1), new RankableObjectWithFields("FOO", 1) },
-                { new RankableObjectWithFields("foo", 1), new RankableObjectWithFields("bar", 1) },
-                { new RankableObjectWithFields("", 0), new RankableObjectWithFields("", 1) },
-                { new RankableObjectWithFields("", 1), new RankableObjectWithFields("bar", 1) } };
-    }
-
-    @Test(dataProvider = "falseDuplicatesData")
-    public void shouldNotBeEqualToFalseDuplicates(RankableObjectWithFields r, RankableObjectWithFields falseDuplicate) {
-        assertFalse(r.equals(falseDuplicate), r + " is equal to " + falseDuplicate + " but it should not be");
-    }
-
-    @Test(dataProvider = "falseDuplicatesData")
-    public void shouldHaveDifferentHashCodeThanFalseDuplicates(RankableObjectWithFields r,
-        RankableObjectWithFields falseDuplicate) {
-        assertThat(r.hashCode()).isNotEqualTo(falseDuplicate.hashCode());
-    }
-
-    @DataProvider
-    public Object[][] trueDuplicatesData() {
-        return new Object[][] {
-                { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("foo", 0) },
-                { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("foo", 0, "someOtherField") },
-                {
-                        new RankableObjectWithFields("foo", 0, "someField"),
-                        new RankableObjectWithFields("foo", 0, "someOtherField") } };
-    }
-
-    @Test(dataProvider = "trueDuplicatesData")
-    public void shouldBeEqualToTrueDuplicates(RankableObjectWithFields r, RankableObjectWithFields trueDuplicate) {
-        assertTrue(r.equals(trueDuplicate), r + " is not equal to " + trueDuplicate + " but it should be");
-    }
-
-    @Test(dataProvider = "trueDuplicatesData")
-    public void shouldHaveSameHashCodeAsTrueDuplicates(RankableObjectWithFields r,
-        RankableObjectWithFields trueDuplicate) {
-        assertThat(r.hashCode()).isEqualTo(trueDuplicate.hashCode());
-    }
-
-    @DataProvider
-    public Object[][] compareToData() {
-        return new Object[][] {
-                { new RankableObjectWithFields("foo", 1000), new RankableObjectWithFields("foo", 0), GREATER_THAN },
-                { new RankableObjectWithFields("foo", 1), new RankableObjectWithFields("foo", 0), GREATER_THAN },
-                { new RankableObjectWithFields("foo", 1000), new RankableObjectWithFields("bar", 0), GREATER_THAN },
-                { new RankableObjectWithFields("foo", 1), new RankableObjectWithFields("bar", 0), GREATER_THAN },
-                { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("foo", 0), EQUAL_TO },
-                { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("bar", 0), EQUAL_TO },
-                { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("foo", 1000), SMALLER_THAN },
-                { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("foo", 1), SMALLER_THAN },
-                { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("bar", 1), SMALLER_THAN },
-                { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("bar", 1000), SMALLER_THAN }, };
-    }
-
-    @Test(dataProvider = "compareToData")
-    public void verifyCompareTo(RankableObjectWithFields first, RankableObjectWithFields second, int expCompareToValue) {
-        assertThat(first.compareTo(second)).isEqualTo(expCompareToValue);
-    }
-
-    @DataProvider
-    public Object[][] toStringData() {
-        return new Object[][] { { new String("foo"), 0L }, { new String("BAR"), 8L } };
-    }
-
-    @Test(dataProvider = "toStringData")
-    public void toStringShouldContainStringRepresentationsOfObjectAndCount(Object obj, long count) {
-        // given
-        RankableObjectWithFields r = new RankableObjectWithFields(obj, count);
-
-        // when
-        String strRepresentation = r.toString();
-
-        // then
-        assertThat(strRepresentation).contains(obj.toString()).contains("" + count);
-    }
-
-    @Test
-    public void shouldReturnTheObject() {
-        // given
-        RankableObjectWithFields r = new RankableObjectWithFields(ANY_OBJECT, ANY_COUNT, ANY_FIELD);
-
-        // when
-        Object obj = r.getObject();
-
-        // then
-        assertThat(obj).isEqualTo(ANY_OBJECT);
-    }
-
-    @Test
-    public void shouldReturnTheCount() {
-        // given
-        RankableObjectWithFields r = new RankableObjectWithFields(ANY_OBJECT, ANY_COUNT, ANY_FIELD);
-
-        // when
-        long count = r.getCount();
-
-        // then
-        assertThat(count).isEqualTo(ANY_COUNT);
-    }
-
-    @DataProvider
-    public Object[][] fieldsData() {
-        return new Object[][] {
-                { ANY_OBJECT, ANY_COUNT, new Object[] { ANY_FIELD } },
-                { "quux", 42L, new Object[] { "one", "two", "three" } } };
-    }
-
-    @Test(dataProvider = "fieldsData")
-    public void shouldReturnTheFields(Object obj, long count, Object[] fields) {
-        // given
-        RankableObjectWithFields r = new RankableObjectWithFields(obj, count, fields);
-
-        // when
-        List<Object> actualFields = r.getFields();
-
-        // then
-        assertThat(actualFields).isEqualTo(Lists.newArrayList(fields));
-    }
-
-    @Test(expectedExceptions = UnsupportedOperationException.class)
-    public void fieldsShouldBeImmutable() {
-        // given
-        RankableObjectWithFields r = new RankableObjectWithFields(ANY_OBJECT, ANY_COUNT, ANY_FIELD);
-
-        // when
-        List<Object> fields = r.getFields();
-        // try to modify the list, which should fail
-        fields.remove(0);
-
-        // then (exception)
-    }
-
-    @Test
-    public void shouldCreateRankableObjectFromTuple() {
-        // given
-        Tuple tuple = mock(Tuple.class);
-        List<Object> tupleValues = Lists.newArrayList(ANY_OBJECT, ANY_COUNT, ANY_FIELD);
-        when(tuple.getValues()).thenReturn(tupleValues);
-
-        // when
-        RankableObjectWithFields r = RankableObjectWithFields.from(tuple);
-
-        // then
-        assertThat(r.getObject()).isEqualTo(ANY_OBJECT);
-        assertThat(r.getCount()).isEqualTo(ANY_COUNT);
-        List<Object> fields = new ArrayList<Object>();
-        fields.add(ANY_FIELD);
-        assertThat(r.getFields()).isEqualTo(fields);
-
-    }
+  private static final Object ANY_OBJECT = new Object();
+  private static final long ANY_COUNT = 271;
+  private static final String ANY_FIELD = "someAdditionalField";
+  private static final int GREATER_THAN = 1;
+  private static final int EQUAL_TO = 0;
+  private static final int SMALLER_THAN = -1;
+
+  @Test(expectedExceptions = IllegalArgumentException.class)
+  public void constructorWithNullObjectAndNoFieldsShouldThrowIAE() {
+    new RankableObjectWithFields(null, ANY_COUNT);
+  }
+
+  @Test(expectedExceptions = IllegalArgumentException.class)
+  public void constructorWithNullObjectAndFieldsShouldThrowIAE() {
+    Object someAdditionalField = new Object();
+    new RankableObjectWithFields(null, ANY_COUNT, someAdditionalField);
+  }
+
+  @Test(expectedExceptions = IllegalArgumentException.class)
+  public void constructorWithNegativeCountAndNoFieldsShouldThrowIAE() {
+    new RankableObjectWithFields(ANY_OBJECT, -1);
+  }
+
+  @Test(expectedExceptions = IllegalArgumentException.class)
+  public void constructorWithNegativeCountAndFieldsShouldThrowIAE() {
+    Object someAdditionalField = new Object();
+    new RankableObjectWithFields(ANY_OBJECT, -1, someAdditionalField);
+  }
+
+  @Test
+  public void shouldBeEqualToItself() {
+    RankableObjectWithFields r = new RankableObjectWithFields(ANY_OBJECT, ANY_COUNT);
+    assertThat(r).isEqualTo(r);
+  }
+
+  @DataProvider
+  public Object[][] otherClassesData() {
+    return new Object[][]{ { new String("foo") }, { new Object() }, { Integer.valueOf(4) }, { Lists.newArrayList(7, 8,
+        9) } };
+  }
+
+  @Test(dataProvider = "otherClassesData")
+  public void shouldNotBeEqualToInstancesOfOtherClasses(Object notARankable) {
+    RankableObjectWithFields r = new RankableObjectWithFields(ANY_OBJECT, ANY_COUNT);
+    assertFalse(r.equals(notARankable), r + " is equal to " + notARankable + " but it should not be");
+  }
+
+  @DataProvider
+  public Object[][] falseDuplicatesData() {
+    return new Object[][]{ { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("foo", 1) },
+        { new RankableObjectWithFields("foo", 1), new RankableObjectWithFields("Foo", 1) },
+        { new RankableObjectWithFields("foo", 1), new RankableObjectWithFields("FOO", 1) },
+        { new RankableObjectWithFields("foo", 1), new RankableObjectWithFields("bar", 1) },
+        { new RankableObjectWithFields("", 0), new RankableObjectWithFields("", 1) }, { new RankableObjectWithFields("",
+        1), new RankableObjectWithFields("bar", 1) } };
+  }
+
+  @Test(dataProvider = "falseDuplicatesData")
+  public void shouldNotBeEqualToFalseDuplicates(RankableObjectWithFields r, RankableObjectWithFields falseDuplicate) {
+    assertFalse(r.equals(falseDuplicate), r + " is equal to " + falseDuplicate + " but it should not be");
+  }
+
+  @Test(dataProvider = "falseDuplicatesData")
+  public void shouldHaveDifferentHashCodeThanFalseDuplicates(RankableObjectWithFields r,
+      RankableObjectWithFields falseDuplicate) {
+    assertThat(r.hashCode()).isNotEqualTo(falseDuplicate.hashCode());
+  }
+
+  @DataProvider
+  public Object[][] trueDuplicatesData() {
+    return new Object[][]{ { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("foo", 0) },
+        { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("foo", 0, "someOtherField") },
+        { new RankableObjectWithFields("foo", 0, "someField"), new RankableObjectWithFields("foo", 0,
+            "someOtherField") } };
+  }
+
+  @Test(dataProvider = "trueDuplicatesData")
+  public void shouldBeEqualToTrueDuplicates(RankableObjectWithFields r, RankableObjectWithFields trueDuplicate) {
+    assertTrue(r.equals(trueDuplicate), r + " is not equal to " + trueDuplicate + " but it should be");
+  }
+
+  @Test(dataProvider = "trueDuplicatesData")
+  public void shouldHaveSameHashCodeAsTrueDuplicates(RankableObjectWithFields r,
+      RankableObjectWithFields trueDuplicate) {
+    assertThat(r.hashCode()).isEqualTo(trueDuplicate.hashCode());
+  }
+
+  @DataProvider
+  public Object[][] compareToData() {
+    return new Object[][]{ { new RankableObjectWithFields("foo", 1000), new RankableObjectWithFields("foo", 0),
+        GREATER_THAN }, { new RankableObjectWithFields("foo", 1), new RankableObjectWithFields("foo", 0),
+        GREATER_THAN }, { new RankableObjectWithFields("foo", 1000), new RankableObjectWithFields("bar", 0),
+        GREATER_THAN }, { new RankableObjectWithFields("foo", 1), new RankableObjectWithFields("bar", 0),
+        GREATER_THAN }, { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("foo", 0), EQUAL_TO },
+        { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("bar", 0), EQUAL_TO },
+        { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("foo", 1000), SMALLER_THAN },
+        { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("foo", 1), SMALLER_THAN },
+        { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("bar", 1), SMALLER_THAN },
+        { new RankableObjectWithFields("foo", 0), new RankableObjectWithFields("bar", 1000), SMALLER_THAN }, };
+  }
+
+  @Test(dataProvider = "compareToData")
+  public void verifyCompareTo(RankableObjectWithFields first, RankableObjectWithFields second, int expCompareToValue) {
+    assertThat(first.compareTo(second)).isEqualTo(expCompareToValue);
+  }
+
+  @DataProvider
+  public Object[][] toStringData() {
+    return new Object[][]{ { new String("foo"), 0L }, { new String("BAR"), 8L } };
+  }
+
+  @Test(dataProvider = "toStringData")
+  public void toStringShouldContainStringRepresentationsOfObjectAndCount(Object obj, long count) {
+    // given
+    RankableObjectWithFields r = new RankableObjectWithFields(obj, count);
+
+    // when
+    String strRepresentation = r.toString();
+
+    // then
+    assertThat(strRepresentation).contains(obj.toString()).contains("" + count);
+  }
+
+  @Test
+  public void shouldReturnTheObject() {
+    // given
+    RankableObjectWithFields r = new RankableObjectWithFields(ANY_OBJECT, ANY_COUNT, ANY_FIELD);
+
+    // when
+    Object obj = r.getObject();
+
+    // then
+    assertThat(obj).isEqualTo(ANY_OBJECT);
+  }
+
+  @Test
+  public void shouldReturnTheCount() {
+    // given
+    RankableObjectWithFields r = new RankableObjectWithFields(ANY_OBJECT, ANY_COUNT, ANY_FIELD);
+
+    // when
+    long count = r.getCount();
+
+    // then
+    assertThat(count).isEqualTo(ANY_COUNT);
+  }
+
+  @DataProvider
+  public Object[][] fieldsData() {
+    return new Object[][]{ { ANY_OBJECT, ANY_COUNT, new Object[]{ ANY_FIELD } },
+        { "quux", 42L, new Object[]{ "one", "two", "three" } } };
+  }
+
+  @Test(dataProvider = "fieldsData")
+  public void shouldReturnTheFields(Object obj, long count, Object[] fields) {
+    // given
+    RankableObjectWithFields r = new RankableObjectWithFields(obj, count, fields);
+
+    // when
+    List<Object> actualFields = r.getFields();
+
+    // then
+    assertThat(actualFields).isEqualTo(Lists.newArrayList(fields));
+  }
+
+  @Test(expectedExceptions = UnsupportedOperationException.class)
+  public void fieldsShouldBeImmutable() {
+    // given
+    RankableObjectWithFields r = new RankableObjectWithFields(ANY_OBJECT, ANY_COUNT, ANY_FIELD);
+
+    // when
+    List<Object> fields = r.getFields();
+    // try to modify the list, which should fail
+    fields.remove(0);
+
+    // then (exception)
+  }
+
+  @Test
+  public void shouldCreateRankableObjectFromTuple() {
+    // given
+    Tuple tuple = mock(Tuple.class);
+    List<Object> tupleValues = Lists.newArrayList(ANY_OBJECT, ANY_COUNT, ANY_FIELD);
+    when(tuple.getValues()).thenReturn(tupleValues);
+
+    // when
+    RankableObjectWithFields r = RankableObjectWithFields.from(tuple);
+
+    // then
+    assertThat(r.getObject()).isEqualTo(ANY_OBJECT);
+    assertThat(r.getCount()).isEqualTo(ANY_COUNT);
+    List<Object> fields = new ArrayList<Object>();
+    fields.add(ANY_FIELD);
+    assertThat(r.getFields()).isEqualTo(fields);
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/a51c8247/test/jvm/storm/starter/tools/RankingsTest.java
----------------------------------------------------------------------
diff --git a/test/jvm/storm/starter/tools/RankingsTest.java b/test/jvm/storm/starter/tools/RankingsTest.java
index b95a86f..138a8b3 100644
--- a/test/jvm/storm/starter/tools/RankingsTest.java
+++ b/test/jvm/storm/starter/tools/RankingsTest.java
@@ -1,248 +1,235 @@
 package storm.starter.tools;
 
-import static org.fest.assertions.api.Assertions.assertThat;
-
-import java.util.List;
-
 import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
 import org.jmock.lib.concurrent.Blitzer;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-import com.google.common.collect.Lists;
-
-public class RankingsTest {
-
-    private static final int ANY_TOPN = 42;
-    private static final Rankable ANY_RANKABLE = new RankableObjectWithFields("someObject", ANY_TOPN);
-    private static final Rankable A = new RankableObjectWithFields("A", 1);
-    private static final Rankable B = new RankableObjectWithFields("B", 2);
-    private static final Rankable C = new RankableObjectWithFields("C", 3);
-    private static final Rankable D = new RankableObjectWithFields("D", 4);
-    private static final Rankable E = new RankableObjectWithFields("E", 5);
-    private static final Rankable F = new RankableObjectWithFields("F", 6);
-    private static final Rankable G = new RankableObjectWithFields("G", 7);
-    private static final Rankable H = new RankableObjectWithFields("H", 8);
-
-    @DataProvider
-    public Object[][] illegalTopNData() {
-        return new Object[][] { { 0 }, { -1 }, { -2 }, { -10 } };
-    }
-
-    @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "illegalTopNData")
-    public void constructorWithNegativeOrZeroTopNShouldThrowIAE(int topN) {
-        new Rankings(topN);
-    }
-
-    @DataProvider
-    public Object[][] legalTopNData() {
-        return new Object[][] { { 1 }, { 2 }, { 1000 }, { 1000000 } };
-    }
-
-    @Test(dataProvider = "legalTopNData")
-    public void constructorWithPositiveTopNShouldBeOk(int topN) {
-        // given/when
-        Rankings rankings = new Rankings(topN);
-
-        // then
-        assertThat(rankings.maxSize()).isEqualTo(topN);
-    }
-
-    @Test
-    public void shouldHaveDefaultConstructor() {
-        new Rankings();
-    }
-
-    @Test
-    public void defaultConstructorShouldSetPositiveTopN() {
-        // given/when
-        Rankings rankings = new Rankings();
-
-        // then
-        assertThat(rankings.maxSize()).isGreaterThan(0);
-    }
-
-    @DataProvider
-    public Object[][] rankingsGrowData() {
-        return new Object[][] {
-                {
-                        2,
-                        Lists.newArrayList(new RankableObjectWithFields("A", 1), new RankableObjectWithFields("B", 2),
-                            new RankableObjectWithFields("C", 3)) },
-                {
-                        2,
-                        Lists.newArrayList(new RankableObjectWithFields("A", 1), new RankableObjectWithFields("B", 2),
-                            new RankableObjectWithFields("C", 3), new RankableObjectWithFields("D", 4)) } };
-    }
-
-    @Test(dataProvider = "rankingsGrowData")
-    public void sizeOfRankingsShouldNotGrowBeyondTopN(int topN, List<Rankable> rankables) {
-        // sanity check of the provided test data
-        assertThat(rankables.size()).overridingErrorMessage(
-            "The supplied test data is not correct: the number of rankables <%d> should be greater than <%d>",
-            rankables.size(), topN).isGreaterThan(topN);
-
-        // given
-        Rankings rankings = new Rankings(topN);
-
-        // when
-        for (Rankable r : rankables) {
-            rankings.updateWith(r);
-        }
-
-        // then
-        assertThat(rankings.size()).isLessThanOrEqualTo(rankings.maxSize());
-    }
-
-    @DataProvider
-    public Object[][] simulatedRankingsData() {
-        return new Object[][] {
-                { Lists.newArrayList(A), Lists.newArrayList(A) },
-                { Lists.newArrayList(B, D, A, C), Lists.newArrayList(D, C, B, A) },
-                { Lists.newArrayList(B, F, A, C, D, E), Lists.newArrayList(F, E, D, C, B, A) },
-                { Lists.newArrayList(G, B, F, A, C, D, E, H), Lists.newArrayList(H, G, F, E, D, C, B, A) } };
-    }
-
-    @Test(dataProvider = "simulatedRankingsData")
-    public void shouldCorrectlyRankWhenUpdatedWithRankables(List<Rankable> unsorted, List<Rankable> expSorted) {
-        // given
-        Rankings rankings = new Rankings(unsorted.size());
-
-        // when
-        for (Rankable r : unsorted) {
-            rankings.updateWith(r);
-        }
-
-        // then
-        assertThat(rankings.getRankings()).isEqualTo(expSorted);
-    }
-
-    @Test(dataProvider = "simulatedRankingsData")
-    public void shouldCorrectlyRankWhenEmptyAndUpdatedWithOtherRankings(List<Rankable> unsorted,
-        List<Rankable> expSorted) {
-        // given
-        Rankings rankings = new Rankings(unsorted.size());
-        Rankings otherRankings = new Rankings(rankings.maxSize());
-        for (Rankable r : unsorted) {
-            otherRankings.updateWith(r);
-        }
-
-        // when
-        rankings.updateWith(otherRankings);
-
-        // then
-        assertThat(rankings.getRankings()).isEqualTo(expSorted);
-    }
-
-    @Test(dataProvider = "simulatedRankingsData")
-    public void shouldCorrectlyRankWhenUpdatedWithEmptyOtherRankings(List<Rankable> unsorted, List<Rankable> expSorted) {
-        // given
-        Rankings rankings = new Rankings(unsorted.size());
-        for (Rankable r : unsorted) {
-            rankings.updateWith(r);
-        }
-        Rankings emptyRankings = new Rankings(ANY_TOPN);
-
-        // when
-        rankings.updateWith(emptyRankings);
-
-        // then
-        assertThat(rankings.getRankings()).isEqualTo(expSorted);
-    }
-
-    @DataProvider
-    public Object[][] simulatedRankingsAndOtherRankingsData() {
-        return new Object[][] {
-                { Lists.newArrayList(A), Lists.newArrayList(A), Lists.newArrayList(A) },
-                { Lists.newArrayList(A, C), Lists.newArrayList(B, D), Lists.newArrayList(D, C, B, A) },
-                { Lists.newArrayList(B, F, A), Lists.newArrayList(C, D, E), Lists.newArrayList(F, E, D, C, B, A) },
-                {
-                        Lists.newArrayList(G, B, F, A, C),
-                        Lists.newArrayList(D, E, H),
-                        Lists.newArrayList(H, G, F, E, D, C, B, A) } };
-    }
-
-    @Test(dataProvider = "simulatedRankingsAndOtherRankingsData")
-    public void shouldCorrectlyRankWhenNotEmptyAndUpdatedWithOtherRankings(List<Rankable> unsorted,
-        List<Rankable> unsortedForOtherRankings, List<Rankable> expSorted) {
-        // given
-        Rankings rankings = new Rankings(expSorted.size());
-        for (Rankable r : unsorted) {
-            rankings.updateWith(r);
-        }
-        Rankings otherRankings = new Rankings(unsortedForOtherRankings.size());
-        for (Rankable r : unsortedForOtherRankings) {
-            otherRankings.updateWith(r);
-        }
-
-        // when
-        rankings.updateWith(otherRankings);
-
-        // then
-        assertThat(rankings.getRankings()).isEqualTo(expSorted);
-    }
+import java.util.List;
 
-    @DataProvider
-    public Object[][] duplicatesData() {
-        Rankable A1 = new RankableObjectWithFields("A", 1);
-        Rankable A2 = new RankableObjectWithFields("A", 2);
-        Rankable A3 = new RankableObjectWithFields("A", 3);
-        return new Object[][] {
-                { Lists.newArrayList(ANY_RANKABLE, ANY_RANKABLE, ANY_RANKABLE) },
-                { Lists.newArrayList(A1, A2, A3) }, };
-    }
+import static org.fest.assertions.api.Assertions.assertThat;
 
-    @Test(dataProvider = "duplicatesData")
-    public void shouldNotRankDuplicateObjectsMoreThanOnce(List<Rankable> duplicates) {
-        // given
-        Rankings rankings = new Rankings(duplicates.size());
+public class RankingsTest {
 
-        // when
-        for (Rankable r : duplicates) {
+  private static final int ANY_TOPN = 42;
+  private static final Rankable ANY_RANKABLE = new RankableObjectWithFields("someObject", ANY_TOPN);
+  private static final Rankable A = new RankableObjectWithFields("A", 1);
+  private static final Rankable B = new RankableObjectWithFields("B", 2);
+  private static final Rankable C = new RankableObjectWithFields("C", 3);
+  private static final Rankable D = new RankableObjectWithFields("D", 4);
+  private static final Rankable E = new RankableObjectWithFields("E", 5);
+  private static final Rankable F = new RankableObjectWithFields("F", 6);
+  private static final Rankable G = new RankableObjectWithFields("G", 7);
+  private static final Rankable H = new RankableObjectWithFields("H", 8);
+
+  @DataProvider
+  public Object[][] illegalTopNData() {
+    return new Object[][]{ { 0 }, { -1 }, { -2 }, { -10 } };
+  }
+
+  @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "illegalTopNData")
+  public void constructorWithNegativeOrZeroTopNShouldThrowIAE(int topN) {
+    new Rankings(topN);
+  }
+
+  @DataProvider
+  public Object[][] legalTopNData() {
+    return new Object[][]{ { 1 }, { 2 }, { 1000 }, { 1000000 } };
+  }
+
+  @Test(dataProvider = "legalTopNData")
+  public void constructorWithPositiveTopNShouldBeOk(int topN) {
+    // given/when
+    Rankings rankings = new Rankings(topN);
+
+    // then
+    assertThat(rankings.maxSize()).isEqualTo(topN);
+  }
+
+  @Test
+  public void shouldHaveDefaultConstructor() {
+    new Rankings();
+  }
+
+  @Test
+  public void defaultConstructorShouldSetPositiveTopN() {
+    // given/when
+    Rankings rankings = new Rankings();
+
+    // then
+    assertThat(rankings.maxSize()).isGreaterThan(0);
+  }
+
+  @DataProvider
+  public Object[][] rankingsGrowData() {
+    return new Object[][]{ { 2, Lists.newArrayList(new RankableObjectWithFields("A", 1), new RankableObjectWithFields(
+        "B", 2), new RankableObjectWithFields("C", 3)) }, { 2, Lists.newArrayList(new RankableObjectWithFields("A", 1),
+        new RankableObjectWithFields("B", 2), new RankableObjectWithFields("C", 3), new RankableObjectWithFields("D",
+        4)) } };
+  }
+
+  @Test(dataProvider = "rankingsGrowData")
+  public void sizeOfRankingsShouldNotGrowBeyondTopN(int topN, List<Rankable> rankables) {
+    // sanity check of the provided test data
+    assertThat(rankables.size()).overridingErrorMessage(
+        "The supplied test data is not correct: the number of rankables <%d> should be greater than <%d>",
+        rankables.size(), topN).isGreaterThan(topN);
+
+    // given
+    Rankings rankings = new Rankings(topN);
+
+    // when
+    for (Rankable r : rankables) {
+      rankings.updateWith(r);
+    }
+
+    // then
+    assertThat(rankings.size()).isLessThanOrEqualTo(rankings.maxSize());
+  }
+
+  @DataProvider
+  public Object[][] simulatedRankingsData() {
+    return new Object[][]{ { Lists.newArrayList(A), Lists.newArrayList(A) }, { Lists.newArrayList(B, D, A, C),
+        Lists.newArrayList(D, C, B, A) }, { Lists.newArrayList(B, F, A, C, D, E), Lists.newArrayList(F, E, D, C, B,
+        A) }, { Lists.newArrayList(G, B, F, A, C, D, E, H), Lists.newArrayList(H, G, F, E, D, C, B, A) } };
+  }
+
+  @Test(dataProvider = "simulatedRankingsData")
+  public void shouldCorrectlyRankWhenUpdatedWithRankables(List<Rankable> unsorted, List<Rankable> expSorted) {
+    // given
+    Rankings rankings = new Rankings(unsorted.size());
+
+    // when
+    for (Rankable r : unsorted) {
+      rankings.updateWith(r);
+    }
+
+    // then
+    assertThat(rankings.getRankings()).isEqualTo(expSorted);
+  }
+
+  @Test(dataProvider = "simulatedRankingsData")
+  public void shouldCorrectlyRankWhenEmptyAndUpdatedWithOtherRankings(List<Rankable> unsorted,
+      List<Rankable> expSorted) {
+    // given
+    Rankings rankings = new Rankings(unsorted.size());
+    Rankings otherRankings = new Rankings(rankings.maxSize());
+    for (Rankable r : unsorted) {
+      otherRankings.updateWith(r);
+    }
+
+    // when
+    rankings.updateWith(otherRankings);
+
+    // then
+    assertThat(rankings.getRankings()).isEqualTo(expSorted);
+  }
+
+  @Test(dataProvider = "simulatedRankingsData")
+  public void shouldCorrectlyRankWhenUpdatedWithEmptyOtherRankings(List<Rankable> unsorted, List<Rankable> expSorted) {
+    // given
+    Rankings rankings = new Rankings(unsorted.size());
+    for (Rankable r : unsorted) {
+      rankings.updateWith(r);
+    }
+    Rankings emptyRankings = new Rankings(ANY_TOPN);
+
+    // when
+    rankings.updateWith(emptyRankings);
+
+    // then
+    assertThat(rankings.getRankings()).isEqualTo(expSorted);
+  }
+
+  @DataProvider
+  public Object[][] simulatedRankingsAndOtherRankingsData() {
+    return new Object[][]{ { Lists.newArrayList(A), Lists.newArrayList(A), Lists.newArrayList(A) },
+        { Lists.newArrayList(A, C), Lists.newArrayList(B, D), Lists.newArrayList(D, C, B, A) }, { Lists.newArrayList(B,
+        F, A), Lists.newArrayList(C, D, E), Lists.newArrayList(F, E, D, C, B, A) }, { Lists.newArrayList(G, B, F, A, C),
+        Lists.newArrayList(D, E, H), Lists.newArrayList(H, G, F, E, D, C, B, A) } };
+  }
+
+  @Test(dataProvider = "simulatedRankingsAndOtherRankingsData")
+  public void shouldCorrectlyRankWhenNotEmptyAndUpdatedWithOtherRankings(List<Rankable> unsorted,
+      List<Rankable> unsortedForOtherRankings, List<Rankable> expSorted) {
+    // given
+    Rankings rankings = new Rankings(expSorted.size());
+    for (Rankable r : unsorted) {
+      rankings.updateWith(r);
+    }
+    Rankings otherRankings = new Rankings(unsortedForOtherRankings.size());
+    for (Rankable r : unsortedForOtherRankings) {
+      otherRankings.updateWith(r);
+    }
+
+    // when
+    rankings.updateWith(otherRankings);
+
+    // then
+    assertThat(rankings.getRankings()).isEqualTo(expSorted);
+  }
+
+  @DataProvider
+  public Object[][] duplicatesData() {
+    Rankable A1 = new RankableObjectWithFields("A", 1);
+    Rankable A2 = new RankableObjectWithFields("A", 2);
+    Rankable A3 = new RankableObjectWithFields("A", 3);
+    return new Object[][]{ { Lists.newArrayList(ANY_RANKABLE, ANY_RANKABLE, ANY_RANKABLE) }, { Lists.newArrayList(A1,
+        A2, A3) }, };
+  }
+
+  @Test(dataProvider = "duplicatesData")
+  public void shouldNotRankDuplicateObjectsMoreThanOnce(List<Rankable> duplicates) {
+    // given
+    Rankings rankings = new Rankings(duplicates.size());
+
+    // when
+    for (Rankable r : duplicates) {
+      rankings.updateWith(r);
+    }
+
+    // then
+    assertThat(rankings.size()).isEqualTo(1);
+  }
+
+  @Test
+  public void updatingWithNewRankablesShouldBeThreadSafe() throws InterruptedException {
+    // given
+    final List<Rankable> entries = ImmutableList.of(A, B, C, D);
+    final Rankings rankings = new Rankings(entries.size());
+
+    // We are capturing exceptions thrown in Blitzer's child threads into this data structure so that we can properly
+    // pass/fail this test.  The reason is that Blitzer doesn't report exceptions, which is a known bug in Blitzer
+    // (JMOCK-263).  See https://github.com/jmock-developers/jmock-library/issues/22 for more information.
+    final List<Exception> exceptions = Lists.newArrayList();
+    Blitzer blitzer = new Blitzer(1000);
+
+    // when
+    blitzer.blitz(new Runnable() {
+      public void run() {
+        for (Rankable r : entries) {
+          try {
             rankings.updateWith(r);
-        }
-
-        // then
-        assertThat(rankings.size()).isEqualTo(1);
-    }
-
-    @Test
-    public void updatingWithNewRankablesShouldBeThreadSafe() throws InterruptedException {
-        // given
-        final List<Rankable> entries = ImmutableList.of(A, B, C, D);
-        final Rankings rankings = new Rankings(entries.size());
-
-        // We are capturing exceptions thrown in Blitzer's child threads into this data structure so that we can properly
-        // pass/fail this test.  The reason is that Blitzer doesn't report exceptions, which is a known bug in Blitzer
-        // (JMOCK-263).  See https://github.com/jmock-developers/jmock-library/issues/22 for more information.
-        final List<Exception> exceptions = Lists.newArrayList();
-        Blitzer blitzer = new Blitzer(1000);
-
-        // when
-        blitzer.blitz(new Runnable() {
-            public void run() {
-                for (Rankable r : entries) {
-                    try {
-                        rankings.updateWith(r);
-                    }
-                    catch (RuntimeException e) {
-                        synchronized(exceptions) {
-                            exceptions.add(e);
-                        }
-                    }
-                }
-            }
-        });
-        blitzer.shutdown();
-
-        // then
-        //
-        if (!exceptions.isEmpty()) {
-            for (Exception e : exceptions) {
-                System.err.println(Throwables.getStackTraceAsString(e));
+          }
+          catch (RuntimeException e) {
+            synchronized(exceptions) {
+              exceptions.add(e);
             }
+          }
         }
-        assertThat(exceptions).isEmpty();
-    }
+      }
+    });
+    blitzer.shutdown();
+
+    // then
+    //
+    if (!exceptions.isEmpty()) {
+      for (Exception e : exceptions) {
+        System.err.println(Throwables.getStackTraceAsString(e));
+      }
+    }
+    assertThat(exceptions).isEmpty();
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/a51c8247/test/jvm/storm/starter/tools/SlidingWindowCounterTest.java
----------------------------------------------------------------------
diff --git a/test/jvm/storm/starter/tools/SlidingWindowCounterTest.java b/test/jvm/storm/starter/tools/SlidingWindowCounterTest.java
index 7361ac8..1c883e5 100644
--- a/test/jvm/storm/starter/tools/SlidingWindowCounterTest.java
+++ b/test/jvm/storm/starter/tools/SlidingWindowCounterTest.java
@@ -1,93 +1,89 @@
 package storm.starter.tools;
 
-import static org.fest.assertions.api.Assertions.assertThat;
-
-import java.util.Map;
-
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-public class SlidingWindowCounterTest {
-
-    private static final int ANY_WINDOW_LENGTH_IN_SLOTS = 2;
-    private static final Object ANY_OBJECT = "ANY_OBJECT";
-
-    @DataProvider
-    public Object[][] illegalWindowLengths() {
-        return new Object[][] { { -10 }, { -3 }, { -2 }, { -1 }, { 0 }, { 1 } };
-    }
-
-    @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "illegalWindowLengths")
-    public void lessThanTwoSlotsShouldThrowIAE(int windowLengthInSlots) {
-        new SlidingWindowCounter<Object>(windowLengthInSlots);
-    }
-
-    @DataProvider
-    public Object[][] legalWindowLengths() {
-        return new Object[][] { { 2 }, { 3 }, { 20 } };
-    }
-
-    @Test(dataProvider = "legalWindowLengths")
-    public void twoOrMoreSlotsShouldBeValid(int windowLengthInSlots) {
-        new SlidingWindowCounter<Object>(windowLengthInSlots);
-    }
-
-    @Test
-    public void newInstanceShouldHaveEmptyCounts() {
-        // given
-        SlidingWindowCounter<Object> counter = new SlidingWindowCounter<Object>(ANY_WINDOW_LENGTH_IN_SLOTS);
-
-        // when
-        Map<Object, Long> counts = counter.getCountsThenAdvanceWindow();
+import java.util.Map;
 
-        // then
-        assertThat(counts).isEmpty();
-    }
+import static org.fest.assertions.api.Assertions.assertThat;
 
-    @DataProvider
-    public Object[][] simulatedCounterIterations() {
-        return new Object[][] {
-                { 2, new int[] { 3, 2, 0, 0, 1, 0, 0, 0 }, new long[] { 3, 5, 2, 0, 1, 1, 0, 0 } },
-                { 3, new int[] { 3, 2, 0, 0, 1, 0, 0, 0 }, new long[] { 3, 5, 5, 2, 1, 1, 1, 0 } },
-                { 4, new int[] { 3, 2, 0, 0, 1, 0, 0, 0 }, new long[] { 3, 5, 5, 5, 3, 1, 1, 1 } },
-                { 5, new int[] { 3, 2, 0, 0, 1, 0, 0, 0 }, new long[] { 3, 5, 5, 5, 6, 3, 1, 1 } },
-                {
-                        5,
-                        new int[] { 3, 11, 5, 13, 7, 17, 0, 3, 50, 600, 7000 },
-                        new long[] { 3, 14, 19, 32, 39, 53, 42, 40, 77, 670, 7653 } }, };
-    }
+public class SlidingWindowCounterTest {
 
-    @Test(dataProvider = "simulatedCounterIterations")
-    public void testCounterWithSimulatedRuns(int windowLengthInSlots, int[] incrementsPerIteration,
-        long[] expCountsPerIteration) {
-        // given
-        SlidingWindowCounter<Object> counter = new SlidingWindowCounter<Object>(windowLengthInSlots);
-        int numIterations = incrementsPerIteration.length;
-
-        for (int i = 0; i < numIterations; i++) {
-            int numIncrements = incrementsPerIteration[i];
-            long expCounts = expCountsPerIteration[i];
-            // Objects are absent if they were zero both this iteration
-            // and the last -- if only this one, we need to report zero.
-            boolean expAbsent = ((expCounts == 0) &&
-                ((i == 0) || (expCountsPerIteration[i-1] == 0)));
-
-            // given (for this iteration)
-            for (int j = 0; j < numIncrements; j++) {
-                counter.incrementCount(ANY_OBJECT);
-            }
-
-            // when (for this iteration)
-            Map<Object, Long> counts = counter.getCountsThenAdvanceWindow();
-
-            // then (for this iteration)
-            if (expAbsent) {
-                assertThat(counts).doesNotContainKey(ANY_OBJECT);
-            }
-            else {
-                assertThat(counts.get(ANY_OBJECT)).isEqualTo(expCounts);
-            }
-        }
+  private static final int ANY_WINDOW_LENGTH_IN_SLOTS = 2;
+  private static final Object ANY_OBJECT = "ANY_OBJECT";
+
+  @DataProvider
+  public Object[][] illegalWindowLengths() {
+    return new Object[][]{ { -10 }, { -3 }, { -2 }, { -1 }, { 0 }, { 1 } };
+  }
+
+  @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "illegalWindowLengths")
+  public void lessThanTwoSlotsShouldThrowIAE(int windowLengthInSlots) {
+    new SlidingWindowCounter<Object>(windowLengthInSlots);
+  }
+
+  @DataProvider
+  public Object[][] legalWindowLengths() {
+    return new Object[][]{ { 2 }, { 3 }, { 20 } };
+  }
+
+  @Test(dataProvider = "legalWindowLengths")
+  public void twoOrMoreSlotsShouldBeValid(int windowLengthInSlots) {
+    new SlidingWindowCounter<Object>(windowLengthInSlots);
+  }
+
+  @Test
+  public void newInstanceShouldHaveEmptyCounts() {
+    // given
+    SlidingWindowCounter<Object> counter = new SlidingWindowCounter<Object>(ANY_WINDOW_LENGTH_IN_SLOTS);
+
+    // when
+    Map<Object, Long> counts = counter.getCountsThenAdvanceWindow();
+
+    // then
+    assertThat(counts).isEmpty();
+  }
+
+  @DataProvider
+  public Object[][] simulatedCounterIterations() {
+    return new Object[][]{ { 2, new int[]{ 3, 2, 0, 0, 1, 0, 0, 0 }, new long[]{ 3, 5, 2, 0, 1, 1, 0, 0 } },
+        { 3, new int[]{ 3, 2, 0, 0, 1, 0, 0, 0 }, new long[]{ 3, 5, 5, 2, 1, 1, 1, 0 } },
+        { 4, new int[]{ 3, 2, 0, 0, 1, 0, 0, 0 }, new long[]{ 3, 5, 5, 5, 3, 1, 1, 1 } },
+        { 5, new int[]{ 3, 2, 0, 0, 1, 0, 0, 0 }, new long[]{ 3, 5, 5, 5, 6, 3, 1, 1 } },
+        { 5, new int[]{ 3, 11, 5, 13, 7, 17, 0, 3, 50, 600, 7000 },
+            new long[]{ 3, 14, 19, 32, 39, 53, 42, 40, 77, 670, 7653 } }, };
+  }
+
+  @Test(dataProvider = "simulatedCounterIterations")
+  public void testCounterWithSimulatedRuns(int windowLengthInSlots, int[] incrementsPerIteration,
+      long[] expCountsPerIteration) {
+    // given
+    SlidingWindowCounter<Object> counter = new SlidingWindowCounter<Object>(windowLengthInSlots);
+    int numIterations = incrementsPerIteration.length;
+
+    for (int i = 0; i < numIterations; i++) {
+      int numIncrements = incrementsPerIteration[i];
+      long expCounts = expCountsPerIteration[i];
+      // Objects are absent if they were zero both this iteration
+      // and the last -- if only this one, we need to report zero.
+      boolean expAbsent = ((expCounts == 0) && ((i == 0) || (expCountsPerIteration[i - 1] == 0)));
+
+      // given (for this iteration)
+      for (int j = 0; j < numIncrements; j++) {
+        counter.incrementCount(ANY_OBJECT);
+      }
+
+      // when (for this iteration)
+      Map<Object, Long> counts = counter.getCountsThenAdvanceWindow();
+
+      // then (for this iteration)
+      if (expAbsent) {
+        assertThat(counts).doesNotContainKey(ANY_OBJECT);
+      }
+      else {
+        assertThat(counts.get(ANY_OBJECT)).isEqualTo(expCounts);
+      }
     }
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/a51c8247/test/jvm/storm/starter/tools/SlotBasedCounterTest.java
----------------------------------------------------------------------
diff --git a/test/jvm/storm/starter/tools/SlotBasedCounterTest.java b/test/jvm/storm/starter/tools/SlotBasedCounterTest.java
index be174d4..aeeec63 100644
--- a/test/jvm/storm/starter/tools/SlotBasedCounterTest.java
+++ b/test/jvm/storm/starter/tools/SlotBasedCounterTest.java
@@ -1,164 +1,164 @@
 package storm.starter.tools;
 
-import static org.fest.assertions.api.Assertions.assertThat;
-
-import java.util.Map;
-
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-public class SlotBasedCounterTest {
-
-    private static final int ANY_NUM_SLOTS = 1;
-    private static final int ANY_SLOT = 0;
-    private static final Object ANY_OBJECT = "ANY_OBJECT";
-
-    @DataProvider
-    public Object[][] illegalNumSlotsData() {
-        return new Object[][] { { -10 }, { -3 }, { -2 }, { -1 }, { 0 } };
-    }
-
-    @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "illegalNumSlotsData")
-    public void negativeOrZeroNumSlotsShouldThrowIAE(int numSlots) {
-        new SlotBasedCounter<Object>(numSlots);
-    }
-
-    @DataProvider
-    public Object[][] legalNumSlotsData() {
-        return new Object[][] { { 1 }, { 2 }, { 3 }, { 20 } };
-    }
-
-    @Test(dataProvider = "legalNumSlotsData")
-    public void positiveNumSlotsShouldBeOk(int numSlots) {
-        new SlotBasedCounter<Object>(numSlots);
-    }
-
-    @Test
-    public void newInstanceShouldHaveEmptyCounts() {
-        // given
-        SlotBasedCounter<Object> counter = new SlotBasedCounter<Object>(ANY_NUM_SLOTS);
-
-        // when
-        Map<Object, Long> counts = counter.getCounts();
-
-        // then
-        assertThat(counts).isEmpty();
-    }
-
-    @Test
-    public void shouldReturnNonEmptyCountsWhenAtLeastOneObjectWasCounted() {
-        // given
-        SlotBasedCounter<Object> counter = new SlotBasedCounter<Object>(ANY_NUM_SLOTS);
-        counter.incrementCount(ANY_OBJECT, ANY_SLOT);
-
-        // when
-        Map<Object, Long> counts = counter.getCounts();
-
-        // then
-        assertThat(counts).isNotEmpty();
-
-        // additional tests that go beyond what this test is primarily about
-        assertThat(counts.size()).isEqualTo(1);
-        assertThat(counts.get(ANY_OBJECT)).isEqualTo(1);
-    }
-
-    @DataProvider
-    public Object[][] incrementCountData() {
-        return new Object[][] { { new String[] { "foo", "bar" }, new int[] { 3, 2 } } };
-    }
-
-    @Test(dataProvider = "incrementCountData")
-    public void shouldIncrementCount(Object[] objects, int[] expCounts) {
-        // given
-        SlotBasedCounter<Object> counter = new SlotBasedCounter<Object>(ANY_NUM_SLOTS);
-
-        // when
-        for (int i = 0; i < objects.length; i++) {
-            Object obj = objects[i];
-            int numIncrements = expCounts[i];
-            for (int j = 0; j < numIncrements; j++) {
-                counter.incrementCount(obj, ANY_SLOT);
-            }
-        }
-
-        // then
-        for (int i = 0; i < objects.length; i++) {
-            assertThat(counter.getCount(objects[i], ANY_SLOT)).isEqualTo(expCounts[i]);
-        }
-        assertThat(counter.getCount("nonexistentObject", ANY_SLOT)).isEqualTo(0);
-    }
-
-    @Test
-    public void shouldReturnZeroForNonexistentObject() {
-        // given
-        SlotBasedCounter<Object> counter = new SlotBasedCounter<Object>(ANY_NUM_SLOTS);
-
-        // when
-        counter.incrementCount("somethingElse", ANY_SLOT);
+import java.util.Map;
 
-        // then
-        assertThat(counter.getCount("nonexistentObject", ANY_SLOT)).isEqualTo(0);
-    }
+import static org.fest.assertions.api.Assertions.assertThat;
 
-    @Test
-    public void shouldIncrementCountOnlyOneSlotAtATime() {
-        // given
-        int numSlots = 3;
-        Object obj = Long.valueOf(10);
-        SlotBasedCounter<Object> counter = new SlotBasedCounter<Object>(numSlots);
-
-        // when (empty)
-        // then
-        assertThat(counter.getCount(obj, 0)).isEqualTo(0);
-        assertThat(counter.getCount(obj, 1)).isEqualTo(0);
-        assertThat(counter.getCount(obj, 2)).isEqualTo(0);
-
-        // when
-        counter.incrementCount(obj, 1);
-
-        // then
-        assertThat(counter.getCount(obj, 0)).isEqualTo(0);
-        assertThat(counter.getCount(obj, 1)).isEqualTo(1);
-        assertThat(counter.getCount(obj, 2)).isEqualTo(0);
-    }
+public class SlotBasedCounterTest {
 
-    @Test
-    public void wipeSlotShouldSetAllCountsInSlotToZero() {
-        // given
-        SlotBasedCounter<Object> counter = new SlotBasedCounter<Object>(ANY_NUM_SLOTS);
-        Object countWasOne = "countWasOne";
-        Object countWasThree = "countWasThree";
-        counter.incrementCount(countWasOne, ANY_SLOT);
-        counter.incrementCount(countWasThree, ANY_SLOT);
-        counter.incrementCount(countWasThree, ANY_SLOT);
-        counter.incrementCount(countWasThree, ANY_SLOT);
-
-        // when
-        counter.wipeSlot(ANY_SLOT);
-
-        // then
-        assertThat(counter.getCount(countWasOne, ANY_SLOT)).isEqualTo(0);
-        assertThat(counter.getCount(countWasThree, ANY_SLOT)).isEqualTo(0);
+  private static final int ANY_NUM_SLOTS = 1;
+  private static final int ANY_SLOT = 0;
+  private static final Object ANY_OBJECT = "ANY_OBJECT";
+
+  @DataProvider
+  public Object[][] illegalNumSlotsData() {
+    return new Object[][]{ { -10 }, { -3 }, { -2 }, { -1 }, { 0 } };
+  }
+
+  @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "illegalNumSlotsData")
+  public void negativeOrZeroNumSlotsShouldThrowIAE(int numSlots) {
+    new SlotBasedCounter<Object>(numSlots);
+  }
+
+  @DataProvider
+  public Object[][] legalNumSlotsData() {
+    return new Object[][]{ { 1 }, { 2 }, { 3 }, { 20 } };
+  }
+
+  @Test(dataProvider = "legalNumSlotsData")
+  public void positiveNumSlotsShouldBeOk(int numSlots) {
+    new SlotBasedCounter<Object>(numSlots);
+  }
+
+  @Test
+  public void newInstanceShouldHaveEmptyCounts() {
+    // given
+    SlotBasedCounter<Object> counter = new SlotBasedCounter<Object>(ANY_NUM_SLOTS);
+
+    // when
+    Map<Object, Long> counts = counter.getCounts();
+
+    // then
+    assertThat(counts).isEmpty();
+  }
+
+  @Test
+  public void shouldReturnNonEmptyCountsWhenAtLeastOneObjectWasCounted() {
+    // given
+    SlotBasedCounter<Object> counter = new SlotBasedCounter<Object>(ANY_NUM_SLOTS);
+    counter.incrementCount(ANY_OBJECT, ANY_SLOT);
+
+    // when
+    Map<Object, Long> counts = counter.getCounts();
+
+    // then
+    assertThat(counts).isNotEmpty();
+
+    // additional tests that go beyond what this test is primarily about
+    assertThat(counts.size()).isEqualTo(1);
+    assertThat(counts.get(ANY_OBJECT)).isEqualTo(1);
+  }
+
+  @DataProvider
+  public Object[][] incrementCountData() {
+    return new Object[][]{ { new String[]{ "foo", "bar" }, new int[]{ 3, 2 } } };
+  }
+
+  @Test(dataProvider = "incrementCountData")
+  public void shouldIncrementCount(Object[] objects, int[] expCounts) {
+    // given
+    SlotBasedCounter<Object> counter = new SlotBasedCounter<Object>(ANY_NUM_SLOTS);
+
+    // when
+    for (int i = 0; i < objects.length; i++) {
+      Object obj = objects[i];
+      int numIncrements = expCounts[i];
+      for (int j = 0; j < numIncrements; j++) {
+        counter.incrementCount(obj, ANY_SLOT);
+      }
     }
 
-    @Test
-    public void wipeZerosShouldRemoveAnyObjectsWithZeroTotalCount() {
-        // given
-        SlotBasedCounter<Object> counter = new SlotBasedCounter<Object>(2);
-        int wipeSlot = 0;
-        int otherSlot = 1;
-        Object willBeRemoved = "willBeRemoved";
-        Object willContinueToBeTracked = "willContinueToBeTracked";
-        counter.incrementCount(willBeRemoved, wipeSlot);
-        counter.incrementCount(willContinueToBeTracked, wipeSlot);
-        counter.incrementCount(willContinueToBeTracked, otherSlot);
-
-        // when
-        counter.wipeSlot(wipeSlot);
-        counter.wipeZeros();
-
-        // then
-        assertThat(counter.getCounts()).doesNotContainKey(willBeRemoved);
-        assertThat(counter.getCounts()).containsKey(willContinueToBeTracked);
+    // then
+    for (int i = 0; i < objects.length; i++) {
+      assertThat(counter.getCount(objects[i], ANY_SLOT)).isEqualTo(expCounts[i]);
     }
+    assertThat(counter.getCount("nonexistentObject", ANY_SLOT)).isEqualTo(0);
+  }
+
+  @Test
+  public void shouldReturnZeroForNonexistentObject() {
+    // given
+    SlotBasedCounter<Object> counter = new SlotBasedCounter<Object>(ANY_NUM_SLOTS);
+
+    // when
+    counter.incrementCount("somethingElse", ANY_SLOT);
+
+    // then
+    assertThat(counter.getCount("nonexistentObject", ANY_SLOT)).isEqualTo(0);
+  }
+
+  @Test
+  public void shouldIncrementCountOnlyOneSlotAtATime() {
+    // given
+    int numSlots = 3;
+    Object obj = Long.valueOf(10);
+    SlotBasedCounter<Object> counter = new SlotBasedCounter<Object>(numSlots);
+
+    // when (empty)
+    // then
+    assertThat(counter.getCount(obj, 0)).isEqualTo(0);
+    assertThat(counter.getCount(obj, 1)).isEqualTo(0);
+    assertThat(counter.getCount(obj, 2)).isEqualTo(0);
+
+    // when
+    counter.incrementCount(obj, 1);
+
+    // then
+    assertThat(counter.getCount(obj, 0)).isEqualTo(0);
+    assertThat(counter.getCount(obj, 1)).isEqualTo(1);
+    assertThat(counter.getCount(obj, 2)).isEqualTo(0);
+  }
+
+  @Test
+  public void wipeSlotShouldSetAllCountsInSlotToZero() {
+    // given
+    SlotBasedCounter<Object> counter = new SlotBasedCounter<Object>(ANY_NUM_SLOTS);
+    Object countWasOne = "countWasOne";
+    Object countWasThree = "countWasThree";
+    counter.incrementCount(countWasOne, ANY_SLOT);
+    counter.incrementCount(countWasThree, ANY_SLOT);
+    counter.incrementCount(countWasThree, ANY_SLOT);
+    counter.incrementCount(countWasThree, ANY_SLOT);
+
+    // when
+    counter.wipeSlot(ANY_SLOT);
+
+    // then
+    assertThat(counter.getCount(countWasOne, ANY_SLOT)).isEqualTo(0);
+    assertThat(counter.getCount(countWasThree, ANY_SLOT)).isEqualTo(0);
+  }
+
+  @Test
+  public void wipeZerosShouldRemoveAnyObjectsWithZeroTotalCount() {
+    // given
+    SlotBasedCounter<Object> counter = new SlotBasedCounter<Object>(2);
+    int wipeSlot = 0;
+    int otherSlot = 1;
+    Object willBeRemoved = "willBeRemoved";
+    Object willContinueToBeTracked = "willContinueToBeTracked";
+    counter.incrementCount(willBeRemoved, wipeSlot);
+    counter.incrementCount(willContinueToBeTracked, wipeSlot);
+    counter.incrementCount(willContinueToBeTracked, otherSlot);
+
+    // when
+    counter.wipeSlot(wipeSlot);
+    counter.wipeZeros();
+
+    // then
+    assertThat(counter.getCounts()).doesNotContainKey(willBeRemoved);
+    assertThat(counter.getCounts()).containsKey(willContinueToBeTracked);
+  }
 }