Merge branches 'PAN-16' and 'master' of https://github.com/atusa17/ptp into PAN-16

# Conflicts:
#	services/build.gradle
This commit is contained in:
2019-03-20 22:00:11 -06:00
48 changed files with 1323 additions and 586 deletions
@@ -4,18 +4,9 @@ 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);
}
}
@@ -1,6 +1,6 @@
package edu.msudenver.tsp.website.controller;
import edu.msudenver.tsp.website.controller.forms.Theorem;
import edu.msudenver.tsp.website.forms.TheoremForm;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
@@ -9,7 +9,6 @@ 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;
@Slf4j
@@ -18,16 +17,16 @@ import org.springframework.web.servlet.ModelAndView;
@RequestMapping("/theorem")
public class TheoremEntryController {
@GetMapping({"/",""})
public ModelAndView enterTheoremPage()
{
public ModelAndView enterTheoremPage() {
LOG.info("Received request to display the theorem entry page: returning model with name 'Theorem'");
return new ModelAndView("Theorem");
}
@PostMapping({"/",""})
public String saveTheorem(@Validated Theorem theorem, Model model) {
model.addAttribute("theromName1", theorem.getTheoremName1());
model.addAttribute("theromName2", theorem.getTheoremName2());
public String saveTheorem(@Validated final TheoremForm theoremForm, final Model model) {
model.addAttribute("theoremName", theoremForm.getTheoremName());
model.addAttribute("theorem", theoremForm.getTheorem());
LOG.info("Saving theorem {}...", theoremForm);
return "success";
}
@@ -1,16 +0,0 @@
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 theoremName1 ;
private String theoremName2 ;
@NotBlank(message = "Theorem name must not be blank") private String theoremName;
private String theorem;
}
@@ -0,0 +1,11 @@
package edu.msudenver.tsp.website.forms;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class TheoremForm {
private String theoremName;
private String theorem;
}
+2 -1
View File
@@ -1,2 +1,3 @@
spring.mvc.view.prefix:/WEB-INF/jsp/
spring.mvc.view.suffix:.jsp
spring.mvc.view.suffix:.jsp
server.port=8090
+17 -13
View File
@@ -1,16 +1,20 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Theroem Page</title>
</head>
<body>
<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>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Theorem Entry</title>
</head>
<body>
<form method="post" action="">
<label>Theorem Name:
<input type="text" name="theoremName"/>
</label>
<br><label>Theorem:
<input type="text" name="theorem"/>
</label><br>
<input type="submit" value="Save">
</form>
</body>
</html>
+4 -4
View File
@@ -1,7 +1,7 @@
<html>
<body>
<br><b>Name:</b><%= request.getParameter("theoremName1")%>
<br><b>Name:</b><%= request.getParameter("theoremName2")%>
<body>
<br><b>Name: </b><%= request.getParameter("theoremName")%>
<br><b>Theorem: </b><%= request.getParameter("theorem")%>
</body>
</body>
</html>
@@ -2,44 +2,23 @@ package edu.msudenver.tsp.website.controller;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.ui.Model;
import org.springframework.web.servlet.ModelAndView;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import java.util.Map;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@RunWith(MockitoJUnitRunner.class)
public class TheoremEntryControllerTest {
@InjectMocks
private TheoremEntryController theoremEntryController;
@Mock private TheoremEntryController theoremEntryController;
@Test
public void theoremPage(){
final ModelAndView modelAndView= theoremEntryController.enterTheoremPage();
public void testEnterTheoremPage() {
final ModelAndView modelAndView = theoremEntryController.enterTheoremPage();
assertNotNull(modelAndView);
assertEquals("Theorem",modelAndView.getViewName());
assertEquals("Theorem", modelAndView.getViewName());
}
@Test
public void saveTheorem(){
final ModelAndView modelAndView= theoremEntryController.enterTheoremPage();
assertNotNull(modelAndView);
assertEquals("Theorem",modelAndView.getViewName());
}
}