单元测试

master
shijie 4 years ago
parent d1df6e4903
commit 84fa18bde2
  1. 47
      src/test/java/com/yipin/liuwanr/Project_ManagementTest.java

@ -225,10 +225,10 @@ public class Project_ManagementTest {
/** /**
* 添加项目管理信息 * 添加项目管理信息
*/ */
@Transactional @Transactional //在单元测试中 Transaction注解会对数据库的更新(insert update delete)进行回滚 ,以保证数据不污染
@Test @Test
public void testInsertProjectManagement() { public void testInsertProjectManagement() {
Project_Management pro = new Project_Management(); /*Project_Management pro = new Project_Management();
pro.setProjectName("简单加法计算"); pro.setProjectName("简单加法计算");
pro.setProjectPermissions(1); pro.setProjectPermissions(1);
pro.setExperimentalGoal("本项目将会帮助学生了解简单的加法计算"); pro.setExperimentalGoal("本项目将会帮助学生了解简单的加法计算");
@ -242,12 +242,17 @@ public class Project_ManagementTest {
pro.setFounder(0); pro.setFounder(0);
List<Judgment_Points> points = new ArrayList<>(); List<Judgment_Points> points = new ArrayList<>();
Judgment_Points judgmentPoints = new Judgment_Points(); Judgment_Points judgmentPoints = new Judgment_Points();
judgmentPoints.setJudgmentPointsId(153); judgmentPoints.setJudgmentPointsId(205);
judgmentPoints.setExperimentalRequirements("声明两个变量,让其相加,得到其和....."); judgmentPoints.setExperimentalRequirements("按要求写出代码并正确运行显示小明考核结果");
judgmentPoints.setScore(100); judgmentPoints.setScore(100);
points.add(judgmentPoints); points.add(judgmentPoints);
List<Integer> roles = new ArrayList<>(); List<Integer> roles = new ArrayList<>();
roles.add(120); roles.add(433);*/
Project_Management pro = projectManagementMapper.getProjectId(302);
pro.setProjectId(null);
pro.setFounder(0);
List<Judgment_Points> points = projectManagementMapper.queryProjectIds(302);
List<Integer> roles = projectManagementMapper.getByRoleProjectId(302);
HashMap<String, Object> map = managementService.insertProjectManagement(pro, points, roles); HashMap<String, Object> map = managementService.insertProjectManagement(pro, points, roles);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value)); map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
} }
@ -258,9 +263,9 @@ public class Project_ManagementTest {
*/ */
@Test @Test
public void testGetByName() { public void testGetByName() {
String projectName = null; String projectName = "测试2";
HashMap<String, Object> map = managementService.getByName(projectName); HashMap<String, Object> map = managementService.getByName(projectName);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value)); map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
} }
/** /**
@ -270,9 +275,31 @@ public class Project_ManagementTest {
@Transactional @Transactional
@Test @Test
public void testUpdateProjectManagement() { public void testUpdateProjectManagement() {
Project_Management pro = null; /*Project_Management pro = new Project_Management();
List<Judgment_Points> points = null; pro.setProjectId(302);
List<Integer> roles = null; pro.setProjectName("简单加法计算");
pro.setProjectPermissions(1);
pro.setExperimentalGoal("本项目将会帮助学生了解简单的加法计算");
pro.setCaseDescription("声明两个变量,让其相加,得到其和");
pro.setIsstartexperimental(0);
pro.setExperimentSuggests("使用加号,将声明的变量相加");
pro.setIsstartexperimentSuggests(0);
pro.setState(1);
pro.setSystemId(6);
pro.setUserId(4);
pro.setFounder(0);
List<Judgment_Points> points = new ArrayList<>();
Judgment_Points judgmentPoints = new Judgment_Points();
judgmentPoints.setJudgmentPointsId(205);
judgmentPoints.setExperimentalRequirements("按要求写出代码并正确运行显示小明考核结果");
judgmentPoints.setScore(100);
points.add(judgmentPoints);
List<Integer> roles = new ArrayList<>();
roles.add(433);*/
Project_Management pro = projectManagementMapper.getProjectId(302);
pro.setFounder(0);
List<Judgment_Points> points = projectManagementMapper.queryProjectIds(302);
List<Integer> roles = projectManagementMapper.getByRoleProjectId(302);
HashMap<String, Object> map = managementService.updateProjectManagement(pro, points, roles); HashMap<String, Object> map = managementService.updateProjectManagement(pro, points, roles);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value)); map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
} }

Loading…
Cancel
Save