Search in sources :

Example 16 with StudentProfileAttributes

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

the class AccountsLogicTest method testCreateAccount.

@Test
public void testCreateAccount() throws Exception {
    ______TS("typical success case");
    StudentProfileAttributes spa = StudentProfileAttributes.builder("id").build();
    spa.shortName = "test acc na";
    spa.email = "test@personal.com";
    spa.gender = Const.GenderTypes.MALE;
    spa.nationality = "American";
    spa.institute = "institute";
    spa.moreInfo = "this is more info";
    AccountAttributes accountToCreate = AccountAttributes.builder().withGoogleId("id").withName("name").withEmail("test@email.com").withInstitute("dev").withIsInstructor(true).withStudentProfileAttributes(spa).build();
    accountsLogic.createAccount(accountToCreate);
    verifyPresentInDatastore(accountToCreate);
    accountsLogic.deleteAccountCascade("id");
    ______TS("invalid parameters exception case");
    accountToCreate = AccountAttributes.builder().withGoogleId("").withName("name").withEmail("test@email.com").withInstitute("dev").withIsInstructor(true).withStudentProfileAttributes(spa).build();
    try {
        accountsLogic.createAccount(accountToCreate);
        signalFailureToDetectException();
    } catch (InvalidParametersException e) {
        ignoreExpectedException();
    }
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) InvalidParametersException(teammates.common.exception.InvalidParametersException) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) Test(org.testng.annotations.Test)

Example 17 with StudentProfileAttributes

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

the class AccountsLogicTest method testAccountFunctions.

@Priority(-1)
@Test
public void testAccountFunctions() throws Exception {
    ______TS("test isAccountPresent");
    assertTrue(accountsLogic.isAccountPresent("idOfInstructor1OfCourse1"));
    assertTrue(accountsLogic.isAccountPresent("student1InCourse1"));
    assertFalse(accountsLogic.isAccountPresent("id-does-not-exist"));
    ______TS("test isAccountAnInstructor");
    assertTrue(accountsLogic.isAccountAnInstructor("idOfInstructor1OfCourse1"));
    assertFalse(accountsLogic.isAccountAnInstructor("student1InCourse1"));
    assertFalse(accountsLogic.isAccountAnInstructor("id-does-not-exist"));
    ______TS("test getInstructorAccounts");
    for (AccountAttributes aa : accountsLogic.getInstructorAccounts()) {
        ______TS(aa.toString());
    }
    assertEquals(12, accountsLogic.getInstructorAccounts().size());
    ______TS("test updateAccount");
    StudentProfileAttributes spa = StudentProfileAttributes.builder("idOfInstructor1OfCourse1").build();
    spa.institute = "dev";
    spa.shortName = "nam";
    AccountAttributes expectedAccount = AccountAttributes.builder().withGoogleId("idOfInstructor1OfCourse1").withName("name").withEmail("test2@email.com").withInstitute("dev").withIsInstructor(true).withStudentProfileAttributes(spa).build();
    // updates the profile
    accountsLogic.updateAccount(expectedAccount, true);
    AccountAttributes actualAccount = accountsLogic.getAccount(expectedAccount.googleId, true);
    expectedAccount.studentProfile.modifiedDate = actualAccount.studentProfile.modifiedDate;
    expectedAccount.createdAt = actualAccount.createdAt;
    assertEquals(expectedAccount.toString(), actualAccount.toString());
    // does not update the profile
    expectedAccount.studentProfile.shortName = "newNam";
    accountsLogic.updateAccount(expectedAccount);
    actualAccount = accountsLogic.getAccount(expectedAccount.googleId, true);
    // no change in the name
    assertEquals("nam", actualAccount.studentProfile.shortName);
    expectedAccount = AccountAttributes.builder().withGoogleId("id-does-not-exist").withName("name").withEmail("test2@email.com").withInstitute("dev").withIsInstructor(true).withStudentProfileAttributes(spa).build();
    try {
        accountsLogic.updateAccount(expectedAccount);
        signalFailureToDetectException();
    } catch (EntityDoesNotExistException edne) {
        AssertHelper.assertContains(AccountsDb.ERROR_UPDATE_NON_EXISTENT_ACCOUNT, edne.getMessage());
    }
    ______TS("test downgradeInstructorToStudentCascade");
    accountsLogic.downgradeInstructorToStudentCascade("idOfInstructor2OfCourse1");
    assertFalse(accountsLogic.isAccountAnInstructor("idOfInstructor2OfCourse1"));
    accountsLogic.downgradeInstructorToStudentCascade("student1InCourse1");
    assertFalse(accountsLogic.isAccountAnInstructor("student1InCourse1"));
    accountsLogic.downgradeInstructorToStudentCascade("id-does-not-exist");
    assertFalse(accountsLogic.isAccountPresent("id-does-not-exist"));
    ______TS("test makeAccountInstructor");
    accountsLogic.makeAccountInstructor("student2InCourse1");
    assertTrue(accountsLogic.isAccountAnInstructor("student2InCourse1"));
    accountsLogic.downgradeInstructorToStudentCascade("student2InCourse1");
    accountsLogic.makeAccountInstructor("id-does-not-exist");
    assertFalse(accountsLogic.isAccountPresent("id-does-not-exist"));
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException) Test(org.testng.annotations.Test) Priority(teammates.test.driver.Priority)

