当前位置: 首页>>代码示例>>Java>>正文


Java MapFeature.Require方法代码示例

本文整理汇总了Java中com.google.common.collect.testing.features.MapFeature.Require方法的典型用法代码示例。如果您正苦于以下问题:Java MapFeature.Require方法的具体用法?Java MapFeature.Require怎么用?Java MapFeature.Require使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.testing.features.MapFeature的用法示例。


在下文中一共展示了MapFeature.Require方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCompute_absentFunctionThrows

import com.google.common.collect.testing.features.MapFeature; //导入方法依赖的package包/类
@MapFeature.Require({SUPPORTS_PUT, SUPPORTS_REMOVE})
public void testCompute_absentFunctionThrows() {
  try {
    getMap()
        .compute(
            k3(),
            (k, v) -> {
              assertEquals(k3(), k);
              assertNull(v);
              throw new ExpectedException();
            });
    fail("Expected ExpectedException");
  } catch (ExpectedException expected) {
  }
  expectUnchanged();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:17,代码来源:MapComputeTester.java

示例2: testPutDuplicateValue

import com.google.common.collect.testing.features.MapFeature; //导入方法依赖的package包/类
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testPutDuplicateValue() {
  List<Entry<K, V>> entries = copyToList(multimap().entries());

  for (Entry<K, V> entry : entries) {
    resetContainer();

    K k = entry.getKey();
    V v = entry.getValue();

    List<V> values = multimap().get(k);
    List<V> expectedValues = copyToList(values);

    assertTrue(multimap().put(k, v));
    expectedValues.add(v);
    assertGet(k, expectedValues);
    assertEquals(v, values.get(values.size() - 1));
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:21,代码来源:ListMultimapPutTester.java

示例3: testCompute_presentNullToPresentNonnull

import com.google.common.collect.testing.features.MapFeature; //导入方法依赖的package包/类
@MapFeature.Require({SUPPORTS_PUT, SUPPORTS_REMOVE, ALLOWS_NULL_VALUES})
@CollectionSize.Require(absent = ZERO)
public void testCompute_presentNullToPresentNonnull() {
  initMapWithNullValue();
  V value = getValueForNullKey();
  assertEquals(
      "Map.compute(presentMappedToNull, functionReturningValue) should return new value",
      value,
      getMap()
          .compute(
              getKeyForNullValue(),
              (k, v)
                  -> {
                    assertEquals(getKeyForNullValue(), k);
                    assertNull(v);
                    return value;
                  }));
  expectReplacement(entry(getKeyForNullValue(), value));
  assertEquals(getNumElements(), getMap().size());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:21,代码来源:MapComputeTester.java

示例4: testPutPresentKeyPropagatesToGet

import com.google.common.collect.testing.features.MapFeature; //导入方法依赖的package包/类
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testPutPresentKeyPropagatesToGet() {
  List<K> keys = Helpers.copyToList(multimap().keySet());
  for (K key : keys) {
    resetContainer();

    int size = getNumElements();

    Collection<V> collection = multimap().get(key);
    Collection<V> expectedCollection = Helpers.copyToList(collection);

    multimap().put(key, v3());
    expectedCollection.add(v3());
    assertEqualIgnoringOrder(expectedCollection, collection);
    assertEquals(size + 1, multimap().size());
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:19,代码来源:MultimapPutTester.java

示例5: testClearPropagatesToGet

import com.google.common.collect.testing.features.MapFeature; //导入方法依赖的package包/类
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testClearPropagatesToGet() {
  for (K key : sampleKeys()) {
    resetContainer();
    Collection<V> collection = multimap().get(key);
    multimap().clear();
    assertEmpty(collection);
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:11,代码来源:MultimapClearTester.java

示例6: testComputeIfAbsent_supportedPresent

import com.google.common.collect.testing.features.MapFeature; //导入方法依赖的package包/类
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testComputeIfAbsent_supportedPresent() {
  assertEquals("computeIfAbsent(present, function) should return existing value", 
      v0(), getMap().computeIfAbsent(k0(), k -> { throw new AssertionFailedError(); }));
  expectUnchanged();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:8,代码来源:MapComputeIfAbsentTester.java

示例7: testKeySetClearClearsInverse

import com.google.common.collect.testing.features.MapFeature; //导入方法依赖的package包/类
@MapFeature.Require(SUPPORTS_REMOVE)
public void testKeySetClearClearsInverse() {
  BiMap<V, K> inv = getMap().inverse();
  getMap().keySet().clear();
  assertTrue(getMap().isEmpty());
  assertTrue(inv.isEmpty());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:8,代码来源:BiMapClearTester.java

示例8: testCreateWithNullKeyAndValueSupported

import com.google.common.collect.testing.features.MapFeature; //导入方法依赖的package包/类
@MapFeature.Require({ALLOWS_NULL_KEYS, ALLOWS_NULL_VALUES})
@CollectionSize.Require(absent = ZERO)
public void testCreateWithNullKeyAndValueSupported() {
  Entry<K, V>[] entries = createSamplesArray();
  entries[getNullLocation()] = entry(null, null);
  resetMap(entries);
  expectContents(entries);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:9,代码来源:MapCreationTester.java

示例9: testReplace_presentNullValueUnsupported

import com.google.common.collect.testing.features.MapFeature; //导入方法依赖的package包/类
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUES)
@CollectionSize.Require(absent = ZERO)
public void testReplace_presentNullValueUnsupported() {
  try {
    getMap().replace(k0(), null);
    fail("Expected NullPointerException");
  } catch (NullPointerException expected) {
  }
  expectUnchanged();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:11,代码来源:ConcurrentMapReplaceTester.java

示例10: testAsMapRemoveImplementsList

import com.google.common.collect.testing.features.MapFeature; //导入方法依赖的package包/类
@MapFeature.Require(SUPPORTS_REMOVE)
public void testAsMapRemoveImplementsList() {
  List<K> keys = new ArrayList<K>(multimap().keySet());
  for (K key : keys) {
    resetCollection();
    assertTrue(multimap().asMap().remove(key) instanceof List);
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:9,代码来源:ListMultimapAsMapTester.java

示例11: testPutAllRejectsNullValue

import com.google.common.collect.testing.features.MapFeature; //导入方法依赖的package包/类
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUES)
public void testPutAllRejectsNullValue() {
  Multimap<K, V> source = getSubjectGenerator().create(Helpers.mapEntry(k0(), null));
  try {
    multimap().putAll(source);
    fail("Expected NullPointerException");
  } catch (NullPointerException expected) {
  }
  expectUnchanged();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:11,代码来源:MultimapPutAllMultimapTester.java

示例12: testAddNullValue

import com.google.common.collect.testing.features.MapFeature; //导入方法依赖的package包/类
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_VALUES})
public void testAddNullValue() {
  Collection<V> result = multimap().asMap().get(k0());
  assertTrue(result.add(null));
  assertTrue(multimap().containsEntry(k0(), null));
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:8,代码来源:MultimapAsMapGetTester.java

示例13: testSizeNullKeyAndValue

import com.google.common.collect.testing.features.MapFeature; //导入方法依赖的package包/类
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require({ALLOWS_NULL_KEYS, ALLOWS_NULL_VALUES})
public void testSizeNullKeyAndValue() {
  initMultimapWithNullKeyAndValue();
  assertEquals(getNumElements(), multimap().size());
  assertFalse(multimap().isEmpty());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:8,代码来源:MultimapSizeTester.java

示例14: testReplaceAll_unsupportedNoOpFunction

import com.google.common.collect.testing.features.MapFeature; //导入方法依赖的package包/类
@MapFeature.Require(absent = SUPPORTS_PUT)
public void testReplaceAll_unsupportedNoOpFunction() {
  try {
    getMap().replaceAll((K k, V v) -> v);
  } catch (UnsupportedOperationException tolerated) {
  }
  expectUnchanged();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:9,代码来源:MapReplaceAllTester.java

示例15: testRemoveNullValueForbidden

import com.google.common.collect.testing.features.MapFeature; //导入方法依赖的package包/类
@MapFeature.Require(value = SUPPORTS_REMOVE, absent = ALLOWS_NULL_VALUE_QUERIES)
public void testRemoveNullValueForbidden() {
  try {
    multimap().remove(k0(), null);
    fail("Expected NullPointerException");
  } catch (NullPointerException expected) {
    // success
  }
  expectUnchanged();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:11,代码来源:MultimapRemoveEntryTester.java


注:本文中的com.google.common.collect.testing.features.MapFeature.Require方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。