|
@@ -1,140 +0,0 @@
|
|
|
-package com.ym;
|
|
|
-
|
|
|
-import java.text.ParseException;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-import junit.framework.TestCase;
|
|
|
-
|
|
|
-import org.junit.Test;
|
|
|
-import org.junit.runner.RunWith;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.boot.test.context.SpringBootTest;
|
|
|
-import org.springframework.http.HttpEntity;
|
|
|
-import org.springframework.http.HttpHeaders;
|
|
|
-import org.springframework.http.HttpMethod;
|
|
|
-import org.springframework.http.MediaType;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
-import org.springframework.test.context.junit4.SpringRunner;
|
|
|
-import org.springframework.util.MultiValueMap;
|
|
|
-import org.springframework.web.client.RestTemplate;
|
|
|
-
|
|
|
-import com.ym.mec.biz.dal.dao.ClassGroupDao;
|
|
|
-import com.ym.mec.biz.dal.dao.CourseScheduleDao;
|
|
|
-import com.ym.mec.biz.dal.dao.StudentAttendanceDao;
|
|
|
-import com.ym.mec.biz.dal.dto.CourseScheduleDto;
|
|
|
-import com.ym.mec.biz.dal.entity.CourseSchedule;
|
|
|
-import com.ym.mec.biz.dal.entity.StudentAttendance;
|
|
|
-import com.ym.mec.biz.dal.enums.StudentAttendanceStatusEnum;
|
|
|
-import com.ym.mec.biz.service.CourseScheduleService;
|
|
|
-import com.ym.mec.common.security.SecurityUtils;
|
|
|
-import com.ym.mec.web.WebApplication;
|
|
|
-
|
|
|
-/**
|
|
|
- * Unit test for simple App.
|
|
|
- */
|
|
|
-
|
|
|
-@RunWith(SpringRunner.class)
|
|
|
-@SpringBootTest(classes = WebApplication.class)
|
|
|
-public class webApplicationTest
|
|
|
- extends TestCase{
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private RestTemplate restTemplate;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private CourseScheduleService css;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private StudentAttendanceDao sad;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ClassGroupDao cgd;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private CourseScheduleDao csd;
|
|
|
-
|
|
|
- @Test
|
|
|
- public void test(){
|
|
|
-
|
|
|
- String url = "http://auth-server/queryUserInfo";
|
|
|
-
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.add("Authorization", "bearer " + SecurityUtils.getAuthentication());
|
|
|
- headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
|
|
-
|
|
|
- HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<MultiValueMap<String, String>>(null, headers);
|
|
|
- ResponseEntity<String> resp = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
|
|
|
-
|
|
|
- System.out.println("---------"+resp);
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void test1(){
|
|
|
- List<StudentAttendance> sas=new ArrayList<>();
|
|
|
- StudentAttendance sa=new StudentAttendance();
|
|
|
- sa.setClassGroupId(1);
|
|
|
- sa.setCourseScheduleId(1L);
|
|
|
- sa.setMusicGroupId(1);
|
|
|
- sa.setRemark("test");
|
|
|
- sa.setStatus(StudentAttendanceStatusEnum.LEAVE);
|
|
|
- sa.setTeacherId(1);
|
|
|
- sa.setUserId(1);
|
|
|
- sas.add(sa);
|
|
|
- sad.addStudentAttendances(sas);
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void test2() throws ParseException {
|
|
|
- System.out.println(new StringBuilder("2019-09-11 15:10:01").toString());
|
|
|
- System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:dd").parse("2019-09-11 15:10:01"));
|
|
|
- System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(new StringBuilder("2019-09-11 15:10:01").toString()));
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void test3() throws ParseException {
|
|
|
- List<CourseSchedule> courseSchedules=new ArrayList<>();
|
|
|
- CourseSchedule cs1=new CourseSchedule();
|
|
|
- cs1.setClassDate(new SimpleDateFormat("yyyy-MM-dd").parse("2019-09-17"));
|
|
|
- cs1.setStartClassTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2019-09-17 15:00:00"));
|
|
|
- cs1.setClassGroupId(1);
|
|
|
- courseSchedules.add(cs1);
|
|
|
- CourseSchedule cs2=new CourseSchedule();
|
|
|
- cs2.setClassDate(new SimpleDateFormat("yyyy-MM-dd").parse("2019-09-17"));
|
|
|
- cs2.setStartClassTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2019-09-17 15:00:00"));
|
|
|
- cs2.setClassGroupId(1);
|
|
|
- courseSchedules.add(cs2);
|
|
|
- CourseSchedule cs3=new CourseSchedule();
|
|
|
- cs3.setClassDate(new SimpleDateFormat("yyyy-MM-dd").parse("2019-09-17"));
|
|
|
- cs3.setStartClassTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2019-09-17 16:00:00"));
|
|
|
- cs3.setClassGroupId(1);
|
|
|
- courseSchedules.add(cs3);
|
|
|
- Map<Date, List<CourseSchedule>> collect = courseSchedules.stream().collect(
|
|
|
- Collectors.groupingBy(CourseSchedule::getClassDate));
|
|
|
- for(Date keyDate:collect.keySet()){
|
|
|
- List<CourseSchedule> currentCourses=collect.get(keyDate);
|
|
|
- Map<Date, List<CourseSchedule>> collect1 = currentCourses.stream().collect(Collectors.groupingBy(CourseSchedule::getStartClassTime));
|
|
|
- System.out.println(collect1.size());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void test4(){
|
|
|
- List<Integer> temp=new ArrayList<>();
|
|
|
- temp.add(1);
|
|
|
- temp.add(2);
|
|
|
- Integer[] integers = csd.countStudentInClass(temp);
|
|
|
- System.out.println(integers.length);
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void test5() throws ParseException {
|
|
|
- List<CourseScheduleDto> courseSchedules = csd.getCourseSchedulesWithDate(new SimpleDateFormat("yyyyMMdd").parse("20190912"));
|
|
|
- System.out.println(courseSchedules.size());
|
|
|
- }
|
|
|
-
|
|
|
-}
|