Search in sources :

Example 6 with CheckResult

use of com.ctrip.framework.apollo.portal.util.checker.CheckResult in project apollo by ctripcorp.

the class UserInfoControllerTest method testCreateOrUpdateUserFailed.

@Test(expected = BadRequestException.class)
public void testCreateOrUpdateUserFailed() {
    UserPO user = new UserPO();
    user.setUsername("username");
    user.setPassword("password");
    String msg = "fake error message";
    Mockito.when(userPasswordChecker.checkWeakPassword(Mockito.anyString())).thenReturn(new CheckResult(Boolean.FALSE, msg));
    try {
        userInfoController.createOrUpdateUser(user);
    } catch (BadRequestException e) {
        Assert.assertEquals(msg, e.getMessage());
        throw e;
    }
}
Also used : CheckResult(com.ctrip.framework.apollo.portal.util.checker.CheckResult) BadRequestException(com.ctrip.framework.apollo.common.exception.BadRequestException) UserPO(com.ctrip.framework.apollo.portal.entity.po.UserPO) Test(org.junit.Test)

Aggregations

CheckResult (com.ctrip.framework.apollo.portal.util.checker.CheckResult)6 Test (org.junit.Test)6 PortalConfig (com.ctrip.framework.apollo.portal.component.config.PortalConfig)4 AuthUserPasswordChecker (com.ctrip.framework.apollo.portal.util.checker.AuthUserPasswordChecker)4 HashMap (java.util.HashMap)3 UserPO (com.ctrip.framework.apollo.portal.entity.po.UserPO)2 BadRequestException (com.ctrip.framework.apollo.common.exception.BadRequestException)1 PortalDBPropertySource (com.ctrip.framework.apollo.portal.service.PortalDBPropertySource)1