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] Add test cases for Feedback response Db #12761

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

yuanxi1
Copy link
Contributor

@yuanxi1 yuanxi1 commented Feb 20, 2024

Part of #12048

Outline of Solution

Add test cases for FeedbackResponseDb

@kevin9foong kevin9foong changed the title [12048] Add test cases for Feedback response Db [#12048] Add test cases for Feedback response Db Feb 20, 2024
@@ -0,0 +1,130 @@
package teammates.storage.sqlapi;
Copy link
Contributor

Choose a reason for hiding this comment

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

nice work splitting the TCs!

Copy link
Contributor

@weiquu weiquu left a comment

Choose a reason for hiding this comment

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

LGTM! Just a quick question below


feedbackResponsesDb.createFeedbackResponse(feedbackResponse);

mockHibernateUtil.verify(() -> HibernateUtil.persist(feedbackResponse));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason for not also adding the times(1)? Same question for testUpdateFeedbackResponse_feedbackResponseExists_success() and testDeleteFeedbackResponse_feedbackResponseExists_success() below - not sure if I missed something since other methods use that

Copy link
Contributor

@cedricongjh cedricongjh left a comment

Choose a reason for hiding this comment

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

mostly good, just 2 test cases to be added

Comment on lines +103 to +112
public void testUpdateFeedbackResponse_feedbackResponseDoesNotExist_throwsEntityDoesNotExistException() {
FeedbackResponse feedbackResponse = getTypicalFeedbackResponse();

mockHibernateUtil.when(() -> HibernateUtil.get(FeedbackResponse.class, feedbackResponse.getId()))
.thenReturn(null);

assertThrows(EntityDoesNotExistException.class,
() -> feedbackResponsesDb.updateFeedbackResponse(feedbackResponse));
mockHibernateUtil.verify(() -> HibernateUtil.merge(feedbackResponse), never());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

let's add a test case for invalid parameters exception as well

Comment on lines +54 to +64
public void testCreateFeedbackResponse_feedbackResponseAlreadyExists_throwsEntityAlreadyExistsException() {
FeedbackResponse feedbackResponse = getTypicalFeedbackResponse();

mockHibernateUtil.when(() -> HibernateUtil.get(FeedbackResponse.class, feedbackResponse.getId()))
.thenReturn(feedbackResponse);

assertThrows(EntityAlreadyExistsException.class, () -> feedbackResponsesDb.createFeedbackResponse(feedbackResponse));

mockHibernateUtil.verify(() -> HibernateUtil.get(FeedbackResponse.class, feedbackResponse.getId()));
mockHibernateUtil.verify(() -> HibernateUtil.persist(feedbackResponse), never());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

let's create a test case for throwing invalid parameters exception as well

@NicolasCwy NicolasCwy changed the base branch from v9-migration to master February 25, 2024 06:28
@cedricongjh cedricongjh added the s.Ongoing The PR is being worked on by the author(s) label Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s.Ongoing The PR is being worked on by the author(s)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants