Search in sources :

Example 1 with AccountImportForm

use of cn.edu.zjnu.acm.judge.data.form.AccountImportForm in project judge by zjnu-acm.

the class AccountControllerTest method testImportUsers.

/**
 * Test of importUsers method, of class AccountController.
 *
 * @see AccountController#importUsers(AccountImportForm)
 */
@Test
public void testImportUsers() throws Exception {
    log.info("importUsers");
    AccountImportForm form = new AccountImportForm();
    Account account = toAccount(mockDataService.user(false));
    Account account2 = toAccount(mockDataService.user(false));
    form.setContent(Arrays.asList(account, account2));
    expect(form, HttpStatus.OK);
    account.setExists(true);
    account2.setExists(true);
    expect(form, HttpStatus.BAD_REQUEST);
    form.setExistsPolicy(Arrays.asList(AccountImportForm.ExistPolicy.ENABLE));
    expect(form, HttpStatus.OK);
}
Also used : Account(cn.edu.zjnu.acm.judge.data.excel.Account) AccountImportForm(cn.edu.zjnu.acm.judge.data.form.AccountImportForm) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with AccountImportForm

use of cn.edu.zjnu.acm.judge.data.form.AccountImportForm in project judge by zjnu-acm.

the class AccountExcelControllerTest method testImportUsers.

/**
 * Test of importUsers method, of class AccountController.
 *
 * {@link AccountExcelController#importUsers(AccountImportForm)}
 */
@Test
public void testImportUsers() throws Exception {
    log.info("importUsers");
    AccountImportForm form = new AccountImportForm();
    Account account = toAccount(mockDataService.user(false));
    Account account2 = toAccount(mockDataService.user(false));
    form.setContent(Arrays.asList(account, account2));
    expect(form, HttpStatus.NO_CONTENT);
    account.setExists(true);
    account2.setExists(true);
    expect(form, HttpStatus.BAD_REQUEST);
    form.getExistsPolicy().add(AccountImportForm.ExistPolicy.ENABLE);
    expect(form, HttpStatus.NO_CONTENT);
}
Also used : Account(cn.edu.zjnu.acm.judge.data.excel.Account) AccountImportForm(cn.edu.zjnu.acm.judge.data.form.AccountImportForm) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Account (cn.edu.zjnu.acm.judge.data.excel.Account)2 AccountImportForm (cn.edu.zjnu.acm.judge.data.form.AccountImportForm)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1