1 /* 2 * Copyright (C) 2012 The Guava Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 * in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the License 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 * or implied. See the License for the specific language governing permissions and limitations under 12 * the License. 13 */ 14 15 package com.google.common.collect.testing.google; 16 17 import static com.google.common.collect.testing.Helpers.copyToSet; 18 import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT; 19 20 import com.google.common.annotations.GwtCompatible; 21 import com.google.common.collect.SetMultimap; 22 import com.google.common.collect.testing.features.MapFeature; 23 24 import java.util.Arrays; 25 import java.util.List; 26 import java.util.Set; 27 28 /** 29 * Tests for {@link SetMultimap#replaceValues}. 30 * 31 * @author Louis Wasserman 32 */ 33 @GwtCompatible 34 public class SetMultimapPutAllTester<K, V> 35 extends AbstractMultimapTester<K, V, SetMultimap<K, V>> { 36 37 @MapFeature.Require(SUPPORTS_PUT) testPutAllHandlesDuplicates()38 public void testPutAllHandlesDuplicates() { 39 V v0 = sampleValues().e3; 40 V v1 = sampleValues().e2; 41 @SuppressWarnings("unchecked") 42 List<V> valuesToPut = Arrays.asList(v0, v1, v0); 43 44 for (K k : sampleKeys()) { 45 resetContainer(); 46 47 Set<V> expectedValues = copyToSet(multimap().get(k)); 48 49 multimap().putAll(k, valuesToPut); 50 expectedValues.addAll(valuesToPut); 51 52 assertGet(k, expectedValues); 53 } 54 } 55 } 56