Detailed information about defect clone:
03-C0.H0.M0.L1_S_S_02.war
Nickname of the defect
fixed-value
Brief desctiption
Student in My Subjects menu has always 20 Total Credits despite any changes anywhere.
How to activate the defect
-
Click on Login in the header
-
Username
brown
, password pass
, click on Login button
-
Click on My Subjects
Visibility of the defect
Expected |
Actual |
|
|
Parts
StudentService |
TeacherService |
DateUtility |
GradeDAO |
UserDAO |
E02StudentService
|
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/E02StudentService.java
Source code with the injected defect
/**
* DELIBERATE ERROR
*
* This error method returns always 20 credits instead of real sum of student credits.
*
* @param studentId database id of student
* @return 20
*/
@Override
@ErrorMethod(errorMessage = "This error method returns always 20 credits instead of real sum of student credits.")
public int getStudentTotalCredits(Long studentId) {
log.error(propertyLoader.getProperty("log.E02StudentService.getStudentTotalCredits"));
return 20;
}
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
/**
* This method returns number of obtained credits.
*
* @param studentId database id of student
* @return number of obtained credits.
*/
@Override
public int getStudentTotalCredits(Long studentId) {
int totalCredits;
User student = userDao.findOne(studentId);
if (student instanceof Student) {
log.info("Getting total number of credits for student with id " + studentId + ".");
totalCredits = ((Student) student).getListOfAbsolvedSubjects().stream().mapToInt(Subject::getCreditRating).sum();
return totalCredits;
}
log.error("Getting total number of credits failed.");
return -1;
}
Logged information up to failure
INFO LogHelper:31 - HHH000204: Processing PersistenceUnitInfo [name: cz.zcu.kiv.matyasj.dp]
INFO Version:46 - HHH000412: Hibernate Core {5.4.1.Final}
INFO Version:49 - HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
INFO C3P0ConnectionProvider:116 - HHH010002: C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/uis-web-db
INFO C3P0ConnectionProvider:117 - HHH10001001: Connection properties: {password=****, useUnicode=true, handling_mode=DELAYED_ACQUISITION_AND_HOLD, characterEncoding=UTF-8, user=uis-web}
INFO C3P0ConnectionProvider:120 - HHH10001003: Autocommit mode: false
INFO C3P0ConnectionProvider:200 - HHH10001007: JDBC isolation level:
INFO Dialect:158 - HHH000400: Using dialect: org.hibernate.dialect.MySQL55Dialect
INFO access:47 - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@721af8d0] 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.
INFO access:47 - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@296a6a10] 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.
INFO JtaPlatformInitiator:52 - HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
INFO SecurityConfig:75 - SECURITY JDBC authentication process is running
INFO SecurityConfig:93 - Authorization configuration process is running
INFO BaseInitializer:97 - Initializing ...
INFO BaseInitializer:463 - Initialized!
INFO BaseInitializer:97 - Initializing ...
INFO LoginController:30 - Request for login view
INFO UserDaoCriteria:74 - User with username brown found.
INFO SecurityConfig:121 - Success login - brown
INFO SecurityConfig:125 - User login role: ROLE_STUDENT
INFO UserDaoCriteria:74 - User with username brown found.
INFO OverviewController:49 - Request for overview of student with id 20 for view.
INFO RegisterSubjectListController:48 - Request for retrieving studied subjects view.
INFO UserDaoCriteria:74 - User with username brown found.
INFO BaseStudentService:82 - Getting list of studied subjects for student with id 20.
INFO UserDaoCriteria:74 - User with username brown found.
INFO BaseStudentService:101 - Getting list of absolved subjects for student with id 20.
INFO UserDaoCriteria:74 - User with username brown found.
INFO BaseStudentService:222 - Getting list of grades for student with id 20.
INFO GradeDaoCriteria:102 - Returning list of 0 for student with id 20
INFO UserDaoCriteria:74 - User with username brown found.
ERROR E02StudentService:54 - INJECTED_ERROR: E02StudentService_getStudentTotalCredits_returns_always_20_credits_instead_of_real_sum_of_student_credits
Overview of functional tests full log
Overview of acceptance tests full report