parent
e3415eaf07
commit
8c44bb712c
|
@ -170,7 +170,7 @@ public class DisposeDeviceManagerTest {
|
||||||
* A 3 change dispose device status.
|
* A 3 change dispose device status.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void a3_changeDisposeDeviceStatus() {
|
public void a3_changeDisposeDeviceStatus() {
|
||||||
|
|
||||||
disposeDeviceMapper.selectAll().forEach(v -> {
|
disposeDeviceMapper.selectAll().forEach(v -> {
|
||||||
for (ObjectStatus obj : ObjectStatus.values()
|
for (ObjectStatus obj : ObjectStatus.values()
|
||||||
|
|
|
@ -0,0 +1,126 @@
|
||||||
|
package com.dispose.test.service;
|
||||||
|
|
||||||
|
import com.dispose.common.DisposeDeviceType;
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
|
import com.dispose.common.HttpType;
|
||||||
|
import com.dispose.common.ObjectStatus;
|
||||||
|
import com.dispose.pojo.entity.DisposeDevice;
|
||||||
|
import com.dispose.pojo.po.AbilityInfo;
|
||||||
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
|
import com.dispose.service.DisposeAbilityRouterService;
|
||||||
|
import com.dispose.service.UserAccountService;
|
||||||
|
import com.dispose.test.Global.InitTestEnvironment;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.FixMethodOrder;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.MethodSorters;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.annotation.Rollback;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type User account service test.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
@Slf4j
|
||||||
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
|
@Transactional
|
||||||
|
@Rollback
|
||||||
|
public class DisposeAbilityRouterServiceTest extends InitTestEnvironment {
|
||||||
|
/**
|
||||||
|
* The constant token.
|
||||||
|
*/
|
||||||
|
private static String token = "";
|
||||||
|
/**
|
||||||
|
* The User account service.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private UserAccountService userAccountService;
|
||||||
|
/**
|
||||||
|
* The dispose device ability router service.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private DisposeAbilityRouterService disposeAbilityRouterService;
|
||||||
|
/**
|
||||||
|
* The Object mapper.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
|
||||||
|
public static Integer VIRTUAL_DISPOSE = 999;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User login test.
|
||||||
|
*
|
||||||
|
* @throws NoSuchAlgorithmException the no such algorithm exception
|
||||||
|
*/
|
||||||
|
@Before
|
||||||
|
public void userLoginTest() throws NoSuchAlgorithmException {
|
||||||
|
MulReturnType<ErrorCode, String> ret = userAccountService.loginService(getUSER_NAME(),
|
||||||
|
getPASSWORD());
|
||||||
|
|
||||||
|
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||||
|
DisposeAbilityRouterServiceTest.token = ret.getSecondParam();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A 1 Add dispose device list.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void a1_addDisposeAbilityDeviceTest() throws JsonProcessingException {
|
||||||
|
DisposeDevice dev = DisposeDevice.builder()
|
||||||
|
.ipAddr("192.168.10.1")
|
||||||
|
.ipPort("")
|
||||||
|
.deviceType(DisposeDeviceType.VIRTUAL_DISPOSE)
|
||||||
|
.areaCode(0)
|
||||||
|
.deviceName("虚拟设备")
|
||||||
|
.manufacturer("Virtual")
|
||||||
|
.model("Unknown")
|
||||||
|
.version("Unknown")
|
||||||
|
.userName("")
|
||||||
|
.password("")
|
||||||
|
.urlPath("")
|
||||||
|
.urlType(HttpType.HTTP)
|
||||||
|
.readme("实验室测试设备")
|
||||||
|
.status(ObjectStatus.NORMAL)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
disposeAbilityRouterService.addDisposeAbilityDevice(dev);
|
||||||
|
|
||||||
|
Assert.assertEquals(dev.getDeviceType().getValue(), VIRTUAL_DISPOSE);
|
||||||
|
|
||||||
|
AbilityInfo abilityInfo = disposeAbilityRouterService.getAbilityDevice(dev.getIpAddr(), dev.getIpPort());
|
||||||
|
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(abilityInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A 2 Gets all ability devices.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void a2_getAllAbilityDevicesTest() throws JsonProcessingException {
|
||||||
|
List<AbilityInfo> abilityInfoList = disposeAbilityRouterService.getAllAbilityDevices();
|
||||||
|
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(abilityInfoList));
|
||||||
|
|
||||||
|
abilityInfoList.forEach(v->{
|
||||||
|
Assert.assertNotNull(v.getDb());
|
||||||
|
Assert.assertNotNull(v.getDev());
|
||||||
|
Assert.assertFalse(v.isLinkStatus());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue