您的位置:首页 > 其它

单元测试:TESTNG和powermock的使用

2017-11-07 09:22 471 查看
pom文件:

<properties>
<testng.version>6.8</testng.version>
<powermock.version>1.6.5</powermock.version>
</properties>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19 </version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-testng</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-core</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>

测试代码:

package com.suning.aimp.core.tx.impl;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.when;

import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;

import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;
import org.testng.IObjectFactory;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.ObjectFactory;
import org.testng.annotations.Test;

import com.suning.aimp.base.entity.BaseEntity;
import com.suning.aimp.core.cache.AttributeMapping2CustNum;
import com.suning.aimp.core.cache.BaseInfoCustRedisManager;
import com.suning.aimp.core.cache.GroupInfoRedisManager;
import com.suning.aimp.core.constants.AliasType;
import com.suning.aimp.core.constants.CardNoState;
import com.suning.aimp.core.constants.CustType;
import com.suning.aimp.core.constants.LockedReason;
import com.suning.aimp.core.constants.UsableStat;
import com.suning.aimp.core.dao.biz.BizDealResultDao;
import com.suning.aimp.core.dao.biz.CustAliasDao;
import com.suning.aimp.core.dao.biz.CustAliasHisDao;
import com.suning.aimp.core.dao.biz.CustCardDao;
import com.suning.aimp.core.entity.biz.AddressInfoEntity;
import com.suning.aimp.core.entity.biz.BaseInfoGroupEntity;
import com.suning.aimp.core.entity.biz.BaseInfoIndividualEntity;
import com.suning.aimp.core.entity.biz.BizDealResultEntity;
import com.suning.aimp.core.entity.biz.CustAliasEntity;
import com.suning.aimp.core.entity.biz.CustCardEntity;
import com.suning.aimp.core.entity.biz.CustLogonPasswordEntity;
import com.suning.aimp.core.entity.biz.CustRegisterEntity;
import com.suning.aimp.core.entity.biz.CustUsableEntity;
import com.suning.aimp.core.entity.biz.InvoiceInfoEntity;
import com.suning.aimp.core.entity.biz.LinkmanInfoGroupEntity;
import com.suning.aimp.core.entity.biz.SocialityInfoEntity;
import com.suning.aimp.core.entity.idx.MobileNumChangeRecordEntity;
import com.suning.aimp.core.service.account.CustAliasService;
import com.suning.aimp.core.service.account.CustCardService;
import com.suning.aimp.core.service.account.CustLogonPasswordService;
import com.suning.aimp.core.service.account.CustRegisterService;
import com.suning.aimp.core.service.account.CustUsableService;
import com.suning.aimp.core.service.account.InfoFullStatService;
import com.suning.aimp.core.service.baseinfo.BaseInfoIndividualService;
import com.suning.aimp.core.service.baseinfo.LinkmanInfoGroupService;
import com.suning.aimp.core.service.common.BackstageOptLogService;
import com.suning.aimp.core.service.idx.AliasCustNumMappingService;
import com.suning.aimp.core.service.idx.MobileNumChangeRecordService;
import com.suning.aimp.core.service.send.SendAisinoInfoService;
import com.suning.aimp.core.service.send.SendCustInfoService;
import com.suning.aimp.core.service.send.SendLevelGrowthInfoService;
import com.suning.aimp.core.service.send.SendMemberDataChangeInfoService;
import com.suning.aimp.core.util.ESBServiceUtils;
import com.suning.aimp.core.util.MobileNumUtil;
import com.suning.aimp.core.util.ScmUtil;
import com.suning.aimp.core.vo.req.CardInfoReq;
import com.suning.aimp.core.vo.req.UpdateCardNoReq;
import com.suning.aimp.core.vo.resp.CardInfoResp;
import com.suning.aimp.core.vo.resp.UpdateCardNoResp;
import com.suning.aimp.intf.dto.GroupFullStatInfo;
import com.suning.aimp.intf.dto.IndividualBaseInfo;
import com.suning.aimp.intf.dto.IndividualFullStatInfo;
import com.suning.aimp.intf.dto.LinkmanInfoGroupInfo;
import com.suning.aimp.intf.req.BaseReq;
import com.suning.aimp.intf.req.alias.DeleteB2CAccountAliasNameReq;
import com.suning.aimp.intf.req.alias.GrabMobileReq;
import com.suning.aimp.intf.req.alias.UpdateCustCardNoReq;
import com.suning.aimp.intf.req.password.login.SetMemberPasswordReq;

