Detailed information about defect clone:
07-C0.H0.M1.L0_S_S_08.war
Nickname of the defect
unknown-additional-record
Brief desctiption
Additional student Tony Noname
appears in modal window Exam Date Participants in My Exam Dates.
How to activate the defect
-
Click on Login in the header
-
Username
green
, password pass
, click on Login button
-
Click on My Exam Dates
-
Click on Participants in the column Participants in the row Web Programming
Visibility of the defect
Parts
StudentService |
TeacherService |
DateUtility |
GradeDAO |
UserDAO |
E08StudentService
|
BaseTeacherService
|
BaseDateUtility
|
GradeTypeDaoCriteria
|
UserDaoCriteria
|
URL to the defect source code
https://gitlab.kiv.zcu.cz/herout/TbUIS-UIS/blob/master/src/main/java/cz/zcu/kiv/matyasj/dp/service/users/error/E05StudentService.java
Source code with the injected defect
/**
* DELIBERATE ERROR
*
* This error method changes participants on exam. It gets list
* of exam dates registered by one particular student. In list
* are not included exam dates with evaluation for particular student, but
* exam date always contains 1 student extra.
*
* @param studentId database student id
* @return List of students for examination dates
*/
@Override
@ErrorMethod(errorMessage = "This error method returns list of students for exam dates with 1 extra student.")
public List getStudentExaminationDatesList(Long studentId) {
User student = userDao.findOne(studentId);
if (student instanceof Student) {
log.info("Getting list of examination dates for student with id " + studentId + ".");
List gradeList = gradeDao.findGradesByStudent((Student) student);
List examinationDateList = examinationDateDao.getExaminationDateOfStudent((Student) student);
// Remove exam dates of already graduated subjects
for (Grade g : gradeList) {
examinationDateList.removeIf(examinationDate -> (examinationDate.getSubject().getId().longValue() == g.getSubject().getId().longValue() && examinationDate.getDateOfTest().equals(g.getDayOfGrant())));
}
Student dummyStudent = new Student("Tony", "Noname", "noname", "pass", "mail@noname.com");
for (ExaminationDate examDate : examinationDateList) {
examDate.getParticipants().add(dummyStudent);
}
log.error(propertyLoader.getProperty("log.E08StudentService.getStudentExaminationDatesList"));
return examinationDateList;
}
log.error("Getting list of examination dates failed.");
return null;
}
URL to the correct source code
https://gitlab.kiv.zcu.cz/herout/TbUIS-UIS/blob/master/src/main/java/cz/zcu/kiv/matyasj/dp/service/users/correct/BaseStudentService.java
Correct source code
/**
* Get list of exam dates registered by one particular student. In list
* are not included exam dates with evaluation for particular student.
*
* @param studentId database student id
* @return List of students for examination dates
*/
@Override
public List getStudentExaminationDatesList(Long studentId) {
User student = userDao.findOne(studentId);
if (student instanceof Student) {
log.info("Getting list of examination dates for student with id " + studentId + ".");
List gradeList = gradeDao.findGradesByStudent((Student) student);
List examinationDateList = examinationDateDao.getExaminationDateOfStudent((Student) student);
// Remove exam dates of already graduated subjects
for (Grade g : gradeList) {
examinationDateList.removeIf(examinationDate -> (examinationDate.getSubject().getId().longValue() == g.getSubject().getId().longValue() && examinationDate.getDateOfTest().equals(g.getDayOfGrant())));
}
return examinationDateList;
}
log.error("Getting list of examination dates failed.");
return null;
}
Logged information up to failure
2019-10-14 09:27:21.731 -- INFO LogHelper:31 - HHH000204: Processing PersistenceUnitInfo [name: cz.zcu.kiv.matyasj.dp]
2019-10-14 09:27:21.965 -- INFO Version:46 - HHH000412: Hibernate Core {5.4.1.Final}
2019-10-14 09:27:22.371 -- INFO Version:49 - HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2019-10-14 09:27:22.778 -- INFO C3P0ConnectionProvider:116 - HHH010002: C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/uis-web-db
2019-10-14 09:27:22.778 -- INFO C3P0ConnectionProvider:117 - HHH10001001: Connection properties: {password=****, useUnicode=true, handling_mode=DELAYED_ACQUISITION_AND_HOLD, characterEncoding=UTF-8, user=uis-web}
2019-10-14 09:27:22.778 -- INFO C3P0ConnectionProvider:120 - HHH10001003: Autocommit mode: false
2019-10-14 09:27:22.981 -- INFO C3P0ConnectionProvider:200 - HHH10001007: JDBC isolation level:
2019-10-14 09:27:23.356 -- INFO Dialect:158 - HHH000400: Using dialect: org.hibernate.dialect.MySQL55Dialect
2019-10-14 09:27:25.043 -- INFO access:47 - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@70420c70] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
2019-10-14 09:27:27.419 -- INFO access:47 - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@564d5883] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
2019-10-14 09:27:40.078 -- INFO JtaPlatformInitiator:52 - HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2019-10-14 09:27:40.312 -- INFO SecurityConfig:75 - SECURITY JDBC authentication process is running
2019-10-14 09:27:42.500 -- INFO SecurityConfig:93 - Authorization configuration process is running
2019-10-14 09:27:42.781 -- INFO BaseInitializer:97 - Initializing ...
2019-10-14 09:27:49.769 -- INFO BaseInitializer:463 - Initialized!
2019-10-14 09:27:49.909 -- INFO BaseInitializer:97 - Initializing ...
2019-10-14 09:35:12.208 -- INFO LoginController:30 - Request for login view
2019-10-14 09:35:17.945 -- INFO UserDaoCriteria:74 - User with username green found.
2019-10-14 09:35:17.976 -- INFO SecurityConfig:121 - Success login - green
2019-10-14 09:35:17.976 -- INFO SecurityConfig:125 - User login role: ROLE_STUDENT
2019-10-14 09:35:18.008 -- INFO UserDaoCriteria:74 - User with username green found.
2019-10-14 09:35:18.023 -- INFO OverviewController:49 - Request for overview of student with id 18 for view.
2019-10-14 09:35:20.289 -- INFO RegisterExamDatesController:44 - Request for retrieving reqistered exam dates view.
2019-10-14 09:35:20.289 -- INFO UserDaoCriteria:74 - User with username green found.
2019-10-14 09:35:20.320 -- INFO E08StudentService:64 - Getting list of examination dates for student with id 18.
2019-10-14 09:35:20.351 -- INFO GradeDaoCriteria:102 - Returning list of 0 for student with id 18
2019-10-14 09:35:20.382 -- INFO ExaminationDateDaoCriteria:70 - Returning list of 3 examination dates for student with id 18.
2019-10-14 09:35:20.382 -- ERROR E08StudentService:78 - INJECTED_ERROR: E08StudentService_getStudentExaminationDatesList_returns_list_of_students_with_1_extra_student
Overview of functional tests full log
Overview of acceptance tests full report