Detailed information about defect clone:

23-C1.H0.M0.L0_T_S_03.war

 

Nickname of the defect

delete-displayed-but-not-in-DB

Brief desctiption

The button X in the column Cancel exam date in My Exam dates deletes this exam date from table in the screen but NOT in the database.
Side-effect: List of participants is not sorted alphabetically.

How to activate the defect

 

Visibility of the defect

Expected Actual

Parts

StudentService TeacherService DateUtility GradeDAO UserDAO
BaseStudentService E03TeacherService 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/E03TeacherService.java

Source code with the injected defect

/** * DELIBERATE ERROR * * This error method removes examination term of specific teacher * from view, but not from database * * @param teacher For this teacher object will be exam date removed * @param examTermId Database id of exam term which teacher wants to remove * @return Indication for removing examination term */ @Override @ErrorMethod(errorMessage = "This error method removes examination term from view, but not from database.") public boolean removeExaminationTerm(Teacher teacher, Long examTermId) { if (teacher == null) { log.error("Removing examination term failed."); return false; } log.info("Removing examination term with id " + examTermId + " from teacher with id " + teacher.getId() + "."); ExaminationDate examinationDate = examinationDateDao.findOne(examTermId); if (examinationDate == null) { return false; } // Test of authorized teacher if (examinationDate.getTeacher() == null || examinationDate.getTeacher().getId().longValue() != teacher.getId().longValue()) { return false; } examTerms.add(examinationDate); log.error(propertyLoader.getProperty("log.E03TeacherService.removeExaminationTerm")); return true; }

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/BaseTeacherService.java

Correct source code

/** * This method removes exam term of specific teacher. * * @param teacher For this teacher object will be exam date removed * @param examTermId Database id of exam term which teacher wants to remove * @return true if operation will be successfully completed, false otherwise */ @Override public boolean removeExaminationTerm(Teacher teacher, Long examTermId) { if (teacher == null) { log.error("Removing examination term failed."); return false; } log.info("Removing examination term with id " + examTermId + " from teacher with id " + teacher.getId() + "."); ExaminationDate examinationDate = examinationDateDao.findOne(examTermId); if (examinationDate == null) { return false; } // Test of authorized teacher if (examinationDate.getTeacher() == null || examinationDate.getTeacher().getId().longValue() != teacher.getId().longValue()) { return false; } //Term have not to be deleted if at least one student is graduated in specific subject! examinationDate.getParticipants().removeAll(examinationDate.getParticipants()); examinationDate.setTeacher(null); examinationDate.setSubject(null); examinationDate.setDateOfTest(null); examinationDate = examinationDateDao.save(examinationDate); examinationDateDao.delete(examinationDate.getId()); examinationDate = examinationDateDao.findOne(examTermId); return examinationDate == null; }

Logged information up to failure

2019-10-14 11:06:56.576 -- INFO LogHelper:31 - HHH000204: Processing PersistenceUnitInfo [name: cz.zcu.kiv.matyasj.dp] 2019-10-14 11:06:56.810 -- INFO Version:46 - HHH000412: Hibernate Core {5.4.1.Final} 2019-10-14 11:06:57.248 -- INFO Version:49 - HCANN000001: Hibernate Commons Annotations {5.1.0.Final} 2019-10-14 11:06:57.670 -- INFO C3P0ConnectionProvider:116 - HHH010002: C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/uis-web-db 2019-10-14 11:06:57.670 -- INFO C3P0ConnectionProvider:117 - HHH10001001: Connection properties: {password=****, useUnicode=true, handling_mode=DELAYED_ACQUISITION_AND_HOLD, characterEncoding=UTF-8, user=uis-web} 2019-10-14 11:06:57.670 -- INFO C3P0ConnectionProvider:120 - HHH10001003: Autocommit mode: false 2019-10-14 11:06:57.873 -- INFO C3P0ConnectionProvider:200 - HHH10001007: JDBC isolation level: <unknown> 2019-10-14 11:06:58.279 -- INFO Dialect:158 - HHH000400: Using dialect: org.hibernate.dialect.MySQL55Dialect 2019-10-14 11:07:00.076 -- INFO access:47 - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@46cd3592] 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 11:07:02.419 -- INFO access:47 - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@5cb63d05] 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 11:07:14.907 -- INFO JtaPlatformInitiator:52 - HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] 2019-10-14 11:07:15.157 -- INFO SecurityConfig:75 - SECURITY JDBC authentication process is running 2019-10-14 11:07:17.547 -- INFO SecurityConfig:93 - Authorization configuration process is running 2019-10-14 11:07:17.907 -- INFO BaseInitializer:97 - Initializing ... 2019-10-14 11:07:24.908 -- INFO BaseInitializer:463 - Initialized! 2019-10-14 11:07:25.064 -- INFO BaseInitializer:97 - Initializing ... 2019-10-14 11:07:27.378 -- INFO LoginController:30 - Request for login view 2019-10-14 11:07:34.942 -- INFO UserDaoCriteria:74 - User with username pedant found. 2019-10-14 11:07:35.004 -- INFO SecurityConfig:121 - Success login - pedant 2019-10-14 11:07:35.004 -- INFO SecurityConfig:125 - User login role: ROLE_TEACHER 2019-10-14 11:07:35.020 -- INFO UserDaoCriteria:74 - User with username pedant found. 2019-10-14 11:07:35.035 -- INFO OverviewController:53 - Request for overview of teacher with id 30 for view. 2019-10-14 11:07:37.911 -- INFO UserDaoCriteria:74 - User with username pedant found. 2019-10-14 11:07:37.927 -- INFO TeachersExamTermsController:48 - Request for retrieving list of exam dates of user with id 30 view. 2019-10-14 11:07:37.927 -- INFO E03TeacherService:61 - Getting all examination terms without graduate participants for teacher with id 30. 2019-10-14 11:07:37.974 -- INFO ExaminationDateDaoCriteria:118 - Returning list of 3 examination dates for teacher with id 30. 2019-10-14 11:07:38.005 -- WARN GradeDaoCriteria:137 - Grade for student Benjamin Green and for subject Computer System Engineering and for date 2019-10-15 11:07:22.0 not found. 2019-10-14 11:07:38.005 -- WARN GradeDaoCriteria:137 - Grade for student Isabella Yellow and for subject Computer System Engineering and for date 2019-10-15 11:07:22.0 not found. 2019-10-14 11:07:38.005 -- WARN GradeDaoCriteria:137 - Grade for student Mia Orange and for subject Computer System Engineering and for date 2019-10-15 11:07:22.0 not found. 2019-10-14 11:07:38.005 -- WARN GradeDaoCriteria:137 - Grade for student Charlotte Purple and for subject Computer System Engineering and for date 2019-10-15 11:07:22.0 not found. 2019-10-14 11:07:38.005 -- WARN GradeDaoCriteria:137 - Grade for student Michael Gray and for subject Database Systems and for date 2019-10-15 11:07:22.0 not found. 2019-10-14 11:07:38.005 -- WARN GradeDaoCriteria:137 - Grade for student Sophia Red and for subject Database Systems and for date 2019-10-15 11:07:22.0 not found. 2019-10-14 11:07:38.021 -- INFO UserDaoCriteria:74 - User with username pedant found. 2019-10-14 11:07:38.036 -- INFO BaseTeacherService:92 - Getting list of taught subjects for teacher with id 30. 2019-10-14 11:07:39.833 -- INFO UserDaoCriteria:74 - User with username pedant found. 2019-10-14 11:07:39.864 -- INFO TeachersExamTermsController:73 - Request of user with id 30 for canceling examination date with id43. 2019-10-14 11:07:39.864 -- INFO E03TeacherService:102 - Removing examination term with id 43 from teacher with id 30. 2019-10-14 11:07:39.880 -- ERROR E03TeacherService:117 - INJECTED_ERROR: E03TeacherService_removeExaminationTerm_removes_exam_term_from_view_not_from_db 2019-10-14 11:07:39.880 -- INFO TeachersExamTermsController:76 - Request for canceling examination date with id43 was successful. 2019-10-14 11:07:39.880 -- INFO UserDaoCriteria:74 - User with username pedant found. 2019-10-14 11:07:39.895 -- INFO TeachersExamTermsController:48 - Request for retrieving list of exam dates of user with id 30 view. 2019-10-14 11:07:39.895 -- INFO E03TeacherService:61 - Getting all examination terms without graduate participants for teacher with id 30. 2019-10-14 11:07:39.927 -- INFO ExaminationDateDaoCriteria:118 - Returning list of 3 examination dates for teacher with id 30. 2019-10-14 11:07:39.927 -- WARN GradeDaoCriteria:137 - Grade for student Benjamin Green and for subject Computer System Engineering and for date 2019-10-15 11:07:22.0 not found. 2019-10-14 11:07:39.927 -- WARN GradeDaoCriteria:137 - Grade for student Isabella Yellow and for subject Computer System Engineering and for date 2019-10-15 11:07:22.0 not found. 2019-10-14 11:07:39.942 -- WARN GradeDaoCriteria:137 - Grade for student Mia Orange and for subject Computer System Engineering and for date 2019-10-15 11:07:22.0 not found. 2019-10-14 11:07:39.942 -- WARN GradeDaoCriteria:137 - Grade for student Charlotte Purple and for subject Computer System Engineering and for date 2019-10-15 11:07:22.0 not found. 2019-10-14 11:07:39.942 -- WARN GradeDaoCriteria:137 - Grade for student Michael Gray and for subject Database Systems and for date 2019-10-15 11:07:22.0 not found. 2019-10-14 11:07:39.942 -- WARN GradeDaoCriteria:137 - Grade for student Sophia Red and for subject Database Systems and for date 2019-10-15 11:07:22.0 not found. 2019-10-14 11:07:39.942 -- INFO UserDaoCriteria:74 - User with username pedant found. 2019-10-14 11:07:39.958 -- INFO BaseTeacherService:92 - Getting list of taught subjects for teacher with id 30.

Overview of functional tests full log

Overview of acceptance tests full report