Search in sources :

Example 1 with Priority

use of teammates.test.driver.Priority 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)

Aggregations

Test (org.testng.annotations.Test)1 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)1 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)1 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)1 Priority (teammates.test.driver.Priority)1