use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.
the class LogMessageGeneratorTest method generateLogMessage_normalPageAction.
@Test
public void generateLogMessage_normalPageAction() {
______TS("Not login");
String url = Const.ActionURIs.INSTRUCTOR_HOME_PAGE;
Map<String, String[]> paramMap = new HashMap<>();
String logMessage = "TEAMMATESLOG|||instructorHomePage|||instructorHomePage|||true|||Unknown|||Unknown" + "|||Unknown|||Unknown|||Not authorized|||/page/instructorHomePage";
String generatedMessage = logCenter.generatePageActionLogMessage(url, paramMap, null, null, null, "Not authorized");
AssertHelper.assertLogMessageEquals(logMessage, generatedMessage);
______TS("Not google login but with key (failure)");
url = Const.ActionURIs.STUDENT_COURSE_JOIN;
paramMap = generateRequestParamsWithRegKey();
logMessage = "TEAMMATESLOG|||studentCourseJoin|||studentCourseJoin|||true|||Unknown|||Unknown|||" + "Unknown|||Unknown|||Not authorized|||/page/studentCourseJoin";
generatedMessage = logCenter.generatePageActionLogMessage(url, paramMap, null, null, null, "Not authorized");
AssertHelper.assertLogMessageEqualsForUnregisteredStudentUser(logMessage, generatedMessage, "student@email.com", "CS2103");
______TS("Not google login but with key (success)");
url = Const.ActionURIs.STUDENT_COURSE_JOIN + "?user=test@email.com&course=1";
logMessage = "TEAMMATESLOG|||studentCourseJoin|||studentCourseJoin|||true|||Unregistered:CS2103|||Joe" + "|||Unknown|||student@email|||Join Course|||" + url;
StudentAttributes student = StudentAttributes.builder("CS2103", "Joe", "student@email").withSection("section1").withTeam("team1").withComments("comments").withGoogleId("unknownGoogleId").build();
// auth success : unregistered student will be passed
generatedMessage = logCenter.generatePageActionLogMessage(url, paramMap, null, null, student, "Join Course");
AssertHelper.assertLogMessageEqualsForUnregisteredStudentUser(logMessage, generatedMessage, "student@email.com", "CS2103");
// --------------- Google login ---------------
______TS("Google login (No account)");
url = Const.ActionURIs.STUDENT_HOME_PAGE + "?course=A&user=test";
paramMap = new HashMap<>();
logMessage = "TEAMMATESLOG|||studentHomePage|||studentHomePage|||true|||Unregistered|||Unknown" + "|||googleId|||Unknown|||Try student home|||" + url;
UserType userType = new UserType("googleId");
// userType and account will be passed for logged-in user
generatedMessage = logCenter.generatePageActionLogMessage(url, paramMap, userType, null, null, "Try student home");
AssertHelper.assertLogMessageEquals(logMessage, generatedMessage);
______TS("Google login (Student)");
String logTemplate = "TEAMMATESLOG|||%1$s|||%1$s|||true|||%2$s|||david" + "|||googleId|||david@email.com|||View Result|||/page/%1$s";
url = Const.ActionURIs.STUDENT_HOME_PAGE;
logMessage = String.format(logTemplate, "studentHomePage", "Student");
userType.isStudent = true;
AccountAttributes acc = AccountAttributes.builder().withGoogleId("googleId").withName("david").withEmail("david@email.com").withInstitute("NUS").withIsInstructor(false).withDefaultStudentProfileAttributes("idOfNewStudent").build();
generatedMessage = logCenter.generatePageActionLogMessage(url, paramMap, userType, acc, null, "View Result");
AssertHelper.assertLogMessageEquals(logMessage, generatedMessage);
______TS("Google login (Instructor and Student auto detect)");
userType.isInstructor = true;
url = Const.ActionURIs.STUDENT_FEEDBACK_RESULTS_PAGE;
logMessage = String.format(logTemplate, "studentFeedbackResultsPage", "Student");
generatedMessage = logCenter.generatePageActionLogMessage(url, paramMap, userType, acc, null, "View Result");
AssertHelper.assertLogMessageEquals(logMessage, generatedMessage);
url = Const.ActionURIs.INSTRUCTOR_COURSE_EDIT_PAGE;
logMessage = String.format(logTemplate, "instructorCourseEditPage", "Instructor");
generatedMessage = logCenter.generatePageActionLogMessage(url, paramMap, userType, acc, null, "View Result");
AssertHelper.assertLogMessageEquals(logMessage, generatedMessage);
______TS("Google login (Admin role auto detect)");
userType.isAdmin = true;
url = Const.ActionURIs.STUDENT_FEEDBACK_RESULTS_PAGE;
logMessage = String.format(logTemplate, "studentFeedbackResultsPage", "Student");
generatedMessage = logCenter.generatePageActionLogMessage(url, paramMap, userType, acc, null, "View Result");
AssertHelper.assertLogMessageEquals(logMessage, generatedMessage);
url = Const.ActionURIs.INSTRUCTOR_COURSES_PAGE;
logMessage = String.format(logTemplate, "instructorCoursesPage", "Instructor");
generatedMessage = logCenter.generatePageActionLogMessage(url, paramMap, userType, acc, null, "View Result");
AssertHelper.assertLogMessageEquals(logMessage, generatedMessage);
url = Const.ActionURIs.ADMIN_ACTIVITY_LOG_PAGE;
logMessage = "TEAMMATESLOG|||adminActivityLogPage|||adminActivityLogPage|||true|||Admin|||david" + "|||googleId|||david@email.com|||View Result|||/admin/adminActivityLogPage";
generatedMessage = logCenter.generatePageActionLogMessage(url, paramMap, userType, acc, null, "View Result");
AssertHelper.assertLogMessageEquals(logMessage, generatedMessage);
______TS("Google login (Admin Masquerade Mode)");
url = Const.ActionURIs.INSTRUCTOR_COURSES_PAGE;
userType.isAdmin = true;
acc = AccountAttributes.builder().withGoogleId("anotherGoogleId").withName("david").withEmail("david@email.com").withInstitute("NUS").withIsInstructor(false).withDefaultStudentProfileAttributes("anotherGoogleId").build();
logMessage = "TEAMMATESLOG|||instructorCoursesPage|||instructorCoursesPage|||true|||Instructor(M)|||david" + "|||anotherGoogleId|||david@email.com|||View comments|||/page/instructorCoursesPage";
// masquerade: userType and account don't have the same google id
generatedMessage = logCenter.generatePageActionLogMessage(url, paramMap, userType, acc, null, "View comments");
AssertHelper.assertLogMessageEqualsInMasqueradeMode(logMessage, generatedMessage, userType.id);
}
use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.
the class ProfilesDbTest method createNewAccount.
private AccountAttributes createNewAccount() throws Exception {
AccountAttributes a = AccountAttributes.builder().withGoogleId("valid.googleId").withEmail("valid@email.com").withName("Valid Fresh Account").withInstitute("TEAMMATES Test Institute 1").withIsInstructor(false).build();
a.studentProfile = StudentProfileAttributes.builder(a.googleId).withInstitute("TEAMMATES Test Institute 1").build();
accountsDb.createAccount(a);
return a;
}
use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.
the class InstructorCourseEnrollPageDataTest method testAll.
@Test
public void testAll() {
______TS("test typical case");
AccountAttributes account = dataBundle.accounts.get("instructor1OfCourse1");
String courseId = "CourseId";
String enroll = "Section | Team | Name | Email | Comments\n" + "Tut Group 1 | Team 1 | Tom Jacobs | tom@email.com\n" + "Tut Group 1 | Team 1 | Jean Wong | jean@email.com | Exchange Student\n" + "Tut Group 1 | Team 2 | Jack Wayne | jack@email.com\n" + "Tut Group 2 | Team 3 | Thora Parker | thora@email.com";
InstructorCourseEnrollPageData pageData = new InstructorCourseEnrollPageData(account, dummySessionToken, courseId, enroll);
assertNotNull(pageData.getCourseId());
assertEquals(courseId, pageData.getCourseId());
assertNotNull(pageData.getEnrollStudents());
assertEquals(enroll, pageData.getEnrollStudents());
assertNotNull(pageData.account);
assertEquals(account.googleId, pageData.account.googleId);
}
use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackSessionsPageDataTest method testInit.
@Test
public void testInit() {
AccountAttributes instructorAccount = dataBundle.accounts.get("instructor1OfCourse1");
______TS("typical success case with existing fs passed in");
InstructorFeedbackSessionsPageData data = new InstructorFeedbackSessionsPageData(instructorAccount, dummySessionToken);
Map<String, InstructorAttributes> courseInstructorMap = new HashMap<>();
List<InstructorAttributes> instructors = getInstructorsForGoogleId(instructorAccount.googleId, true);
for (InstructorAttributes instructor : instructors) {
courseInstructorMap.put(instructor.courseId, instructor);
}
List<InstructorAttributes> instructorsForUser = new ArrayList<>(courseInstructorMap.values());
List<CourseAttributes> courses = getCoursesForInstructor(instructorsForUser);
List<FeedbackSessionAttributes> fsList = getFeedbackSessionsListForInstructor(instructorsForUser);
FeedbackSessionAttributes fsa = dataBundle.feedbackSessions.get("session1InCourse1");
data.init(courses, null, fsList, courseInstructorMap, fsa, null, null);
______TS("typical success case with existing fs passed in: test new fs form");
// Test new fs form model
FeedbackSessionsForm formModel = data.getNewFsForm();
assertNull(formModel.getCourseId());
assertEquals(1, formModel.getCoursesSelectField().size());
assertEquals(2, formModel.getFeedbackSessionTypeOptions().size());
assertEquals("session using template: team peer evaluation", formModel.getFeedbackSessionTypeOptions().get(1).getContent());
assertNull(formModel.getFeedbackSessionTypeOptions().get(1).getAttributes().get("selected"));
assertTrue(formModel.getFeedbackSessionTypeOptions().get(1).getAttributes().containsKey("selected"));
assertEquals("Fri, 30 Apr, 2027", formModel.getFsEndDate());
assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getFsEndTimeOptions().size());
assertEquals("First feedback session", formModel.getFsName());
assertEquals("Sun, 01 Apr, 2012", formModel.getFsStartDate());
assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getFsStartTimeOptions().size());
assertEquals(7, formModel.getGracePeriodOptions().size());
int expectedDefaultGracePeriodOptionsIndex = 2;
assertNull(formModel.getGracePeriodOptions().get(expectedDefaultGracePeriodOptionsIndex).getAttributes().get("selected"));
assertTrue(formModel.getGracePeriodOptions().get(expectedDefaultGracePeriodOptionsIndex).getAttributes().containsKey("selected"));
assertEquals("Please please fill in the following questions.", formModel.getInstructions());
assertEquals("Sat, 01 May, 2027", formModel.getAdditionalSettings().getResponseVisibleDateValue());
assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getAdditionalSettings().getResponseVisibleTimeOptions().size());
assertEquals("Wed, 28 Mar, 2012", formModel.getAdditionalSettings().getSessionVisibleDateValue());
assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getAdditionalSettings().getSessionVisibleTimeOptions().size());
assertFalse(formModel.getAdditionalSettings().isResponseVisiblePublishManuallyChecked());
assertTrue(formModel.getAdditionalSettings().isResponseVisibleDateChecked());
assertFalse(formModel.getAdditionalSettings().isResponseVisibleImmediatelyChecked());
assertFalse(formModel.getAdditionalSettings().isResponseVisibleDateDisabled());
assertFalse(formModel.getAdditionalSettings().isSessionVisibleAtOpenChecked());
assertFalse(formModel.getAdditionalSettings().isSessionVisibleDateDisabled());
assertTrue(formModel.getAdditionalSettings().isSessionVisibleDateButtonChecked());
assertFalse(formModel.getAdditionalSettings().isSessionVisiblePrivateChecked());
______TS("typical success case with existing fs passed in: session rows");
FeedbackSessionsTable fsTableModel = data.getFsList();
List<FeedbackSessionsTableRow> fsRows = fsTableModel.getExistingFeedbackSessions();
assertEquals(6, fsRows.size());
String firstFsName = "Grace Period Session";
assertEquals(firstFsName, fsRows.get(0).getName());
String lastFsName = "First feedback session";
assertEquals(lastFsName, fsRows.get(fsRows.size() - 1).getName());
______TS("typical success case with existing fs passed in: copy modal");
FeedbackSessionsCopyFromModal copyModalModel = data.getCopyFromModal();
assertEquals(1, copyModalModel.getCoursesSelectField().size());
assertEquals("First feedback session", copyModalModel.getFsName());
assertEquals(6, copyModalModel.getExistingFeedbackSessions().size());
}
use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.
the class StudentCourseDetailsPageActionTest method testTeamMemberDetailsOnViewTeamPage.
@Test
public void testTeamMemberDetailsOnViewTeamPage() {
AccountAttributes student = typicalBundle.accounts.get("student1InCourse1");
String[] submissionParams = createValidParamsForProfile();
StudentProfileAttributes expectedProfile = getProfileAttributesFrom(student.googleId, submissionParams);
gaeSimulation.loginAsStudent(student.googleId);
// adding profile picture for student1InCourse1
StudentProfileEditSaveAction action = getStudentProfileEditSaveAction(submissionParams);
RedirectResult result = getRedirectResult(action);
expectedProfile.googleId = student.googleId;
assertFalse(result.isError);
StudentAttributes student1 = typicalBundle.students.get("student1InCourse1");
gaeSimulation.logoutUser();
gaeSimulation.loginAsStudent(typicalBundle.accounts.get("student2InCourse1").googleId);
String[] submissionParam = new String[] { Const.ParamsNames.COURSE_ID, student1.course };
StudentCourseDetailsPageAction pageAction = getAction(submissionParam);
ShowPageResult pageResult = getShowPageResult(pageAction);
StudentCourseDetailsPageData pageData = (StudentCourseDetailsPageData) pageResult.data;
List<StudentAttributes> actualStudentsList = pageData.getStudentCourseDetailsPanel().getTeammates();
boolean isStudentDisplayedOnViewTeam = false;
for (StudentAttributes stud : actualStudentsList) {
if (student1.email.equals(stud.email) && student1.name.equals(stud.name) && student1.getPublicProfilePictureUrl().equals(stud.getPublicProfilePictureUrl())) {
isStudentDisplayedOnViewTeam = true;
}
}
assertTrue(isStudentDisplayedOnViewTeam);
}
Aggregations