use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class StudentAttributesTest method testIsRegistered.
@Test
public void testIsRegistered() {
StudentAttributes sd = StudentAttributes.builder("course1", "name 1", "email@email.com").withSection("sect 1").withComments("comment 1").withTeam("team 1").build();
// Id is not given yet
assertFalse(sd.isRegistered());
// Id empty
sd.googleId = "";
assertFalse(sd.isRegistered());
// Id given
sd.googleId = "googleId.1";
assertTrue(sd.isRegistered());
}
use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class StudentAttributesTest method testBuilderCopy.
@Test
public void testBuilderCopy() {
StudentAttributes originalStudent = StudentAttributes.builder("courseId1", "name 1", "email@email.com").withGoogleId("googleId.1").withSection("section 1").withComments("comment 1").withTeam("team 1").build();
StudentAttributes copyStudent = originalStudent.getCopy();
assertEquals(originalStudent.course, copyStudent.course);
assertEquals(originalStudent.name, copyStudent.name);
assertEquals(originalStudent.email, copyStudent.email);
assertEquals(originalStudent.googleId, copyStudent.googleId);
assertEquals(originalStudent.comments, copyStudent.comments);
assertEquals(originalStudent.key, copyStudent.key);
assertEquals(originalStudent.updateStatus, copyStudent.updateStatus);
assertEquals(originalStudent.lastName, copyStudent.lastName);
assertEquals(originalStudent.section, copyStudent.section);
assertEquals(originalStudent.team, copyStudent.team);
assertEquals(originalStudent.getCreatedAt(), copyStudent.getCreatedAt());
assertEquals(originalStudent.getUpdatedAt(), copyStudent.getUpdatedAt());
}
use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class StudentAttributesTest method testValidate.
@Test
public void testValidate() throws Exception {
StudentAttributes s = generateValidStudentAttributesObject();
assertTrue("valid value", s.isValid());
s.googleId = "invalid@google@id";
s.name = "";
s.email = "invalid email";
s.course = "";
s.comments = StringHelperExtension.generateStringOfLength(FieldValidator.STUDENT_ROLE_COMMENTS_MAX_LENGTH + 1);
s.team = StringHelperExtension.generateStringOfLength(FieldValidator.TEAM_NAME_MAX_LENGTH + 1);
assertFalse("invalid value", s.isValid());
String errorMessage = getPopulatedErrorMessage(FieldValidator.GOOGLE_ID_ERROR_MESSAGE, "invalid@google@id", FieldValidator.GOOGLE_ID_FIELD_NAME, FieldValidator.REASON_INCORRECT_FORMAT, FieldValidator.GOOGLE_ID_MAX_LENGTH) + System.lineSeparator() + getPopulatedEmptyStringErrorMessage(FieldValidator.COURSE_ID_ERROR_MESSAGE_EMPTY_STRING, FieldValidator.COURSE_ID_FIELD_NAME, FieldValidator.COURSE_ID_MAX_LENGTH) + System.lineSeparator() + getPopulatedErrorMessage(FieldValidator.EMAIL_ERROR_MESSAGE, "invalid email", FieldValidator.EMAIL_FIELD_NAME, FieldValidator.REASON_INCORRECT_FORMAT, FieldValidator.EMAIL_MAX_LENGTH) + System.lineSeparator() + getPopulatedErrorMessage(FieldValidator.SIZE_CAPPED_NON_EMPTY_STRING_ERROR_MESSAGE, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", FieldValidator.TEAM_NAME_FIELD_NAME, FieldValidator.REASON_TOO_LONG, FieldValidator.TEAM_NAME_MAX_LENGTH) + System.lineSeparator() + getPopulatedErrorMessage(FieldValidator.SIZE_CAPPED_POSSIBLY_EMPTY_STRING_ERROR_MESSAGE, s.comments, FieldValidator.STUDENT_ROLE_COMMENTS_FIELD_NAME, FieldValidator.REASON_TOO_LONG, FieldValidator.STUDENT_ROLE_COMMENTS_MAX_LENGTH) + System.lineSeparator() + getPopulatedEmptyStringErrorMessage(FieldValidator.SIZE_CAPPED_NON_EMPTY_STRING_ERROR_MESSAGE_EMPTY_STRING, FieldValidator.PERSON_NAME_FIELD_NAME, FieldValidator.PERSON_NAME_MAX_LENGTH);
assertEquals("invalid value", errorMessage, StringHelper.toString(s.getInvalidityInfo()));
}
use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class StudentAttributesTest method testBuilderWithDefaultValues.
@Test
public void testBuilderWithDefaultValues() {
StudentAttributes sd = StudentAttributes.builder("courseId", "Joe White", "e@e.com").build();
assertEquals(Const.TIME_REPRESENTS_DEFAULT_TIMESTAMP, sd.getCreatedAt());
assertEquals(Const.TIME_REPRESENTS_DEFAULT_TIMESTAMP, sd.getUpdatedAt());
assertEquals("", sd.googleId);
assertEquals(Const.DEFAULT_SECTION, sd.section);
assertEquals(StudentUpdateStatus.UNKNOWN, sd.updateStatus);
assertEquals("White", sd.lastName);
}
use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class StudentAttributesTest method testGetRegistrationLink.
@Test
public void testGetRegistrationLink() {
StudentAttributes sd = StudentAttributes.builder("course1", "name 1", "email@email.com").withSection("sect 1").withComments("comment 1").withTeam("team 1").build();
sd.key = "testkey";
String regUrl = Config.getAppUrl(Const.ActionURIs.STUDENT_COURSE_JOIN_NEW).withRegistrationKey(StringHelper.encrypt("testkey")).withStudentEmail("email@email.com").withCourseId("course1").toString();
assertEquals(regUrl, sd.getRegistrationUrl());
}
Aggregations