updated with passed tests
This commit is contained in:
@@ -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.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -17,28 +16,28 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
public class TheoremEntryController {
|
||||
|
||||
|
||||
@RequestMapping("/welcome")
|
||||
public ModelAndView firstPage()
|
||||
{
|
||||
return new ModelAndView("welcome");
|
||||
}
|
||||
|
||||
@RequestMapping("/theorem")
|
||||
public ModelAndView theoremPage()
|
||||
{
|
||||
//System.out.println("Inside controller");
|
||||
|
||||
|
||||
return new ModelAndView("Theorem");
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||
public String saveTheorem(@Validated Theorem theorem, Model model) {
|
||||
|
||||
model.addAttribute("theromName1", theorem.getTheoremName1());
|
||||
model.addAttribute("theromName2", theorem.getTheoremName2());
|
||||
model.addAttribute("theromName", theorem.getTheoremName());
|
||||
|
||||
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>
|
||||
<body>
|
||||
<form action="save" method="post">
|
||||
Enter Theorem 1: <input type="text" name="theoremName1">
|
||||
<br>Enter Theorem 2: <input type="text" name="theoremName2"><br>
|
||||
Enter Theorem Name: <input type="text" name="theoremName">
|
||||
|
||||
<input type="submit" value="save">
|
||||
</form>
|
||||
</body>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
<br><b>Name1:</b><%= request.getParameter("theoremName1")%>
|
||||
<br><b>Name2:</b><%= request.getParameter("theoremName2")%>
|
||||
<br><b>Name:</b><%= request.getParameter("theoremName")%>
|
||||
|
||||
</body>
|
||||
</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">
|
||||
<html>
|
||||
<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