@Test
  public void serialization() {
    int size = COLLISIONS.size();
    for (int i = 1; i < size; i++) {
      MutableSet<Integer> set =
          UnifiedSetWithHashingStrategy.newSet(INTEGER_HASHING_STRATEGY, SIZE)
              .withAll(COLLISIONS.subList(0, i));
      Verify.assertPostSerializedEqualsAndHashCode(set);
      set.add(null);
      Verify.assertPostSerializedEqualsAndHashCode(set);
    }

    UnifiedSetWithHashingStrategy<Integer> nullBucketZero =
        UnifiedSetWithHashingStrategy.newSetWith(
            INTEGER_HASHING_STRATEGY, null, COLLISION_1, COLLISION_2);
    Verify.assertPostSerializedEqualsAndHashCode(nullBucketZero);

    UnifiedSetWithHashingStrategy<Integer> simpleSetWithNull =
        UnifiedSetWithHashingStrategy.newSetWith(INTEGER_HASHING_STRATEGY, null, 1, 2);
    Verify.assertPostSerializedEqualsAndHashCode(simpleSetWithNull);

    UnifiedSetWithHashingStrategy<Person> people =
        UnifiedSetWithHashingStrategy.newSet(LAST_NAME_HASHING_STRATEGY, PEOPLE);
    Verify.assertPostSerializedEqualsAndHashCode(people);
    // Testing the hashingStrategy is serialized correctly by making sure it is still hashing by
    // last name
    Verify.assertSetsEqual(LAST_NAME_HASHED_SET.castToSet(), people.withAll(PEOPLE.castToList()));
  }
  private static void assertUnifiedSetEqualsAndHashCode(int shift) {
    MutableSet<CollidingInt> set1 = MultiReaderUnifiedSet.newSet();
    Set<CollidingInt> set2 = new HashSet<CollidingInt>();
    MutableSet<CollidingInt> set3 = MultiReaderUnifiedSet.newSet();
    MutableSet<CollidingInt> set4 = MultiReaderUnifiedSet.newSet();

    int size = 100000;
    for (int i = 0; i < size; i++) {
      set1.add(new CollidingInt(i, shift));
      set2.add(new CollidingInt(i, shift));
      set3.add(new CollidingInt(i, shift));
      set4.add(new CollidingInt(size - i - 1, shift));
    }

    Assert.assertEquals(set1, set2);
    Assert.assertEquals(set1.hashCode(), set2.hashCode());
    Verify.assertSetsEqual(set1, set3);
    Verify.assertEqualsAndHashCode(set1, set3);
    Verify.assertSetsEqual(set2, set4);
    Assert.assertEquals(set4, set2);
    Assert.assertEquals(set2.hashCode(), set4.hashCode());
  }
 @Test
 public void addingAllToOtherSet() {
   MutableSet<String> newSet = UnifiedSet.newSet(Sets.fixedSize.of("1", "2", "3", "4"));
   newSet.add("5");
   Verify.assertContainsAll(newSet, "1", "2", "3", "4", "5");
 }
 @Override
 public <V> StateMachine<T> define(V state) {
   states.add(state);
   return this;
 }
 @Test
 public void testNewEmpty() {
   MutableSet<String> set = this.unmodifiableSet.newEmpty();
   set.add(LED_ZEPPELIN);
   Verify.assertContains(LED_ZEPPELIN, set);
 }