Ejemplo n.º 1
0
 @Override
 @Test
 public void getIfAbsentWith() {
   MutableMap<Integer, String> map = new SingletonMap<Integer, String>(1, "1");
   Assert.assertNull(map.get(4));
   Assert.assertEquals("4", map.getIfAbsentWith(4, Functions.getToString(), 4));
   Assert.assertEquals("1", map.getIfAbsentWith(1, Functions.getToString(), 1));
   Assert.assertEquals(UnifiedMap.newWithKeysValues(1, "1"), map);
 }
Ejemplo n.º 2
0
 @Override
 @Test
 public void getIfAbsentPutWith() {
   final MutableMap<Integer, String> map = new SingletonMap<Integer, String>(1, "1");
   Verify.assertThrows(
       UnsupportedOperationException.class,
       new Runnable() {
         public void run() {
           map.getIfAbsentPutWith(4, Functions.getToString(), 4);
         }
       });
   Assert.assertEquals("1", map.getIfAbsentPutWith(1, Functions.getToString(), 1));
 }