Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#12048] v9: Skeleton implementation #12056

Merged
merged 7 commits into from
Feb 6, 2023

Conversation

samuelfangjw
Copy link
Member

@samuelfangjw samuelfangjw commented Feb 5, 2023

Part of #12048

Libraries/Frameworks added:

  • Hibernate
  • Liquibase for sql migrations
  • Mockito for unit tests
  • Testcontainers for integration tests
  • Related dependencies

Major Changes from POC:

  1. Reworked logic classes to have dependencies injected (for future unit tests).
  2. Removed *Attributes class.
  3. Hibernate SessionFactory now set up in a ServletContextListener rather than a Filter.
  4. Hibernate begin session/transaction moved to servlet root (from filter). This way exceptions can be caught and rollback initiated.
  5. Differentiate between Integration and Unit tests (currently following popular *Test.java and *IT.java convention).
  6. Add gradle tasks to run unit and integration tests separately.

Liquibase:
To access liquidate commands, ./gradlew <command>. A list of commands can be found by checking ./gradlew tasks. In particular, ./gradlew liquibaseUpdate to perform all migrations.

Changelogs are organised by release, with db.changelog-v9 containing changelogs for v9, Unfortunately, the very useful liquidate-hibernate6 extension seems to be java 17 and above only. I have been generating changelogs by letting hibernate update the db then using liquibaseGenerateChangelog. Will find another flow to generate changelogs.

Sample implementation:
Partial implementation of course related api/logic/db.

Copy link
Contributor

@zhaojj2209 zhaojj2209 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set up and tested skeleton using postgres on local machine, will need someone else to help test using the docker image. Am able to create a course and have it persist in the DB.

I assume we'll leave fixing of component & E2E tests to future PRs?

@samuelfangjw
Copy link
Member Author

Set up and tested skeleton using postgres on local machine, will need someone else to help test using the docker image. Am able to create a course and have it persist in the DB.

I assume we'll leave fixing of component & E2E tests to future PRs?

I'll take a quick look at the tests tomorrow and fix those that I can. For the E2E test, I can fix the no transaction in session issue but cannot fix the test until GetCourseAction is implemented properly.

Copy link
Member

