use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.
the class GateKeeperTest method testGetCurrentUser.
// TODO: test isUserLoggedIn method
@Test
public void testGetCurrentUser() throws Exception {
______TS("admin+instructor+student");
InstructorAttributes instructor = dataBundle.instructors.get("instructor1OfCourse1");
CourseAttributes course = dataBundle.courses.get("typicalCourse2");
gaeSimulation.loginAsAdmin(instructor.googleId);
// also make this user a student of another course
StudentAttributes instructorAsStudent = StudentAttributes.builder(course.getId(), "Instructor As Student", "instructorasstudent@yahoo.com").withSection("Section 1").withTeam("Team 1").withComments("").build();
instructorAsStudent.googleId = instructor.googleId;
new Logic().createStudentWithoutDocument(instructorAsStudent);
UserType user = gateKeeper.getCurrentUser();
assertEquals(instructor.googleId, user.id);
assertTrue(user.isAdmin);
assertTrue(user.isInstructor);
assertTrue(user.isStudent);
______TS("unregistered");
gaeSimulation.loginUser("unknown");
user = gateKeeper.getCurrentUser();
assertEquals("unknown", user.id);
assertFalse(user.isAdmin);
assertFalse(user.isInstructor);
assertFalse(user.isStudent);
______TS("not logged in");
// check for user not logged in
gaeSimulation.logoutUser();
assertNull(gateKeeper.getCurrentUser());
}
use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.
the class StudentsLogicTest method testIsStudentInTeam.
private void testIsStudentInTeam() {
______TS("non-existent student");
String nonExistStudentEmail = "nonExist@google.tmt";
String teamName = "Team 1";
CourseAttributes course1 = dataBundle.courses.get("typicalCourse1");
assertFalse(studentsLogic.isStudentInTeam(course1.getId(), teamName, nonExistStudentEmail));
______TS("student not in given team");
StudentAttributes student1InCourse1 = dataBundle.students.get("student1InCourse1");
assertFalse(studentsLogic.isStudentInTeam(course1.getId(), teamName, nonExistStudentEmail));
______TS("typical case");
teamName = student1InCourse1.team;
assertTrue(studentsLogic.isStudentInTeam(course1.getId(), teamName, student1InCourse1.email));
}
use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.
the class StudentsLogicTest method testIsStudentsInSameTeam.
private void testIsStudentsInSameTeam() {
______TS("non-existent student1");
CourseAttributes course1 = dataBundle.courses.get("typicalCourse1");
StudentAttributes student2InCourse1 = dataBundle.students.get("student2InCourse1");
String nonExistStudentEmail = "nonExist@google.tmt";
assertFalse(studentsLogic.isStudentsInSameTeam(course1.getId(), nonExistStudentEmail, student2InCourse1.email));
______TS("students of different teams");
StudentAttributes student5InCourse1 = dataBundle.students.get("student5InCourse1");
assertFalse(studentsLogic.isStudentsInSameTeam(course1.getId(), student2InCourse1.email, student5InCourse1.email));
______TS("students of different teams");
StudentAttributes student1InCourse1 = dataBundle.students.get("student1InCourse1");
assertTrue(studentsLogic.isStudentsInSameTeam(course1.getId(), student2InCourse1.email, student1InCourse1.email));
}
use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.
the class StudentsLogicTest method testIsStudentInCourse.
private void testIsStudentInCourse() {
______TS("non-existent student");
String nonExistStudentEmail = "nonExist@google.tmt";
CourseAttributes course1 = dataBundle.courses.get("typicalCourse1");
assertFalse(studentsLogic.isStudentInCourse(course1.getId(), nonExistStudentEmail));
______TS("typical case");
StudentAttributes student1InCourse1 = dataBundle.students.get("student1InCourse1");
assertTrue(studentsLogic.isStudentInCourse(course1.getId(), student1InCourse1.email));
}
use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.
the class StudentsLogicTest method testValidateSections.
private void testValidateSections() throws Exception {
CourseAttributes typicalCourse1 = dataBundle.courses.get("typicalCourse1");
String courseId = typicalCourse1.getId();
______TS("Typical case");
List<StudentAttributes> studentList = new ArrayList<>();
studentList.add(StudentAttributes.builder(courseId, "New Student", "emailNew@com").withSection("Section 3").withTeam("Team 1.3").withComments("").build());
studentList.add(StudentAttributes.builder(courseId, "student2 In Course1", "student2InCourse1@gmail.tmt").withSection("Section 2").withTeam("Team 1.4").withComments("").build());
studentsLogic.validateSectionsAndTeams(studentList, courseId);
______TS("Failure case: invalid section");
studentList = new ArrayList<>();
for (int i = 0; i < 100; i++) {
StudentAttributes addedStudent = StudentAttributes.builder(courseId, "Name " + i, "email@com" + i).withSection("Section 1").withTeam("Team " + i).withComments("cmt" + i).build();
studentList.add(addedStudent);
}
try {
studentsLogic.validateSectionsAndTeams(studentList, courseId);
} catch (EnrollException e) {
assertEquals(String.format(Const.StatusMessages.SECTION_QUOTA_EXCEED, "Section 1"), e.getMessage());
}
______TS("Failure case: invalid team");
studentList = new ArrayList<>();
studentList.add(StudentAttributes.builder(courseId, "New Student", "newemail@com").withSection("Section 2").withTeam("Team 1.1").withComments("").build());
try {
studentsLogic.validateSectionsAndTeams(studentList, courseId);
} catch (EnrollException e) {
assertEquals(String.format(Const.StatusMessages.TEAM_INVALID_SECTION_EDIT, "Team 1.1</td></div>'\"") + "Please use the enroll page to edit multiple students", e.getMessage());
}
}
Aggregations