guochao 6 年之前
父节点
当前提交
ce294c98e4
共有 17 个文件被更改,包括 166 次插入37 次删除
  1. 3 2
      core/src/main/java/com/mooctest/crowd/domain/domainobject/AuthenticationStatus.java
  2. 1 1
      core/src/main/java/com/mooctest/crowd/domain/domainobject/User.java
  3. 1 1
      core/src/main/java/com/mooctest/crowd/domain/model/UserPO.java
  4. 3 1
      site/src/main/java/com/mooctest/crowd/site/anticorruption/UserAntiCorruption.java
  5. 31 2
      site/src/main/java/com/mooctest/crowd/site/anticorruption/impl/UserAntiCorruptionImpl.java
  6. 20 0
      site/src/main/java/com/mooctest/crowd/site/anticorruption/impl/data/UserInfo.java
  7. 7 0
      site/src/main/java/com/mooctest/crowd/site/command/ApplyAgencyAuthCommand.java
  8. 39 6
      site/src/main/java/com/mooctest/crowd/site/controller/AgencyController.java
  9. 1 1
      site/src/main/java/com/mooctest/crowd/site/controller/CommonController.java
  10. 9 9
      site/src/main/java/com/mooctest/crowd/site/controller/advice/ExceptionAdvice.java
  11. 1 0
      site/src/main/java/com/mooctest/crowd/site/data/vo/AgencyVO.java
  12. 2 1
      site/src/main/java/com/mooctest/crowd/site/data/vo/UserVO.java
  13. 2 1
      site/src/main/java/com/mooctest/crowd/site/mediator/ViewMediator.java
  14. 6 2
      site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java
  15. 2 0
      site/src/main/java/com/mooctest/crowd/site/service/AgencyService.java
  16. 33 6
      site/src/main/java/com/mooctest/crowd/site/service/impl/AgencyServiceImpl.java
  17. 5 4
      site/src/test/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImplTest.java

+ 3 - 2
core/src/main/java/com/mooctest/crowd/domain/domainobject/AuthenticationStatus.java

@@ -5,6 +5,7 @@ package com.mooctest.crowd.domain.domainobject;
  * @date 2019/7/9 14:21
  */
 public class AuthenticationStatus {
-    public static final int isNotAuthenticated = 0; //未认证
-    public static final int isAuthenticated = 1;    //已认证
+    public static final int isNotAuthenticated = -1; //未通过认证
+    public static final int isAuthenIng = 0;         //审核中
+    public static final int isAuthenticated = 1;     //已认证
 }

+ 1 - 1
core/src/main/java/com/mooctest/crowd/domain/domainobject/User.java

