|
@@ -1,8 +1,31 @@
|
|
|
package com.dragonsoft.dcuc.approve.business.impl;
|
|
|
|
|
|
|
|
|
+import com.dragoninfo.dcuc.common.http.SkipSslVerificationHttpRequestFactory;
|
|
|
+import com.dragoninfo.dcuc.common.utils.ResponseUtil;
|
|
|
+import com.dragonsoft.dcuc.approve.model.resp.bu.BuApproveSyncBizApproveReqVO;
|
|
|
+import com.dragonsoft.dcuc.approve.model.resp.bu.BuApproveSyncBizDataReqVO;
|
|
|
+import com.dragonsoft.dcuc.approve.model.resp.bu.BuApproveSyncReqVO;
|
|
|
+import com.dragonsoft.dcuc.approve.properties.ApproveBuProperties;
|
|
|
+import com.dragonsoft.dcuc.approve.properties.BimProperties;
|
|
|
+import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
|
|
|
+import com.dragonsoft.duceap.commons.util.UUIDUtils;
|
|
|
+import com.dragonsoft.smtools.enums.SmTypeEunm;
|
|
|
+import com.dragonsoft.smtools.loader.SMFactory;
|
|
|
+import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.github.dreamhead.moco.HttpServer;
|
|
|
+import com.github.dreamhead.moco.junit.MocoJunitRunner;
|
|
|
import org.junit.Assert;
|
|
|
+import org.junit.Before;
|
|
|
+import org.junit.Rule;
|
|
|
import org.junit.Test;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+import static com.github.dreamhead.moco.Moco.*;
|
|
|
+import static com.github.dreamhead.moco.Moco.pathResource;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -14,12 +37,80 @@ import org.junit.Test;
|
|
|
*/
|
|
|
public class BuSyncBusinessImplTest {
|
|
|
|
|
|
+ static int port = 19000;
|
|
|
+
|
|
|
+
|
|
|
+ static String baseUrl = "http://127.0.0.1:" + port;
|
|
|
+
|
|
|
+ static String syncToBuUrl = "/sync/tuBu";
|
|
|
+
|
|
|
+ String fullBusinessUrl = baseUrl + syncToBuUrl;
|
|
|
+
|
|
|
+ static BuSyncBusinessImpl buSyncBusiness;
|
|
|
+
|
|
|
+ HttpServer httpServer = httpServer(port, log());
|
|
|
+ @Rule
|
|
|
+ public MocoJunitRunner mocoJunitRunner = MocoJunitRunner.httpRunner(httpServer);
|
|
|
+
|
|
|
+
|
|
|
+ @Before
|
|
|
+ public void before() throws Exception {
|
|
|
+
|
|
|
+ httpServer.request(by(uri(syncToBuUrl)))
|
|
|
+ .response(pathResource("bu/buSuccess.json"));
|
|
|
+
|
|
|
+ SkipSslVerificationHttpRequestFactory skipSslVerificationHttpRequestFactory
|
|
|
+ = new SkipSslVerificationHttpRequestFactory();
|
|
|
+ skipSslVerificationHttpRequestFactory.setReadTimeout(5000);
|
|
|
+ skipSslVerificationHttpRequestFactory.setConnectTimeout(5000);
|
|
|
+ RestTemplate restTemplate = new RestTemplate(skipSslVerificationHttpRequestFactory);
|
|
|
+ ApproveBuProperties approveBuProperties = new ApproveBuProperties();
|
|
|
+ approveBuProperties.setEnable(true);
|
|
|
+ approveBuProperties.setSyncTaskUrl(fullBusinessUrl);
|
|
|
+
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ // 忽略不对应的字段
|
|
|
+ objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
|
+
|
|
|
+ buSyncBusiness = new BuSyncBusinessImpl();
|
|
|
+ buSyncBusiness.setRestTemplate(restTemplate);
|
|
|
+ buSyncBusiness.setApproveBuProperties(approveBuProperties);
|
|
|
+ buSyncBusiness.setDragonObjectMapper(objectMapper);
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void isStanderTaskNo() {
|
|
|
- BuSyncBusinessImpl buSyncBusiness = new BuSyncBusinessImpl();
|
|
|
Assert.assertTrue(buSyncBusiness.isStanderTaskNo("RWBH0100000000002023071409530500000010"));
|
|
|
Assert.assertFalse(buSyncBusiness.isStanderTaskNo("iwrw0100000000002023071409530500000010"));
|
|
|
Assert.assertFalse(buSyncBusiness.isStanderTaskNo("iwrw010000000000202307140953050000001022"));
|
|
|
+ }
|
|
|
+ @Test
|
|
|
+ public void baseReq(){
|
|
|
+
|
|
|
+ BuApproveSyncReqVO buApproveSyncReqVO = new BuApproveSyncReqVO();
|
|
|
+ buApproveSyncReqVO.setAppId("aaa");
|
|
|
+ buApproveSyncReqVO.setAppName("ss");
|
|
|
+ buApproveSyncReqVO.setCreateTime(new Date());
|
|
|
+ buApproveSyncReqVO.setFinishTime(new Date());
|
|
|
+ buApproveSyncReqVO.setPid("sss");
|
|
|
+ buApproveSyncReqVO.setLastReviewerIdCard("sss");
|
|
|
+ buApproveSyncReqVO.setLastReviewerName("sssss");
|
|
|
+ buApproveSyncReqVO.setLastReviewerUnit("ss");
|
|
|
+ buApproveSyncReqVO.setLastReviewerUnitCode("sssss");
|
|
|
+
|
|
|
+ BuApproveSyncBizApproveReqVO buApproveSyncBizApproveReqVO = new BuApproveSyncBizApproveReqVO();
|
|
|
+ buApproveSyncBizApproveReqVO.setBizId(UUIDUtils.getUUID());
|
|
|
+ buApproveSyncBizApproveReqVO.setBizTitle("ss");
|
|
|
+ buApproveSyncBizApproveReqVO.setTaskClass("sss");
|
|
|
+ buApproveSyncBizApproveReqVO.setApproveMode("1");
|
|
|
+ buApproveSyncBizApproveReqVO.setBizTermStart(new Date());
|
|
|
+ buApproveSyncBizApproveReqVO.setBizTermEnd(new Date());
|
|
|
+
|
|
|
+ BuApproveSyncBizDataReqVO buApproveSyncBizDataReqVO = new BuApproveSyncBizDataReqVO();
|
|
|
+ buApproveSyncBizDataReqVO.setBizApprove(buApproveSyncBizApproveReqVO);
|
|
|
+ buApproveSyncReqVO.setBizData(buApproveSyncBizDataReqVO);
|
|
|
|
|
|
+ ResponseStatus responseStatus = buSyncBusiness.requestSyncToBu(buApproveSyncReqVO);
|
|
|
+ Assert.assertTrue(ResponseUtil.isSuccess(responseStatus));
|
|
|
}
|
|
|
}
|