1 /* 2 * Copyright (C) 2008 The Guava Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.common.collect; 18 19 import com.google.common.annotations.GwtCompatible; 20 import com.google.common.collect.testing.MapInterfaceTest; 21 22 import java.util.Collection; 23 import java.util.Map; 24 25 /** 26 * Test {@link Multimap#asMap()} for a {@link Multimaps#forMap} multimap with 27 * {@link MapInterfaceTest}. 28 * 29 * @author Jared Levy 30 */ 31 @GwtCompatible 32 public class ForMapMultimapAsMapImplementsMapTest 33 extends AbstractMultimapAsMapImplementsMapTest { 34 ForMapMultimapAsMapImplementsMapTest()35 public ForMapMultimapAsMapImplementsMapTest() { 36 super(true, true, true); 37 } 38 makeEmptyMap()39 @Override protected Map<String, Collection<Integer>> makeEmptyMap() { 40 Map<String, Integer> map = Maps.newHashMap(); 41 return Multimaps.forMap(map).asMap(); 42 } 43 makePopulatedMap()44 @Override protected Map<String, Collection<Integer>> makePopulatedMap() { 45 Map<String, Integer> map = Maps.newHashMap(); 46 map.put("foo", 1); 47 map.put("bar", 2); 48 map.put("cow", 3); 49 return Multimaps.forMap(map).asMap(); 50 } 51 testEntrySetRemoveAllNullFromEmpty()52 @Override public void testEntrySetRemoveAllNullFromEmpty() { 53 try { 54 super.testEntrySetRemoveAllNullFromEmpty(); 55 } catch (RuntimeException tolerated) { 56 // GWT's HashMap.entrySet().removeAll(null) doesn't throws NPE. 57 } 58 } 59 testEntrySetRetainAllNullFromEmpty()60 @Override public void testEntrySetRetainAllNullFromEmpty() { 61 try { 62 super.testEntrySetRetainAllNullFromEmpty(); 63 } catch (RuntimeException tolerated) { 64 // GWT's HashMap.entrySet().retainAll(null) doesn't throws NPE. 65 } 66 } 67 testKeySetRemoveAllNullFromEmpty()68 @Override public void testKeySetRemoveAllNullFromEmpty() { 69 try { 70 super.testKeySetRemoveAllNullFromEmpty(); 71 } catch (RuntimeException tolerated) { 72 // GWT's HashMap.keySet().removeAll(null) doesn't throws NPE. 73 } 74 } 75 testKeySetRetainAllNullFromEmpty()76 @Override public void testKeySetRetainAllNullFromEmpty() { 77 try { 78 super.testKeySetRetainAllNullFromEmpty(); 79 } catch (RuntimeException tolerated) { 80 // GWT's HashMap.keySet().retainAll(null) doesn't throws NPE. 81 } 82 } 83 testValuesRemoveAllNullFromEmpty()84 @Override public void testValuesRemoveAllNullFromEmpty() { 85 try { 86 super.testValuesRemoveAllNullFromEmpty(); 87 } catch (RuntimeException tolerated) { 88 // GWT's HashMap.values().removeAll(null) doesn't throws NPE. 89 } 90 } 91 testValuesRetainAllNullFromEmpty()92 @Override public void testValuesRetainAllNullFromEmpty() { 93 try { 94 super.testValuesRemoveAllNullFromEmpty(); 95 } catch (RuntimeException tolerated) { 96 // GWT's HashMap.values().retainAll(null) doesn't throws NPE. 97 } 98 } 99 } 100