title: How do I get Mockito to return different values based on an enum?
body: <p>So I am trying to mock a method <code>getPremium</code> that takes a single parameter, an instance of <code>PanicLevel</code> which is an <code>enum</code>. It needs to return a different double value depending on the <code>PanicLevel</code> passed in.</p>
  
  <p>If I want to do this per enum value then something like thi should work.</p>
  
  <pre><code>Mockito.when(mockData.getPremium(PanicLevel.NORMAL)).thenReturn(1.1);
  </code></pre>
  
  <p>But that needs a line per enum value. I'd much rather do something like:</p>
  
  <pre><code>Mockito.when(mockData.getPremium(anyPanicLevel())).thenReturn(premiums.get(passedInPanicLevel());
  </code></pre>
  
  <p>Obviously this isn't valid...but something similar should be....</p>
  
  <p>I found this but it uses a method <code>anyString</code> from somewhere:
  <a href="https://stackoverflow.com/questions/22338536/mockito-return-value-based-on-property-of-a-parameter">mockito return value based on property of a parameter</a></p>
  
  <p>How do I get Mockito to do this without doing repeated <code>when</code> for each key?</p>