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 // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests. 037public class SortedSetMultimapAsMapTester<K, V> 038 extends AbstractMultimapTester<K, V, SortedSetMultimap<K, V>> { 039 public void testAsMapValuesImplementSortedSet() { 040 for (Collection<V> valueCollection : multimap().asMap().values()) { 041 SortedSet<V> valueSet = (SortedSet<V>) valueCollection; 042 assertEquals(multimap().valueComparator(), valueSet.comparator()); 043 } 044 } 045 046 public void testAsMapGetImplementsSortedSet() { 047 for (K key : multimap().keySet()) { 048 SortedSet<V> valueSet = (SortedSet<V>) multimap().asMap().get(key); 049 assertEquals(multimap().valueComparator(), valueSet.comparator()); 050 } 051 } 052 053 @MapFeature.Require(SUPPORTS_REMOVE) 054 public void testAsMapRemoveImplementsSortedSet() { 055 List<K> keys = new ArrayList<K>(multimap().keySet()); 056 for (K key : keys) { 057 resetCollection(); 058 SortedSet<V> valueSet = (SortedSet<V>) multimap().asMap().remove(key); 059 assertEquals(multimap().valueComparator(), valueSet.comparator()); 060 } 061 } 062}