|
@@ -1,10 +1,7 @@
|
|
|
package com.mooctest.crowd.domain.repository;
|
|
|
|
|
|
import com.mooctest.crowd.domain.dao.*;
|
|
|
-import com.mooctest.crowd.domain.domainobject.EvaluationAgency;
|
|
|
-import com.mooctest.crowd.domain.domainobject.Permission;
|
|
|
-import com.mooctest.crowd.domain.domainobject.Role;
|
|
|
-import com.mooctest.crowd.domain.domainobject.User;
|
|
|
+import com.mooctest.crowd.domain.domainobject.*;
|
|
|
import com.mooctest.crowd.domain.exception.PermissionNotFoundException;
|
|
|
import com.mooctest.crowd.domain.exception.RoleNotFoundException;
|
|
|
import com.mooctest.crowd.domain.exception.UserNotExistException;
|
|
@@ -51,6 +48,11 @@ public class UserRepoTest {
|
|
|
private AgencyAbilityDao agencyAbilityDao;
|
|
|
@Mock
|
|
|
private AgencyResourceDao agencyResourceDao;
|
|
|
+ @Mock
|
|
|
+ private PersonalAuthenticationDao personalAuthenticationDao;
|
|
|
+
|
|
|
+ @Mock
|
|
|
+ private EvaluationAgencyRepo resourceRepo;
|
|
|
|
|
|
private UserPO expectUserPO;
|
|
|
private RolePO expectRolePO;
|
|
@@ -64,6 +66,7 @@ public class UserRepoTest {
|
|
|
private RegionalPO expectRegionalPO;
|
|
|
private EvaluationAgencyAbilityPO evaluationAgencyAbilityPO;
|
|
|
private EvaluationAgencyResourcePO evaluationAgencyResourcePO;
|
|
|
+ private PersonalAuthenticationPO personalAuthenticationPO;
|
|
|
private List<RegionalManagerPO> expectRegionalPOManagerList = new ArrayList<>();
|
|
|
private List<EvaluationAgencyPO> evaluationAgencyPOList = new ArrayList<>();
|
|
|
private List<EvaluationAgencyAbilityPO> evaluationAgencyAbilityPOList = new ArrayList<>();
|
|
@@ -135,6 +138,11 @@ public class UserRepoTest {
|
|
|
evaluationAgencyResourcePO.setTotalNum(10);
|
|
|
evaluationAgencyResourcePO.setAvailableNum(5);
|
|
|
evaluationAgencyResourcePOList.add(evaluationAgencyResourcePO);
|
|
|
+
|
|
|
+ personalAuthenticationPO = new PersonalAuthenticationPO();
|
|
|
+ personalAuthenticationPO.setUserId(expectUserPO.getId());
|
|
|
+ when(personalAuthenticationDao.findByUserIdAndIsDeleted(expectUserPO.getId(),0)).thenReturn(personalAuthenticationPO);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -251,6 +259,22 @@ public class UserRepoTest {
|
|
|
role.setPermissionList(permissionList);
|
|
|
roleList.add(role);
|
|
|
EvaluationAgency evaluationAgency = new EvaluationAgency();
|
|
|
+ evaluationAgency.setId(1L);
|
|
|
+ EvaluationAgencyAbility evaluationAgencyAbility = new EvaluationAgencyAbility();
|
|
|
+ EvaluationAgencyResource evaluationAgencyResource = new EvaluationAgencyResource();
|
|
|
+ List<EvaluationAgencyResource> evaluationAgencyResourceList = new ArrayList<>();
|
|
|
+ List<EvaluationAgencyAbility> evaluationAgencyAbilityList = new ArrayList<>();
|
|
|
+ evaluationAgencyAbility.setId(1L);
|
|
|
+ evaluationAgencyAbility.setEvaluationAgencyId(1L);
|
|
|
+ evaluationAgencyAbilityList.add(evaluationAgencyAbility);
|
|
|
+
|
|
|
+ evaluationAgencyResource.setId(1L);
|
|
|
+ evaluationAgencyResource.setEvaluationAgencyId(1L);
|
|
|
+ evaluationAgencyResourceList.add(evaluationAgencyResource);
|
|
|
+
|
|
|
+ evaluationAgency.setEvaluationAgencyAbilityList(evaluationAgencyAbilityList);
|
|
|
+ evaluationAgency.setEvaluationAgencyResourceList(evaluationAgencyResourceList);
|
|
|
+
|
|
|
User user = new User();
|
|
|
user.setEvaluationAgency(evaluationAgency);
|
|
|
user.setRoleList(roleList);
|
|
@@ -259,6 +283,8 @@ public class UserRepoTest {
|
|
|
|
|
|
when(userDao.save(any(UserPO.class))).thenReturn(expectUserPO);
|
|
|
when(userDao.findById(any(Long.class))).thenReturn(Optional.of(expectUserPO));
|
|
|
+ when(evaluationAgencyDao.save(any(EvaluationAgencyPO.class))).thenReturn(expectEvaluationAgencyPO);
|
|
|
+ when(resourceRepo.saveEvaluationAgencyResource(any())).thenReturn(null);
|
|
|
//action
|
|
|
User resultUser = userRepo.saveUser(user);
|
|
|
//assert
|
|
@@ -273,16 +299,36 @@ public class UserRepoTest {
|
|
|
permissionList.add(permission);
|
|
|
List<Role> roleList = new LinkedList<>();
|
|
|
Role role = new Role();
|
|
|
+ role.setId(1L);
|
|
|
role.setPermissionList(permissionList);
|
|
|
roleList.add(role);
|
|
|
EvaluationAgency evaluationAgency = new EvaluationAgency();
|
|
|
+ evaluationAgency.setId(1L);
|
|
|
+ EvaluationAgencyAbility evaluationAgencyAbility = new EvaluationAgencyAbility();
|
|
|
+ EvaluationAgencyResource evaluationAgencyResource = new EvaluationAgencyResource();
|
|
|
+ List<EvaluationAgencyResource> evaluationAgencyResourceList = new ArrayList<>();
|
|
|
+ List<EvaluationAgencyAbility> evaluationAgencyAbilityList = new ArrayList<>();
|
|
|
+ evaluationAgencyAbility.setId(1L);
|
|
|
+ evaluationAgencyAbility.setEvaluationAgencyId(1L);
|
|
|
+ evaluationAgencyAbilityList.add(evaluationAgencyAbility);
|
|
|
+
|
|
|
+ evaluationAgencyResource.setId(1L);
|
|
|
+ evaluationAgencyResource.setEvaluationAgencyId(1L);
|
|
|
+ evaluationAgencyResourceList.add(evaluationAgencyResource);
|
|
|
+
|
|
|
+ evaluationAgency.setEvaluationAgencyAbilityList(evaluationAgencyAbilityList);
|
|
|
+ evaluationAgency.setEvaluationAgencyResourceList(evaluationAgencyResourceList);
|
|
|
+
|
|
|
User user = new User();
|
|
|
user.setEvaluationAgency(evaluationAgency);
|
|
|
user.setRoleList(null);
|
|
|
+
|
|
|
expectUserPO.setId(0L);
|
|
|
|
|
|
when(userDao.save(any(UserPO.class))).thenReturn(expectUserPO);
|
|
|
when(userDao.findById(any(Long.class))).thenReturn(Optional.of(expectUserPO));
|
|
|
+ when(evaluationAgencyDao.save(any(EvaluationAgencyPO.class))).thenReturn(expectEvaluationAgencyPO);
|
|
|
+ when(resourceRepo.saveEvaluationAgencyResource(any())).thenReturn(null);
|
|
|
//action
|
|
|
User resultUser = userRepo.saveUser(user);
|
|
|
//assert
|