Coverage Summary for Class: BiMapEntrySetTester (com.google.common.collect.testing.google)

Class Class, % Method, % Line, %
BiMapEntrySetTester 0% (0/1) 0% (0/5) 0% (0/30)


1 /* 2  * Copyright (C) 2017 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.testing.google; 18  19 import static com.google.common.collect.testing.features.CollectionSize.SEVERAL; 20 import static com.google.common.collect.testing.features.CollectionSize.ZERO; 21 import static com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_VALUES; 22 import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT; 23  24 import com.google.common.annotations.GwtCompatible; 25 import com.google.common.collect.testing.features.CollectionSize; 26 import com.google.common.collect.testing.features.MapFeature; 27 import java.util.Map.Entry; 28 import org.junit.Ignore; 29  30 /** Tester for {@code BiMap.entrySet} and methods on the entries in the set. */ 31 @GwtCompatible 32 @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests. 33 public class BiMapEntrySetTester<K, V> extends AbstractBiMapTester<K, V> { 34  @MapFeature.Require(SUPPORTS_PUT) 35  @CollectionSize.Require(absent = ZERO) 36  public void testSetValue_valueAbsent() { 37  for (Entry<K, V> entry : getMap().entrySet()) { 38  if (entry.getKey().equals(k0())) { 39  assertEquals("entry.setValue() should return the old value", v0(), entry.setValue(v3())); 40  } 41  } 42  expectReplacement(entry(k0(), v3())); 43  } 44  45  @MapFeature.Require(SUPPORTS_PUT) 46  @CollectionSize.Require(SEVERAL) 47  public void testSetValue_valuePresent() { 48  for (Entry<K, V> entry : getMap().entrySet()) { 49  if (entry.getKey().equals(k0())) { 50  try { 51  entry.setValue(v1()); 52  fail("Expected IllegalArgumentException"); 53  } catch (IllegalArgumentException expected) { 54  } 55  } 56  } 57  expectUnchanged(); 58  } 59  60  @MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUES) 61  @CollectionSize.Require(absent = ZERO) 62  public void testSetValueNullUnsupported() { 63  for (Entry<K, V> entry : getMap().entrySet()) { 64  try { 65  entry.setValue(null); 66  fail("Expected NullPointerException"); 67  } catch (NullPointerException expected) { 68  } 69  expectUnchanged(); 70  } 71  } 72  73  @MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_VALUES}) 74  @CollectionSize.Require(absent = ZERO) 75  public void testSetValueNullSupported() { 76  for (Entry<K, V> entry : getMap().entrySet()) { 77  if (entry.getKey().equals(k0())) { 78  entry.setValue(null); 79  } 80  } 81  expectReplacement(entry(k0(), (V) null)); 82  } 83 }