diff --git a/src/test/java/org/springframework/samples/petclinic/owner/VisitControllerTests.java b/src/test/java/org/springframework/samples/petclinic/owner/VisitControllerTests.java index e42e75034..a8cb8c08b 100644 --- a/src/test/java/org/springframework/samples/petclinic/owner/VisitControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/owner/VisitControllerTests.java @@ -10,7 +10,7 @@ * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and + * See the License for specific language governing permissions and * limitations under the License. */ @@ -46,8 +46,8 @@ import java.util.Optional; class VisitControllerTests { private static final int TEST_OWNER_ID = 1; - private static final int TEST_PET_ID = 1; + private static final String NEW_VISIT_URL = "/owners/{ownerId}/pets/{petId}/visits/new"; @Autowired private MockMvc mockMvc; @@ -66,7 +66,7 @@ class VisitControllerTests { @Test void testInitNewVisitForm() throws Exception { - mockMvc.perform(get("/owners/{ownerId}/pets/{petId}/visits/new", TEST_OWNER_ID, TEST_PET_ID)) + mockMvc.perform(get(NEW_VISIT_URL, TEST_OWNER_ID, TEST_PET_ID)) .andExpect(status().isOk()) .andExpect(view().name("pets/createOrUpdateVisitForm")); } @@ -74,7 +74,7 @@ class VisitControllerTests { @Test void testProcessNewVisitFormSuccess() throws Exception { mockMvc - .perform(post("/owners/{ownerId}/pets/{petId}/visits/new", TEST_OWNER_ID, TEST_PET_ID) + .perform(post(NEW_VISIT_URL, TEST_OWNER_ID, TEST_PET_ID) .param("name", "George") .param("description", "Visit Description")) .andExpect(status().is3xxRedirection()) @@ -84,11 +84,11 @@ class VisitControllerTests { @Test void testProcessNewVisitFormHasErrors() throws Exception { mockMvc - .perform(post("/owners/{ownerId}/pets/{petId}/visits/new", TEST_OWNER_ID, TEST_PET_ID).param("name", + .perform(post(NEW_VISIT_URL, TEST_OWNER_ID, TEST_PET_ID).param("name", "George")) .andExpect(model().attributeHasErrors("visit")) .andExpect(status().isOk()) .andExpect(view().name("pets/createOrUpdateVisitForm")); } -} +} \ No newline at end of file