Skip to content

Commit

Permalink
Refactor to fit integration tests structure
Browse files Browse the repository at this point in the history
  • Loading branch information
FergusMok committed Apr 16, 2024
1 parent 505d2e3 commit def7f0a
Show file tree
Hide file tree
Showing 7 changed files with 289 additions and 416 deletions.
4 changes: 2 additions & 2 deletions src/it/java/teammates/it/ui/webapi/BaseActionIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import teammates.logic.api.MockRecaptchaVerifier;
import teammates.logic.api.MockTaskQueuer;
import teammates.logic.api.MockUserProvision;
import teammates.sqllogic.api.LogicExtension;
import teammates.sqllogic.api.Logic;
import teammates.storage.sqlentity.Account;
import teammates.storage.sqlentity.Course;
import teammates.storage.sqlentity.Instructor;
Expand Down Expand Up @@ -63,7 +63,7 @@ public abstract class BaseActionIT<T extends Action> extends BaseTestCaseWithSql
static final String DELETE = HttpDelete.METHOD_NAME;

SqlDataBundle typicalBundle = getTypicalSqlDataBundle();
LogicExtension logic = new LogicExtension();
Logic logic = Logic.inst();
MockTaskQueuer mockTaskQueuer = new MockTaskQueuer();
MockEmailSender mockEmailSender = new MockEmailSender();
MockLogsProcessor mockLogsProcessor = new MockLogsProcessor();
Expand Down
620 changes: 244 additions & 376 deletions src/it/java/teammates/it/ui/webapi/SubmitFeedbackResponsesActionIT.java

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions src/it/resources/data/typicalDataBundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,21 @@
"name": "student3 In Course1",
"comments": ""
},
"student4InCourse1": {
"id": "00000000-0000-4000-8000-000000000611",
"account": {
"id": "00000000-0000-4000-8000-000000000104"
},
"course": {
"id": "course-1"
},
"team": {
"id": "00000000-0000-4000-8000-000000000305"
},
"email": "student4@teammates.tmt",
"name": "student4 In Course1",
"comments": "This student is not in the same team as others in course 1"
},
"student1InCourse2": {
"id": "00000000-0000-4000-8000-000000000604",
"course": {
Expand Down Expand Up @@ -686,21 +701,6 @@
"email": "studentOfArchivedCourse@teammates.tmt",
"name": "Student In Archived Course",
"comments": ""
},
"student4InCourse1": {
"id": "00000000-0000-4000-8000-000000000611",
"account": {
"id": "00000000-0000-4000-8000-000000000104"
},
"course": {
"id": "course-1"
},
"team": {
"id": "00000000-0000-4000-8000-000000000305"
},
"email": "student4@teammates.tmt",
"name": "student4 In Course1",
"comments": "comment for student4Course1"
}
},
"feedbackSessions": {
Expand Down
20 changes: 18 additions & 2 deletions src/main/java/teammates/sqllogic/api/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ public void deleteDeadlineExtension(DeadlineExtension de) {
}

/**
* Fetch the deadline extension for a given user and session feedback.
* Fetch the deadline extension end time for a given user and session feedback.
*
* @return deadline extension instant if exists, else the default end time instant
* for the session feedback.
Expand All @@ -421,14 +421,23 @@ public Instant getDeadlineForUser(FeedbackSession session, User user) {
}

/**
* Fetch the deadline extension for a given user and session feedback.
* Fetch the deadline extension end time for a given user and session feedback.
*
* @return deadline extension instant if exists, else return null since no deadline extensions.
*/
public Instant getExtendedDeadlineForUser(FeedbackSession session, User user) {
return deadlineExtensionsLogic.getExtendedDeadlineForUser(session, user);
}

/**
* Fetch the deadline extension entity for a given user and session feedback.
*
* @return deadline extension entity if exists, else return null.
*/
public DeadlineExtension getDeadlineExtensionEntityForUser(FeedbackSession session, User user) {
return deadlineExtensionsLogic.getDeadlineExtensionEntityForUser(session, user);
}

/**
* Gets a list of deadline extensions with endTime coming up soon
* and possibly need a closing email to be sent.
Expand Down Expand Up @@ -1223,6 +1232,13 @@ public List<FeedbackQuestion> getFeedbackQuestionsForSession(FeedbackSession fee
return feedbackQuestionsLogic.getFeedbackQuestionsForSession(feedbackSession);
}

/**
* Gets the unique feedback question based on sessionId and questionNumber.
*/
public FeedbackQuestion getFeedbackQuestionForSessionQuestionNumber(UUID sessionId, int questionNumber) {
return feedbackQuestionsLogic.getFeedbackQuestionForSessionQuestionNumber(sessionId, questionNumber);
}

/**
* Gets a list of all questions for the given session that
* students can view/submit.
Expand Down
18 changes: 0 additions & 18 deletions src/main/java/teammates/sqllogic/api/LogicExtension.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void initLogicDependencies(DeadlineExtensionsDb deadlineExtensionsDb, FeedbackSe
}

/**
* Get extended deadline for this session and user if it exists, otherwise get the deadline of the session.
* Get extended deadline end time for this session and user if it exists, otherwise get the deadline of the session.
*/
public Instant getDeadlineForUser(FeedbackSession session, User user) {
Instant extendedDeadline =
Expand All @@ -54,7 +54,7 @@ public Instant getDeadlineForUser(FeedbackSession session, User user) {
}

/**
* Get extended deadline for this session and user if it exists, otherwise return null.
* Get extended deadline end time for this session and user if it exists, otherwise return null.
*/
public Instant getExtendedDeadlineForUser(FeedbackSession feedbackSession, User user) {
DeadlineExtension deadlineExtension =
Expand All @@ -66,6 +66,13 @@ public Instant getExtendedDeadlineForUser(FeedbackSession feedbackSession, User
return deadlineExtension.getEndTime();
}

/**
* Get deadline entity for this session and user if it exists, otherwise return null.
*/
public DeadlineExtension getDeadlineExtensionEntityForUser(FeedbackSession feedbackSession, User user) {
return deadlineExtensionsDb.getDeadlineExtension(user.getId(), feedbackSession.getId());
}

/**
* Creates a deadline extension.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ public void testAccessControl_studentSubmissionLoggedInAsAdmin_shouldFail() thro
}

@Test
public void testAccessControl_studentSubmissionLoggedInAsAdminMasqueradeAsStudent_shouldFail() throws Exception {
public void testAccessControl_studentSubmissionLoggedInAsAdminMasqueradeAsStudent_shouldAllow() throws Exception {
FeedbackSessionAttributes session = getSession("gracePeriodSession");
StudentAttributes student = getStudent("student1InCourse1");
setEndTime(session, 1);
Expand Down

0 comments on commit def7f0a

Please sign in to comment.