@SuppressWarnings("unchecked")
  public static <K, V> Map<K, V> map(K firstKey, V firstValue, Object... others) {
    Map<K, V> map = new HashMap<>();
    map.put(firstKey, firstValue);
    Iterator iterator = Arrays.asList(others).iterator();
    while (iterator.hasNext()) {
      map.put((K)iterator.next(), (V)iterator.next());
    }
    return map;
  }
A simple (but not production quality) way to create mutable hashmaps for unit tests
@param firstKey the first key in the map
@param firstValue the first value in the map
@param others further keys and values
@param <K> key type
@param <V> value type
@return the map
ambari-server/src/test/java/org/apache/ambari/server/testutils/TestCollectionUtils.java