@hhdqirui hhdqirui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@samuelfangjw samuelfangjw merged commit fab110f into TEAMMATES:v9-migration Feb 6, 2023
@samuelfangjw samuelfangjw deleted the 12048-v9-skeleton branch February 6, 2023 08:22
@samuelfangjw samuelfangjw added s.ToMerge The PR is approved by all reviewers including final reviewer; ready for merging c.Task Other non-user-facing works, e.g. refactoring, adding tests labels Feb 9, 2023
hhdqirui pushed a commit to hhdqirui/teammates that referenced this pull request Feb 11, 2023
domlimm pushed a commit to domlimm/teammates that referenced this pull request Feb 22, 2023
hhdqirui added a commit that referenced this pull request Mar 20, 2023
* [#12048] Set up github action workflows

* [#12048] v9: Skeleton implementation (#12056)

* [#12048] Add isMigrated flag to course (#12063)

* [#12048] Add is migrated flag to datastore account (#12070)

* Temporarily disable liquibase migrations

* [#12048] Create Notification Entity for PostgreSQL migration (#12061)

* [#12048] Create notification DB layer for v9 migration (#12075)

* [#12048] Add UsageStatistics entity and db (#12076)

* Migrate GetCourseAction.java

* Migrate DeleteCourseAction.java and relevant logic functions

* Migrate BinCourseAction.java and its related logic functions

* Update checkSpecificAccessControl functions in BinCourseAction and DeleteCourseAction classes

* Migrate RestoreCourseAction and its related logic functions

* Migrate UpdateCourseAction with its related logic functions

* [#12048] Add Account Entity (#12087)

* [#12048] Create SQL logic for CreateNotificationAction and add relevant tests for v9 migration (#12077)

* [#12048] Create Student, Instructor and User Entities for PostgreSQL Migration (#12071)

* [#12048] V9: Cleanup and refactor (#12090)

* Edit GetCourseAction and refactor out the old datastore code

* [#12048] Remove redundant InstructorRole Enum (#12091)

* Fix compilation error

* Update check for database to fetch from

* Add unit tests for CoursesDb

* [#12048] Update GetUsageStatisticsAction to include SQL entities (#12084)

* Add CoursesLogicTest class

* Disable failing tests

* Fix compilation error

* Fix Checkstyle errors

* Merge branch

* Change flow for updating courses.

* Update updateCourse JavaDoc comment.

* Update CreateCourseAction and related methods

* Update GetCourseAction.

* Update UpdateCourseAction

* Update BinCourseAction and RestoreCourseAction

* Update DeleteCourseAction

* Migrate GetCourseSectionNamesAction and related methods.

* Add Unit tests for Logic layer of Course.

* Fix Checkstyle errors

* Add unit test for GetCourseAction's execute function

* Add verify for CoursesDb unit tests and use assertNull and assertNotNull

* Move fetching of course to logic layer.

* Fix Checkstyle errors.

* Move canCreateCourse logic to logic layer.

* Change *CourseAction classes to use isCourseMigrated

* Fix CoursesLogic's initLogicDependencies method call

* Add unit tests for GetCourseAction.

* Remove commented out method.

* Add minimal unit tests for BinCourseAction, DeleteCourseAction and RestoreCourseAction.

* Add minimal unit tests for GetCourseSectionAction and UpdateCourseAction.

* Remove unused EntityType parameter.

* Add minimal unit tests for CreateCourseAction.

* Fix Checkstyle errors.

* Ignore all old datastore test cases for *CourseAction classes.

* Fix 'text' type to 'test'.

* Change binCourseToRecycleBin to return the binned course.

* Update moveCourseToRecycleBin test.

* Update test name.

---------

Co-authored-by: Samuel Fang <samuelfangjw@gmail.com>
Co-authored-by: dao ngoc hieu <53283766+daongochieu2810@users.noreply.github.com>
Co-authored-by: Samuel Fang <60355570+samuelfangjw@users.noreply.github.com>
Co-authored-by: wuqirui <53338059+hhdqirui@users.noreply.github.com>
Co-authored-by: Dominic Lim <46486515+domlimm@users.noreply.github.com>
samuelfangjw added a commit that referenced this pull request Mar 20, 2023
* [#12048] Set up github action workflows

* [#12048] v9: Skeleton implementation (#12056)

* [#12048] Add isMigrated flag to course (#12063)

* [#12048] Add is migrated flag to datastore account (#12070)

* Temporarily disable liquibase migrations

* [#12048] Create Notification Entity for PostgreSQL migration (#12061)

* [#12048] Create notification DB layer for v9 migration (#12075)

* [#12048] Add UsageStatistics entity and db (#12076)

* Migrate GetCourseAction.java

* Migrate DeleteCourseAction.java and relevant logic functions

* Migrate BinCourseAction.java and its related logic functions

* Update checkSpecificAccessControl functions in BinCourseAction and DeleteCourseAction classes

* Migrate RestoreCourseAction and its related logic functions

* Migrate UpdateCourseAction with its related logic functions

* [#12048] Add Account Entity (#12087)

* [#12048] Create SQL logic for CreateNotificationAction and add relevant tests for v9 migration (#12077)

* [#12048] Create Student, Instructor and User Entities for PostgreSQL Migration (#12071)

* [#12048] V9: Cleanup and refactor (#12090)

* Edit GetCourseAction and refactor out the old datastore code

* [#12048] Remove redundant InstructorRole Enum (#12091)

* Fix compilation error

* Update check for database to fetch from

* Add unit tests for CoursesDb

* [#12048] Update GetUsageStatisticsAction to include SQL entities (#12084)

* Add CoursesLogicTest class

* Disable failing tests

* Fix compilation error

* Fix Checkstyle errors

* Merge branch

* Change flow for updating courses.

* Update updateCourse JavaDoc comment.

* Update CreateCourseAction and related methods

* Update GetCourseAction.

* Update UpdateCourseAction

* Update BinCourseAction and RestoreCourseAction

* Update DeleteCourseAction

* Migrate GetCourseSectionNamesAction and related methods.

* Add Unit tests for Logic layer of Course.

* Fix Checkstyle errors

* Add unit test for GetCourseAction's execute function

* Add verify for CoursesDb unit tests and use assertNull and assertNotNull

* Move fetching of course to logic layer.

* Fix Checkstyle errors.

* Move canCreateCourse logic to logic layer.

* Change *CourseAction classes to use isCourseMigrated

* Fix CoursesLogic's initLogicDependencies method call

* Add unit tests for GetCourseAction.

* Remove commented out method.

* Add minimal unit tests for BinCourseAction, DeleteCourseAction and RestoreCourseAction.

* Add minimal unit tests for GetCourseSectionAction and UpdateCourseAction.

* Remove unused EntityType parameter.

* Add minimal unit tests for CreateCourseAction.

* Fix Checkstyle errors.

* Ignore all old datastore test cases for *CourseAction classes.

* Fix 'text' type to 'test'.

* Change binCourseToRecycleBin to return the binned course.

* Update moveCourseToRecycleBin test.

* Update test name.

---------

Co-authored-by: Samuel Fang <samuelfangjw@gmail.com>
Co-authored-by: dao ngoc hieu <53283766+daongochieu2810@users.noreply.github.com>
Co-authored-by: Samuel Fang <60355570+samuelfangjw@users.noreply.github.com>
Co-authored-by: wuqirui <53338059+hhdqirui@users.noreply.github.com>
Co-authored-by: Dominic Lim <46486515+domlimm@users.noreply.github.com>
samuelfangjw added a commit that referenced this pull request Apr 8, 2023
* [#12048] Set up github action workflows

* [#12048] v9: Skeleton implementation (#12056)

* [#12048] Add isMigrated flag to course (#12063)

* [#12048] Add is migrated flag to datastore account (#12070)

* Temporarily disable liquibase migrations

* [#12048] Create Notification Entity for PostgreSQL migration (#12061)

* [#12048] Create notification DB layer for v9 migration (#12075)

* [#12048] Add UsageStatistics entity and db (#12076)

* Migrate GetCourseAction.java

* Migrate DeleteCourseAction.java and relevant logic functions

* Migrate BinCourseAction.java and its related logic functions

* Update checkSpecificAccessControl functions in BinCourseAction and DeleteCourseAction classes

* Migrate RestoreCourseAction and its related logic functions

* Migrate UpdateCourseAction with its related logic functions

* [#12048] Add Account Entity (#12087)

* [#12048] Create SQL logic for CreateNotificationAction and add relevant tests for v9 migration (#12077)

* [#12048] Create Student, Instructor and User Entities for PostgreSQL Migration (#12071)

* [#12048] V9: Cleanup and refactor (#12090)

* Edit GetCourseAction and refactor out the old datastore code

* [#12048] Remove redundant InstructorRole Enum (#12091)

* Fix compilation error

* Update check for database to fetch from

* Add unit tests for CoursesDb

* [#12048] Update GetUsageStatisticsAction to include SQL entities (#12084)

* Add CoursesLogicTest class

* Disable failing tests

* Fix compilation error

* Fix Checkstyle errors

* Merge branch

* Change flow for updating courses.

* Update updateCourse JavaDoc comment.

* Update CreateCourseAction and related methods

* Update GetCourseAction.

* Update UpdateCourseAction

* Update BinCourseAction and RestoreCourseAction

* Update DeleteCourseAction

* Migrate GetCourseSectionNamesAction and related methods.

* Add Unit tests for Logic layer of Course.

* Fix Checkstyle errors

* Add unit test for GetCourseAction's execute function

* Add verify for CoursesDb unit tests and use assertNull and assertNotNull

* Move fetching of course to logic layer.

* Fix Checkstyle errors.

* Move canCreateCourse logic to logic layer.

* Change *CourseAction classes to use isCourseMigrated

* Fix CoursesLogic's initLogicDependencies method call

* Add unit tests for GetCourseAction.

* Remove commented out method.

* Add minimal unit tests for BinCourseAction, DeleteCourseAction and RestoreCourseAction.

* Add minimal unit tests for GetCourseSectionAction and UpdateCourseAction.

* Remove unused EntityType parameter.

* Add minimal unit tests for CreateCourseAction.

* Fix Checkstyle errors.

* Ignore all old datastore test cases for *CourseAction classes.

* Fix 'text' type to 'test'.

* Change binCourseToRecycleBin to return the binned course.

* Update moveCourseToRecycleBin test.

* Update test name.

---------

Co-authored-by: Samuel Fang <samuelfangjw@gmail.com>
Co-authored-by: dao ngoc hieu <53283766+daongochieu2810@users.noreply.github.com>
Co-authored-by: Samuel Fang <60355570+samuelfangjw@users.noreply.github.com>
Co-authored-by: wuqirui <53338059+hhdqirui@users.noreply.github.com>
Co-authored-by: Dominic Lim <46486515+domlimm@users.noreply.github.com>
@wkurniawan07 wkurniawan07 added this to the V9.0.0-beta.0 milestone Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c.Task Other non-user-facing works, e.g. refactoring, adding tests s.ToMerge The PR is approved by all reviewers including final reviewer; ready for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants