Detailed information about defect clone:

13-C0.H1.M0.L0_G_T_D_01.war

 

Nickname of the defect

wrong-enum-in-DB

Brief desctiption

The selection Grade in Set Evaluation contains numbers (1 to 4) not letters (A to F).

How to activate the defect

 

Visibility of the defect

Expected Actual

Parts

StudentService TeacherService DateUtility GradeDAO UserDAO
BaseStudentService BaseTeacherService BaseDateUtility E01GradeTypeDao 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/dao/jpa/error/E01GradeTypeDao.java

Source code with the injected defect

/** * DELIBERATE ERROR * * This error method returns always type of grades 1, 2, 3, 4 * * @return list of grade types */ @Override @ErrorMethod(errorMessage = "This method return bad grade types") public List<GradeType> getAllGradeTypes() { GradeType A = new GradeType(); A.setName("1"); A.setId(100L); GradeType B = new GradeType(); B.setName("2"); B.setId(101L); GradeType C = new GradeType(); C.setName("3"); C.setId(102L); GradeType D = new GradeType(); D.setName("4"); D.setId(103L); List<GradeType> resultList = new ArrayList<>(); resultList.add(A); resultList.add(B); resultList.add(C); resultList.add(D); log.error(propertyLoader.getProperty("log.E01GradeTypeDao.getAllGradeTypes")); return resultList; }

URL to the correct source code

https://gitlab.kiv.zcu.cz/herout/TbUIS-UIS/blob/master/src/main/java/cz/zcu/kiv/matyasj/dp/dao/jpa/correct/GradeTypeDaoCriteria.java

Correct source code

/** * This method returns all type of grades in system (e.g. typically A, B, C, D, E, F). * * @return list of grade types */ @Override public List<GradeType> getAllGradeTypes() { CriteriaBuilder cb = entityManager.getCriteriaBuilder(); CriteriaQuery<GradeType> query = cb.createQuery(GradeType.class); Root<GradeType> root = query.from(GradeType.class); query.select(root); List<GradeType> gradeTypes = findAll(); log.info("Returning list of " + gradeTypes.size() + " grade types."); return gradeTypes; }

Logged information up to failure