/**
*
* 别名事务单元测试
*
* @author 16060834
* @see [相关类/方法](可选)
* @since [产品/模块版本] (可选)
*/
@PrepareForTest({ ScmUtil.class, ESBServiceUtils.class, ContextLoader.class })
@SuppressStaticInitializationFor({ "com.suning.aimp.core.util.ScmUtil" })
@PowerMockIgnore({ "org.springframework.web.* com.suning.aimp.core.processor.*", "com.suning.aimp.core.util.ScmUtil" })
public class MemberAccountAliasInfoTxServiceImplTest {

@InjectMocks
private MemberAccountAliasInfoTxServiceImpl memberAccountAliasInfoTxServiceImpl;

@Mock
private CustAliasService custAliasService;

@Mock
private BaseInfoCustRedisManager baseInfoCustRedisManager;

@Mock
private LinkmanInfoGroupService linkmanInfoGroupService;

@Mock
private GroupInfoRedisManager groupInfoRedisManager;

@Mock
private BaseInfoIndividualService individualBaseInfoService;

@Mock
private BizDealResultDao bizDealResultDao;

@Mock
private InfoFullStatService infoFullStatService;

@Mock
private CustCardService custCardService;

@Mock
private CustRegisterService custRegisterService;

@Mock
private SendLevelGrowthInfoService sendLevelGrowthInfoService;

@Mock
private SendCustInfoService sendCustInfoService;

@Mock
private AttributeMapping2CustNum attributeMapping2CustNum;

@Mock
private CustCardDao custCardDao;

@Mock
private MobileNumUtil mobileNumUtil;

@Mock
private SendAisinoInfoService sendAisinoInfoService;

@Mock
private AliasCustNumMappingService aliasCustNumMappingService;

@Mock
private CustLogonPasswordService custLogonPasswordService;

@Mock
private CustUsableService custUsableService;

@Mock
private CustAliasHisDao custAliasHisDao;

@Mock
private MobileNumChangeRecordService mobileNumChangeRecordService;

@Mock
private BackstageOptLogService backstageOptLogService;

@Mock
private CustAliasDao custAliasDao;

@Mock
private IdxTxServiceImpl idxTxServiceImpl;

@Mock
private SendMemberDataChangeInfoService sendMemberDataChangeInfoService;

@BeforeMethod
public void initMocks() {
MockitoAnnotations.initMocks(this);
}

@ObjectFactory
public IObjectFactory getObjectFactory() {
return new org.powermock.modules.testng.PowerMockObjectFactory();
}

private static final Logger LOGGER = LoggerFactory.getLogger(MemberAccountAliasInfoTxServiceImplTest.class);

@Mock
private ThreadPoolTaskExecutor threadPoolTaskExecutor;

@Mock
private WebApplicationContext webApplicationContext;

@Mock
private AutowireCapableBeanFactory autowiredCapableBeanFactory;

public void callThread() {
PowerMockito.mockStatic(ContextLoader.class);
PowerMockito.when(ContextLoader.getCurrentWebApplicationContext()).thenReturn(webApplicationContext);
Mockito.when(webApplicationContext.getAutowireCapableBeanFactory()).thenReturn(autowiredCapableBeanFactory);
Mockito.doNothing().when(autowiredCapableBeanFactory).autowireBean(anyObject());
}

@Test
public void updateByCustNumAndAliasType() {
CustAliasEntity entity = new CustAliasEntity();
entity.setAliasType(AliasType.ALIAS_MOBILE_NUM);
BaseEntity baseEntity = new BaseEntity();
String methodName = "";
MobileNumChangeRecordEntity mobileNumChangeRecordEntity = null;
CustAliasEntity hisEntity = new CustAliasEntity();
hisEntity.setAliasType("12");
when(custAliasService.updateByCustNumAndAliasType(any(CustAliasEntity.class))).thenReturn(hisEntity);
CustRegisterEntity custRegisterEntity = new CustRegisterEntity();
custRegisterEntity.setCustType(CustType.CUST_TYPE_INDIVIDUAL);
when(baseInfoCustRedisManager.queryCustRegister(anyString())).thenReturn(custRegisterEntity);
BaseInfoIndividualEntity baseInfoIndividualEntity = new BaseInfoIndividualEntity();
when(
individualBaseInfoService.modifyIndividualBaseInfo(anyString(), any(IndividualBaseInfo.class),
any(BaseEntity.class), anyString())).thenReturn(baseInfoIndividualEntity);
doNothing().when(baseInfoCustRedisManager).batchDelBaseInfoFields(anyString(), any(String[].class));
doNothing().when(groupInfoRedisManager).delGroupInfoValues(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
this.callThread();
memberAccountAliasInfoTxServiceImpl.updateByCustNumAndAliasType("1", "1", null, entity, baseEntity, methodName,
mobileNumChangeRecordEntity);
}

@Test
public void updateByCustNumAndAliasType1() {
CustAliasEntity entity = new CustAliasEntity();
entity.setAliasType(AliasType.ALIAS_MOBILE_NUM);
BaseEntity baseEntity = new BaseEntity();
String methodName = "";
MobileNumChangeRecordEntity mobileNumChangeRecordEntity = null;
CustAliasEntity hisEntity = new CustAliasEntity();
hisEntity.setAliasType("12");
when(custAliasService.updateByCustNumAndAliasType(any(CustAliasEntity.class))).thenReturn(hisEntity);
CustRegisterEntity custRegisterEntity = new CustRegisterEntity();
custRegisterEntity.setCustType(CustType.CUST_TYPE_ORGANIZATION);
when(baseInfoCustRedisManager.queryCustRegister(anyString())).thenReturn(custRegisterEntity);
BaseInfoIndividualEntity baseInfoIndividualEntity = new BaseInfoIndividualEntity();
when(
individualBaseInfoService.modifyIndividualBaseInfo(anyString(), any(IndividualBaseInfo.class),
any(BaseEntity.class), anyString())).thenReturn(baseInfoIndividualEntity);
doNothing().when(baseInfoCustRedisManager).batchDelBaseInfoFields(anyString(), any(String[].class));
doNothing().when(groupInfoRedisManager).delGroupInfoValues(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
LinkmanInfoGroupEntity linkmanInfoGroupEntity = new LinkmanInfoGroupEntity();
when(linkmanInfoGroupService.modify(anyString(), any(LinkmanInfoGroupInfo.class), any(BaseEntity.class)))
.thenReturn(linkmanInfoGroupEntity);
this.callThread();
memberAccountAliasInfoTxServiceImpl.updateByCustNumAndAliasType("1", "1", null, entity, baseEntity, methodName,
mobileNumChangeRecordEntity);
}

@Test
public void updateByCustNumAndAliasType2() {
CustAliasEntity entity = new CustAliasEntity();
entity.setAliasType(AliasType.ALIAS_MOBILE_NUM);
BaseEntity baseEntity = new BaseEntity();
String methodName = "";
MobileNumChangeRecordEntity mobileNumChangeRecordEntity = new MobileNumChangeRecordEntity();
mobileNumChangeRecordEntity.setMobileNum("123");
CustAliasEntity hisEntity = new CustAliasEntity();
hisEntity.setAliasType("12");
when(custAliasService.updateByCustNumAndAliasType(any(CustAliasEntity.class))).thenReturn(hisEntity);
CustRegisterEntity custRegisterEntity = new CustRegisterEntity();
custRegisterEntity.setCustType(CustType.CUST_TYPE_ORGANIZATION);
when(baseInfoCustRedisManager.queryCustRegister(anyString())).thenReturn(custRegisterEntity);
BaseInfoIndividualEntity baseInfoIndividualEntity = new BaseInfoIndividualEntity();
when(
individualBaseInfoService.modifyIndividualBaseInfo(anyString(), any(IndividualBaseInfo.class),
any(BaseEntity.class), anyString())).thenReturn(baseInfoIndividualEntity);
doNothing().when(baseInfoCustRedisManager).batchDelBaseInfoFields(anyString(), any(String[].class));
doNothing().when(groupInfoRedisManager).delGroupInfoValues(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
LinkmanInfoGroupEntity linkmanInfoGroupEntity = new LinkmanInfoGroupEntity();
when(linkmanInfoGroupService.modify(anyString(), any(LinkmanInfoGroupInfo.class), any(BaseEntity.class)))
.thenReturn(linkmanInfoGroupEntity);
this.callThread();
memberAccountAliasInfoTxServiceImpl.updateByCustNumAndAliasType("1", "1", null, entity, baseEntity, methodName,
mobileNumChangeRecordEntity);
}

@Test
public void updateByCustNumAndAliasType3() {
CustAliasEntity entity = new CustAliasEntity();
entity.setAliasType(AliasType.ALIAS_MOBILE_NUM);
BaseEntity baseEntity = new BaseEntity();
String methodName = "";
MobileNumChangeRecordEntity mobileNumChangeRecordEntity = null;
CustAliasEntity hisEntity = new CustAliasEntity();
hisEntity.setAliasType("12");
when(custAliasService.updateByCustNumAndAliasType(any(CustAliasEntity.class))).thenReturn(hisEntity);
CustRegisterEntity custRegisterEntity = new CustRegisterEntity();
custRegisterEntity.setCustType(CustType.CUST_TYPE_INDIVIDUAL);
when(baseInfoCustRedisManager.queryCustRegister(anyString())).thenReturn(custRegisterEntity);
BaseInfoIndividualEntity baseInfoIndividualEntity = new BaseInfoIndividualEntity();
when(
individualBaseInfoService.modifyIndividualBaseInfo(anyString(), any(IndividualBaseInfo.class),
any(BaseEntity.class), anyString())).thenReturn(baseInfoIndividualEntity);
doNothing().when(baseInfoCustRedisManager).batchDelBaseInfoFields(anyString(), any(String[].class));
doNothing().when(groupInfoRedisManager).delGroupInfoValues(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
when(attributeMapping2CustNum.checkCustNumAndGetCustType(anyString()))
.thenReturn(CustType.CUST_TYPE_INDIVIDUAL);
when(sendMemberDataChangeInfoService.addSendInfo(anyString(), anyString())).thenReturn(1);
BaseInfoIndividualEntity baseInfoIndividualHisEntity = new BaseInfoIndividualEntity();
baseInfoIndividualHisEntity.setMobileNum("43");
when(
individualBaseInfoService.modifyIndividualBaseInfo(anyString(), any(IndividualBaseInfo.class),
any(BaseEntity.class), anyString())).thenReturn(baseInfoIndividualHisEntity);
this.callThread();
memberAccountAliasInfoTxServiceImpl.updateByCustNumAndAliasType("1", "1", null, entity, baseEntity, methodName,
mobileNumChangeRecordEntity);
entity.setAliasType(AliasType.ALIAS_NICK_NAME);
memberAccountAliasInfoTxServiceImpl.updateByCustNumAndAliasType("1", "1", null, entity, baseEntity, methodName,
mobileNumChangeRecordEntity);
entity.setAliasType(AliasType.ALIAS_USERNAME);
memberAccountAliasInfoTxServiceImpl.updateByCustNumAndAliasType("1", "1", null, entity, baseEntity, methodName,
mobileNumChangeRecordEntity);
}

@Test
public void addByCustNumAndAliasType() {
PowerMockito.mockStatic(ScmUtil.class);
Object[] obj = { "1", "1", "true", "43", "re" };
SetMemberPasswordReq setMemberPasswordReq = null;
BaseEntity baseEntity = new BaseEntity();
CustAliasEntity entity = new CustAliasEntity();
entity.setAliasType(AliasType.ALIAS_MOBILE_NUM);
MobileNumChangeRecordEntity mobileNumChangeRecordEntity = null;
CustRegisterEntity custRegisterEntity = new CustRegisterEntity();
custRegisterEntity.setCustType(CustType.CUST_TYPE_ORGANIZATION);
when(baseInfoCustRedisManager.queryCustRegister(anyString())).thenReturn(custRegisterEntity);
CustCardEntity custCardEntity = new CustCardEntity();
when(baseInfoCustRedisManager.custCardQuery(anyString())).thenReturn(custCardEntity);
LinkmanInfoGroupEntity linkmanInfoGroupEntity = new LinkmanInfoGroupEntity();
when(linkmanInfoGroupService.modify(anyString(), any(LinkmanInfoGroupInfo.class), any(BaseEntity.class)))
.thenReturn(linkmanInfoGroupEntity);
BaseInfoGroupEntity baseInfoGroupEntity = new BaseInfoGroupEntity();
when(baseInfoCustRedisManager.baseInfoGroupQuery(anyString())).thenReturn(baseInfoGroupEntity);
when(linkmanInfoGroupService.queryLinkmanInfoGroupInfo4Redis(anyString())).thenReturn(linkmanInfoGroupEntity);
InvoiceInfoEntity invoiceInfoEntity = new InvoiceInfoEntity();
when(baseInfoCustRedisManager.invoiceInfoQuery(anyString())).thenReturn(invoiceInfoEntity);
when(infoFullStatService.checkRequiredInfoState(any(GroupFullStatInfo.class))).thenReturn("1");
when(custCardService.generatedCardPwd4Rule(anyString(), any(CustCardEntity.class), anyString(), anyString()))
.thenReturn(true);
doNothing().when(custCardService).sendCardPwd(anyString(), any(Boolean.class), anyString(),
any(CustCardEntity.class));
when(infoFullStatService.calcCustInfoFullStat(anyString(), any(CustCardEntity.class))).thenReturn("12");
CustCardEntity hisCustCardEntity = new CustCardEntity();
when(custCardService.modifyCustCard(anyString(), any(CustCardEntity.class), any(BaseEntity.class))).thenReturn(
hisCustCardEntity);
CustRegisterEntity hisCustRegisterEntity = new CustRegisterEntity();
when(custRegisterService.modifyInfoFullStat(anyString(), anyString(), any(BaseEntity.class))).thenReturn(
hisCustRegisterEntity);
when(sendMemberDataChangeInfoService.addSendInfo(anyString(), anyString())).thenReturn(1);
when(sendLevelGrowthInfoService.addSendLevelGrowth(anyString(), anyString())).thenReturn(1);
PowerMockito.when(ScmUtil.isCMFSynData(anyString())).thenReturn(false);
when(sendCustInfoService.addSendInfo(anyString(), anyString())).thenReturn(0);
doNothing().when(baseInfoCustRedisManager).batchDelBaseInfoFields(anyString(), any(String[].class));
doNothing().when(groupInfoRedisManager).delGroupInfoValues(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
this.callThread();
memberAccountAliasInfoTxServiceImpl.addByCustNumAndAliasType(obj, setMemberPasswordReq, baseEntity, entity,
mobileNumChangeRecordEntity);
entity.setAliasType(AliasType.ALIAS_NICK_NAME);
memberAccountAliasInfoTxServiceImpl.addByCustNumAndAliasType(obj, setMemberPasswordReq, baseEntity, entity,
mobileNumChangeRecordEntity);
entity.setAliasType(AliasType.ALIAS_USERNAME);
memberAccountAliasInfoTxServiceImpl.addByCustNumAndAliasType(obj, setMemberPasswordReq, baseEntity, entity,
mobileNumChangeRecordEntity);

}

@Test
public void addByCustNumAndAliasType1() {
PowerMockito.mockStatic(ScmUtil.class);
Object[] obj = { "1", "1", "true", "43", "re" };
SetMemberPasswordReq setMemberPasswordReq = null;
BaseEntity baseEntity = new BaseEntity();
CustAliasEntity entity = new CustAliasEntity();
entity.setAliasType(AliasType.ALIAS_MOBILE_NUM);
MobileNumChangeRecordEntity mobileNumChangeRecordEntity = new MobileNumChangeRecordEntity();
mobileNumChangeRecordEntity.setMobileNum("12");
CustRegisterEntity custRegisterEntity = new CustRegisterEntity();
custRegisterEntity.setCustType(CustType.CUST_TYPE_ORGANIZATION);
when(baseInfoCustRedisManager.queryCustRegister(anyString())).thenReturn(custRegisterEntity);
CustCardEntity custCardEntity = new CustCardEntity();
when(baseInfoCustRedisManager.custCardQuery(anyString())).thenReturn(custCardEntity);
LinkmanInfoGroupEntity linkmanInfoGroupEntity = new LinkmanInfoGroupEntity();
when(linkmanInfoGroupService.modify(anyString(), any(LinkmanInfoGroupInfo.class), any(BaseEntity.class)))
.thenReturn(linkmanInfoGroupEntity);
BaseInfoGroupEntity baseInfoGroupEntity = new BaseInfoGroupEntity();
when(baseInfoCustRedisManager.baseInfoGroupQuery(anyString())).thenReturn(baseInfoGroupEntity);
when(linkmanInfoGroupService.queryLinkmanInfoGroupInfo4Redis(anyString())).thenReturn(linkmanInfoGroupEntity);
InvoiceInfoEntity invoiceInfoEntity = new InvoiceInfoEntity();
when(baseInfoCustRedisManager.invoiceInfoQuery(anyString())).thenReturn(invoiceInfoEntity);
when(infoFullStatService.checkRequiredInfoState(any(GroupFullStatInfo.class))).thenReturn("1");
when(custCardService.generatedCardPwd4Rule(anyString(), any(CustCardEntity.class), anyString(), anyString()))
.thenReturn(true);
doNothing().when(custCardService).sendCardPwd(anyString(), any(Boolean.class), anyString(),
any(CustCardEntity.class));
when(infoFullStatService.calcCustInfoFullStat(anyString(), any(CustCardEntity.class))).thenReturn("12");
CustCardEntity hisCustCardEntity = new CustCardEntity();
when(custCardService.modifyCustCard(anyString(), any(CustCardEntity.class), any(BaseEntity.class))).thenReturn(
hisCustCardEntity);
CustRegisterEntity hisCustRegisterEntity = new CustRegisterEntity();
when(custRegisterService.modifyInfoFullStat(anyString(), anyString(), any(BaseEntity.class))).thenReturn(
hisCustRegisterEntity);
when(sendLevelGrowthInfoService.addSendLevelGrowth(anyString(), anyString())).thenReturn(1);
PowerMockito.when(ScmUtil.isCMFSynData(anyString())).thenReturn(false);
when(sendCustInfoService.addSendInfo(anyString(), anyString())).thenReturn(0);
doNothing().when(baseInfoCustRedisManager).batchDelBaseInfoFields(anyString(), any(String[].class));
doNothing().when(groupInfoRedisManager).delGroupInfoValues(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
this.callThread();
memberAccountAliasInfoTxServiceImpl.addByCustNumAndAliasType(obj, setMemberPasswordReq, baseEntity, entity,
mobileNumChangeRecordEntity);

}

@Test
public void addByCustNumAndAliasType2() {
PowerMockito.mockStatic(ScmUtil.class);
Object[] obj = { "1", "1", "true", "43", "re" };
SetMemberPasswordReq setMemberPasswordReq = null;
BaseEntity baseEntity = new BaseEntity();
CustAliasEntity entity = new CustAliasEntity();
entity.setAliasType(AliasType.ALIAS_MOBILE_NUM);
MobileNumChangeRecordEntity mobileNumChangeRecordEntity = new MobileNumChangeRecordEntity();
mobileNumChangeRecordEntity.setMobileNum("12");
CustRegisterEntity custRegisterEntity = new CustRegisterEntity();
custRegisterEntity.setCustType(CustType.CUST_TYPE_INDIVIDUAL);
when(baseInfoCustRedisManager.queryCustRegister(anyString())).thenReturn(custRegisterEntity);
CustCardEntity custCardEntity = new CustCardEntity();
when(baseInfoCustRedisManager.custCardQuery(anyString())).thenReturn(custCardEntity);
LinkmanInfoGroupEntity linkmanInfoGroupEntity = new LinkmanInfoGroupEntity();
when(linkmanInfoGroupService.modify(anyString(), any(LinkmanInfoGroupInfo.class), any(BaseEntity.class)))
.thenReturn(linkmanInfoGroupEntity);
BaseInfoIndividualEntity baseInfoGroupEntity = new BaseInfoIndividualEntity();
when(baseInfoCustRedisManager.baseInfoIndividualQuery(anyString())).thenReturn(baseInfoGroupEntity);
when(linkmanInfoGroupService.queryLinkmanInfoGroupInfo4Redis(anyString())).thenReturn(linkmanInfoGroupEntity);
InvoiceInfoEntity invoiceInfoEntity = new InvoiceInfoEntity();
when(baseInfoCustRedisManager.invoiceInfoQuery(anyString())).thenReturn(invoiceInfoEntity);
when(infoFullStatService.checkRequiredInfoState(any(GroupFullStatInfo.class))).thenReturn("1");
when(custCardService.generatedCardPwd4Rule(anyString(), any(CustCardEntity.class), anyString(), anyString()))
.thenReturn(true);
doNothing().when(custCardService).sendCardPwd(anyString(), any(Boolean.class), anyString(),
any(CustCardEntity.class));
when(infoFullStatService.calcCustInfoFullStat(anyString(), any(CustCardEntity.class))).thenReturn("12");
CustCardEntity hisCustCardEntity = new CustCardEntity();
when(custCardService.modifyCustCard(anyString(), any(CustCardEntity.class), any(BaseEntity.class))).thenReturn(
hisCustCardEntity);
CustRegisterEntity hisCustRegisterEntity = new CustRegisterEntity();
when(custRegisterService.modifyInfoFullStat(anyString(), anyString(), any(BaseEntity.class))).thenReturn(
hisCustRegisterEntity);
when(sendLevelGrowthInfoService.addSendLevelGrowth(anyString(), anyString())).thenReturn(1);
PowerMockito.when(ScmUtil.isCMFSynData(anyString())).thenReturn(false);
when(sendCustInfoService.addSendInfo(anyString(), anyString())).thenReturn(0);
doNothing().when(baseInfoCustRedisManager).batchDelBaseInfoFields(anyString(), any(String[].class));
doNothing().when(groupInfoRedisManager).delGroupInfoValues(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
this.callThread();
memberAccountAliasInfoTxServiceImpl.addByCustNumAndAliasType(obj, setMemberPasswordReq, baseEntity, entity,
mobileNumChangeRecordEntity);

}

@Test
public void addByCustNumAndAliasType3() {
PowerMockito.mockStatic(ScmUtil.class);
PowerMockito.mockStatic(ESBServiceUtils.class);
Object[] obj = { "1", "1", "true", "43", "re" };
SetMemberPasswordReq setMemberPasswordReq = null;
BaseEntity baseEntity = new BaseEntity();
CustAliasEntity entity = new CustAliasEntity();
entity.setAliasType(AliasType.ALIAS_CARDNO);
entity.setCustAlias("1234");
MobileNumChangeRecordEntity mobileNumChangeRecordEntity = new MobileNumChangeRecordEntity();
mobileNumChangeRecordEntity.setMobileNum("12");
CustRegisterEntity custRegisterEntity = new CustRegisterEntity();
custRegisterEntity.setCustType(CustType.CUST_TYPE_INDIVIDUAL);
when(baseInfoCustRedisManager.queryCustRegister(anyString())).thenReturn(custRegisterEntity);
CustCardEntity custCardEntity = new CustCardEntity();
when(baseInfoCustRedisManager.custCardQuery(anyString())).thenReturn(custCardEntity);
LinkmanInfoGroupEntity linkmanInfoGroupEntity = new LinkmanInfoGroupEntity();
when(linkmanInfoGroupService.modify(anyString(), any(LinkmanInfoGroupInfo.class), any(BaseEntity.class)))
.thenReturn(linkmanInfoGroupEntity);
BaseInfoIndividualEntity baseInfoGroupEntity = new BaseInfoIndividualEntity();
when(baseInfoCustRedisManager.baseInfoIndividualQuery(anyString())).thenReturn(baseInfoGroupEntity);
when(linkmanInfoGroupService.queryLinkmanInfoGroupInfo4Redis(anyString())).thenReturn(linkmanInfoGroupEntity);
InvoiceInfoEntity invoiceInfoEntity = new InvoiceInfoEntity();
when(baseInfoCustRedisManager.invoiceInfoQuery(anyString())).thenReturn(invoiceInfoEntity);
when(infoFullStatService.checkRequiredInfoState(any(GroupFullStatInfo.class))).thenReturn("1");
when(custCardService.generatedCardPwd4Rule(anyString(), any(CustCardEntity.class), anyString(), anyString()))
.thenReturn(true);
doNothing().when(custCardService).sendCardPwd(anyString(), any(Boolean.class), anyString(),
any(CustCardEntity.class));
when(infoFullStatService.calcCustInfoFullStat(anyString(), any(CustCardEntity.class))).thenReturn("12");
CustCardEntity hisCustCardEntity = new CustCardEntity();
when(custCardService.modifyCustCard(anyString(), any(CustCardEntity.class), any(BaseEntity.class))).thenReturn(
hisCustCardEntity);
CustRegisterEntity hisCustRegisterEntity = new CustRegisterEntity();
when(custRegisterService.modifyInfoFullStat(anyString(), anyString(), any(BaseEntity.class))).thenReturn(
hisCustRegisterEntity);
when(sendLevelGrowthInfoService.addSendLevelGrowth(anyString(), anyString())).thenReturn(1);
PowerMockito.when(ScmUtil.isCMFSynData(anyString())).thenReturn(false);
when(sendCustInfoService.addSendInfo(anyString(), anyString())).thenReturn(0);
doNothing().when(baseInfoCustRedisManager).batchDelBaseInfoFields(anyString(), any(String[].class));
doNothing().when(groupInfoRedisManager).delGroupInfoValues(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
CardInfoResp resp = new CardInfoResp();
resp.setCardStat(CardNoState.CARDNO_STATE_SITE_USED);
PowerMockito.when(ESBServiceUtils.getCardByCardNo(any(CardInfoReq.class))).thenReturn(resp);
UpdateCardNoResp updateCardNoResp = new UpdateCardNoResp();
PowerMockito.when(ESBServiceUtils.updateCardStat(any(UpdateCardNoReq.class))).thenReturn(updateCardNoResp);
when(attributeMapping2CustNum.cardNo2CustNum(anyString())).thenReturn(null);
when(custCardDao.insert(any(CustCardEntity.class))).thenReturn(0);
this.callThread();
memberAccountAliasInfoTxServiceImpl.addByCustNumAndAliasType(obj, setMemberPasswordReq, baseEntity, entity,
mobileNumChangeRecordEntity);

}

@Test
public void addByCustNumAndAliasType4() {
PowerMockito.mockStatic(ScmUtil.class);
Object[] obj = { "1", "1", "true", "43", "re" };
SetMemberPasswordReq setMemberPasswordReq = null;
BaseEntity baseEntity = new BaseEntity();
CustAliasEntity entity = new CustAliasEntity();
entity.setAliasType(AliasType.ALIAS_EMAIL);
MobileNumChangeRecordEntity mobileNumChangeRecordEntity = null;
CustRegisterEntity custRegisterEntity = new CustRegisterEntity();
custRegisterEntity.setCustType(CustType.CUST_TYPE_ORGANIZATION);
when(baseInfoCustRedisManager.queryCustRegister(anyString())).thenReturn(custRegisterEntity);
CustCardEntity custCardEntity = new CustCardEntity();
when(baseInfoCustRedisManager.custCardQuery(anyString())).thenReturn(custCardEntity);
LinkmanInfoGroupEntity linkmanInfoGroupEntity = new LinkmanInfoGroupEntity();
when(linkmanInfoGroupService.modify(anyString(), any(LinkmanInfoGroupInfo.class), any(BaseEntity.class)))
.thenReturn(linkmanInfoGroupEntity);
BaseInfoGroupEntity baseInfoGroupEntity = new BaseInfoGroupEntity();
when(baseInfoCustRedisManager.baseInfoGroupQuery(anyString())).thenReturn(baseInfoGroupEntity);
when(linkmanInfoGroupService.queryLinkmanInfoGroupInfo4Redis(anyString())).thenReturn(linkmanInfoGroupEntity);
InvoiceInfoEntity invoiceInfoEntity = new InvoiceInfoEntity();
when(baseInfoCustRedisManager.invoiceInfoQuery(anyString())).thenReturn(invoiceInfoEntity);
when(infoFullStatService.checkRequiredInfoState(any(GroupFullStatInfo.class))).thenReturn("1");
when(custCardService.generatedCardPwd4Rule(anyString(), any(CustCardEntity.class), anyString(), anyString()))
.thenReturn(true);
doNothing().when(custCardService).sendCardPwd(anyString(), any(Boolean.class), anyString(),
any(CustCardEntity.class));
when(infoFullStatService.calcCustInfoFullStat(anyString(), any(CustCardEntity.class))).thenReturn("12");
CustCardEntity hisCustCardEntity = new CustCardEntity();
when(custCardService.modifyCustCard(anyString(), any(CustCardEntity.class), any(BaseEntity.class))).thenReturn(
hisCustCardEntity);
CustRegisterEntity hisCustRegisterEntity = new CustRegisterEntity();
when(custRegisterService.modifyInfoFullStat(anyString(), anyString(), any(BaseEntity.class))).thenReturn(
hisCustRegisterEntity);
when(sendLevelGrowthInfoService.addSendLevelGrowth(anyString(), anyString())).thenReturn(1);
PowerMockito.when(ScmUtil.isCMFSynData(anyString())).thenReturn(false);
when(sendCustInfoService.addSendInfo(anyString(), anyString())).thenReturn(0);
doNothing().when(baseInfoCustRedisManager).batchDelBaseInfoFields(anyString(), any(String[].class));
doNothing().when(groupInfoRedisManager).delGroupInfoValues(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
when(attributeMapping2CustNum.checkCustNumAndGetCustType(anyString()))
.thenReturn(CustType.CUST_TYPE_INDIVIDUAL);
this.callThread();
memberAccountAliasInfoTxServiceImpl.addByCustNumAndAliasType(obj, setMemberPasswordReq, baseEntity, entity,
mobileNumChangeRecordEntity);

}

@Test
public void addByCustNumAndAliasType5() {
PowerMockito.mockStatic(ScmUtil.class);
Object[] obj = { "1", "1", "true", "43", "re" };
SetMemberPasswordReq setMemberPasswordReq = null;
BaseEntity baseEntity = new BaseEntity();
CustAliasEntity entity = new CustAliasEntity();
entity.setAliasType(AliasType.ALIAS_MOBILE_NUM);
MobileNumChangeRecordEntity mobileNumChangeRecordEntity = null;
CustRegisterEntity custRegisterEntity = new CustRegisterEntity();
custRegisterEntity.setCustType(CustType.CUST_TYPE_ORGANIZATION);
when(baseInfoCustRedisManager.queryCustRegister(anyString())).thenReturn(custRegisterEntity);
CustCardEntity custCardEntity = new CustCardEntity();
when(baseInfoCustRedisManager.custCardQuery(anyString())).thenReturn(custCardEntity);
LinkmanInfoGroupEntity linkmanInfoGroupEntity = new LinkmanInfoGroupEntity();
when(linkmanInfoGroupService.modify(anyString(), any(LinkmanInfoGroupInfo.class), any(BaseEntity.class)))
.thenReturn(linkmanInfoGroupEntity);
BaseInfoGroupEntity baseInfoGroupEntity = new BaseInfoGroupEntity();
when(baseInfoCustRedisManager.baseInfoGroupQuery(anyString())).thenReturn(baseInfoGroupEntity);
when(linkmanInfoGroupService.queryLinkmanInfoGroupInfo4Redis(anyString())).thenReturn(linkmanInfoGroupEntity);
InvoiceInfoEntity invoiceInfoEntity = new InvoiceInfoEntity();
when(baseInfoCustRedisManager.invoiceInfoQuery(anyString())).thenReturn(invoiceInfoEntity);
when(infoFullStatService.checkRequiredInfoState(any(GroupFullStatInfo.class))).thenReturn("1");
when(custCardService.generatedCardPwd4Rule(anyString(), any(CustCardEntity.class), anyString(), anyString()))
.thenReturn(true);
doNothing().when(custCardService).sendCardPwd(anyString(), any(Boolean.class), anyString(),
any(CustCardEntity.class));
when(infoFullStatService.calcCustInfoFullStat(anyString(), any(CustCardEntity.class))).thenReturn("12");
CustCardEntity hisCustCardEntity = new CustCardEntity();
when(custCardService.modifyCustCard(anyString(), any(CustCardEntity.class), any(BaseEntity.class))).thenReturn(
hisCustCardEntity);
CustRegisterEntity hisCustRegisterEntity = new CustRegisterEntity();
when(custRegisterService.modifyInfoFullStat(anyString(), anyString(), any(BaseEntity.class))).thenReturn(
hisCustRegisterEntity);
when(sendLevelGrowthInfoService.addSendLevelGrowth(anyString(), anyString())).thenReturn(1);
PowerMockito.when(ScmUtil.isCMFSynData(anyString())).thenReturn(false);
when(sendCustInfoService.addSendInfo(anyString(), anyString())).thenReturn(0);
doNothing().when(baseInfoCustRedisManager).batchDelBaseInfoFields(anyString(), any(String[].class));
doNothing().when(groupInfoRedisManager).delGroupInfoValues(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
when(attributeMapping2CustNum.checkCustNumAndGetCustType(anyString()))
.thenReturn(CustType.CUST_TYPE_INDIVIDUAL);
this.callThread();
memberAccountAliasInfoTxServiceImpl.addByCustNumAndAliasType(obj, setMemberPasswordReq, baseEntity, entity,
mobileNumChangeRecordEntity);

}

@Test
public void setIndividualFullStatInfo() {
IndividualFullStatInfo individualFullStatInfo = new IndividualFullStatInfo();
BaseInfoIndividualEntity baseInfoIndividualEntity = new BaseInfoIndividualEntity();
CustCardEntity custCardEntity = new CustCardEntity();
SocialityInfoEntity socialityInfoEntity = new SocialityInfoEntity();
AddressInfoEntity addressInfoEntity = new AddressInfoEntity();
String mobile = "1321";
memberAccountAliasInfoTxServiceImpl.setIndividualFullStatInfo(individualFullStatInfo, baseInfoIndividualEntity,
custCardEntity, socialityInfoEntity, addressInfoEntity, mobile);
;
}

@Test
public void updateCardPasswordWrongCheckTimes() {
String custNum = "2123";
Integer seqNo = 1;
BaseReq baseReq = new BaseReq();
when(custCardDao.updateCardPasswordWrongCheckTimes(anyString(), any(BaseEntity.class))).thenReturn(0);
memberAccountAliasInfoTxServiceImpl.updateCardPasswordWrongCheckTimes(custNum, seqNo, baseReq);
}

@Test
public void deleteB2CAccountAliasName() {
String mobile = "1";
String email = "131314141@qq.com";
DeleteB2CAccountAliasNameReq req = new DeleteB2CAccountAliasNameReq();
req.setAliasType(AliasType.ALIAS_MOBILE_NUM);
CustRegisterEntity custRegisterEntity = new CustRegisterEntity();
custRegisterEntity.setCustType(CustType.CUST_TYPE_INDIVIDUAL);
when(baseInfoCustRedisManager.queryCustRegister(anyString())).thenReturn(custRegisterEntity);
when(mobileNumUtil.canUnBind(anyString(), Mockito.anyString())).thenReturn(true);
CustAliasEntity hisEntity = new CustAliasEntity();
when(custAliasService.updateByCustNumAndAliasType(any(CustAliasEntity.class))).thenReturn(hisEntity);
CustAliasEntity hisCustAliasEntity = new CustAliasEntity();
when(custAliasService.queryCustAlias(anyString(), anyString())).thenReturn(hisCustAliasEntity);
when(custAliasService.deleteByCustNumAndAliasType(anyString(), anyString())).thenReturn(1);
when(sendCustInfoService.addSendInfo(anyString(), anyString())).thenReturn(0);
doNothing().when(baseInfoCustRedisManager).delBaseInfoValues(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
when(sendMemberDataChangeInfoService.addSendInfo(anyString(), anyString())).thenReturn(1);
this.callThread();
memberAccountAliasInfoTxServiceImpl.deleteB2CAccountAliasName(mobile, email, req);
req.setAliasType(AliasType.ALIAS_NICK_NAME);
memberAccountAliasInfoTxServiceImpl.deleteB2CAccountAliasName(mobile, email, req);
req.setAliasType(AliasType.ALIAS_USERNAME);
memberAccountAliasInfoTxServiceImpl.deleteB2CAccountAliasName(mobile, email, req);

}

@Test
public void deleteB2CAccountAliasName2() {
String mobile = "1";
String email = "131314141@qq.com";
DeleteB2CAccountAliasNameReq req = new DeleteB2CAccountAliasNameReq();
req.setAliasType(AliasType.ALIAS_EMAIL);
CustRegisterEntity custRegisterEntity = new CustRegisterEntity();
custRegisterEntity.setCustType(CustType.CUST_TYPE_INDIVIDUAL);
when(baseInfoCustRedisManager.queryCustRegister(anyString())).thenReturn(custRegisterEntity);
when(mobileNumUtil.canUnBind(anyString(), Mockito.anyString())).thenReturn(true);
CustAliasEntity hisEntity = new CustAliasEntity();
when(custAliasService.updateByCustNumAndAliasType(any(CustAliasEntity.class))).thenReturn(hisEntity);
CustAliasEntity hisCustAliasEntity = new CustAliasEntity();
when(custAliasService.queryCustAlias(anyString(), anyString())).thenReturn(hisCustAliasEntity);
when(custAliasService.deleteByCustNumAndAliasType(anyString(), anyString())).thenReturn(1);
when(sendCustInfoService.addSendInfo(anyString(), anyString())).thenReturn(0);
doNothing().when(baseInfoCustRedisManager).delBaseInfoValues(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
this.callThread();
memberAccountAliasInfoTxServiceImpl.deleteB2CAccountAliasName(mobile, email, req);

}

@Test
public void deleteB2CAccountAliasName3() {
String mobile = "1";
String email = "131314141@qq.com";
DeleteB2CAccountAliasNameReq req = new DeleteB2CAccountAliasNameReq();
req.setAliasType(AliasType.ALIAS_MOBILE_NUM);
req.setExtField1("FRF");
CustRegisterEntity custRegisterEntity = new CustRegisterEntity();
custRegisterEntity.setCustType(CustType.CUST_TYPE_ORGANIZATION);
when(baseInfoCustRedisManager.queryCustRegister(anyString())).thenReturn(custRegisterEntity);
when(mobileNumUtil.canUnBind(anyString(), Mockito.anyString())).thenReturn(false);
CustAliasEntity hisEntity = new CustAliasEntity();
when(custAliasService.updateByCustNumAndAliasType(any(CustAliasEntity.class))).thenReturn(hisEntity);
CustAliasEntity hisCustAliasEntity = new CustAliasEntity();
when(custAliasService.queryCustAlias(anyString(), anyString())).thenReturn(hisCustAliasEntity);
when(custAliasService.deleteByCustNumAndAliasType(anyString(), anyString())).thenReturn(1);
when(sendCustInfoService.addSendInfo(anyString(), anyString())).thenReturn(0);
doNothing().when(baseInfoCustRedisManager).delBaseInfoValues(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
this.callThread();
try {
memberAccountAliasInfoTxServiceImpl.deleteB2CAccountAliasName(mobile, email, req);
} catch (Exception e) {
LOGGER.info("unit test error", e);
}

}

@Test
public void deleteB2CAccountAliasName4() {
String mobile = "1";
String email = "131314141@qq.com";
DeleteB2CAccountAliasNameReq req = new DeleteB2CAccountAliasNameReq();
req.setAliasType(AliasType.ALIAS_MOBILE_NUM);
req.setExtField1("FRF");
CustRegisterEntity custRegisterEntity = new CustRegisterEntity();
custRegisterEntity.setCustType(CustType.CUST_TYPE_ORGANIZATION);
when(baseInfoCustRedisManager.queryCustRegister(anyString())).thenReturn(custRegisterEntity);
when(mobileNumUtil.canUnBind(anyString(), Mockito.anyString())).thenReturn(true);
CustAliasEntity hisEntity = new CustAliasEntity();
when(custAliasService.updateByCustNumAndAliasType(any(CustAliasEntity.class))).thenReturn(hisEntity);
CustAliasEntity hisCustAliasEntity = new CustAliasEntity();
when(custAliasService.queryCustAlias(anyString(), anyString())).thenReturn(hisCustAliasEntity);
when(custAliasService.deleteByCustNumAndAliasType(anyString(), anyString())).thenReturn(1);
when(sendCustInfoService.addSendInfo(anyString(), anyString())).thenReturn(0);
doNothing().when(baseInfoCustRedisManager).delBaseInfoValues(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
this.callThread();
try {
memberAccountAliasInfoTxServiceImpl.deleteB2CAccountAliasName(mobile, email, req);
} catch (Exception e) {
LOGGER.info("unit test error", e);
}

}

@Test
public void grabMobile() {
CustAliasEntity entity = new CustAliasEntity();
entity.setAliasType(AliasType.ALIAS_MOBILE_NUM);
MobileNumChangeRecordEntity mobileNumChangeRecordEntity = new MobileNumChangeRecordEntity();
mobileNumChangeRecordEntity.setMobileNum("123");
CustAliasEntity hisEntity = new CustAliasEntity();
hisEntity.setAliasType("12");
when(custAliasService.updateByCustNumAndAliasType(any(CustAliasEntity.class))).thenReturn(hisEntity);
CustRegisterEntity custRegisterEntity = new CustRegisterEntity();
custRegisterEntity.setCustType(CustType.CUST_TYPE_ORGANIZATION);
when(baseInfoCustRedisManager.queryCustRegister(anyString())).thenReturn(custRegisterEntity);
BaseInfoIndividualEntity baseInfoIndividualEntity = new BaseInfoIndividualEntity();
when(
individualBaseInfoService.modifyIndividualBaseInfo(anyString(), any(IndividualBaseInfo.class),
any(BaseEntity.class), anyString())).thenReturn(baseInfoIndividualEntity);
doNothing().when(baseInfoCustRedisManager).batchDelBaseInfoFields(anyString(), any(String[].class));
doNothing().when(groupInfoRedisManager).delGroupInfoValues(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
LinkmanInfoGroupEntity linkmanInfoGroupEntity = new LinkmanInfoGroupEntity();
when(linkmanInfoGroupService.modify(anyString(), any(LinkmanInfoGroupInfo.class), any(BaseEntity.class)))
.thenReturn(linkmanInfoGroupEntity);
when(attributeMapping2CustNum.bindingTel2CustNum(anyString())).thenReturn("1");
when(mobileNumUtil.canBind(anyString(), Mockito.anyString())).thenReturn(true);
when(custAliasService.deleteByCustNumAndAliasType(anyString(), anyString())).thenReturn(0);
CustAliasEntity e = new CustAliasEntity();
when(custAliasService.queryCustAlias(anyString(), anyString())).thenReturn(e);
doNothing().when(baseInfoCustRedisManager).delBaseInfoValues(anyString(), any(String[].class));
CustAliasEntity custAliasEntity = new CustAliasEntity();
when(baseInfoCustRedisManager.custAliasQuery(anyString(), anyString())).thenReturn(custAliasEntity);
this.callThread();

GrabMobileReq req = new GrabMobileReq();
memberAccountAliasInfoTxServiceImpl.dealGrabMember(req, null, "173000000020");
}

@Test
public void grabMobile1() {
CustAliasEntity entity = new CustAliasEntity();
entity.setAliasType(AliasType.ALIAS_MOBILE_NUM);
MobileNumChangeRecordEntity mobileNumChangeRecordEntity = new MobileNumChangeRecordEntity();
mobileNumChangeRecordEntity.setMobileNum("123");
CustAliasEntity hisEntity = new CustAliasEntity();
hisEntity.setAliasType("12");
when(custAliasService.updateByCustNumAndAliasType(any(CustAliasEntity.class))).thenReturn(hisEntity);
CustRegisterEntity custRegisterEntity = new CustRegisterEntity();
custRegisterEntity.setCustType(CustType.CUST_TYPE_ORGANIZATION);
when(baseInfoCustRedisManager.queryCustRegister(anyString())).thenReturn(custRegisterEntity);
BaseInfoIndividualEntity baseInfoIndividualEntity = new BaseInfoIndividualEntity();
when(
individualBaseInfoService.modifyIndividualBaseInfo(anyString(), any(IndividualBaseInfo.class),
any(BaseEntity.class), anyString())).thenReturn(baseInfoIndividualEntity);
doNothing().when(baseInfoCustRedisManager).batchDelBaseInfoFields(anyString(), any(String[].class));
doNothing().when(groupInfoRedisManager).delGroupInfoValues(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
LinkmanInfoGroupEntity linkmanInfoGroupEntity = new LinkmanInfoGroupEntity();
when(linkmanInfoGroupService.modify(anyString(), any(LinkmanInfoGroupInfo.class), any(BaseEntity.class)))
.thenReturn(linkmanInfoGroupEntity);
when(attributeMapping2CustNum.bindingTel2CustNum(anyString())).thenReturn("1");
when(mobileNumUtil.canBind(anyString(), Mockito.anyString())).thenReturn(true);
when(custAliasService.deleteByCustNumAndAliasType(anyString(), anyString())).thenReturn(0);
CustAliasEntity e = new CustAliasEntity();
when(custAliasService.queryCustAlias(anyString(), anyString())).thenReturn(e);
doNothing().when(baseInfoCustRedisManager).delBaseInfoValues(anyString(), any(String[].class));
when(baseInfoCustRedisManager.custAliasQuery(anyString(), anyString())).thenReturn(null);
when(sendLevelGrowthInfoService.addSendLevelGrowth(anyString(), anyString())).thenReturn(1);
this.callThread();

GrabMobileReq req = new GrabMobileReq();
memberAccountAliasInfoTxServiceImpl.dealGrabMember(req, null, "173000000020");
}

@Test
public void updateCardNo() {
PowerMockito.mockStatic(ScmUtil.class);
UpdateCustCardNoReq req = new UpdateCustCardNoReq();
String custNum = "1";
String oldCardNo = "2";
CardInfoResp newCardNoInfo = new CardInfoResp();
boolean sendAisionFlag = true;
when(custCardService.modifyCustCard(anyString(), any(CardInfoResp.class), any(BaseEntity.class))).thenReturn(
null);
when(custAliasService.modifyCustAliasByType(anyString(), anyString(), anyString(), any(BaseEntity.class)))
.thenReturn(null);
PowerMockito.when(ScmUtil.isCMFSynData(anyString())).thenReturn(false);
when(sendAisinoInfoService.addAisionInfo(anyString(), anyString())).thenReturn(0);
doNothing().when(baseInfoCustRedisManager).batchDelBaseInfoFields(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
this.callThread();
memberAccountAliasInfoTxServiceImpl.updateCardNo(req, custNum, oldCardNo, newCardNoInfo, sendAisionFlag);
}

@Test
public void updateCardNo1() {
PowerMockito.mockStatic(ScmUtil.class);
UpdateCustCardNoReq req = new UpdateCustCardNoReq();
String custNum = "1";
String oldCardNo = "2";
CardInfoResp newCardNoInfo = new CardInfoResp();
newCardNoInfo.setCardNo("31");
boolean sendAisionFlag = true;
when(custCardService.modifyCustCard(anyString(), any(CardInfoResp.class), any(BaseEntity.class))).thenReturn(
null);
when(custAliasService.modifyCustAliasByType(anyString(), anyString(), anyString(), any(BaseEntity.class)))
.thenReturn(null);
PowerMockito.when(ScmUtil.isCMFSynData(anyString())).thenReturn(false);
when(sendAisinoInfoService.addAisionInfo(anyString(), anyString())).thenReturn(0);
doNothing().when(baseInfoCustRedisManager).batchDelBaseInfoFields(anyString(), any(String[].class));
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
this.callThread();
memberAccountAliasInfoTxServiceImpl.updateCardNo(req, custNum, oldCardNo, newCardNoInfo, sendAisionFlag);
}

@Test
public void getBaseInfoCustEnumaIndex() {
memberAccountAliasInfoTxServiceImpl.getBaseInfoCustEnumaIndex(AliasType.ALIAS_MOBILE_NUM);
memberAccountAliasInfoTxServiceImpl.getBaseInfoCustEnumaIndex(AliasType.ALIAS_EMAIL);
memberAccountAliasInfoTxServiceImpl.getBaseInfoCustEnumaIndex(AliasType.ALIAS_USERNAME);
memberAccountAliasInfoTxServiceImpl.getBaseInfoCustEnumaIndex(AliasType.ALIAS_NICK_NAME);
memberAccountAliasInfoTxServiceImpl.getBaseInfoCustEnumaIndex(AliasType.ALIAS_CARDNO);
}

@Test
public void setB2CPassword() {
String passwordDecrypt = "1";
SetMemberPasswordReq setMemberPasswordReq = new SetMemberPasswordReq();
CustUsableEntity custUsableEntity = new CustUsableEntity();
when(baseInfoCustRedisManager.custUsableQuery(anyString())).thenReturn(custUsableEntity);
when(custLogonPasswordService.queryCustLogonPasswordInfoByCustNum(anyString())).thenReturn(null);
when(custLogonPasswordService.createLoginPassword(anyString(), anyString(), any(SetMemberPasswordReq.class)))
.thenReturn(0);
doNothing().when(baseInfoCustRedisManager).delBaseInfoValues(anyString(), any(String[].class));
this.callThread();
memberAccountAliasInfoTxServiceImpl.setB2CPassword(passwordDecrypt, setMemberPasswordReq);
}

@Test
public void setB2CPassword1() {
String passwordDecrypt = "1";
SetMemberPasswordReq setMemberPasswordReq = new SetMemberPasswordReq();
CustUsableEntity custUsableEntity = new CustUsableEntity();
custUsableEntity.setUsableStat(UsableStat.USABLE_STAT_LOCKED);
custUsableEntity.setUsableStatUpdReason(LockedReason.USABLE_STAT_AUTO_LOCKED);
when(baseInfoCustRedisManager.custUsableQuery(anyString())).thenReturn(custUsableEntity);
when(custLogonPasswordService.queryCustLogonPasswordInfoByCustNum(anyString())).thenReturn(null);
when(custLogonPasswordService.createLoginPassword(anyString(), anyString(), any(SetMemberPasswordReq.class)))
.thenReturn(0);
doNothing().when(baseInfoCustRedisManager).delBaseInfoValues(anyString(), any(String[].class));
when(custUsableService.unLockCust4SysLockAuto(anyString(), any(Integer.class), any(BaseReq.class))).thenReturn(
null);
when(custCardDao.selectCustCardInfoByCustNum(anyString())).thenReturn(null);
this.callThread();
memberAccountAliasInfoTxServiceImpl.setB2CPassword(passwordDecrypt, setMemberPasswordReq);
}

@Test
public void setB2CPassword2() {
String passwordDecrypt = "1";
SetMemberPasswordReq setMemberPasswordReq = new SetMemberPasswordReq();
CustUsableEntity custUsableEntity = new CustUsableEntity();
custUsableEntity.setUsableStat(UsableStat.USABLE_STAT_LOCKED);
custUsableEntity.setUsableStatUpdReason(LockedReason.USABLE_STAT_AUTO_LOCKED);
when(baseInfoCustRedisManager.custUsableQuery(anyString())).thenReturn(custUsableEntity);
CustLogonPasswordEntity custPwdInfo = new CustLogonPasswordEntity();
when(custLogonPasswordService.queryCustLogonPasswordInfoByCustNum(anyString())).thenReturn(custPwdInfo);
when(custLogonPasswordService.createLoginPassword(anyString(), anyString(), any(SetMemberPasswordReq.class)))
.thenReturn(0);
doNothing().when(baseInfoCustRedisManager).delBaseInfoValues(anyString(), any(String[].class));
when(custUsableService.unLockCust4SysLockAuto(anyString(), any(Integer.class), any(BaseReq.class))).thenReturn(
null);
when(custCardDao.selectCustCardInfoByCustNum(anyString())).thenReturn(null);
when(
custLogonPasswordService.updateLoginPasswordInfo(anyString(), anyString(), any(Integer.class),
any(Timestamp.class), any(CustLogonPasswordEntity.class), any(BaseReq.class))).thenReturn(0);
this.callThread();
memberAccountAliasInfoTxServiceImpl.setB2CPassword(passwordDecrypt, setMemberPasswordReq);
}

@Test
public void getAliasField() {
memberAccountAliasInfoTxServiceImpl.getAliasField(AliasType.ALIAS_MOBILE_NUM);
memberAccountAliasInfoTxServiceImpl.getAliasField(AliasType.ALIAS_EMAIL);
memberAccountAliasInfoTxServiceImpl.getAliasField(AliasType.ALIAS_USERNAME);
memberAccountAliasInfoTxServiceImpl.getAliasField(AliasType.ALIAS_NICK_NAME);
memberAccountAliasInfoTxServiceImpl.getAliasField(AliasType.ALIAS_CARDNO);
}

@Test
public void dealGrabbedMember() {
CustAliasEntity hisEntity = new CustAliasEntity();
when(custAliasDao.select(anyString(), anyString())).thenReturn(hisEntity);
when(custAliasHisDao.insert(hisEntity)).thenReturn(0);
when(custAliasDao.deleteByCustNumAndAliasType(any(CustAliasEntity.class))).thenReturn(0);
doNothing().when(baseInfoCustRedisManager).delBaseInfoValues(anyString(), anyString());
when(bizDealResultDao.insert(any(BizDealResultEntity.class))).thenReturn(0);
memberAccountAliasInfoTxServiceImpl.dealGrabbedMember("43", "180942054741", "4r242");
}

@SuppressWarnings("unchecked")
@Test
public void relieveMobile() {
when(custAliasService.deleteByCustNumAndAliasType(anyString(), anyString())).thenReturn(0);
this.callThread();
when(aliasCustNumMappingService.removeAlias(anyString(), anyString(), anyString())).thenReturn(0);
MobileNumChangeRecordEntity entity = new MobileNumChangeRecordEntity();
when(mobileNumChangeRecordService.addMobileNumChangeRecordByMobilNum(entity)).thenReturn(0);
doNothing().when(idxTxServiceImpl).addMobileNumChangeRecord(any(MobileNumChangeRecordEntity.class));
when(
backstageOptLogService.addBackstageOptLog(any(Map.class), anyString(), anyString(), anyString(),
any(String[].class))).thenReturn(0);
CustAliasEntity custalias = new CustAliasEntity();
MobileNumChangeRecordEntity mobileNumChangeRecordEntity = new MobileNumChangeRecordEntity();
Map<String, Object> param = new HashMap<String, Object>();
memberAccountAliasInfoTxServiceImpl.relieveMobile(custalias, mobileNumChangeRecordEntity, param);
}

@Test
public void getIndividualRequiredInfoState() {
BaseInfoIndividualEntity baseInfoIndividualEntity = new BaseInfoIndividualEntity();
baseInfoIndividualEntity.setMobileNum("18094205642");
when(baseInfoCustRedisManager.baseInfoIndividualQuery(anyString())).thenReturn(baseInfoIndividualEntity);
SocialityInfoEntity socialityInfoEntity = new SocialityInfoEntity();
when(baseInfoCustRedisManager.querySocialityInfo(anyString())).thenReturn(socialityInfoEntity);
AddressInfoEntity addressInfoEntity = new AddressInfoEntity();
when(baseInfoCustRedisManager.queryAddressInfo(anyString(), anyString())).thenReturn(addressInfoEntity);
when(infoFullStatService.checkRequiredInfoState(any(IndividualFullStatInfo.class))).thenReturn(null);
CustCardEntity custCardEntity = new CustCardEntity();
memberAccountAliasInfoTxServiceImpl.getIndividualRequiredInfoState(anyString(), custCardEntity, "");
}

@Test
public void unLockCustAndResetCardWrongTimes4SysLock() {
when(custUsableService.unLockCust4SysLockAuto(anyString(), any(Integer.class), any(BaseReq.class))).thenReturn(
null);
CustCardEntity cardPwdDB = new CustCardEntity();
when(custCardDao.selectCustCardInfoByCustNum(anyString())).thenReturn(cardPwdDB);
when(custCardDao.updateCardPasswordWrongCheckTimes(anyString(), any(BaseEntity.class))).thenReturn(0);
CustUsableEntity custUsableInfo = new CustUsableEntity();
BaseReq baseReq = new BaseReq();
memberAccountAliasInfoTxServiceImpl.unLockCustAndResetCardWrongTimes4SysLock(custUsableInfo, baseReq);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: