title: Not getting mocked object returned when trying to mock a map
body: <p>I'm having some troubles mocking a map of mocked objects. </p>
  
  <p>I am using Mockito.</p>
  
  <p>Here is my function:</p>
  
  <pre><code>@Override
  protected void doGet(SlingHttpServletRequest request,
      SlingHttpServletResponse response) throws ServletException, IOException {
      try {
          Session session = request.getResourceResolver().adaptTo(Session.class);
              PrintWriter writer = response.getWriter();
              boolean testsPassed = isValid(agentMgr.getAgents().values()) &amp;&amp; testAgents(agentMgr.getAgents(), session);
              if (testsPassed) {
                  writer.write(successOutput);
              } else {
              writer.write(failureOutput);
      }
      } catch (InterruptedException e) {
          e.printStackTrace();
      }
  }
  
  private boolean isValid(Map&lt;String, Agent&gt; agents) {
  for (Map.Entry&lt;String, Agent&gt; agentEntry : agents.entrySet()) {
      if (agentEntry != null) {
          Agent agent = agentEntry.getValue();
              boolean isValid = agent.isValid();
              String id = agent.getId();
              // regex match string id
              if (id.matches(regex) || id.equalsIgnoreCase(goldId)) {
                  if (agent != null) {
                      if (!agent.isValid()) {
                          return false;
                      }
                  }
              }
          }
      }
      return true;
  }
  </code></pre>
  
  <p>I have tried to assemble my mock objects like this:</p>
  
  <pre><code>when(passAgent1.isValid()).thenReturn(true);
  when(passAgent1.getId()).thenReturn("publish");
  Map&lt;String, Agent&gt; mockAgents = new HashMap&lt;String, Agent&gt;();
  mockAgents.put("publish", passAgent1);
  mockAgents.put("i-12345678", passAgent2);
  when(agentMgr.getAgents()).thenReturn(mockAgents);
  </code></pre>
  
  <p>When I run, it appears as though the Agent object is returned as a Agent$$EnhancerWithMockitoByGLIB$$738eb07c</p>
  
  <p>The mocked functions of isValid and getId both return null, and thus, my tests fail.</p>
  
  <p>Any advice would be greatly appreciated.</p>