2019-10-15 19:23:07.416 -- INFO LogHelper:31 - HHH000204: Processing PersistenceUnitInfo [name: cz.zcu.kiv.matyasj.dp] 2019-10-15 19:23:07.651 -- INFO Version:46 - HHH000412: Hibernate Core {5.4.1.Final} 2019-10-15 19:23:08.104 -- INFO Version:49 - HCANN000001: Hibernate Commons Annotations {5.1.0.Final} 2019-10-15 19:23:08.557 -- INFO C3P0ConnectionProvider:116 - HHH010002: C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/uis-web-db 2019-10-15 19:23:08.557 -- INFO C3P0ConnectionProvider:117 - HHH10001001: Connection properties: {password=****, useUnicode=true, handling_mode=DELAYED_ACQUISITION_AND_HOLD, characterEncoding=UTF-8, user=uis-web} 2019-10-15 19:23:08.557 -- INFO C3P0ConnectionProvider:120 - HHH10001003: Autocommit mode: false 2019-10-15 19:23:08.760 -- INFO C3P0ConnectionProvider:200 - HHH10001007: JDBC isolation level: <unknown> 2019-10-15 19:23:09.166 -- INFO Dialect:158 - HHH000400: Using dialect: org.hibernate.dialect.MySQL55Dialect 2019-10-15 19:23:10.971 -- INFO access:47 - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@50ad030a] 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-15 19:23:13.276 -- INFO access:47 - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@65beeceb] 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-15 19:23:25.254 -- INFO JtaPlatformInitiator:52 - HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] 2019-10-15 19:23:25.535 -- INFO SecurityConfig:75 - SECURITY JDBC authentication process is running 2019-10-15 19:23:27.903 -- INFO SecurityConfig:93 - Authorization configuration process is running 2019-10-15 19:23:28.216 -- INFO BaseInitializer:97 - Initializing ... 2019-10-15 19:23:35.505 -- INFO BaseInitializer:463 - Initialized! 2019-10-15 19:23:35.646 -- INFO BaseInitializer:97 - Initializing ... 2019-10-15 19:23:51.622 -- INFO LoginController:30 - Request for login view 2019-10-15 19:24:13.118 -- INFO UserDaoCriteria:74 - User with username scatterbrained found. 2019-10-15 19:24:13.167 -- INFO SecurityConfig:121 - Success login - scatterbrained 2019-10-15 19:24:13.167 -- INFO SecurityConfig:125 - User login role: ROLE_TEACHER 2019-10-15 19:24:13.198 -- INFO UserDaoCriteria:74 - User with username scatterbrained found. 2019-10-15 19:24:13.214 -- INFO OverviewController:53 - Request for overview of teacher with id 31 for view. 2019-10-15 19:24:15.408 -- INFO NewGradeController:45 - Request for retrieving new evaluation form view. 2019-10-15 19:24:15.408 -- INFO UserDaoCriteria:74 - User with username scatterbrained found. 2019-10-15 19:24:15.502 -- INFO BaseTeacherService:294 - Getting all examination terms without graduate participants for teacher with id 31. 2019-10-15 19:24:15.549 -- INFO ExaminationDateDaoCriteria:118 - Returning list of 1 examination dates for teacher with id 31. 2019-10-15 19:24:15.564 -- WARN GradeDaoCriteria:137 - Grade for student William Maroon and for subject Computation Structures and for date 2019-10-16 19:23:32.0 not found. 2019-10-15 19:24:15.564 -- WARN GradeDaoCriteria:137 - Grade for student Benjamin Green and for subject Computation Structures and for date 2019-10-16 19:23:32.0 not found. 2019-10-15 19:24:15.564 -- WARN GradeDaoCriteria:137 - Grade for student Michael Gray and for subject Computation Structures and for date 2019-10-16 19:23:32.0 not found. 2019-10-15 19:24:15.580 -- WARN GradeDaoCriteria:137 - Grade for student Ethan Cyan and for subject Computation Structures and for date 2019-10-16 19:23:32.0 not found. 2019-10-15 19:24:15.580 -- WARN GradeDaoCriteria:137 - Grade for student Sophia Red and for subject Computation Structures and for date 2019-10-16 19:23:32.0 not found. 2019-10-15 19:24:15.580 -- WARN GradeDaoCriteria:137 - Grade for student Isabella Yellow and for subject Computation Structures and for date 2019-10-16 19:23:32.0 not found. 2019-10-15 19:24:15.580 -- WARN GradeDaoCriteria:137 - Grade for student Mia Orange and for subject Computation Structures and for date 2019-10-16 19:23:32.0 not found. 2019-10-15 19:24:15.580 -- WARN GradeDaoCriteria:137 - Grade for student Charlotte Purple and for subject Computation Structures and for date 2019-10-16 19:23:32.0 not found. 2019-10-15 19:24:15.580 -- INFO BaseTeacherService:669 - Getting all grade types. 2019-10-15 19:24:15.580 -- ERROR E01GradeTypeDao:81 - INJECTED_ERROR: E01GradeTypeDao_getAllGradeTypes_returns_always_static_list_of_grade_types_1,_2,_3,_4 2019-10-15 19:24:23.526 -- INFO UserDaoCriteria:74 - User with username scatterbrained found. 2019-10-15 19:24:23.557 -- INFO NewGradeController:96 - Request from user with id 31 for saving new grade for exam term with id 34 for student with id 16. 2019-10-15 19:24:23.557 -- INFO BaseTeacherService:630 - Getting examination date with id 34. 2019-10-15 19:24:23.589 -- INFO BaseTeacherService:556 - Creating new grade for teacher with id 31, student with id 16, grade type with id 101 and examination term with id 34. 2019-10-15 19:24:23.651 -- WARN GradeDaoCriteria:137 - Grade for student William Maroon and for subject Computation Structures and for date 2019-10-16 19:23:32.0 not found. 2019-10-15 19:24:23.651 -- ERROR E01GradeTypeDao:81 - INJECTED_ERROR: E01GradeTypeDao_getAllGradeTypes_returns_always_static_list_of_grade_types_1,_2,_3,_4 2019-10-15 19:24:23.651 -- ERROR BaseTeacherService:589 - Creating grade with non existent grade type is not possible! 2019-10-15 19:24:23.651 -- ERROR NewGradeController:105 - Request for new grade created by teacher Thomas Scatterbrained failed. 2019-10-15 19:24:23.651 -- INFO NewGradeController:112 - Request for retrieving new grade form by selected date ExaminationDate{dateOfTest=2019-10-16 19:23:32.0, participants=[Student [User=User[id=16, userName=maroon, firstName=William, lastName=Maroon, email=maroon@mail.edu, password={PROTECTED}], absolvedSubjects=[], learned subjects=[Subject[id=2, name=Computation Structures, creditRating=5, teachersSize=1, studentsSize=9, absolventsSize=0], Subject[id=10, name=Programming in Java, creditRating=4, teachersSize=1, studentsSize=11, absolventsSize=0]]], Student [User=User[id=18, userName=green, firstName=Benjamin, lastName=Green, email=green@mail.edu, password={PROTECTED}], absolvedSubjects=[], learned subjects=[Subject[id=1, name=Computer System Engineering, creditRating=6, teachersSize=1, studentsSize=5, absolventsSize=0], Subject[id=2, name=Computation Structures, creditRating=5, teachersSize=1, studentsSize=9, absolventsSize=0], Subject[id=10, name=Programming in Java, creditRating=4, teachersSize=1, studentsSize=11, absolventsSize=0], Subject[id=14, name=Web Programming, creditRating=4, teachersSize=1, studentsSize=4, absolventsSize=0]]], Student [User=User[id=19, userName=gray, firstName=Michael, lastName=Gray, email=gray@mail.edu, password={PROTECTED}], absolvedSubjects=[], learned subjects=[Subject[id=2, name=Computation Structures, creditRating=5, teachersSize=1, studentsSize=9, absolventsSize=0], Subject[id=3, name=Database Systems, creditRating=3, teachersSize=2, studentsSize=2, absolventsSize=0], Subject[id=10, name=Programming in Java, creditRating=4, teachersSize=1, studentsSize=11, absolventsSize=0], Subject[id=14, name=Web Programming, creditRating=4, teachersSize=1, studentsSize=4, absolventsSize=0]]], Student [User=User[id=20, userName=cyan, firstName=Ethan, lastName=Cyan, email=cyan@mail.edu, password={PROTECTED}], absolvedSubjects=[], learned subjects=[Subject[id=2, name=Computation Structures, creditRating=5, teachersSize=1, studentsSize=9, absolventsSize=0], Subject[id=5, name=Introduction to Algorithms, creditRating=3, teachersSize=1, studentsSize=3, absolventsSize=0], Subject[id=7, name=Mobile Applications, creditRating=5, teachersSize=1, studentsSize=2, absolventsSize=0], Subject[id=10, name=Programming in Java, creditRating=4, teachersSize=1, studentsSize=11, absolventsSize=0], Subject[id=14, name=Web Programming, creditRating=4, teachersSize=1, studentsSize=4, absolventsSize=0]]], Student [User=User[id=22, userName=red, firstName=Sophia, lastName=Red, email=red@mail.edu, password={PROTECTED}], absolvedSubjects=[], learned subjects=[Subject[id=2, name=Computation Structures, creditRating=5, teachersSize=1, studentsSize=9, absolventsSize=0], Subject[id=3, name=Database Systems, creditRating=3, teachersSize=2, studentsSize=2, absolventsSize=0], Subject[id=10, name=Programming in Java, creditRating=4, teachersSize=1, studentsSize=11, absolventsSize=0], Subject[id=12, name=Software Engineering, creditRating=6, teachersSize=1, studentsSize=2, absolventsSize=0], Subject[id=13, name=Software Quality Assurance, creditRating=5, teachersSize=1, studentsSize=4, absolventsSize=0]]], Student [User=User[id=23, userName=yellow, firstName=Isabella, lastName=Yellow, email=yellow@mail.edu, password={PROTECTED}], absolvedSubjects=[], learned subjects=[Subject[id=1, name=Computer System Engineering, creditRating=6, teachersSize=1, studentsSize=5, absolventsSize=0], Subject[id=2, name=Computation Structures, creditRating=5, teachersSize=1, studentsSize=9, absolventsSize=0], Subject[id=10, name=Programming in Java, creditRating=4, teachersSize=1, studentsSize=11, absolventsSize=0], Subject[id=12, name=Software Engineering, creditRating=6, teachersSize=1, studentsSize=2, absolventsSize=0], Subject[id=13, name=Software Quality Assurance, creditRating=5, teachersSize=1, studentsSize=4, absolventsSize=0]]], Student [User=User[id=24, userName=orange, firstName=Mia, lastName=Orange, email=orange@mail.edu, password={PROTECTED}], absolvedSubjects=[], learned subjects=[Subject[id=1, name=Computer System Engineering, creditRating=6, teachersSize=1, studentsSize=5, absolventsSize=0], Subject[id=2, name=Computation Structures, creditRating=5, teachersSize=1, studentsSize=9, absolventsSize=0], Subject[id=4, name=Fundamentals of Computer Networks, creditRating=3, teachersSize=1, studentsSize=2, absolventsSize=0], Subject[id=5, name=Introduction to Algorithms, creditRating=3, teachersSize=1, studentsSize=3, absolventsSize=0], Subject[id=10, name=Programming in Java, creditRating=4, teachersSize=1, studentsSize=11, absolventsSize=0], Subject[id=13, name=Software Quality Assurance, creditRating=5, teachersSize=1, studentsSize=4, absolventsSize=0], Subject[id=14, name=Web Programming, creditRating=4, teachersSize=1, studentsSize=4, absolventsSize=0]]], Student [User=User[id=25, userName=purple, firstName=Charlotte, lastName=Purple, email=purple@mail.edu, password={PROTECTED}], absolvedSubjects=[], learned subjects=[Subject[id=1, name=Computer System Engineering, creditRating=6, teachersSize=1, studentsSize=5, absolventsSize=0], Subject[id=2, name=Computation Structures, creditRating=5, teachersSize=1, studentsSize=9, absolventsSize=0], Subject[id=4, name=Fundamentals of Computer Networks, creditRating=3, teachersSize=1, studentsSize=2, absolventsSize=0], Subject[id=10, name=Programming in Java, creditRating=4, teachersSize=1, studentsSize=11, absolventsSize=0], Subject[id=11, name=Programming Techniques, creditRating=1, teachersSize=1, studentsSize=1, absolventsSize=0]]]], teacher=Teacher [User=User[id=31, userName=scatterbrained, firstName=Thomas, lastName=Scatterbrained, email=scatterbrained@mail.edu, password={PROTECTED}], teached subjects=131], subject=Subject[id=2, name=Computation Structures, creditRating=5, teachersSize=1, studentsSize=9, absolventsSize=0], maxParticipants=10}. 2019-10-15 19:24:23.651 -- INFO BaseTeacherService:669 - Getting all grade types. 2019-10-15 19:24:23.651 -- ERROR E01GradeTypeDao:81 - INJECTED_ERROR: E01GradeTypeDao_getAllGradeTypes_returns_always_static_list_of_grade_types_1,_2,_3,_4 2019-10-15 19:24:23.651 -- INFO UserDaoCriteria:74 - User with username scatterbrained found. 2019-10-15 19:24:23.682 -- INFO BaseTeacherService:294 - Getting all examination terms without graduate participants for teacher with id 31. 2019-10-15 19:24:23.714 -- INFO ExaminationDateDaoCriteria:118 - Returning list of 1 examination dates for teacher with id 31. 2019-10-15 19:24:23.714 -- WARN GradeDaoCriteria:137 - Grade for student William Maroon and for subject Computation Structures and for date 2019-10-16 19:23:32.0 not found. 2019-10-15 19:24:23.714 -- WARN GradeDaoCriteria:137 - Grade for student Benjamin Green and for subject Computation Structures and for date 2019-10-16 19:23:32.0 not found. 2019-10-15 19:24:23.729 -- WARN GradeDaoCriteria:137 - Grade for student Michael Gray and for subject Computation Structures and for date 2019-10-16 19:23:32.0 not found. 2019-10-15 19:24:23.729 -- WARN GradeDaoCriteria:137 - Grade for student Ethan Cyan and for subject Computation Structures and for date 2019-10-16 19:23:32.0 not found. 2019-10-15 19:24:23.729 -- WARN GradeDaoCriteria:137 - Grade for student Sophia Red and for subject Computation Structures and for date 2019-10-16 19:23:32.0 not found. 2019-10-15 19:24:23.729 -- WARN GradeDaoCriteria:137 - Grade for student Isabella Yellow and for subject Computation Structures and for date 2019-10-16 19:23:32.0 not found. 2019-10-15 19:24:23.729 -- WARN GradeDaoCriteria:137 - Grade for student Mia Orange and for subject Computation Structures and for date 2019-10-16 19:23:32.0 not found. 2019-10-15 19:24:23.729 -- WARN GradeDaoCriteria:137 - Grade for student Charlotte Purple and for subject Computation Structures and for date 2019-10-16 19:23:32.0 not found.

Overview of functional tests full log

Overview of acceptance tests full report