Search in sources :

Example 81 with StudentAttributes

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());
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) Test(org.testng.annotations.Test)

Example 82 with StudentAttributes

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());
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) Test(org.testng.annotations.Test)

Example 83 with StudentAttributes

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()));
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) Test(org.testng.annotations.Test)

Example 84 with StudentAttributes

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);
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) Test(org.testng.annotations.Test)

Example 85 with StudentAttributes

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());
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) Test(org.testng.annotations.Test)

Aggregations

StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)241 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)85 Test (org.testng.annotations.Test)80 ArrayList (java.util.ArrayList)55 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)33 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)33 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)30 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)27 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)22 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)17 ShowPageResult (teammates.ui.controller.ShowPageResult)15 HashMap (java.util.HashMap)14 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)14 InvalidParametersException (teammates.common.exception.InvalidParametersException)14 EmailWrapper (teammates.common.util.EmailWrapper)13 RedirectResult (teammates.ui.controller.RedirectResult)12 List (java.util.List)11 StatusMessage (teammates.common.util.StatusMessage)10 HashSet (java.util.HashSet)9 StudentEnrollDetails (teammates.common.datatransfer.StudentEnrollDetails)9