001/* 002 * Copyright (C) 2013 The Guava Authors 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 005 * in compliance with the License. You may obtain a copy of the License at 006 * 007 * http://www.apache.org/licenses/LICENSE-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, software distributed under the License 010 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 011 * or implied. See the License for the specific language governing permissions and limitations under 012 * the License. 013 */ 014 015package com.google.common.collect.testing.google; 016 017import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_REMOVE; 018 019import com.google.common.annotations.GwtCompatible; 020import com.google.common.collect.SortedSetMultimap; 021import com.google.common.collect.testing.features.MapFeature; 022import java.util.ArrayList; 023import java.util.Collection; 024import java.util.List; 025import java.util.SortedSet; 026import org.junit.Ignore; 027 028/** 029 * Testers for {@link SortedSetMultimap#asMap}. 030 * 031 * @author Louis Wasserman 032 * @param <K> The key type of the tested multimap. 033 * @param <V> The value type of the tested multimap. 034 */ 035@GwtCompatible 036@Ignore("test runners must not instantiate and run this directly, only via suites we build") 037// @Ignore affects the Android test runner, which respects JUnit 4 annotations on JUnit 3 tests. 038@SuppressWarnings("JUnit4ClassUsedInJUnit3") 039public class SortedSetMultimapAsMapTester<K, V> 040 extends AbstractMultimapTester<K, V, SortedSetMultimap<K, V>> { 041 public void testAsMapValuesImplementSortedSet() { 042 for (Collection<V> valueCollection : multimap().asMap().values()) { 043 SortedSet<V> valueSet = (SortedSet<V>) valueCollection; 044 assertEquals(multimap().valueComparator(), valueSet.comparator()); 045 } 046 } 047 048 public void testAsMapGetImplementsSortedSet() { 049 for (K key : multimap().keySet()) { 050 SortedSet<V> valueSet = (SortedSet<V>) multimap().asMap().get(key); 051 assertEquals(multimap().valueComparator(), valueSet.comparator()); 052 } 053 } 054 055 @MapFeature.Require(SUPPORTS_REMOVE) 056 public void testAsMapRemoveImplementsSortedSet() { 057 List<K> keys = new ArrayList<>(multimap().keySet()); 058 for (K key : keys) { 059 resetCollection(); 060 SortedSet<V> valueSet = (SortedSet<V>) multimap().asMap().remove(key); 061 assertEquals(multimap().valueComparator(), valueSet.comparator()); 062 } 063 } 064}