parent
cf20704395
commit
781907eb12
|
@ -715,7 +715,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
.build();
|
||||
super.initDeviceEnv(urlPath, username, password);
|
||||
|
||||
// 获取所有检测设备
|
||||
// 获取所有清洗设备
|
||||
initCleanupDevices();
|
||||
|
||||
// 更新设备信息
|
||||
|
|
|
@ -0,0 +1,139 @@
|
|||
package com.dispose.test.dev.controller;
|
||||
|
||||
import com.dispose.common.ConstValue;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.common.ProtoCryptoType;
|
||||
import com.dispose.mapper.ServiceGroupMapper;
|
||||
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
|
||||
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||
import com.dispose.pojo.dto.protocol.device.business.AddUserSvrReq;
|
||||
import com.dispose.pojo.dto.protocol.device.business.AddUserSvrRsp;
|
||||
import com.dispose.pojo.dto.protocol.device.business.UserSvrInfo;
|
||||
import com.dispose.service.UserBusinessManagerService;
|
||||
import com.dispose.test.dev.Global.InitTestEnvironment;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jodd.net.HttpStatus;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Assert;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@AutoConfigureMockMvc
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@Transactional
|
||||
@Rollback
|
||||
@Slf4j
|
||||
public class UserBusinessControllerTest extends InitTestEnvironment {
|
||||
/**
|
||||
* The Mock mvc.
|
||||
*/
|
||||
@Resource
|
||||
private MockMvc mockMvc;
|
||||
/**
|
||||
* The Object mapper.
|
||||
*/
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
/**
|
||||
* The User business manager service.
|
||||
*/
|
||||
@Resource
|
||||
private UserBusinessManagerService userBusinessManagerService;
|
||||
|
||||
/**
|
||||
* The service group mapper.
|
||||
*/
|
||||
@Resource
|
||||
private ServiceGroupMapper serviceGroupMapper;
|
||||
/**
|
||||
* A 1 add user business test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void a1_addUserBusinessTest() throws Exception{
|
||||
List<UserSvrInfo> newList = new ArrayList<>();
|
||||
newList.add(UserSvrInfo.builder()
|
||||
.businessId("controller1")
|
||||
.businessType("GAME")
|
||||
.businessIp("192.168.1.1")
|
||||
.businessBandwidth("50")
|
||||
.build());
|
||||
newList.add(UserSvrInfo.builder()
|
||||
.businessId("controller2")
|
||||
.businessType("GAME")
|
||||
.businessIp("192.168.1.2")
|
||||
.businessBandwidth("150")
|
||||
.build());
|
||||
|
||||
AddUserSvrReq req = AddUserSvrReq.builder()
|
||||
.items(newList)
|
||||
.build();
|
||||
|
||||
ProtocolReqDTO<AddUserSvrReq> reqInfo = new ProtocolReqDTO<>();
|
||||
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||
reqInfo.setCryptoType(ProtoCryptoType.CRYPTO_NONE.getCode());
|
||||
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||
reqInfo.setMsgContent(req);
|
||||
log.info("reqIfo: {}",reqInfo);
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manage")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", ConstValue.STRING_HTTP_AUTH_HEAD + getLoginToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(HttpStatus.ok().status()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ProtocolRespDTO<AddUserSvrRsp> rspInfo = objectMapper.readValue(ret,
|
||||
new TypeReference<ProtocolRespDTO<AddUserSvrRsp>>() {
|
||||
});
|
||||
|
||||
verifyRespProtocol(rspInfo);
|
||||
log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(rspInfo));
|
||||
|
||||
Assert.assertNotNull(rspInfo.getMsgContent().getItems());
|
||||
|
||||
rspInfo.getMsgContent().getItems().forEach(k -> {
|
||||
Assert.assertNotNull(k.getStatus());
|
||||
if (k.getStatus() == ErrorCode.ERR_OK.getCode()) {
|
||||
Assert.assertNotNull(k.getMessage());
|
||||
Assert.assertNotNull(k.getBusinessId());
|
||||
Assert.assertTrue(serviceGroupMapper.selectAll().stream().anyMatch(v ->
|
||||
k.getBusinessId().equals(v.getServiceId())
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -90,16 +90,16 @@ public class ServiceGroupMapperTest extends InitTestEnvironment {
|
|||
public void a3_delServiceGroupByIdTest(){
|
||||
List<ServiceInfo> service = new ArrayList<>();
|
||||
service.add(ServiceInfo.builder()
|
||||
.serviceId("100")
|
||||
.serviceId("102")
|
||||
.serviceType("GAME")
|
||||
.serviceBandwidth(1000L)
|
||||
.serviceIp("192.168.100.1-192.168.100.10,192.168.100.20-192.168.100.21")
|
||||
.serviceIp("192.168.102.1-192.168.102.10,192.168.102.20-192.168.102.21")
|
||||
.build());
|
||||
service.add(ServiceInfo.builder()
|
||||
.serviceId("101")
|
||||
.serviceId("103")
|
||||
.serviceType("DNS")
|
||||
.serviceBandwidth(2000L)
|
||||
.serviceIp("192.168.101.1-192.168.101.10")
|
||||
.serviceIp("192.168.103.1-192.168.103.10")
|
||||
.build());
|
||||
serviceGroupMapper.addServiceGroup(service);
|
||||
|
||||
|
@ -125,16 +125,16 @@ public class ServiceGroupMapperTest extends InitTestEnvironment {
|
|||
public void a4_delServiceGroupByServiceIdTest(){
|
||||
List<ServiceInfo> service = new ArrayList<>();
|
||||
service.add(ServiceInfo.builder()
|
||||
.serviceId("100")
|
||||
.serviceId("104")
|
||||
.serviceType("GAME")
|
||||
.serviceBandwidth(1000L)
|
||||
.serviceIp("192.168.100.1-192.168.100.10,192.168.100.20-192.168.100.21")
|
||||
.serviceIp("192.168.104.1-192.168.104.10,192.168.104.20-192.168.104.21")
|
||||
.build());
|
||||
service.add(ServiceInfo.builder()
|
||||
.serviceId("101")
|
||||
.serviceId("105")
|
||||
.serviceType("DNS")
|
||||
.serviceBandwidth(2000L)
|
||||
.serviceIp("192.168.101.1-192.168.101.10")
|
||||
.serviceIp("192.168.105.1-192.168.105.10")
|
||||
.build());
|
||||
serviceGroupMapper.addServiceGroup(service);
|
||||
|
||||
|
|
Loading…
Reference in New Issue