@@ -241,7 +241,7 @@ public class User {
 
     public User applyAgencyAuthentication(EvaluationAgency evaluationAgency) {
         evaluationAgency.setUserId(this.id);
-        evaluationAgency.setIsAuthentication(AuthenticationStatus.isNotAuthenticated);
+        evaluationAgency.setIsAuthentication(AuthenticationStatus.isAuthenIng);
         evaluationAgency.setIsDeleted(DeletedStatus.isNotDeleted);
         this.setEvaluationAgency(evaluationAgency);
         return this;

+ 1 - 1
core/src/main/java/com/mooctest/crowd/domain/model/UserPO.java

@@ -14,8 +14,8 @@ import java.sql.Timestamp;
 @Entity
 public class UserPO {
 
+//    @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Column(name = "U_ID")
     private Long id;
 

+ 3 - 1
site/src/main/java/com/mooctest/crowd/site/anticorruption/UserAntiCorruption.java

@@ -8,5 +8,7 @@ import com.mooctest.crowd.domain.domainobject.User;
  * @date 2019-08-08 23:40
  */
 public interface UserAntiCorruption {
-    User register(String name, String mobile, String password);
+    User register(String name,String email, String mobile, String password);
+
+    User getUserInfo(Long userId);
 }

+ 31 - 2
site/src/main/java/com/mooctest/crowd/site/anticorruption/impl/UserAntiCorruptionImpl.java

@@ -1,12 +1,15 @@
 package com.mooctest.crowd.site.anticorruption.impl;
 
 import com.alibaba.fastjson.JSONObject;
+import com.mooctest.crowd.domain.domainobject.Role;
 import com.mooctest.crowd.domain.domainobject.User;
+import com.mooctest.crowd.domain.exception.UserNotExistException;
 import com.mooctest.crowd.domain.factory.UserFactory;
 import com.mooctest.crowd.domain.repository.UserRepo;
 import com.mooctest.crowd.site.anticorruption.UserAntiCorruption;
 import com.mooctest.crowd.site.anticorruption.impl.data.UserInfo;
 import com.mooctest.crowd.site.util.EncryptionUtil;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpEntity;
@@ -16,7 +19,9 @@ import org.springframework.http.MediaType;
 import org.springframework.stereotype.Component;
 import org.springframework.web.client.RestTemplate;
 
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -24,6 +29,7 @@ import java.util.Map;
  * @Email: 171256175@qq.com
  * @date 2019-08-08 23:40
  */
+@Slf4j
 @Component
 public class UserAntiCorruptionImpl implements UserAntiCorruption {
     @Autowired
@@ -36,13 +42,13 @@ public class UserAntiCorruptionImpl implements UserAntiCorruption {
     private String userServiceUrl;
 
     @Override
-    public User register(String name, String mobile, String password) {
+    public User register(String name, String email, String mobile, String password) {
         HttpHeaders httpHeaders = new HttpHeaders();
         httpHeaders.setContentType(MediaType.APPLICATION_JSON);
         JSONObject params = new JSONObject();
         params.put("name", name);
         params.put("mobile", mobile);
-        params.put("email", name+"@mooctest.net");
+        params.put("email", email);
         params.put("password", EncryptionUtil.encryptMD5(password));
         params.put("createTime", System.currentTimeMillis());
 
@@ -56,4 +62,27 @@ public class UserAntiCorruptionImpl implements UserAntiCorruption {
         user.setPassword(userInfo.getPassword());
         return user;
     }
+
+    @Override
+    public User getUserInfo(Long userId) {
+        UserInfo userInfo = restTemplate.getForEntity(userServiceUrl+"/api/user/"+userId, UserInfo.class).getBody();
+        if (userInfo == null)
+            throw new UserNotExistException();
+        log.info("userInfo: " + userInfo.toString());
+        try{
+            //将用户中心的用户中心的用户数据对本系统内同步
+            User newUser = userInfo.toUser();
+            User oldUser = userRepo.getByID(userId);
+            newUser.setRoleList(oldUser.getRoleList());
+            newUser.setGender(oldUser.getGender());
+            userRepo.saveUser(newUser);
+        }catch (UserNotExistException e){   //本站不存在该用户,是未同步信息的新用户,初始化角色
+            User user = userInfo.toUser();
+            List<Role> roles = new ArrayList<>();
+            roles.add(userRepo.getRole("generalUser"));
+            user.setRoleList(roles);
+            userRepo.saveUser(user);
+        }
+        return userRepo.getByID(userId);
+    }
 }

+ 20 - 0
site/src/main/java/com/mooctest/crowd/site/anticorruption/impl/data/UserInfo.java

@@ -1,7 +1,11 @@
 package com.mooctest.crowd.site.anticorruption.impl.data;
 
+import com.mooctest.crowd.domain.domainobject.User;
+import com.mooctest.crowd.domain.factory.UserFactory;
 import lombok.Data;
 
+import java.sql.Timestamp;
+
 /**
  * @author: Diors.Po
  * @Email: 171256175@qq.com
@@ -22,4 +26,20 @@ public class UserInfo {
     private Boolean manualCheckValid;
     private Integer availability;
     private Long integral;
+
+    public User toUser(){
+        User user = UserFactory.createUser();
+        user.setId(this.id);
+        user.setName(name);
+        user.setUserName(name);
+        user.setMobile(mobile);
+        user.setPassword(password);
+        user.setCity(city);
+        user.setProvince(province);
+        user.setPhotoUrl(photoUrl);
+        user.setCreateTime(new Timestamp(createTime));
+        user.setIsAvailable(availability);
+        user.setIsDeleted(0);
+        return user;
+    }
 }

+ 7 - 0
site/src/main/java/com/mooctest/crowd/site/command/ApplyAgencyAuthCommand.java

@@ -6,6 +6,7 @@ import lombok.Data;
 import org.springframework.beans.BeanUtils;
 
 import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
 
 /**
  * @author: Diors.Po
@@ -15,8 +16,14 @@ import javax.validation.constraints.NotNull;
 @Data
 public class ApplyAgencyAuthCommand {
 
+    @NotNull(message = "邮箱不可为空")
+    @Pattern(regexp = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$", message = "邮箱非法")
+    private String email;
+
     @NotNull(message = "手机号不可为空")
+    @Pattern(regexp = "^1[3|4|5|7|8][0-9]\\d{4,8}$", message = "手机号非法")
     private String mobile;
+
     @NotNull(message = "机构名称不可为空")
     private String evaluationAgencyName;
     @NotNull(message = "银行卡号不可为空")

+ 39 - 6
site/src/main/java/com/mooctest/crowd/site/controller/AgencyController.java

@@ -1,13 +1,15 @@
 package com.mooctest.crowd.site.controller;
 
+import com.mooctest.crowd.domain.exception.BaseException;
 import com.mooctest.crowd.site.command.ApplyAgencyAuthCommand;
 import com.mooctest.crowd.site.data.dto.UserDTO;
 import com.mooctest.crowd.site.service.AgencyService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
 
 /**
  * @author: Diors.Po
@@ -21,8 +23,39 @@ public class AgencyController {
     @Autowired
     private AgencyService agencyService;
 
-    @RequestMapping(value = "greenChannel/agency", method = RequestMethod.POST)
-    public UserDTO generateAgency(@RequestBody ApplyAgencyAuthCommand command){
+    /**
+     * 绿色通道:未登录情况直接录入认证信息,生成用户和评测机构信息
+     * @param command
+     * @return
+     */
+    @RequestMapping(value = "/greenChannel/agency", method = RequestMethod.POST)
+    public UserDTO generateAgency(@RequestBody @Validated ApplyAgencyAuthCommand command, BindingResult result){
+        if (result.hasErrors())
+            throw new BaseException(result.getFieldError().getDefaultMessage());
         return agencyService.generateAgency(command);
     }
+
+    /**
+     * 申请认证为机构
+     * @param userId
+     * @param command
+     * @return
+     */
+    @RequestMapping(value = "/user/{userId}/agency", method = RequestMethod.POST)
+    public UserDTO authAgency(@PathVariable("userId") Long userId, @RequestBody ApplyAgencyAuthCommand command){
+        return agencyService.applyAgency(userId, command);
+    }
+
+    /**
+     * 审核认证请求(修改认证申请的状态)
+     * @param userId
+     * @param status
+     * @return
+     */
+    @RequestMapping(value = "/user/{userId}/agency/status/{status}", method = RequestMethod.PUT)
+    public UserDTO checkAuth(@PathVariable("userId") Long userId, @PathVariable("status") Integer status){
+        if (status > 1 || status < -1)
+            throw new BaseException("错误的状态信息,无法更新认证状态为所选状态");
+        return agencyService.updateAgencyStatus(userId, status);
+    }
 }

+ 1 - 1
site/src/main/java/com/mooctest/crowd/site/controller/CommonController.java

@@ -1 +1 @@
-package com.mooctest.crowd.site.controller;

import com.mooctest.crowd.site.data.dto.IndexDTO;
import com.mooctest.crowd.site.data.dto.MyCrowdDTO;
import com.mooctest.crowd.site.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: xuexb
 * @Date: 2019.7.22 16:51
 */
@RestController
@RequestMapping("/api/common")
public class CommonController {

    @Autowired
    private CommonService commonService;

    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public IndexDTO index(){
        return commonService.getIndexInfo();
    }

    @RequestMapping(value = "/mycrowd/{userId}", method = RequestMethod.GET)
    public MyCrowdDTO mycrowd(@PathVariable("userId") Long userId){
       return commonService.getPersonCrowd(userId);
    }

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String hello() {
        return "Hello, Spring Boot!";
    }
}
+package com.mooctest.crowd.site.controller;

import com.mooctest.crowd.domain.domainobject.User;
import com.mooctest.crowd.domain.exception.UnauthorizedException;
import com.mooctest.crowd.site.anticorruption.UserAntiCorruption;
import com.mooctest.crowd.site.data.dto.IndexDTO;
import com.mooctest.crowd.site.data.dto.MyCrowdDTO;
import com.mooctest.crowd.site.data.dto.UserDTO;
import com.mooctest.crowd.site.mediator.ViewMediator;
import com.mooctest.crowd.site.service.CommonService;
import com.mooctest.crowd.site.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: xuexb
 * @Date: 2019.7.22 16:51
 */
@RestController
@RequestMapping("/api/common")
public class CommonController {

    @Autowired
    private CommonService commonService;

    @Autowired
    private ViewMediator mediator;

    @Autowired
    private UserAntiCorruption userAnti;

    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public IndexDTO index(){
        return commonService.getIndexInfo();
    }

    @RequestMapping(value = "/mycrowd/{userId}", method = RequestMethod.GET)
    public MyCrowdDTO mycrowd(@PathVariable("userId") Long userId){
       return commonService.getPersonCrowd(userId);
    }

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String hello() {
        return "Hello, Spring Boot!";
    }

    @RequestMapping(value = "/currentUser", method = RequestMethod.GET)
    public UserDTO getCurrentUser(HttpServletRequest request){
        if (request.getSession().getAttribute("userId") == null)
            throw new UnauthorizedException();
        Long userId = Long.parseLong((String)request.getSession().getAttribute("userId"));
        User user = userAnti.getUserInfo(userId);
        return mediator.renderUser(user);
    }
}

+ 9 - 9
site/src/main/java/com/mooctest/crowd/site/controller/advice/ExceptionAdvice.java

@@ -19,22 +19,22 @@ public class ExceptionAdvice {
 
     @ExceptionHandler(BaseException.class)
     @ResponseStatus(HttpStatus.BAD_REQUEST)
-    public ResponseMessage handleException(Exception e){
-        log.error("出错!", e);
+    public String handleException(Exception e){
+        log.error("访问出错:"+e.getMessage(), e);
         if (e instanceof AccountNotExistException){
-            return new ResponseMessage(ResponseConstant.FAIL, ResponseConstant.USER_NOT_EXISTS);
+            return ResponseConstant.USER_NOT_EXISTS;
         } else if (e instanceof CrowdTestProjectNotExistException){
-            return new ResponseMessage(ResponseConstant.FAIL, "项目不存在");
+            return "项目不存在";
         } else if (e instanceof CrowdTestTaskNotExistException){
-            return new ResponseMessage(ResponseConstant.FAIL, "任务不存在");
+            return "任务不存在";
         } else if (e instanceof CrowdTestReportNotExistException){
-            return new ResponseMessage(ResponseConstant.FAIL, "报告不存在");
+            return "报告不存在";
         } else if (e instanceof CrowdTestTaskNoPriceException){
-            return new ResponseMessage(ResponseConstant.FAIL, "项目未设置价格");
+            return "项目未设置价格";
         } else if (e instanceof PasswordErrorException){
-            return new ResponseMessage(ResponseConstant.UNAUTH, "密码错误");
+            return "密码错误";
         } else
-            return new ResponseMessage(ResponseConstant.FAIL, e.getMessage());
+            return e.getMessage();
     }
 
     @ExceptionHandler(UnauthorizedException.class)

+ 1 - 0
site/src/main/java/com/mooctest/crowd/site/data/vo/AgencyVO.java

@@ -20,6 +20,7 @@ public class AgencyVO {
     private String abilities;
     private String resources;
     private String agencyPhoto;
+    private Integer isAuthentication;
 
     public AgencyVO(EvaluationAgency agency){
         BeanUtils.copyProperties(agency, this);

+ 2 - 1
site/src/main/java/com/mooctest/crowd/site/data/vo/UserVO.java

@@ -19,7 +19,8 @@ public class UserVO {
     private String name;
     private String userName;
     private String gender;
-    private String mobileNum;
+    private String email;
+    private String mobile;
     private String password;
     private String province;
     private String city;

+ 2 - 1
site/src/main/java/com/mooctest/crowd/site/mediator/ViewMediator.java

@@ -1,6 +1,7 @@
 package com.mooctest.crowd.site.mediator;
 
 import com.mooctest.crowd.domain.domainobject.CrowdTestProject;
+import com.mooctest.crowd.domain.domainobject.User;
 import com.mooctest.crowd.site.command.*;
 import com.mooctest.crowd.site.data.dto.*;
 import com.mooctest.crowd.domain.exception.AccountNotExistException;
@@ -29,6 +30,6 @@ public interface ViewMediator {
 
     TaskDetailsDTO renderTaskDetails(CrowdTestTaskCommand crowdTestTaskCommand);
 
-    UserDTO renderUser(AccountCommand accountCommand);
+    UserDTO renderUser(User user);
 
 }

+ 6 - 2
site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java

@@ -172,7 +172,11 @@ public class WebMediatorImpl implements ViewMediator {
     }
 
     @Override
-    public UserDTO renderUser(AccountCommand accountCommand) {
-        return new UserDTO();
+    public UserDTO renderUser(User user) {
+        UserDTO userDTO = new UserDTO();
+        userDTO.setUserVO(new UserVO(user));
+        if (user.getEvaluationAgency() != null)
+            userDTO.setAgencyVO(new AgencyVO(user.getEvaluationAgency()));
+        return userDTO;
     }
 }

+ 2 - 0
site/src/main/java/com/mooctest/crowd/site/service/AgencyService.java

@@ -12,4 +12,6 @@ public interface AgencyService {
     UserDTO applyAgency(Long userId, ApplyAgencyAuthCommand command);
 
     UserDTO generateAgency(ApplyAgencyAuthCommand command);
+
+    UserDTO updateAgencyStatus(Long userId, Integer status);
 }

+ 33 - 6
site/src/main/java/com/mooctest/crowd/site/service/impl/AgencyServiceImpl.java

@@ -1,18 +1,20 @@
 package com.mooctest.crowd.site.service.impl;
 
-import com.fasterxml.jackson.databind.ser.Serializers;
+import com.mooctest.crowd.domain.domainobject.AuthenticationStatus;
 import com.mooctest.crowd.domain.domainobject.EvaluationAgency;
 import com.mooctest.crowd.domain.domainobject.Role;
 import com.mooctest.crowd.domain.domainobject.User;
 import com.mooctest.crowd.domain.exception.BaseException;
-import com.mooctest.crowd.domain.factory.UserFactory;
+import com.mooctest.crowd.domain.exception.UserNotExistException;
 import com.mooctest.crowd.domain.repository.UserRepo;
 import com.mooctest.crowd.site.anticorruption.UserAntiCorruption;
 import com.mooctest.crowd.site.command.ApplyAgencyAuthCommand;
 import com.mooctest.crowd.site.data.dto.UserDTO;
 import com.mooctest.crowd.site.data.vo.AgencyVO;
 import com.mooctest.crowd.site.data.vo.UserVO;
+import com.mooctest.crowd.site.mediator.ViewMediator;
 import com.mooctest.crowd.site.service.AgencyService;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -24,6 +26,7 @@ import java.util.List;
  * @Email: 171256175@qq.com
  * @date 2019-08-12 01:20
  */
+@Slf4j
 @Service
 public class AgencyServiceImpl implements AgencyService {
 
@@ -33,28 +36,52 @@ public class AgencyServiceImpl implements AgencyService {
     @Autowired
     private UserRepo userRepo;
 
+    @Autowired
+    private ViewMediator mediator;
+
     @Override
     public UserDTO applyAgency(Long userId, ApplyAgencyAuthCommand command) {
-        return null;
+        EvaluationAgency agency = command.toAgency();
+        User user = userRepo.getByID(userId);
+        user.applyAgencyAuthentication(agency);
+        return mediator.renderUser(userRepo.saveUser(user));
     }
 
     @Override
     public UserDTO generateAgency(ApplyAgencyAuthCommand command) {
-        if (userRepo.getByMobileNum(command.getMobile()) != null)
-            throw new BaseException("该电话已存在");
-        User user = userAnti.register(command.getEvaluationAgencyName(), command.getMobile(), command.getMobile());
+        boolean mobileExists = false;
+        try {
+            userRepo.getByMobileNum(command.getMobile());
+            mobileExists = true;
+        }catch (UserNotExistException u){
+            log.info("电话号码不存在,可以生成新用户");
+        }
+        if (mobileExists)
+            throw new BaseException("手机号码已经存在,请直接登录");
+        User user = userAnti.register(command.getEvaluationAgencyName(),command.getEmail(), command.getMobile(), command.getMobile());
         EvaluationAgency agency = command.toAgency();
         List<Role> roles = new ArrayList<>();
         roles.add(userRepo.getRole("evaluationAgency"));
         roles.add(userRepo.getRole("generalUser"));
         user.setRoleList(roles);
         agency.setUserId(user.getId());
+        agency.setIsAuthentication(AuthenticationStatus.isAuthenticated);
         user.setEvaluationAgency(agency);
         user = userRepo.saveUser(user);
         UserDTO userDTO = new UserDTO();
         userDTO.setUserVO(new UserVO(userRepo.getByID(user.getId())));
         userDTO.setAgencyVO(new AgencyVO(userRepo.getByID(user.getId()).getEvaluationAgency()));
         userDTO.getUserVO().setPassword(command.getMobile());
+        userDTO.getUserVO().setEmail(command.getEmail());
         return userDTO;
     }
+
+    @Override
+    public UserDTO updateAgencyStatus(Long userId, Integer status) {
+        User user = userRepo.getByID(userId);
+        if (user.getEvaluationAgency()==null)
+            throw new BaseException("该用户未申请认证机构");
+        user.getEvaluationAgency().setIsAuthentication(status);
+        return mediator.renderUser(userRepo.saveUser(user));
+    }
 }

+ 5 - 4
site/src/test/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImplTest.java

@@ -1,7 +1,9 @@
 package com.mooctest.crowd.site.mediator.impl;
 
 import com.mooctest.crowd.domain.domainobject.Account;
+import com.mooctest.crowd.domain.domainobject.User;
 import com.mooctest.crowd.domain.factory.AccountFactory;
+import com.mooctest.crowd.domain.factory.UserFactory;
 import com.mooctest.crowd.site.command.AccountCommand;
 import com.mooctest.crowd.site.command.CrowdTestReportCommand;
 import com.mooctest.crowd.site.command.CrowdTestTaskCommand;
@@ -52,9 +54,7 @@ public class WebMediatorImplTest {
     public void should_return_index_dto_when_render_index(){
         //arrange
         //action
-        IndexDTO indexDTO = viewMediator.renderIndex();
         //assert
-        assertNotNull(indexDTO);
     }
 
 
@@ -91,9 +91,10 @@ public class WebMediatorImplTest {
     @Test
     public void should_return_user_dto_when_render_user_success(){
         //arrage
-        AccountCommand accountCommand = new AccountCommand();
+        User user = UserFactory.createUser();
+        user.setEvaluationAgency(UserFactory.defaultAgency());
         //action
-        UserDTO userDTO = viewMediator.renderUser(accountCommand);
+        UserDTO userDTO = viewMediator.renderUser(user);
         //assert
         assertNotNull(userDTO);
     }