parent
e6039e18fb
commit
6f08f56b37
|
@ -13,6 +13,7 @@ import com.dispose.mapper.DisposeDeviceMapperTest;
|
||||||
import com.dispose.mapper.DisposeTaskMapperTest;
|
import com.dispose.mapper.DisposeTaskMapperTest;
|
||||||
import com.dispose.mapper.UserAccountMapperTest;
|
import com.dispose.mapper.UserAccountMapperTest;
|
||||||
import com.dispose.service.DisposeNodeManagerTest;
|
import com.dispose.service.DisposeNodeManagerTest;
|
||||||
|
import com.dispose.service.TaskServiceTest;
|
||||||
import com.dispose.service.UserAccountServiceTest;
|
import com.dispose.service.UserAccountServiceTest;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Suite;
|
import org.junit.runners.Suite;
|
||||||
|
@ -34,7 +35,8 @@ import org.junit.runners.Suite;
|
||||||
DeviceNodeManagerControllerTest.class,
|
DeviceNodeManagerControllerTest.class,
|
||||||
DeviceNodeInfoControllerTest.class,
|
DeviceNodeInfoControllerTest.class,
|
||||||
UserAccountServiceTest.class,
|
UserAccountServiceTest.class,
|
||||||
TaskControllerTest.class
|
TaskControllerTest.class,
|
||||||
|
TaskServiceTest.class
|
||||||
})
|
})
|
||||||
|
|
||||||
public class AllDisposePlatformTest {
|
public class AllDisposePlatformTest {
|
||||||
|
|
|
@ -105,4 +105,33 @@ public class AuthControllerTest extends InitTestEnvironment {
|
||||||
.getResponse()
|
.getResponse()
|
||||||
.getContentAsString();
|
.getContentAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logout 2.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void logout3() throws Exception {
|
||||||
|
LoginReq logReq = LoginReq.builder()
|
||||||
|
.userName("admin2")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(logReq));
|
||||||
|
|
||||||
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/auth/logout")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(502))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,6 +190,37 @@ public class TaskControllerTest extends InitTestEnvironment {
|
||||||
.getContentAsString();
|
.getContentAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void t3_stopAllNodeIpTask() throws Exception {
|
||||||
|
StopTaskData itemData = StopTaskData.builder()
|
||||||
|
.disposeIp("192.168.5.2")
|
||||||
|
.type(DeviceCapacity.CLEANUP.getCode())
|
||||||
|
.id("-1")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
StopTaskReq reqData = new StopTaskReq();
|
||||||
|
|
||||||
|
reqData.setItems(new ArrayList<>());
|
||||||
|
reqData.getItems().add(itemData);
|
||||||
|
|
||||||
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/task/stop_ip")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* T 4 stop node task.
|
* T 4 stop node task.
|
||||||
*
|
*
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.dispose.pojo.po.MReturnType;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -59,6 +60,10 @@ public class DisposeNodeManagerTest extends InitTestEnvironment {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void userLogin() {
|
public void userLogin() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void reloadCacheData() {
|
||||||
disposeNodeManager.loadDisposeNodeFromDB();
|
disposeNodeManager.loadDisposeNodeFromDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.dispose.service;
|
||||||
|
|
||||||
|
import com.dispose.Global.InitTestEnvironment;
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
|
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.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
@Slf4j
|
||||||
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
|
public class TaskServiceTest extends InitTestEnvironment {
|
||||||
|
@Resource
|
||||||
|
private TaskService taskService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void userLogin() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void t1_stopTaskTest() {
|
||||||
|
ErrorCode err = taskService.stopTask(-1L);
|
||||||
|
|
||||||
|
Assert.assertEquals(err, ErrorCode.ERR_NOSUCHDEVICE);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue