fixed again, thanks Alex for your detailed reviews I have learned alot :)
This commit is contained in:
@@ -70,6 +70,8 @@ subprojects {
|
|||||||
testCompile group: 'junit', name: 'junit', version: '4.11'
|
testCompile group: 'junit', name: 'junit', version: '4.11'
|
||||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
testCompile group: 'junit', name: 'junit', version: '4.12'
|
||||||
testCompile('org.mockito:mockito-core:1.10.19') {exclude(group: 'org.hamcrest')}
|
testCompile('org.mockito:mockito-core:1.10.19') {exclude(group: 'org.hamcrest')}
|
||||||
|
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.1.2.RELEASE'
|
||||||
|
testCompile 'javax.el:javax.el-api:3.0.0'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-5
@@ -1,16 +1,14 @@
|
|||||||
package edu.msudenver.tsp.website.controller;
|
package edu.msudenver.tsp.website;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
|
||||||
|
|
||||||
public class Application {
|
public class Application {
|
||||||
|
|
||||||
public static void main(final String[] args) {
|
public static void main(final String[] args)
|
||||||
|
{
|
||||||
SpringApplication.run(Application.class, args);
|
SpringApplication.run(Application.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6,6 +6,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
@@ -13,31 +15,20 @@ import org.springframework.web.servlet.ModelAndView;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Controller
|
@Controller
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@RequestMapping("/theorem")
|
||||||
public class TheoremEntryController {
|
public class TheoremEntryController {
|
||||||
|
@GetMapping({"/",""})
|
||||||
|
public ModelAndView enterTheoremPage()
|
||||||
|
|
||||||
@RequestMapping("/theorem")
|
|
||||||
public ModelAndView theoremPage()
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
return new ModelAndView("Theorem");
|
return new ModelAndView("Theorem");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping({"/",""})
|
||||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
||||||
public String saveTheorem(@Validated Theorem theorem, Model model) {
|
public String saveTheorem(@Validated Theorem theorem, Model model) {
|
||||||
|
|
||||||
model.addAttribute("theromName", theorem.getTheoremName());
|
model.addAttribute("theromName1", theorem.getTheoremName1());
|
||||||
|
model.addAttribute("theromName2", theorem.getTheoremName2());
|
||||||
|
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ModelAndView firstPage() {
|
|
||||||
return new ModelAndView("welcome");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,23 +3,14 @@ package edu.msudenver.tsp.website.controller.forms;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
|
||||||
public class Theorem {
|
public class Theorem {
|
||||||
private String theoremName ;
|
private String theoremName1 ;
|
||||||
|
private String theoremName2 ;
|
||||||
|
@NotBlank(message = "Theorem name must not be blank") private String theoremName;
|
||||||
public String getTheoremName() {
|
private String theorem;
|
||||||
return theoremName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTheoremName1(String theoremName) {
|
|
||||||
this.theoremName = theoremName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
<title>Theroem Page</title>
|
<title>Theroem Page</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<form action="save" method="post">
|
<form action="" method="post">
|
||||||
Enter Theorem Name: <input type="text" name="theoremName">
|
Enter Theorem Name : <input type="text" name="theoremName1">
|
||||||
|
<br>Enter Theorem: <input type="text" name="theoremName2"><br>
|
||||||
<input type="submit" value="save">
|
<input type="submit" value="save">
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<br><b>Name:</b><%= request.getParameter("theoremName")%>
|
<br><b>Name:</b><%= request.getParameter("theoremName1")%>
|
||||||
|
<br><b>Name:</b><%= request.getParameter("theoremName2")%>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|
||||||
<title>Guru Success Page</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<a><b>Welcome User!!!!</b></a>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
+10
-18
@@ -23,27 +23,19 @@ public class TheoremEntryControllerTest {
|
|||||||
@InjectMocks
|
@InjectMocks
|
||||||
private TheoremEntryController theoremEntryController;
|
private TheoremEntryController theoremEntryController;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected MockMvc mockMvc;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void contexLoads() throws Exception {
|
|
||||||
assertNotNull(theoremEntryController);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void firstPage(){
|
|
||||||
|
|
||||||
final ModelAndView modelAndView= theoremEntryController.firstPage();
|
|
||||||
|
|
||||||
assertNotNull(modelAndView);
|
|
||||||
assertEquals("welcome",modelAndView.getViewName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void theoremPage(){
|
public void theoremPage(){
|
||||||
|
|
||||||
final ModelAndView modelAndView= theoremEntryController.theoremPage();
|
final ModelAndView modelAndView= theoremEntryController.enterTheoremPage();
|
||||||
|
|
||||||
|
assertNotNull(modelAndView);
|
||||||
|
assertEquals("Theorem",modelAndView.getViewName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void saveTheorem(){
|
||||||
|
|
||||||
|
final ModelAndView modelAndView= theoremEntryController.enterTheoremPage();
|
||||||
|
|
||||||
assertNotNull(modelAndView);
|
assertNotNull(modelAndView);
|
||||||
assertEquals("Theorem",modelAndView.getViewName());
|
assertEquals("Theorem",modelAndView.getViewName());
|
||||||
|
|||||||
Reference in New Issue
Block a user