All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.common.collect.testing.google.MultimapTestSuiteBuilder Maven / Gradle / Ivy

Go to download

Guava testlib is a set of java classes used for more convenient unit testing - particularly to assist the tests for Guava itself.

There is a newer version: 33.3.1-jre
Show newest version
/*
 * Copyright (C) 2012 The Guava Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.common.collect.testing.google;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.testing.Helpers.mapEntry;

import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multiset;
import com.google.common.collect.testing.AbstractTester;
import com.google.common.collect.testing.CollectionTestSuiteBuilder;
import com.google.common.collect.testing.DerivedGenerator;
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
import com.google.common.collect.testing.Helpers;
import com.google.common.collect.testing.MapTestSuiteBuilder;
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
import com.google.common.collect.testing.PerCollectionSizeTestSuiteBuilder;
import com.google.common.collect.testing.SampleElements;
import com.google.common.collect.testing.TestCollectionGenerator;
import com.google.common.collect.testing.TestMapGenerator;
import com.google.common.collect.testing.TestSubjectGenerator;
import com.google.common.collect.testing.features.CollectionFeature;
import com.google.common.collect.testing.features.CollectionSize;
import com.google.common.collect.testing.features.Feature;
import com.google.common.collect.testing.features.ListFeature;
import com.google.common.collect.testing.features.MapFeature;
import com.google.common.testing.SerializableTester;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import junit.framework.TestSuite;

/**
 * Creates, based on your criteria, a JUnit test suite that exhaustively tests a {@code Multimap}
 * implementation.
 *
 * @author Louis Wasserman
 */
