Skip to content

875: Migrate QuestionBank / QuestionBankRepository to use Optional - #868

Merged
angelayu0530 merged 2 commits into
mainfrom
875
Mar 19, 2026
Merged

875: Migrate QuestionBank / QuestionBankRepository to use Optional#868
angelayu0530 merged 2 commits into
mainfrom
875

Conversation

@angelayu0530

@angelayu0530 angelayu0530 commented Mar 18, 2026

Copy link
Copy Markdown
Member

875

Description of changes

-Used Optional in QuestionBank and Question
-Fixed other stuff

Checklist before review

  • I have done a thorough self-review of the PR
  • Copilot has reviewed my latest changes, and all comments have been fixed and/or closed.
  • If I have made database changes, I have made sure I followed all the db repo rules listed in the wiki here. (check if no db changes)
  • All tests have passed
  • I have successfully deployed this PR to staging
  • I have done manual QA in both dev (and staging if possible) and attached screenshots below.

Screenshots

Dev

Screen.Recording.2026-03-18.at.4.13.51.PM.mov

Staging

Screen.Recording.2026-03-18.at.4.20.01.PM.mov

@github-actions

Copy link
Copy Markdown
Contributor

Available PR Commands

  • /ai - Triggers all AI review commands at once
  • /review - AI review of the PR changes
  • /describe - AI-powered description of the PR
  • /improve - AI-powered suggestions
  • /deploy - Deploy to staging

See: https://github.com/tahminator/codebloom/wiki/CI-Commands

@github-actions

Copy link
Copy Markdown
Contributor

Title

875: Migrate QuestionBank / QuestionBankRepository to use Optional


PR Type

Enhancement


Description

  • Migrated QuestionBank description field to Optional.

  • Updated QuestionBankRepository read methods to return Optional.

  • Adapted service components to consume Optional returns.

  • Refactored tests to handle Optional types.


Diagram Walkthrough

flowchart LR
    A[QuestionBank Model] --> B[QuestionBank Repository]
    B --> C[Service Components]
    C --> D[Tests]

    A -- "description: String -> Optional<String>" --> B
    B -- "get/find methods: QuestionBank -> Optional<QuestionBank>" --> C
    C -- "Adapt to Optional unwrapping" --> D
    D -- "Update mocks & assertions" --> F[Enhanced Null Safety]
Loading

File Walkthrough

Relevant files
Enhancement
6 files
DuelManager.java
Adapted question retrieval to handle Optional returns from repository
+7/-1     
QuestionBank.java
Updated description field to Optional and removed custom nullability
annotations
+3/-12   
QuestionBankRepository.java
Modified read/find methods to return `Optional`
+4/-3     
QuestionBankSqlRepository.java
Implemented Optional return types and handled Optional for description
in SQL operations
+13/-18 
QuestionBankDto.java
Adjusted DTO creation to unwrap Optional for the description field
+1/-1     
SubmissionsHandler.java
Adapted to Optional returns from QuestionBankRepository and handled
Optional for description
+21/-21 
Tests
3 files
DuelManagerTest.java
Updated test mocks to return Optional for QuestionBankRepository
methods
+4/-4     
QuestionBankRepositoryTest.java
Modified tests to use Optional for QuestionBank description and unwrap
repository returns
+11/-6   
SubmissionsHandlerTest.java
Updated test mocks and QuestionBank builder to use Optional for
description
+2/-2     

@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Model Consistency

The PR description mentions migrating both QuestionBank and Question to use Optional. While QuestionBank changes are visible, the Question model is not part of this diff. Please confirm that the Question model's description field has also been updated to Optional<String> to maintain consistency and prevent potential type mismatches, especially in line 216 of SubmissionsHandler.java where bankQuestion.getDescription() is directly assigned.

.description(bankQuestion.getDescription())
Database Schema

The @NotNullColumn and @NullColumn annotations were removed from the QuestionBank model, with nullability now handled by Optional at the Java level. Please ensure that the corresponding database schema for the description column (and any other columns previously marked with these annotations) still correctly enforces or allows nullability as intended. This PR does not include database migration files, so it's important to verify the existing schema aligns with the new Java model.

@Builder.Default
private Optional<String> description = Optional.empty();

@github-actions

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

No code suggestions found for the PR.

@angelayu0530

Copy link
Copy Markdown
Member Author

/deploy

Comment thread src/main/java/org/patinanetwork/codebloom/common/components/duel/DuelManager.java Outdated
@github-actions

Copy link
Copy Markdown
Contributor

Title

875: Migrate QuestionBank / QuestionBankRepository to use Optional


PR Type

Enhancement


Description

  • Migrates QuestionBank model's description to Optional<String>.

  • Updates QuestionBankRepository read methods to return Optional<QuestionBank>.

  • Adapts DuelManager and SubmissionsHandler to handle Optional returns.

  • Refactors SQL repository and DTOs for Optional compatibility.


Diagram Walkthrough

flowchart LR
    A[QuestionBank Model] --> B[QuestionBankRepository Interface]
    B --> C[QuestionBankSqlRepository Implementation]
    B --> D[DuelManager]
    B --> E[SubmissionsHandler]
    A --> F[QuestionBankDto]
    C --> G[Tests]
    D --> G
    E --> G
Loading

File Walkthrough

Relevant files
Enhancement
6 files
DuelManager.java
Adapts duel logic to handle Optional returns from
QuestionBankRepository
+7/-1     
QuestionBank.java
Updates `description` field to `Optional` in QuestionBank model
+3/-12   
QuestionBankRepository.java
Modifies read methods to return `Optional` for null safety
+4/-3     
QuestionBankSqlRepository.java
Implements Optional returns for read methods and handles Optional
description
+13/-18 
QuestionBankDto.java
Adjusts `fromQuestionBank` to extract description from `Optional`
+1/-1     
SubmissionsHandler.java
Updates submission handling to use Optional for question bank
retrieval
+21/-21 
Tests
3 files
DuelManagerTest.java
Updates mock expectations for QuestionBankRepository to return
Optional
+4/-4     
QuestionBankRepositoryTest.java
Modifies test cases to handle Optional returns and description field
+11/-6   
SubmissionsHandlerTest.java
Updates test logic for Optional description and QuestionBank mocks
+2/-2     

@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@angelayu0530

Copy link
Copy Markdown
Member Author

/deploy

@angelayu0530
angelayu0530 enabled auto-merge (rebase) March 19, 2026 17:12
@github-actions

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

No code suggestions found for the PR.

@angelayu0530
angelayu0530 merged commit a816dd8 into main Mar 19, 2026
35 checks passed
@angelayu0530
angelayu0530 deleted the 875 branch March 19, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants