diff --git a/src/test/java/integration/MainPageIT.java b/src/test/java/integration/MainPageIT.java index 4c3f2701b..43893f169 100644 --- a/src/test/java/integration/MainPageIT.java +++ b/src/test/java/integration/MainPageIT.java @@ -28,16 +28,11 @@ public class MainPageIT { } @Test - public void googleTitleIT() { + public void petclinicTitleIT() { WebDriver driver = config.getDriver(); driver.get(url); assertEquals("Title not as expected: ", "PetClinic :: a Spring Framework demonstration", getTitle()); - // Save the random value from the page. String welcomeText = driver.findElement(By.id("welcome")).getText(); - // Reload the page and get a new random value. - driver.get(url); - String value2 = driver.findElement(By.id("random-value")).getText(); - // Values should not be the same. assertEquals("Wrong welcome text.", "Welcome to the Pet Clinic!", welcomeText); System.out.println("Text extracted: " + welcomeText); } diff --git a/src/test/java/org/springframework/samples/petclinic/vet/VetControllerTests.java b/src/test/java/org/springframework/samples/petclinic/vet/VetControllerTests.java index 83ef50144..c1fca1e35 100644 --- a/src/test/java/org/springframework/samples/petclinic/vet/VetControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/vet/VetControllerTests.java @@ -43,43 +43,40 @@ import org.springframework.test.web.servlet.ResultActions; @WebMvcTest(VetController.class) public class VetControllerTests { - @Autowired - private MockMvc mockMvc; + @Autowired + private MockMvc mockMvc; - @MockBean - private VetRepository vets; + @MockBean + private VetRepository vets; - @Before - public void setup() { - Vet james = new Vet(); - james.setFirstName("James"); - james.setLastName("Carter"); - james.setId(1); - Vet helen = new Vet(); - helen.setFirstName("Helen"); - helen.setLastName("Leary"); - helen.setId(2); - Specialty radiology = new Specialty(); - radiology.setId(1); - radiology.setName("radiology"); - helen.addSpecialty(radiology); - given(this.vets.findAll()).willReturn(Lists.newArrayList(james, helen)); - } + @Before + public void setup() { + Vet james = new Vet(); + james.setFirstName("James"); + james.setLastName("Carter"); + james.setId(1); + Vet helen = new Vet(); + helen.setFirstName("Helen"); + helen.setLastName("Leary"); + helen.setId(2); + Specialty radiology = new Specialty(); + radiology.setId(1); + radiology.setName("radiology"); + helen.addSpecialty(radiology); + given(this.vets.findAll()).willReturn(Lists.newArrayList(james, helen)); + } - @Test - public void testShowVetListHtml() throws Exception { - mockMvc.perform(get("/vets.html")) - .andExpect(status().isOk()) - .andExpect(model().attributeExists("vets")) - .andExpect(view().name("vets/vetList")); - } + @Test + public void testShowVetListHtml() throws Exception { + mockMvc.perform(get("/vets.html")).andExpect(status().isOk()).andExpect(model().attributeExists("vets")) + .andExpect(view().name("vets/vetList")); + } - @Test - public void testShowResourcesVetList() throws Exception { - ResultActions actions = mockMvc.perform(get("/vets") - .accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()); - actions.andExpect(content().contentType("application/json;charset=UTF-8")) - .andExpect(jsonPath("$.vetList[0].id").value(1)); - } + @Test + public void testShowResourcesVetList() throws Exception { + ResultActions actions = mockMvc.perform(get("/vets").accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()); + actions.andExpect(content().contentType("application/json")).andExpect(jsonPath("$.vetList[0].id").value(1)); + } }