-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
base: master
Are you sure you want to change the base?
Conversation
…into feedback-response-db-test
@@ -0,0 +1,130 @@ | |||
package teammates.storage.sqlapi; |
There was a problem hiding this comment.
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!
There was a problem hiding this 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)); |
There was a problem hiding this comment.
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
There was a problem hiding this 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
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()); | ||
} |
There was a problem hiding this comment.
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
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()); | ||
} |
There was a problem hiding this comment.
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
Part of #12048
Outline of Solution
Add test cases for FeedbackResponseDb