Merge branch 'master' of https://github.com/atusa17/ptp into PAN-15

# Conflicts:
#	src/main/java/edu/msudenver/tsp/website/Application.java
This commit is contained in:
dantanxiaotian
2019-03-24 15:00:20 -06:00
23 changed files with 174 additions and 239 deletions
@@ -3,16 +3,10 @@ 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) {
SpringApplication.run(Application.class, args);
}
}
@@ -1,4 +0,0 @@
package edu.msudenver.tsp.website;
public class ProofsDriver {
}
@@ -0,0 +1,33 @@
package edu.msudenver.tsp.website.controller;
import edu.msudenver.tsp.website.forms.TheoremForm;
import lombok.AllArgsConstructor;
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.servlet.ModelAndView;
@Slf4j
@Controller
@AllArgsConstructor
@RequestMapping("/theorem")
public class TheoremEntryController {
@GetMapping({"/",""})
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 final TheoremForm theoremForm, final Model model) {
model.addAttribute("theoremName", theoremForm.getTheoremName());
model.addAttribute("theorem", theoremForm.getTheorem());
LOG.info("Saving theorem {}...", theoremForm);
return "success";
}
}
@@ -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;
}
@@ -0,0 +1,2 @@
spring.mvc.view.prefix:/WEB-INF/jsp/
spring.mvc.view.suffix:.jsp
+20
View File
@@ -0,0 +1,20 @@
<%@ 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>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>
+7
View File
@@ -0,0 +1,7 @@
<html>
<body>
<br><b>Name: </b><%= request.getParameter("theoremName")%>
<br><b>Theorem: </b><%= request.getParameter("theorem")%>
</body>
</html>
-25
View File
@@ -1,25 +0,0 @@
<%--
Created by IntelliJ IDEA.
User: atusa
Date: 2/1/19
Time: 8:03 PM
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" 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 Prover</title>
</head>
<body>
<div>
<div>
<h1>Theorem Prover</h1>
<h2>Hello! ${message}</h2>
Click on this <strong><a href="next">link</a></strong> to visit theorem entering page.
</div>
</div>
</body>
</html>
@@ -1,5 +0,0 @@
package edu.msudenver.tsp.website;
public class ProofsDriverTest {
}
@@ -0,0 +1,23 @@
package edu.msudenver.tsp.website.controller;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.web.servlet.ModelAndView;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@RunWith(MockitoJUnitRunner.class)
public class TheoremEntryControllerTest {
private final TheoremEntryController theoremEntryController = new TheoremEntryController();
@Test
public void testEnterTheoremPage() {
final ModelAndView modelAndView = theoremEntryController.enterTheoremPage();
assertNotNull(modelAndView);
assertEquals("Theorem", modelAndView.getViewName());
}
}