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 @ElementTypesAreNonnullByDefault 32 public class ForMapMultimapAsMapImplementsMapTest extends AbstractMultimapAsMapImplementsMapTest { 33 ForMapMultimapAsMapImplementsMapTest()34 public ForMapMultimapAsMapImplementsMapTest() { 35 super(true, true, true); 36 } 37 38 @Override makeEmptyMap()39 protected Map<String, Collection<Integer>> makeEmptyMap() { 40 Map<String, Integer> map = Maps.newHashMap(); 41 return Multimaps.forMap(map).asMap(); 42 } 43 44 @Override makePopulatedMap()45 protected Map<String, Collection<Integer>> makePopulatedMap() { 46 Map<String, Integer> map = Maps.newHashMap(); 47 map.put("foo", 1); 48 map.put("bar", 2); 49 map.put("cow", 3); 50 return Multimaps.forMap(map).asMap(); 51 } 52 53 @Override testEntrySetRemoveAllNullFromEmpty()54 public void testEntrySetRemoveAllNullFromEmpty() { 55 try { 56 super.testEntrySetRemoveAllNullFromEmpty(); 57 } catch (RuntimeException tolerated) { 58 // GWT's HashMap.entrySet().removeAll(null) doesn't throws NPE. 59 } 60 } 61 62 @Override testEntrySetRetainAllNullFromEmpty()63 public void testEntrySetRetainAllNullFromEmpty() { 64 try { 65 super.testEntrySetRetainAllNullFromEmpty(); 66 } catch (RuntimeException tolerated) { 67 // GWT's HashMap.entrySet().retainAll(null) doesn't throws NPE. 68 } 69 } 70 71 @Override testKeySetRemoveAllNullFromEmpty()72 public void testKeySetRemoveAllNullFromEmpty() { 73 try { 74 super.testKeySetRemoveAllNullFromEmpty(); 75 } catch (RuntimeException tolerated) { 76 // GWT's HashMap.keySet().removeAll(null) doesn't throws NPE. 77 } 78 } 79 80 @Override testKeySetRetainAllNullFromEmpty()81 public void testKeySetRetainAllNullFromEmpty() { 82 try { 83 super.testKeySetRetainAllNullFromEmpty(); 84 } catch (RuntimeException tolerated) { 85 // GWT's HashMap.keySet().retainAll(null) doesn't throws NPE. 86 } 87 } 88 89 @Override testValuesRemoveAllNullFromEmpty()90 public void testValuesRemoveAllNullFromEmpty() { 91 try { 92 super.testValuesRemoveAllNullFromEmpty(); 93 } catch (RuntimeException tolerated) { 94 // GWT's HashMap.values().removeAll(null) doesn't throws NPE. 95 } 96 } 97 98 @Override testValuesRetainAllNullFromEmpty()99 public void testValuesRetainAllNullFromEmpty() { 100 try { 101 super.testValuesRemoveAllNullFromEmpty(); 102 } catch (RuntimeException tolerated) { 103 // GWT's HashMap.values().retainAll(null) doesn't throws NPE. 104 } 105 } 106 } 107