title: EnumMap Initialization from a HashMap
body: <p>I've looked to find that initializing a java EnumMap is possible with value of another HashMap but this is with testing.  I'm not in need of using an efficient double bracket or anything like that I just need to create the map from a given map.</p>
  
  <pre><code>public EnumMap&lt;ITEMS, Map&lt;String, Double&gt;&gt; getPromotionItems(String state, Map&lt;String, Double&gt; prices) {
      EnumMap&lt;ITEMS, Map&lt;String, Double&gt;&gt; promoItems = new EnumMap&lt;&gt;(ITEMS.class);
      Iterator iterator = prices.entrySet().iterator();
      Iterator keys = prices.keySet().iterator();
  
      HashMap map = new HashMap&lt;String, Double&gt;();
      while(keys.hasNext()) {
          map.put(iterator.next(),keys.next());
      }
      promoItems.put(ITEMS.valueOf(state),map);
      return promoItems;
  }
  </code></pre>
  
  <p>I'm writing in Junit and this says that my iterators are wrong somehow</p>
  
  <p><code>java.lang.AssertionError: expected: java.util.EnumMap&lt;{ORIGINAL={ProductC=3.0, ProductA=1.0, ProductB=2.0}}&gt; but was: java.util.EnumMap&lt;{ORIGINAL={ProductC=3.0, ProductA=1.0, ProductB=2.0}}&gt;</code></p>
  
  <p><strong>SOLUTION</strong>
  I needed to use only one enumMap in my class and unit test calling the method using the test class enumMap.</p>
  
  <p>This was in my test class: TestClassForItems.java
      public enum ITEMS {
          ONPROMO, ORIGINAL, OFFPROMO
      }</p>
  
  <pre><code>@Test
  public void onRedLinePromotionListOriginalPriceTest() {
      testPromoState = "ORIGINAL";
  
      testPrices.put("Product_A", 1.00);
      testPrices.put("Product_B", 2.00);
      testPrices.put("Product_C", 3.00);
      expectedPrices = testPrices;
      expectedGoodsMap.put(TestClassForItems.ITEMS.ORIGINAL, testPrices);
  
      assertSame(expectedGoodsMap, TestClass.getPromotionItems(TestClassForItems.ITEMS.ORIGINAL,testPrices));
  }
  </code></pre>
  
  <p>Returning the same String result but different object usage due to instantiating from the main for all of the necessary attributes to run my Junit test.</p>