title: Is it possible to address one specific form using MockMvc
body: <p>Hello there, <br>
  I wanted to aks if it's possible to address one specific form in a html template using MockMvc. I have got a template which has 3 forms, and I am not able to address one of them.</p>
  
  <p>
  This is my test:</p>
  
  <pre><code>@Test
  public void CreateNewIllMessageTest() throws Exception {
  
      initializeDummyTourWithDummyGuide();
  
      User user = userRepository.findUserByName("dummy");
      String moreInf = "moreInformation";
  
      mvc.perform(get("/tourmanagement").with(user(user.getUsername()).roles("EMPLOYEE"))).
              andExpect(status().isOk()).
              andExpect(view().name("tourmanagement")).
              andExpect(model().attributeExists("illnessform")).
              andExpect(model().attribute("illnessform", hasProperty("customer", is(nullValue())))).
              andExpect(model().attribute("illnessform", hasProperty("moreInf", isEmptyOrNullString())));
      mvc.perform(post("/tourmanagement").with(user(user.getUsername()).roles("EMPLOYEE")).
              param("customer", user.getAccount().getId().toString()).
              param("moreInf", moreInf)
              ).
              andExpect(status().is3xxRedirection());
  }
  </code></pre>
  
  <p>This is the template:</p>
  
  <pre><code>&lt;form action="#" th:object="${illnessform}" method="post" name="illnessform"
            th:action="@{/tourmanagement/ill(tour=${tourid}, start=${startDate}, end=${endDate}, tourname=${tour.name})}"&gt;
          &lt;div id="ill" style="display: none" class="form-group"&gt;
  
              &lt;label for="illselect" th:text="#{tourmanagement.whoisill}"&gt;Which Tourist Is Ill?&lt;/label&gt;
              &lt;select class="form-control" id="illselect" name="customer"&gt;
  
                  &lt;option th:each="customer : ${customerList}" th:value="${customer.account.id}"&gt;
                      &lt;p th:text="${customer.account.id}"&gt;&lt;/p&gt;
                  &lt;/option&gt;
  
              &lt;/select&gt;
  
              &lt;label for="illInf" th:text="#{tourmanagement.moreinfs}"&gt;More Information:&lt;/label&gt;
              &lt;input id="illInf" type="text" class="form-control" required name="moreInf" th:field="*{moreInf}"&gt;
  
              &lt;button class="btn btn-info" name="submit" type="submit" th:text="#{contact.submit}"&gt;Submit&lt;/button&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  
      &lt;form action="#" th:object="${insuranceform}" method="post"
            th:action="@{/tourmanagement/ins(tour=${tourid}, start=${startDate}, end=${endDate}, tourname=${tour.name})}"&gt;
          &lt;div id="ins" style="display: none" class="form-group"&gt;
  
              &lt;label for="inssellect" th:text="#{tourmanagement.whatkindofins}"&gt;What Kind Of Insurance Case?&lt;/label&gt;
              &lt;select class="form-control" id="inssellect" name="caseType" th:field="*{caseType}"&gt;
                  &lt;option th:text="#{tourmanagement.theft}" th:value="#{tourmanagement.theft}"&gt;Theft&lt;/option&gt;
                  &lt;option th:text="#{tourmanagement.accident}" th:value="#{tourmanagement.accident}"&gt;Accident&lt;/option&gt;
              &lt;/select&gt;
  
              &lt;label for="inssellecttourist" th:text="#{tourmanagement.whichtourist}"&gt;Which Tourist Did It Happen
                  To?&lt;/label&gt;
              &lt;select class="form-control" id="inssellecttourist" name="customer" th:field="*{customer}"&gt;
  
                  &lt;option th:each="customer : ${customerList}" th:value="${customer.account.id}"&gt;
                      &lt;p th:text="${customer.account.id}"&gt;&lt;/p&gt;
                  &lt;/option&gt;
  
              &lt;/select&gt;
  
              &lt;label for="insInf" th:text="#{tourmanagement.moreinfs}"&gt;More Information:&lt;/label&gt;
              &lt;input id="insInf" type="text" class="form-control" required name="moreInf" th:field="*{moreInf}"&gt;
  
              &lt;button class="btn btn-info" type="submit" th:text="#{contact.submit}"&gt;Submit&lt;/button&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  </code></pre>
  
  
  
  <p>As you can see, I have more than one form and I want to test the first. The error I get is:</p>
  
  <pre><code>java.lang.AssertionError: Range for response status value 405 
  </code></pre>
  
  <p>Expected :REDIRECTION
  Actual   :CLIENT_ERROR
   </p>
  
  <pre><code>at org.springframework.test.util.AssertionErrors.fail(AssertionErrors.java:54)
  at org.springframework.test.util.AssertionErrors.assertEquals(AssertionErrors.java:81)
  at org.springframework.test.web.servlet.result.StatusResultMatchers$5.match(StatusResultMatchers.java:107)
  at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:171)
  at kickstart.Message.MessageIntegrationTest.CreateNewIllMessageTest(MessageIntegrationTest.java:145)
  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.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
  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>
  
  
  
  <p>I would really appreciate any help or alternative ways to test these forms.</p>
  
  <p>Greetings, Alex</p>