@GwtIncompatible
public class MultimapTestSuiteBuilder>
    extends PerCollectionSizeTestSuiteBuilder<
        MultimapTestSuiteBuilder, TestMultimapGenerator, M, Entry> {

  public static > MultimapTestSuiteBuilder using(
      TestMultimapGenerator generator) {
    return new MultimapTestSuiteBuilder().usingGenerator(generator);
  }

  // Class parameters must be raw.
  @SuppressWarnings("rawtypes") // class literals
  @Override
  protected List> getTesters() {
    return ImmutableList.>of(
        MultimapAsMapGetTester.class,
        MultimapAsMapTester.class,
        MultimapSizeTester.class,
        MultimapClearTester.class,
        MultimapContainsKeyTester.class,
        MultimapContainsValueTester.class,
        MultimapContainsEntryTester.class,
        MultimapEntriesTester.class,
        MultimapEqualsTester.class,
        MultimapForEachTester.class,
        MultimapGetTester.class,
        MultimapKeySetTester.class,
        MultimapKeysTester.class,
        MultimapPutTester.class,
        MultimapPutAllMultimapTester.class,
        MultimapPutIterableTester.class,
        MultimapReplaceValuesTester.class,
        MultimapRemoveEntryTester.class,
        MultimapRemoveAllTester.class,
        MultimapToStringTester.class,
        MultimapValuesTester.class);
  }

  @Override
  protected List createDerivedSuites(
      FeatureSpecificTestSuiteBuilder>>
          parentBuilder) {
    // TODO: Once invariant support is added, supply invariants to each of the
    // derived suites, to check that mutations to the derived collections are
    // reflected in the underlying map.

    List derivedSuites = super.createDerivedSuites(parentBuilder);

    if (parentBuilder.getFeatures().contains(CollectionFeature.SERIALIZABLE)) {
      derivedSuites.add(
          MultimapTestSuiteBuilder.using(
                  new ReserializedMultimapGenerator(parentBuilder.getSubjectGenerator()))
              .withFeatures(computeReserializedMultimapFeatures(parentBuilder.getFeatures()))
              .named(parentBuilder.getName() + " reserialized")
              .suppressing(parentBuilder.getSuppressedTests())
              .withSetUp(parentBuilder.getSetUp())
              .withTearDown(parentBuilder.getTearDown())
              .createTestSuite());
    }

    derivedSuites.add(
        MapTestSuiteBuilder.using(new AsMapGenerator(parentBuilder.getSubjectGenerator()))
            .withFeatures(computeAsMapFeatures(parentBuilder.getFeatures()))
            .named(parentBuilder.getName() + ".asMap")
            .suppressing(parentBuilder.getSuppressedTests())
            .withSetUp(parentBuilder.getSetUp())
            .withTearDown(parentBuilder.getTearDown())
            .createTestSuite());

    derivedSuites.add(computeEntriesTestSuite(parentBuilder));
    derivedSuites.add(computeMultimapGetTestSuite(parentBuilder));
    derivedSuites.add(computeMultimapAsMapGetTestSuite(parentBuilder));
    derivedSuites.add(computeKeysTestSuite(parentBuilder));
    derivedSuites.add(computeValuesTestSuite(parentBuilder));

    return derivedSuites;
  }

  TestSuite computeValuesTestSuite(
      FeatureSpecificTestSuiteBuilder>>
          parentBuilder) {
    return CollectionTestSuiteBuilder.using(
            new ValuesGenerator(parentBuilder.getSubjectGenerator()))
        .withFeatures(computeValuesFeatures(parentBuilder.getFeatures()))
        .named(parentBuilder.getName() + ".values")
        .suppressing(parentBuilder.getSuppressedTests())
        .createTestSuite();
  }

  TestSuite computeEntriesTestSuite(
      FeatureSpecificTestSuiteBuilder>>
          parentBuilder) {
    return CollectionTestSuiteBuilder.using(
            new EntriesGenerator(parentBuilder.getSubjectGenerator()))
        .withFeatures(computeEntriesFeatures(parentBuilder.getFeatures()))
        .named(parentBuilder.getName() + ".entries")
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())
        .createTestSuite();
  }

  TestSuite computeMultimapGetTestSuite(
      FeatureSpecificTestSuiteBuilder>>
          parentBuilder) {
    return CollectionTestSuiteBuilder.using(
            new MultimapGetGenerator(parentBuilder.getSubjectGenerator()))
        .withFeatures(computeMultimapGetFeatures(parentBuilder.getFeatures()))
        .named(parentBuilder.getName() + ".get[key]")
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())
        .createTestSuite();
  }

  TestSuite computeMultimapAsMapGetTestSuite(
      FeatureSpecificTestSuiteBuilder>>
          parentBuilder) {
    Set> features = computeMultimapAsMapGetFeatures(parentBuilder.getFeatures());
    if (Collections.disjoint(features, EnumSet.allOf(CollectionSize.class))) {
      return new TestSuite();
    } else {
      return CollectionTestSuiteBuilder.using(
              new MultimapAsMapGetGenerator(parentBuilder.getSubjectGenerator()))
          .withFeatures(features)
          .named(parentBuilder.getName() + ".asMap[].get[key]")
          .suppressing(parentBuilder.getSuppressedTests())
          .withSetUp(parentBuilder.getSetUp())
          .withTearDown(parentBuilder.getTearDown())
          .createTestSuite();
    }
  }

  TestSuite computeKeysTestSuite(
      FeatureSpecificTestSuiteBuilder>>
          parentBuilder) {
    return MultisetTestSuiteBuilder.using(
            new KeysGenerator(parentBuilder.getSubjectGenerator()))
        .withFeatures(computeKeysFeatures(parentBuilder.getFeatures()))
        .named(parentBuilder.getName() + ".keys")
        .suppressing(parentBuilder.getSuppressedTests())
        .withSetUp(parentBuilder.getSetUp())
        .withTearDown(parentBuilder.getTearDown())
        .createTestSuite();
  }

  static Set> computeDerivedCollectionFeatures(Set> multimapFeatures) {
    Set> derivedFeatures = Helpers.copyToSet(multimapFeatures);
    if (!derivedFeatures.remove(CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS)) {
      derivedFeatures.remove(CollectionFeature.SERIALIZABLE);
    }
    if (derivedFeatures.remove(MapFeature.SUPPORTS_REMOVE)) {
      derivedFeatures.add(CollectionFeature.SUPPORTS_REMOVE);
    }
    return derivedFeatures;
  }

  static Set> computeEntriesFeatures(Set> multimapFeatures) {
    Set> result = computeDerivedCollectionFeatures(multimapFeatures);
    if (multimapFeatures.contains(MapFeature.ALLOWS_NULL_ENTRY_QUERIES)) {
      result.add(CollectionFeature.ALLOWS_NULL_QUERIES);
    }
    return result;
  }

  static Set> computeValuesFeatures(Set> multimapFeatures) {
    Set> result = computeDerivedCollectionFeatures(multimapFeatures);
    if (multimapFeatures.contains(MapFeature.ALLOWS_NULL_VALUES)) {
      result.add(CollectionFeature.ALLOWS_NULL_VALUES);
    }
    if (multimapFeatures.contains(MapFeature.ALLOWS_NULL_VALUE_QUERIES)) {
      result.add(CollectionFeature.ALLOWS_NULL_QUERIES);
    }
    return result;
  }

  static Set> computeKeysFeatures(Set> multimapFeatures) {
    Set> result = computeDerivedCollectionFeatures(multimapFeatures);
    if (multimapFeatures.contains(MapFeature.ALLOWS_NULL_KEYS)) {
      result.add(CollectionFeature.ALLOWS_NULL_VALUES);
    }
    if (multimapFeatures.contains(MapFeature.ALLOWS_NULL_KEY_QUERIES)) {
      result.add(CollectionFeature.ALLOWS_NULL_QUERIES);
    }
    return result;
  }

  private static Set> computeReserializedMultimapFeatures(
      Set> multimapFeatures) {
    Set> derivedFeatures = Helpers.copyToSet(multimapFeatures);
    derivedFeatures.remove(CollectionFeature.SERIALIZABLE);
    derivedFeatures.remove(CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS);
    return derivedFeatures;
  }

  private static Set> computeAsMapFeatures(Set> multimapFeatures) {
    Set> derivedFeatures = Helpers.copyToSet(multimapFeatures);
    derivedFeatures.remove(MapFeature.GENERAL_PURPOSE);
    derivedFeatures.remove(MapFeature.SUPPORTS_PUT);
    derivedFeatures.remove(MapFeature.ALLOWS_NULL_VALUES);
    derivedFeatures.add(MapFeature.ALLOWS_NULL_VALUE_QUERIES);
    derivedFeatures.add(MapFeature.REJECTS_DUPLICATES_AT_CREATION);
    if (!derivedFeatures.contains(CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS)) {
      derivedFeatures.remove(CollectionFeature.SERIALIZABLE);
    }
    return derivedFeatures;
  }

  private static final ImmutableMultimap, Feature> GET_FEATURE_MAP =
      ImmutableMultimap., Feature>builder()
          .put(
              MapFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
              CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION)
          .put(MapFeature.GENERAL_PURPOSE, ListFeature.SUPPORTS_ADD_WITH_INDEX)
          .put(MapFeature.GENERAL_PURPOSE, ListFeature.SUPPORTS_REMOVE_WITH_INDEX)
          .put(MapFeature.GENERAL_PURPOSE, ListFeature.SUPPORTS_SET)
          .put(MapFeature.ALLOWS_NULL_VALUE_QUERIES, CollectionFeature.ALLOWS_NULL_QUERIES)
          .put(MapFeature.ALLOWS_NULL_VALUES, CollectionFeature.ALLOWS_NULL_VALUES)
          .put(MapFeature.SUPPORTS_REMOVE, CollectionFeature.SUPPORTS_REMOVE)
          .put(MapFeature.SUPPORTS_PUT, CollectionFeature.SUPPORTS_ADD)
          .build();

  Set> computeMultimapGetFeatures(Set> multimapFeatures) {
    Set> derivedFeatures = Helpers.copyToSet(multimapFeatures);
    for (Entry, Feature> entry : GET_FEATURE_MAP.entries()) {
      if (derivedFeatures.contains(entry.getKey())) {
        derivedFeatures.add(entry.getValue());
      }
    }
    if (derivedFeatures.remove(MultimapFeature.VALUE_COLLECTIONS_SUPPORT_ITERATOR_REMOVE)) {
      derivedFeatures.add(CollectionFeature.SUPPORTS_ITERATOR_REMOVE);
    }
    if (!derivedFeatures.contains(CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS)) {
      derivedFeatures.remove(CollectionFeature.SERIALIZABLE);
    }
    derivedFeatures.removeAll(GET_FEATURE_MAP.keySet());
    return derivedFeatures;
  }

  Set> computeMultimapAsMapGetFeatures(Set> multimapFeatures) {
    Set> derivedFeatures =
        Helpers.copyToSet(computeMultimapGetFeatures(multimapFeatures));
    if (derivedFeatures.remove(CollectionSize.ANY)) {
      derivedFeatures.addAll(CollectionSize.ANY.getImpliedFeatures());
    }
    derivedFeatures.remove(CollectionSize.ZERO);
    return derivedFeatures;
  }

  private static class AsMapGenerator>
      implements TestMapGenerator>, DerivedGenerator {
    private final OneSizeTestContainerGenerator> multimapGenerator;

    public AsMapGenerator(OneSizeTestContainerGenerator> multimapGenerator) {
      this.multimapGenerator = multimapGenerator;
    }

    @Override
    public TestSubjectGenerator getInnerGenerator() {
      return multimapGenerator;
    }

    private Collection createCollection(V v) {
      return ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
          .createCollection(Collections.singleton(v));
    }

    @Override
    public SampleElements>> samples() {
      SampleElements sampleKeys =
          ((TestMultimapGenerator) multimapGenerator.getInnerGenerator()).sampleKeys();
      SampleElements sampleValues =
          ((TestMultimapGenerator) multimapGenerator.getInnerGenerator()).sampleValues();
      return new SampleElements<>(
          mapEntry(sampleKeys.e0(), createCollection(sampleValues.e0())),
          mapEntry(sampleKeys.e1(), createCollection(sampleValues.e1())),
          mapEntry(sampleKeys.e2(), createCollection(sampleValues.e2())),
          mapEntry(sampleKeys.e3(), createCollection(sampleValues.e3())),
          mapEntry(sampleKeys.e4(), createCollection(sampleValues.e4())));
    }

    @Override
    public Map> create(Object... elements) {
      Set keySet = new HashSet<>();
      List> builder = new ArrayList<>();
      for (Object o : elements) {
        Entry entry = (Entry) o;
        // These come from Entry>> objects somewhere.
        @SuppressWarnings("unchecked")
        K key = (K) entry.getKey();
        keySet.add(key);
        for (Object v : (Collection) entry.getValue()) {
          // These come from Entry>> objects somewhere.
          @SuppressWarnings("unchecked")
          V value = (V) v;
          builder.add(mapEntry(key, value));
        }
      }
      checkArgument(keySet.size() == elements.length, "Duplicate keys");
      return multimapGenerator.create(builder.toArray()).asMap();
    }

    @SuppressWarnings("unchecked")
    @Override
    public Entry>[] createArray(int length) {
      return (Entry>[]) new Entry[length];
    }

    @Override
    public Iterable>> order(List>> insertionOrder) {
      Map> map = new HashMap<>();
      List> builder = new ArrayList<>();
      for (Entry> entry : insertionOrder) {
        for (V v : entry.getValue()) {
          builder.add(mapEntry(entry.getKey(), v));
        }
        map.put(entry.getKey(), entry.getValue());
      }
      Iterable> ordered = multimapGenerator.order(builder);
      LinkedHashMap> orderedMap = new LinkedHashMap<>();
      for (Entry entry : ordered) {
        orderedMap.put(entry.getKey(), map.get(entry.getKey()));
      }
      return orderedMap.entrySet();
    }

    @Override
    public K[] createKeyArray(int length) {
      return ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
          .createKeyArray(length);
    }

    @SuppressWarnings("unchecked")
    @Override
    public Collection[] createValueArray(int length) {
      return (Collection[]) new Collection[length];
    }
  }

  static class EntriesGenerator>
      implements TestCollectionGenerator>, DerivedGenerator {
    private final OneSizeTestContainerGenerator> multimapGenerator;

    public EntriesGenerator(OneSizeTestContainerGenerator> multimapGenerator) {
      this.multimapGenerator = multimapGenerator;
    }

    @Override
    public TestSubjectGenerator getInnerGenerator() {
      return multimapGenerator;
    }

    @Override
    public SampleElements> samples() {
      return multimapGenerator.samples();
    }

    @Override
    public Collection> create(Object... elements) {
      return multimapGenerator.create(elements).entries();
    }

    @SuppressWarnings("unchecked")
    @Override
    public Entry[] createArray(int length) {
      return (Entry[]) new Entry[length];
    }

    @Override
    public Iterable> order(List> insertionOrder) {
      return multimapGenerator.order(insertionOrder);
    }
  }

  static class ValuesGenerator>
      implements TestCollectionGenerator {
    private final OneSizeTestContainerGenerator> multimapGenerator;

    public ValuesGenerator(OneSizeTestContainerGenerator> multimapGenerator) {
      this.multimapGenerator = multimapGenerator;
    }

    @Override
    public SampleElements samples() {
      return ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
          .sampleValues();
    }

    @Override
    public Collection create(Object... elements) {
      K k =
          ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
              .sampleKeys()
              .e0();
      Object[] entries = new Object[elements.length];
      for (int i = 0; i < elements.length; i++) {
        @SuppressWarnings("unchecked") // These come from Entry objects somewhere.
        V value = (V) elements[i];
        entries[i] = mapEntry(k, value);
      }
      return multimapGenerator.create(entries).values();
    }

    @Override
    public V[] createArray(int length) {
      return ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
          .createValueArray(length);
    }

    @Override
    public Iterable order(List insertionOrder) {
      K k =
          ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
              .sampleKeys()
              .e0();
      List> entries = new ArrayList<>();
      for (V v : insertionOrder) {
        entries.add(mapEntry(k, v));
      }
      Iterable> ordered = multimapGenerator.order(entries);
      List orderedValues = new ArrayList<>();
      for (Entry entry : ordered) {
        orderedValues.add(entry.getValue());
      }
      return orderedValues;
    }
  }

  static class KeysGenerator>
      implements TestMultisetGenerator, DerivedGenerator {
    private final OneSizeTestContainerGenerator> multimapGenerator;

    public KeysGenerator(OneSizeTestContainerGenerator> multimapGenerator) {
      this.multimapGenerator = multimapGenerator;
    }

    @Override
    public TestSubjectGenerator getInnerGenerator() {
      return multimapGenerator;
    }

    @Override
    public SampleElements samples() {
      return ((TestMultimapGenerator) multimapGenerator.getInnerGenerator()).sampleKeys();
    }

    @Override
    public Multiset create(Object... elements) {
      /*
       * This is nasty and complicated, but it's the only way to make sure keys get mapped to enough
       * distinct values.
       */
      Entry[] entries = new Entry[elements.length];
      Map> valueIterators = new HashMap<>();
      for (int i = 0; i < elements.length; i++) {
        @SuppressWarnings("unchecked") // These come from Entry objects somewhere.
        K key = (K) elements[i];

        Iterator valueItr = valueIterators.get(key);
        if (valueItr == null) {
          valueIterators.put(key, valueItr = sampleValuesIterator());
        }
        entries[i] = mapEntry(key, valueItr.next());
      }
      return multimapGenerator.create((Object[]) entries).keys();
    }

    private Iterator sampleValuesIterator() {
      return ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
          .sampleValues()
          .iterator();
    }

    @Override
    public K[] createArray(int length) {
      return ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
          .createKeyArray(length);
    }

    @Override
    public Iterable order(List insertionOrder) {
      Iterator valueIter = sampleValuesIterator();
      List> entries = new ArrayList<>();
      for (K k : insertionOrder) {
        entries.add(mapEntry(k, valueIter.next()));
      }
      Iterable> ordered = multimapGenerator.order(entries);
      List orderedValues = new ArrayList<>();
      for (Entry entry : ordered) {
        orderedValues.add(entry.getKey());
      }
      return orderedValues;
    }
  }

  static class MultimapGetGenerator>
      implements TestCollectionGenerator {
    final OneSizeTestContainerGenerator> multimapGenerator;

    public MultimapGetGenerator(OneSizeTestContainerGenerator> multimapGenerator) {
      this.multimapGenerator = multimapGenerator;
    }

    @Override
    public SampleElements samples() {
      return ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
          .sampleValues();
    }

    @Override
    public V[] createArray(int length) {
      return ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
          .createValueArray(length);
    }

    @Override
    public Iterable order(List insertionOrder) {
      K k =
          ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
              .sampleKeys()
              .e0();
      List> entries = new ArrayList<>();
      for (V v : insertionOrder) {
        entries.add(mapEntry(k, v));
      }
      Iterable> orderedEntries = multimapGenerator.order(entries);
      List values = new ArrayList<>();
      for (Entry entry : orderedEntries) {
        values.add(entry.getValue());
      }
      return values;
    }

    @Override
    public Collection create(Object... elements) {
      Entry[] array = multimapGenerator.createArray(elements.length);
      K k =
          ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
              .sampleKeys()
              .e0();
      for (int i = 0; i < elements.length; i++) {
        @SuppressWarnings("unchecked") // These come from Entry objects somewhere.
        V value = (V) elements[i];
        array[i] = mapEntry(k, value);
      }
      return multimapGenerator.create((Object[]) array).get(k);
    }
  }

  static class MultimapAsMapGetGenerator>
      extends MultimapGetGenerator {

    public MultimapAsMapGetGenerator(
        OneSizeTestContainerGenerator> multimapGenerator) {
      super(multimapGenerator);
    }

    @Override
    public Collection create(Object... elements) {
      Entry[] array = multimapGenerator.createArray(elements.length);
      K k =
          ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
              .sampleKeys()
              .e0();
      for (int i = 0; i < elements.length; i++) {
        @SuppressWarnings("unchecked") // These come from Entry objects somewhere.
        V value = (V) elements[i];
        array[i] = mapEntry(k, value);
      }
      return multimapGenerator.create((Object[]) array).asMap().get(k);
    }
  }

  private static class ReserializedMultimapGenerator>
      implements TestMultimapGenerator {
    private final OneSizeTestContainerGenerator> multimapGenerator;

    public ReserializedMultimapGenerator(
        OneSizeTestContainerGenerator> multimapGenerator) {
      this.multimapGenerator = multimapGenerator;
    }

    @Override
    public SampleElements> samples() {
      return multimapGenerator.samples();
    }

    @Override
    public Entry[] createArray(int length) {
      return multimapGenerator.createArray(length);
    }

    @Override
    public Iterable> order(List> insertionOrder) {
      return multimapGenerator.order(insertionOrder);
    }

    @Override
    public M create(Object... elements) {
      return SerializableTester.reserialize(
          ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
              .create(elements));
    }

    @Override
    public K[] createKeyArray(int length) {
      return ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
          .createKeyArray(length);
    }

    @Override
    public V[] createValueArray(int length) {
      return ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
          .createValueArray(length);
    }

    @Override
    public SampleElements sampleKeys() {
      return ((TestMultimapGenerator) multimapGenerator.getInnerGenerator()).sampleKeys();
    }

    @Override
    public SampleElements sampleValues() {
      return ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
          .sampleValues();
    }

    @Override
    public Collection createCollection(Iterable values) {
      return ((TestMultimapGenerator) multimapGenerator.getInnerGenerator())
          .createCollection(values);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy