fixed again, thanks Alex for your detailed reviews I have learned alot :)
This commit is contained in:
+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.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
|
||||
|
||||
public class Application {
|
||||
|
||||
public static void main(final String[] args) {
|
||||
public static void main(final String[] args)
|
||||
{
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
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.RequestMethod;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
@@ -13,31 +15,20 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
@Slf4j
|
||||
@Controller
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/theorem")
|
||||
public class TheoremEntryController {
|
||||
|
||||
|
||||
|
||||
@RequestMapping("/theorem")
|
||||
public ModelAndView theoremPage()
|
||||
@GetMapping({"/",""})
|
||||
public ModelAndView enterTheoremPage()
|
||||
{
|
||||
|
||||
|
||||
return new ModelAndView("Theorem");
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||
@PostMapping({"/",""})
|
||||
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";
|
||||
}
|
||||
|
||||
|
||||
public ModelAndView firstPage() {
|
||||
return new ModelAndView("welcome");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -3,23 +3,14 @@ package edu.msudenver.tsp.website.controller.forms;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
|
||||
public class Theorem {
|
||||
private String theoremName ;
|
||||
|
||||
|
||||
public String getTheoremName() {
|
||||
return theoremName;
|
||||
}
|
||||
|
||||
public void setTheoremName1(String theoremName) {
|
||||
this.theoremName = theoremName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private String theoremName1 ;
|
||||
private String theoremName2 ;
|
||||
@NotBlank(message = "Theorem name must not be blank") private String theoremName;
|
||||
private String theorem;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
<title>Theroem Page</title>
|
||||
</head>
|
||||
<body>
|
||||
<form action="save" method="post">
|
||||
Enter Theorem Name: <input type="text" name="theoremName">
|
||||
|
||||
<form action="" method="post">
|
||||
Enter Theorem Name : <input type="text" name="theoremName1">
|
||||
<br>Enter Theorem: <input type="text" name="theoremName2"><br>
|
||||
<input type="submit" value="save">
|
||||
</form>
|
||||
</body>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<html>
|
||||
<body>
|
||||
<br><b>Name:</b><%= request.getParameter("theoremName")%>
|
||||
<br><b>Name:</b><%= request.getParameter("theoremName1")%>
|
||||
<br><b>Name:</b><%= request.getParameter("theoremName2")%>
|
||||
|
||||
</body>
|
||||
</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
|
||||
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
|
||||
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);
|
||||
assertEquals("Theorem",modelAndView.getViewName());
|
||||
|
||||
Reference in New Issue
Block a user