Fixed tests

This commit is contained in:
Andrew Pitt 2020-01-06 12:28:42 -05:00
parent 55dae5ac8d
commit 0d17a00cf5
2 changed files with 32 additions and 40 deletions

View file

@ -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);
}

View file

@ -68,18 +68,15 @@ public class VetControllerTests {
@Test
public void testShowVetListHtml() throws Exception {
mockMvc.perform(get("/vets.html"))
.andExpect(status().isOk())
.andExpect(model().attributeExists("vets"))
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));
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));
}
}