updated with passed tests
This commit is contained in:
@@ -70,8 +70,6 @@ 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'
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
package edu.msudenver.tsp.website;
|
|
||||||
|
|
||||||
|
|
||||||
import lombok.extern.java.Log;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.CommandLineRunner;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
|
||||||
@Slf4j
|
|
||||||
|
|
||||||
public class Application {
|
|
||||||
|
|
||||||
public static void main(final String[] args) {
|
|
||||||
SpringApplication.run(Application.class, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package edu.msudenver.tsp.website.controller;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+10
-11
@@ -1,9 +1,8 @@
|
|||||||
package edu.msudenver.tsp.website;
|
package edu.msudenver.tsp.website.controller;
|
||||||
|
|
||||||
import edu.msudenver.tsp.website.forms.Theorem;
|
import edu.msudenver.tsp.website.controller.forms.Theorem;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
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;
|
||||||
@@ -17,28 +16,28 @@ import org.springframework.web.servlet.ModelAndView;
|
|||||||
public class TheoremEntryController {
|
public class TheoremEntryController {
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("/welcome")
|
|
||||||
public ModelAndView firstPage()
|
|
||||||
{
|
|
||||||
return new ModelAndView("welcome");
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping("/theorem")
|
@RequestMapping("/theorem")
|
||||||
public ModelAndView theoremPage()
|
public ModelAndView theoremPage()
|
||||||
{
|
{
|
||||||
//System.out.println("Inside controller");
|
|
||||||
|
|
||||||
return new ModelAndView("Theorem");
|
return new ModelAndView("Theorem");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||||
public String saveTheorem(@Validated Theorem theorem, Model model) {
|
public String saveTheorem(@Validated Theorem theorem, Model model) {
|
||||||
|
|
||||||
model.addAttribute("theromName1", theorem.getTheoremName1());
|
model.addAttribute("theromName", theorem.getTheoremName());
|
||||||
model.addAttribute("theromName2", theorem.getTheoremName2());
|
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ModelAndView firstPage() {
|
||||||
|
return new ModelAndView("welcome");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package edu.msudenver.tsp.website.controller.forms;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
|
||||||
|
public class Theorem {
|
||||||
|
private String theoremName ;
|
||||||
|
|
||||||
|
|
||||||
|
public String getTheoremName() {
|
||||||
|
return theoremName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTheoremName1(String theoremName) {
|
||||||
|
this.theoremName = theoremName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package edu.msudenver.tsp.website.forms;
|
|
||||||
|
|
||||||
public class Theorem {
|
|
||||||
private String theoremName1 ;
|
|
||||||
private String theoremName2 ;
|
|
||||||
|
|
||||||
public String getTheoremName1() {
|
|
||||||
return theoremName1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTheoremName1(String theoremName) {
|
|
||||||
this.theoremName1 = theoremName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTheoremName2() {
|
|
||||||
return theoremName2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTheoremName2(String theoremName) {
|
|
||||||
this.theoremName2 = theoremName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<form action="save" method="post">
|
<form action="save" method="post">
|
||||||
Enter Theorem 1: <input type="text" name="theoremName1">
|
Enter Theorem Name: <input type="text" name="theoremName">
|
||||||
<br>Enter Theorem 2: <input type="text" name="theoremName2"><br>
|
|
||||||
<input type="submit" value="save">
|
<input type="submit" value="save">
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<br><b>Name1:</b><%= request.getParameter("theoremName1")%>
|
<br><b>Name:</b><%= request.getParameter("theoremName")%>
|
||||||
<br><b>Name2:</b><%= request.getParameter("theoremName2")%>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
|
|
||||||
pageEncoding="ISO-8859-1"%>
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package edu.msudenver.tsp.website.controller;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.InjectMocks;
|
||||||
|
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.*;
|
||||||
|
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
|
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();
|
||||||
|
|
||||||
|
assertNotNull(modelAndView);
|
||||||
|
assertEquals("Theorem",modelAndView.getViewName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user