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 import java.util.Collection; 22 import java.util.Map; 23 24 /** 25 * Test {@link Multimap#asMap()} for a {@link Multimaps#forMap} multimap with {@link 26 * MapInterfaceTest}. 27 * 28 * @author Jared Levy 29 */ 30 @GwtCompatible 31 public class ForMapMultimapAsMapImplementsMapTest extends AbstractMultimapAsMapImplementsMapTest { 32 ForMapMultimapAsMapImplementsMapTest()33 public ForMapMultimapAsMapImplementsMapTest() { 34 super(true, true, true); 35 } 36 37 @Override makeEmptyMap()38 protected Map<String, Collection<Integer>> makeEmptyMap() { 39 Map<String, Integer> map = Maps.newHashMap(); 40 return Multimaps.forMap(map).asMap(); 41 } 42 43 @Override makePopulatedMap()44 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 52 @Override testEntrySetRemoveAllNullFromEmpty()53 public void testEntrySetRemoveAllNullFromEmpty() { 54 try { 55 super.testEntrySetRemoveAllNullFromEmpty(); 56 } catch (RuntimeException tolerated) { 57 // GWT's HashMap.entrySet().removeAll(null) doesn't throws NPE. 58 } 59 } 60 61 @Override testEntrySetRetainAllNullFromEmpty()62 public void testEntrySetRetainAllNullFromEmpty() { 63 try { 64 super.testEntrySetRetainAllNullFromEmpty(); 65 } catch (RuntimeException tolerated) { 66 // GWT's HashMap.entrySet().retainAll(null) doesn't throws NPE. 67 } 68 } 69 70 @Override testKeySetRemoveAllNullFromEmpty()71 public void testKeySetRemoveAllNullFromEmpty() { 72 try { 73 super.testKeySetRemoveAllNullFromEmpty(); 74 } catch (RuntimeException tolerated) { 75 // GWT's HashMap.keySet().removeAll(null) doesn't throws NPE. 76 } 77 } 78 79 @Override testKeySetRetainAllNullFromEmpty()80 public void testKeySetRetainAllNullFromEmpty() { 81 try { 82 super.testKeySetRetainAllNullFromEmpty(); 83 } catch (RuntimeException tolerated) { 84 // GWT's HashMap.keySet().retainAll(null) doesn't throws NPE. 85 } 86 } 87 88 @Override testValuesRemoveAllNullFromEmpty()89 public void testValuesRemoveAllNullFromEmpty() { 90 try { 91 super.testValuesRemoveAllNullFromEmpty(); 92 } catch (RuntimeException tolerated) { 93 // GWT's HashMap.values().removeAll(null) doesn't throws NPE. 94 } 95 } 96 97 @Override testValuesRetainAllNullFromEmpty()98 public void testValuesRetainAllNullFromEmpty() { 99 try { 100 super.testValuesRemoveAllNullFromEmpty(); 101 } catch (RuntimeException tolerated) { 102 // GWT's HashMap.values().retainAll(null) doesn't throws NPE. 103 } 104 } 105 } 106