Home | History | Annotate | Download | only in collect
      1 /*
      2  * Copyright (C) 2011 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 java.util.Map;
     20 import java.util.SortedMap;
     21 
     22 import com.google.common.annotations.GwtCompatible;
     23 import com.google.common.base.Function;
     24 import com.google.common.base.Functions;
     25 
     26 /**
     27  * Tests for {@link Maps#transformValues(SortedMap, Function)}.
     28  *
     29  * @author Louis Wasserman
     30  */
     31 @GwtCompatible
     32 public class MapsSortedTransformValuesTest extends MapsTransformValuesTest {
     33 
     34   @Override
     35   protected SortedMap<String, String> makeEmptyMap() {
     36     return Maps.transformValues(Maps.<String, String>newTreeMap(),
     37         Functions.<String>identity());
     38   }
     39 
     40   @Override
     41   protected SortedMap<String, String> makePopulatedMap() {
     42     SortedMap<String, Integer> underlying = Maps.newTreeMap();
     43     underlying.put("a", 1);
     44     underlying.put("b", 2);
     45     underlying.put("c", 3);
     46     return Maps.transformValues(underlying, Functions.toStringFunction());
     47   }
     48 
     49   public void testTransformValuesSecretlySortedMap() {
     50     Map<String, String> sortedMap = Maps.newTreeMap();
     51     assertTrue(Maps.transformValues(sortedMap, Functions.<String>identity())
     52         instanceof SortedMap);
     53   }
     54 }
     55