Commit 5bf70d3b by liyanlin

测试文件加上rollback,防止误点导致数据丢失

parent 0dd46e8e
......@@ -12,7 +12,10 @@ import com.bailuntec.common.SpringContextUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.blt.other.common.interceptor.mail.MailService;
import com.blt.other.common.rabbitmq.service.receiver.DefaultRegisterQueueService;
import com.blt.other.common.rabbitmq.service.sender.DefaultSendService;
import com.blt.other.common.util.OAuth1Util;
import com.blt.other.database.model.CostCashiercallbackDomain;
import com.blt.other.database.model.CostCompanyDomain;
import com.blt.other.database.model.CostTypeDomain;
import com.blt.other.module.auth.dao.OaDepartmentMapper;
......@@ -22,9 +25,16 @@ import com.blt.other.module.auth.model.OaUser;
import com.blt.other.module.auth.service.IOaDepartmentService;
import com.blt.other.module.auth.service.IOaUserService;
import com.blt.other.module.cost.dao.*;
import com.blt.other.module.cost.dto.response.CostTypeResult;
import com.blt.other.module.cost.model.AccountingSubject;
import com.blt.other.module.cost.model.CostCurrentReviewer;
import com.blt.other.module.cost.model.CostDetailDomain;
import com.blt.other.module.cost.model.CostDomain;
import com.blt.other.module.netsuite.dao.NetsuiteLogDao;
import com.blt.other.module.netsuite.dto.NetsuiCostinfoDto;
import com.blt.other.module.netsuite.dto.NetsuiteDataDto;
import com.blt.other.module.netsuite.model.NetsuiteLogDomain;
import com.blt.other.module.netsuite.service.NetsuiteLogService;
import com.blt.other.module.sys.dao.CostReviewerMapper;
import com.blt.other.module.sys.dao.DepartmentReviewerMapper;
import com.blt.other.module.sys.dto.request.DepartmentReviewerListReq;
......@@ -37,6 +47,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
......@@ -44,12 +55,12 @@ import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import org.thymeleaf.util.StringUtils;
import javax.annotation.Resource;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -75,8 +86,14 @@ public class OtherApplicationTests {
CostReviewerMapper costReviewerMapper;
@Resource
DepartmentReviewerMapper departmentReviewerMapper;
@Resource
NetsuiteLogDao netsuiteLogDao;
@Resource
CostDetailDao costDetailDao;
@Resource
NetsuiteLogService netsuiteLogService;
@Rollback(value = false)
@Rollback
@Test
public void syncDepartmentReviewer() {
departmentReviewerMapper.delete(new LambdaQueryWrapper<>());
......@@ -435,24 +452,62 @@ public class OtherApplicationTests {
@Resource
CostTypeDao costTypeDao;
@Resource
CostCashiercallbackDao costCashiercallbackDao;
@Test
public void test(){
OAuth1Util.setupContext("4e1786849ffd6cb866f2f22b43cce56793e446d56f1cf60fe45674aa02424646",
"d66b2d4c6d6a9bf59b7923e3d32535b1e3685babf4109581884230fdb00ec330",
"042c17360b2f3c831c9531365c8b98ef6aeeaf40ce4e7c46144ee70aad2e7667",
"d974ba497472b258a06175cc62a2edba6104f94c131afba38143e8c3a2f0e125",
"6916374_SB1");
try {
OAuth1Util.executePost("https://6916374-sb1.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=78&deploy=1",null,"[{\"tranid\":\"test_F20210312\",\"currency\":\"CNY\",\"subsidiary\":\"gzbl\",\"trandate\":\"2021/03/12\",\"custbody_iofeetype\":\"1\",\"payment\":[{\"account\":\"220201\",\"amount\":\"500\",\"memo\":\"测试\"},{\"account\":\"630108\",\"amount\":\"500\",\"memo\":\"测试\"}],\"receipt\":[{\"account\":\"630108\",\"amount\":\"500\",\"memo\":\"测试\"},{\"account\":\"220201\",\"amount\":\"500\",\"memo\":\"测试\"}]}]");
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
@Rollback(value = false)
public void test() {
CostDomain costDomain = costDao.selectByCostNo("F036461");
List<CostDetailDomain> costDetailDomainList = costDetailDao.selectListByCostNo("F036461");
costDomain.setCostDetailDomainList(costDetailDomainList);
CostCashiercallbackDomain costCashiercallbackDomain = costCashiercallbackDao.selectByCostNo("F036461");
CostTypeResult costTypeResult = costTypeDao.queryDetail(costDomain.getTypeId());
if (costDomain.getCompanyValue() != 2) {
return;
}
String companyCode = "xgbl";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
NetsuiteDataDto netsuiteDataDto = new NetsuiteDataDto();
netsuiteDataDto.setTranid(costDomain.getCostNo());
netsuiteDataDto.setCurrency("CNY");
netsuiteDataDto.setSubsidiary(companyCode);
netsuiteDataDto.setTrandate(sdf.format(costDomain.getActualTime()));
netsuiteDataDto.setCustbody_iofeetype(costDomain.getCostForm().toString());
//费用详情
List<NetsuiCostinfoDto> netsuiCostInfoDtos = new ArrayList<>();
//费用系统信息
NetsuiCostinfoDto feeSysInfo = new NetsuiCostinfoDto(
costTypeResult.getNsAccountingSubjectId().toString(),
costDomain.getAmount().toString(),
StringUtils.isEmpty(costDomain.getCostReason()) ? costDomain.getCostRemark() : costDomain.getCostReason()
);
netsuiCostInfoDtos.add(feeSysInfo);
//财务系统信息
NetsuiCostinfoDto cwSysInfo = new NetsuiCostinfoDto(
"1002",
costCashiercallbackDomain.getPayamount().toString(),
costCashiercallbackDomain.getPaynote()
);
netsuiCostInfoDtos.add(cwSysInfo);
netsuiteDataDto.setCostinfo(netsuiCostInfoDtos);
NetsuiteLogDomain netsuiteLogDomain = new NetsuiteLogDomain();
netsuiteLogDomain.setCostNo(costDomain.getCostNo());
netsuiteLogDomain.setPublishStatus(NetsuiteLogDomain.UNPUBLISH);
netsuiteLogDomain.setScript(NetsuiteLogDomain.SCRIPT_FEE);
netsuiteLogDomain.setJsonStr(JSON.toJSONString(netsuiteDataDto));
netsuiteLogDao.upsert(netsuiteLogDomain);
}
@Rollback(value = false)
@Test
public void publishToNetsuiteTest() {
netsuiteLogService.publishToNetsuite(100);
}
@Rollback(value = false)
......@@ -513,5 +568,36 @@ public class OtherApplicationTests {
}
@Autowired
private RabbitTemplate rabbitTemplate;
@Resource
private DefaultSendService sendService;
@Resource
private DefaultRegisterQueueService registerQueueService;
@Test
public void rabbitMqTest() {
for (int i = 0; i < 10; i++) {
DepartmentReviewerListReq req = new DepartmentReviewerListReq();
req.setPageNum(i);
req.setPageSize(100);
sendService.send("com.bailuntec.fee", "com.bailuntec.fee.netsuite.task", req, null, null);
}
}
@Test
public void rabbitMqTest1() {
boolean isRegister = registerQueueService
.exchange("com.bailuntec.fee")
.queue("com.bailuntec.fee.netsuite.task")
.routingKey("com.bailuntec.fee.netsuite.task")
.registerQueue();
while (true) ;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment