title: MockMVC in junit tests - checking result for List<Object> and Map<Enum, Object>
body: <p>I have problems with mockMVC and test written with that. My tests fails.
  I have two tests methods:</p>
  
  <pre><code>@Test
  public void getPersonsForApiConsumerTest() throws Exception {
      mockMvc.perform(get(getUri("/consumers/1/persons")))
              .andExpect(status().isOk())
              .andExpect(jsonPath("$", hasSize(2)))
              .andExpect(jsonPath("$[1].name", is("Ligza")))
              .andExpect(jsonPath("$[2].name", is("Vekrir")));
  
  }
  
  @Test
  public void getPersonsForApiConsumerMapTest() throws Exception {
      mockMvc.perform(get(getUri("/consumers/1/persons/map")))
              .andExpect(status().isOk())
              .andExpect(jsonPath("$[1].name", is("Verkir")))
              .andExpect(jsonPath("$[2].name", is("Ligza")));
  }
  </code></pre>
  
  <p>Rest methods with mapping:</p>
  
  <pre><code> @RequestMapping(value = "/{consumerId}/persons")
      public List&lt;PersonDto&gt; getPersonsForApiConsumer(@PathVariable("consumerId") Integer consumerId) throws IOException {
          return apiConsumerService.getPersonsListForApiConsumer(consumerId);
      }
  
      @RequestMapping(value = "/{consumerId}/persons/map")
      public Map&lt;ApiConsumerPersonRole, List&lt;Person&gt;&gt; getPersonsForApiConsumerMap(@PathVariable("consumerId") Integer consumerId) throws IOException {
          return apiConsumerService.getPersonsMapForApiConsumer(consumerId);
      }
  </code></pre>
  
  <p>By Postman I can gain data such:</p>
  
  <p>for list:</p>
  
  <pre><code>[
      {
          "id": 1,
          "firstName": "Ligza",
          "lastName": "Zetasor",
          "role": "REPRESENTATIVE",
          "phone": "123123123",
          "email": "ligza.zetasor@gmail.com"
      },
      {
          "id": 4,
          "firstName": "Vekrir",
          "lastName": "Omegaram",
          "role": "SECURITY_OFFICER",
          "phone": "354654545",
          "email": "vekrir.omegaram@gmail.com"
      }
  ]
  </code></pre>
  
  <p>for map:</p>
  
  <pre><code>{
      "SECURITY_OFFICER": [
          {
              "id": 4,
              "firstName": "Vekrir",
              "lastName": "Omegaram",
              "telephone": "354654545",
              "email": "vekrir.omegaram@gmail.com"
          }
      ],
      "REPRESENTATIVE": [
          {
              "id": 1,
              "firstName": "Ligza",
              "lastName": "Zetasor",
              "telephone": "123123123",
              "email": "ligza.zetasor@gmail.com"
          }
      ],
      "COMPLAINT_OFFICER": [],
      "LOCAL_REPRESENTATIVE": []
  }
  </code></pre>
  
  <p>I dont have any clue how to write it properly. I want to check the data inside this list and map. </p>
  
  <p>Is it possible to stream it into that collection or check it easily in the way it is wriiten already?</p>
  
  <hr>
  
  <p>Edit: logs:</p>
  
  <pre><code>java.lang.AssertionError: No value at JSON path "$[1].firstname", exception: No results for path: $[1]['firstname']
  
      at org.springframework.test.util.JsonPathExpectationsHelper.evaluateJsonPath(JsonPathExpectationsHelper.java:245)
      at org.springframework.test.util.JsonPathExpectationsHelper.assertValue(JsonPathExpectationsHelper.java:73)
      at org.springframework.test.web.servlet.result.JsonPathResultMatchers$1.match(JsonPathResultMatchers.java:87)
      at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:171)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
      at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
      at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
      at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
  
  
  Process finished with exit code -1
  
  MockHttpServletResponse:
             Status = 200
      Error message = null
            Headers = {X-Content-Type-Options=[nosniff], X-XSS-Protection=[1; mode=block], Cache-Control=[no-cache, no-store, max-age=0, must-revalidate], Pragma=[no-cache], Expires=[0], X-Frame-Options=[DENY], Content-Type=[application/json;charset=UTF-8]}
       Content type = application/json;charset=UTF-8
               Body = {"COMPLAINT_OFFICER":[],"REPRESENTATIVE":[{"id":1,"firstName":"Ligza","lastName":"Zetasor","telephone":"123123123","email":"ligza.zetasor@gmail.com"}],"LOCAL_REPRESENTATIVE":[],"SECURITY_OFFICER":[{"id":4,"firstName":"Vekrir","lastName":"Omegaram","telephone":"354654545","email":"vekrir.omegaram@gmail.com"}]}
      Forwarded URL = null
     Redirected URL = null
            Cookies = []
  
  java.lang.AssertionError: No value at JSON path "$[1].firstname", exception: Filter: [1]['firstname'] can only be applied to arrays. Current context is: {COMPLAINT_OFFICER=[], REPRESENTATIVE=[{"id":1,"firstName":"Ligza","lastName":"Zetasor","telephone":"123123123","email":"ligza.zetasor@gmail.com"}], LOCAL_REPRESENTATIVE=[], SECURITY_OFFICER=[{"id":4,"firstName":"Vekrir","lastName":"Omegaram","telephone":"354654545","email":"vekrir.omegaram@gmail.com"}]}
  
      at org.springframework.test.util.JsonPathExpectationsHelper.evaluateJsonPath(JsonPathExpectationsHelper.java:245)
      at org.springframework.test.util.JsonPathExpectationsHelper.assertValue(JsonPathExpectationsHelper.java:73)
      at org.springframework.test.web.servlet.result.JsonPathResultMatchers$1.match(JsonPathResultMatchers.java:87)
      at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:171)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
      at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
      at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
      at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
  </code></pre>