Example 18 with StudentProfileAttributes

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

the class ProfilesDbTest method testUpdateProfileSuccessWithNoPictureKey.

private void testUpdateProfileSuccessWithNoPictureKey(AccountAttributes a) throws Exception {
    ______TS("typical success case, no picture");
    a.studentProfile.moreInfo = "This is more than enough info...";
    a.studentProfile.email = "e@email.com";
    profilesDb.updateStudentProfile(a.studentProfile);
    StudentProfileAttributes updatedProfile = profilesDb.getStudentProfile(a.studentProfile.googleId);
    assertEquals(a.studentProfile.moreInfo, updatedProfile.moreInfo);
    assertEquals(a.studentProfile.email, updatedProfile.email);
}
Also used : StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes)

Example 19 with StudentProfileAttributes

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

the class ProfilesDbTest method testUpdateProfilePictureSuccessInitiallyEmpty.

private void testUpdateProfilePictureSuccessInitiallyEmpty(AccountAttributes a) throws IOException, EntityDoesNotExistException {
    ______TS("update picture key - initially empty");
    a.studentProfile.pictureKey = uploadDefaultPictureForProfile(a.googleId);
    profilesDb.updateStudentProfilePicture(a.googleId, a.studentProfile.pictureKey);
    StudentProfileAttributes updatedProfile = profilesDb.getStudentProfile(a.studentProfile.googleId);
    assertEquals(a.studentProfile.pictureKey, updatedProfile.pictureKey);
}
Also used : StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes)

Example 20 with StudentProfileAttributes

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

the class StudentCourseJoinAuthenticatedAction method addStatusMessageToUser.

private void addStatusMessageToUser() throws EntityDoesNotExistException {
    CourseAttributes course = logic.getCourse(getStudent().course);
    String courseDisplayText = "[" + course.getId() + "] " + SanitizationHelper.sanitizeForHtml(course.getName());
    statusToUser.add(new StatusMessage(String.format(Const.StatusMessages.STUDENT_COURSE_JOIN_SUCCESSFUL, courseDisplayText), StatusMessageColor.SUCCESS));
    List<FeedbackSessionAttributes> fsa = logic.getFeedbackSessionsForUserInCourse(getStudent().course, getStudent().email);
    if (fsa.isEmpty()) {
        statusToUser.add(new StatusMessage(String.format(Const.StatusMessages.HINT_FOR_NO_SESSIONS_STUDENT, courseDisplayText), StatusMessageColor.INFO));
        StudentProfileAttributes spa = logic.getStudentProfile(account.googleId);
        String updateProfileMessage = spa.generateUpdateMessageForStudent();
        if (!updateProfileMessage.isEmpty()) {
            statusToUser.add(new StatusMessage(updateProfileMessage, StatusMessageColor.INFO));
        }
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) StatusMessage(teammates.common.util.StatusMessage)

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