Search in sources :

Example 36 with StudentProfileAttributes

use of teammates.common.datatransfer.attributes.StudentProfileAttributes in project teammates by TEAMMATES.

the class ProfilesDbTest method testDeletePictureSuccess.

private void testDeletePictureSuccess(AccountAttributes a) throws EntityDoesNotExistException {
    ______TS("delete picture");
    profilesDb.deleteStudentProfilePicture(a.googleId);
    StudentProfileAttributes updatedProfile = profilesDb.getStudentProfile(a.studentProfile.googleId);
    assertFalse(doesFileExistInGcs(new BlobKey(updatedProfile.pictureKey)));
    assertEquals("", updatedProfile.pictureKey);
}
Also used : BlobKey(com.google.appengine.api.blobstore.BlobKey) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes)

Example 37 with StudentProfileAttributes

use of teammates.common.datatransfer.attributes.StudentProfileAttributes in project teammates by TEAMMATES.

the class ProfilesDbTest method testUpdateProfileSuccessInitiallyEmptyPictureKey.

private void testUpdateProfileSuccessInitiallyEmptyPictureKey(AccountAttributes a) throws Exception, EntityDoesNotExistException {
    ______TS("success case: add picture (initially empty)");
    a.studentProfile.pictureKey = uploadDefaultPictureForProfile(a.googleId);
    profilesDb.updateStudentProfile(a.studentProfile);
    StudentProfileAttributes updatedProfile = profilesDb.getStudentProfile(a.studentProfile.googleId);
    assertEquals(a.studentProfile.pictureKey, updatedProfile.pictureKey);
}
Also used : StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes)

Example 38 with StudentProfileAttributes

use of teammates.common.datatransfer.attributes.StudentProfileAttributes in project teammates by TEAMMATES.

the class StudentCourseDetailsPageActionTest method getProfileAttributesFrom.

private StudentProfileAttributes getProfileAttributesFrom(String googleId, String[] submissionParams) {
    StudentProfileAttributes spa = StudentProfileAttributes.builder(googleId).build();
    spa.shortName = StringHelper.trimIfNotNull(submissionParams[1]);
    spa.email = StringHelper.trimIfNotNull(submissionParams[3]);
    spa.institute = StringHelper.trimIfNotNull(submissionParams[5]);
    spa.nationality = StringHelper.trimIfNotNull(submissionParams[7]);
    spa.gender = StringHelper.trimIfNotNull(submissionParams[9]);
    spa.moreInfo = StringHelper.trimIfNotNull(submissionParams[11]);
    spa.modifiedDate = null;
    return spa;
}
Also used : StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes)

Example 39 with StudentProfileAttributes

use of teammates.common.datatransfer.attributes.StudentProfileAttributes 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);
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) ShowPageResult(teammates.ui.controller.ShowPageResult) RedirectResult(teammates.ui.controller.RedirectResult) StudentProfileEditSaveAction(teammates.ui.controller.StudentProfileEditSaveAction) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) StudentCourseDetailsPageData(teammates.ui.pagedata.StudentCourseDetailsPageData) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) StudentCourseDetailsPageAction(teammates.ui.controller.StudentCourseDetailsPageAction) Test(org.testng.annotations.Test)

Example 40 with StudentProfileAttributes

use of teammates.common.datatransfer.attributes.StudentProfileAttributes in project teammates by TEAMMATES.

the class StudentProfileEditSaveActionTest method testActionSuccess.

private void testActionSuccess(AccountAttributes student, String caseDescription) {
    String[] submissionParams = createValidParamsForProfile();
    StudentProfileAttributes expectedProfile = getProfileAttributesFrom(student.googleId, submissionParams);
    gaeSimulation.loginAsStudent(student.googleId);
    ______TS(caseDescription);
    StudentProfileEditSaveAction action = getAction(submissionParams);
    RedirectResult result = getRedirectResult(action);
    expectedProfile.googleId = student.googleId;
    assertFalse(result.isError);
    AssertHelper.assertContains(getPageResultDestination(Const.ActionURIs.STUDENT_PROFILE_PAGE, false, student.googleId), result.getDestinationWithParams());
    assertEquals(Const.StatusMessages.STUDENT_PROFILE_EDITED, result.getStatusMessage());
    verifyLogMessage(student, action, expectedProfile, false);
}
Also used : RedirectResult(teammates.ui.controller.RedirectResult) StudentProfileEditSaveAction(teammates.ui.controller.StudentProfileEditSaveAction) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes)

Aggregations

StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)45 Test (org.testng.annotations.Test)15 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)11 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)7 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)6 BlobKey (com.google.appengine.api.blobstore.BlobKey)5 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)5 RedirectResult (teammates.ui.controller.RedirectResult)5 ArrayList (java.util.ArrayList)4 InvalidParametersException (teammates.common.exception.InvalidParametersException)4 StatusMessage (teammates.common.util.StatusMessage)4 StudentProfile (teammates.storage.entity.StudentProfile)4 StudentProfileEditSaveAction (teammates.ui.controller.StudentProfileEditSaveAction)4 CourseDetailsBundle (teammates.common.datatransfer.CourseDetailsBundle)3 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)3 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)3 Text (com.google.appengine.api.datastore.Text)2 ShowPageResult (teammates.ui.controller.ShowPageResult)2 InstructorStudentRecordsPageData (teammates.ui.pagedata.InstructorStudentRecordsPageData)2 Key (com.googlecode.objectify.Key)1