add behavior js
This commit is contained in:
parent
8c641bde3b
commit
4f482a40ec
|
@ -161,13 +161,14 @@
|
|||
<version>2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.tomakehurst</groupId>
|
||||
<artifactId>wiremock</artifactId>
|
||||
<version>1.46</version>
|
||||
<groupId>com.github.tomakehurst</groupId>
|
||||
<artifactId>wiremock</artifactId>
|
||||
<version>1.46</version>
|
||||
|
||||
<!-- Include this if you have dependency conflicts for Guava, Jetty, Jackson or Apache HTTP Client -->
|
||||
<classifier>standalone</classifier>
|
||||
</dependency>
|
||||
<!-- Include this if you have dependency conflicts for Guava, Jetty, Jackson
|
||||
or Apache HTTP Client -->
|
||||
<classifier>standalone</classifier>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>bench4q-web</finalName>
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package org.bench4q.web.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.agent.RunScenarioModel;
|
||||
import org.bench4q.share.models.master.OperateScriptServerResponseModel;
|
||||
import org.bench4q.web.masterMessager.ScriptMessager;
|
||||
import org.bench4q.web.model.ScenarioModel;
|
||||
import org.bench4q.web.newapi.BaseController;
|
||||
import org.bench4q.web.newservice.ScriptServiceNew;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
@Controller
|
||||
@SessionAttributes("accessToken")
|
||||
public class DeviceController extends BaseController {
|
||||
private Logger logger = Logger.getLogger(DeviceController.class);
|
||||
private ScriptServiceNew scriptService;
|
||||
|
||||
private ScriptMessager scriptMessager;
|
||||
|
||||
public ScriptServiceNew getScriptService() {
|
||||
return scriptService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setScriptService(ScriptServiceNew scriptService) {
|
||||
this.scriptService = scriptService;
|
||||
}
|
||||
|
||||
public ScriptMessager getScriptMessager() {
|
||||
return scriptMessager;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setScriptMessager(ScriptMessager scriptMessager) {
|
||||
this.scriptMessager = scriptMessager;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "deviceScript", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Map<String, Object> uploadPluginEditedScript(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@RequestBody ScenarioModel script) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
if (script.getUsePlugins() == null
|
||||
|| script.getUsePlugins().size() == 0) {
|
||||
fail(map, "empty use plugin");
|
||||
}
|
||||
if (script.getBehaviors() == null || script.getBehaviors().size() == 0) {
|
||||
fail(map, "empty behaviors");
|
||||
}
|
||||
RunScenarioModel runScenarioModel = this.getScriptService()
|
||||
.createRunScenarioModel(script.getUsePlugins(),
|
||||
script.getBehaviors());
|
||||
String scenarioModel = MarshalHelper.tryMarshal(runScenarioModel);
|
||||
logger.info(scenarioModel);
|
||||
OperateScriptServerResponseModel operateScriptServerResponseModel = this
|
||||
.getScriptMessager().uploadScript(accessToken,
|
||||
script.getName(), scenarioModel, null, null);
|
||||
if (operateScriptServerResponseModel.isSuccess()) {
|
||||
return success(map);
|
||||
} else {
|
||||
logger.info("fail:"
|
||||
+ operateScriptServerResponseModel.getFailCauseString());
|
||||
return fail(map,
|
||||
operateScriptServerResponseModel.getFailCauseString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,6 @@ import javax.xml.bind.JAXBException;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.master.plugin.BehaviorInfoModel;
|
||||
import org.bench4q.share.models.master.plugin.PluginResponseModel;
|
||||
import org.bench4q.share.models.master.plugin.PluginUIModel;
|
||||
import org.bench4q.web.exception.CustomGenericException;
|
||||
|
@ -135,7 +134,6 @@ public class PluginActionController extends BaseController {
|
|||
BaseResponseModel loadPluginUIInfo(
|
||||
@ModelAttribute("accessToken") String accessToken)
|
||||
throws CustomGenericException {
|
||||
System.out.println("loadPluginUIList");
|
||||
String caller = new String("PluginActionController:loadPluginUIList");
|
||||
String url = this.getBaseUrl() + "/loadPluginList";
|
||||
PluginResponseModel pluginResponseModel = (PluginResponseModel) this
|
||||
|
@ -175,37 +173,23 @@ public class PluginActionController extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
@RequestMapping("loadBehaviorList")
|
||||
@RequestMapping("loadBehaviorList/{pluginName}")
|
||||
public @ResponseBody
|
||||
BaseResponseModel loadBehaviorList(HttpServletRequest request,
|
||||
Map<String, Object> loadBehaviorList(HttpServletRequest request,
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@RequestParam String pluginName) throws CustomGenericException {
|
||||
String caller = new String("PluginActionController:loadBehaviorList");
|
||||
String url = this.getBaseUrl() + "/loadBehaviors/" + pluginName;
|
||||
Map<String, String> params = BaseService.makeParamsMap("pluginName",
|
||||
pluginName);
|
||||
PluginResponseModel pluginResponseModel = (PluginResponseModel) this
|
||||
.getCommunicateWithMaster().getResponseModel(accessToken, url,
|
||||
PluginResponseModel.class, params, caller);
|
||||
|
||||
try {
|
||||
Logger.getLogger(PluginActionController.class).info(
|
||||
MarshalHelper.marshal(PluginResponseModel.class,
|
||||
pluginResponseModel));
|
||||
} catch (JAXBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (pluginResponseModel.isSuccess()) {
|
||||
List<BehaviorInfoModel> behaviorInfoModels = pluginResponseModel
|
||||
.getBehaviorInfoModels();
|
||||
if (behaviorInfoModels == null) {
|
||||
behaviorInfoModels = new ArrayList<BehaviorInfoModel>();
|
||||
}
|
||||
return new BaseResponseModel(true, behaviorInfoModels);
|
||||
@PathVariable String pluginName) throws CustomGenericException {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
;
|
||||
PluginResponseModel pluginResponseModel = this.getPluginMessager()
|
||||
.loadBehaviors(accessToken, pluginName);
|
||||
if (!pluginResponseModel.isSuccess()) {
|
||||
return fail(map, pluginResponseModel.getFailMessage());
|
||||
} else {
|
||||
return new BaseResponseModel(false,
|
||||
pluginResponseModel.getFailMessage());
|
||||
map = success(map);
|
||||
map.put("behaviors", pluginResponseModel.getBehaviorInfoModels());
|
||||
}
|
||||
return map;
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = "uploadPluginFile", method = RequestMethod.POST)
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.bench4q.web.service.BaseService;
|
|||
import org.bench4q.web.service.CommunicateWithMaster;
|
||||
import org.bench4q.web.service.ScriptService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -52,7 +51,6 @@ import org.xml.sax.SAXException;
|
|||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
@Controller
|
||||
@SessionAttributes("accessToken")
|
||||
public class ScriptActionController {
|
||||
|
||||
|
@ -412,7 +410,7 @@ public class ScriptActionController {
|
|||
RunScenarioModel runScenarioModel = scenarioModel.getRunScenarioModel();
|
||||
List<PageModel> pageModels = runScenarioModel.getPages();
|
||||
List<UsePluginModel> usePluginModels = runScenarioModel.getUsePlugins();
|
||||
String scriptName = scenarioModel.getScriptName();
|
||||
String scriptName = scenarioModel.getName();
|
||||
if (!validateScenarioModel(pageModels, usePluginModels))
|
||||
return new BaseResponseModel(false, "invalidate script");
|
||||
try {
|
||||
|
|
|
@ -1,15 +1,33 @@
|
|||
package org.bench4q.web.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bench4q.share.models.agent.RunScenarioModel;
|
||||
import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
|
||||
import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
|
||||
|
||||
public class ScenarioModel {
|
||||
private String scriptName;
|
||||
private String name;
|
||||
private List<UsePluginModel> usePlugins;
|
||||
private List<BehaviorModel> behaviors;
|
||||
private RunScenarioModel runScenarioModel;
|
||||
public String getScriptName() {
|
||||
return scriptName;
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setScriptName(String scriptName) {
|
||||
this.scriptName = scriptName;
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public List<UsePluginModel> getUsePlugins() {
|
||||
return usePlugins;
|
||||
}
|
||||
public void setUsePlugins(List<UsePluginModel> usePlugins) {
|
||||
this.usePlugins = usePlugins;
|
||||
}
|
||||
public List<BehaviorModel> getBehaviors() {
|
||||
return behaviors;
|
||||
}
|
||||
public void setBehaviors(List<BehaviorModel> behaviors) {
|
||||
this.behaviors = behaviors;
|
||||
}
|
||||
public RunScenarioModel getRunScenarioModel() {
|
||||
return runScenarioModel;
|
||||
|
@ -17,6 +35,5 @@ public class ScenarioModel {
|
|||
public void setRunScenarioModel(RunScenarioModel runScenarioModel) {
|
||||
this.runScenarioModel = runScenarioModel;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.bench4q.web.newapi;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public abstract class BaseController {
|
||||
private final String SUCCESS = "success";
|
||||
private final String FAILMESSAGE = "failedMessage";
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package org.bench4q.web.newservice;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bench4q.share.models.agent.RunScenarioModel;
|
||||
import org.bench4q.share.models.agent.scriptrecord.BatchModel;
|
||||
import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
|
||||
import org.bench4q.share.models.agent.scriptrecord.PageModel;
|
||||
import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ScriptServiceNew {
|
||||
|
||||
public RunScenarioModel createRunScenarioModel(
|
||||
List<UsePluginModel> usePlugins, List<BehaviorModel> behaviorModels) {
|
||||
RunScenarioModel runScenarioModel = new RunScenarioModel();
|
||||
runScenarioModel.setUsePlugins(usePlugins);
|
||||
List<PageModel> pageModels = new LinkedList<PageModel>();
|
||||
int count = 0;
|
||||
for (BehaviorModel behaviorModel : behaviorModels) {
|
||||
List<BehaviorModel> behaviorList = new LinkedList<BehaviorModel>();
|
||||
behaviorModel.setId(count);
|
||||
behaviorList.add(behaviorModel);
|
||||
BatchModel batchModel = new BatchModel();
|
||||
batchModel.setBehaviors(behaviorList);
|
||||
batchModel.setChildId(-1);
|
||||
batchModel.setId(count);
|
||||
batchModel.setParentId(-1);
|
||||
List<BatchModel> batchModels = new LinkedList<BatchModel>();
|
||||
batchModels.add(batchModel);
|
||||
PageModel pageModel = new PageModel();
|
||||
pageModel.setBatches(batchModels);
|
||||
pageModels.add(pageModel);
|
||||
count++;
|
||||
}
|
||||
runScenarioModel.setPages(pageModels);
|
||||
return runScenarioModel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.bench4q.web.validation;
|
||||
|
||||
public class ScriptValidate {
|
||||
|
||||
}
|
|
@ -1 +1 @@
|
|||
masterAddress=127.0.0.1:10086/
|
||||
masterAddress=127.0.0.1:7979/
|
|
@ -7,7 +7,7 @@
|
|||
<link id="bs-css" href="lib/chrisma/css/bootstrap-cerulean.css"
|
||||
rel="stylesheet">
|
||||
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
|
||||
<link href="css/script-editor.css" rel="stylesheet">
|
||||
<link href="css/device.css" rel="stylesheet">
|
||||
<link rel="shortcut icon" href="images/bench4q.png">
|
||||
<style type="text/css">
|
||||
body {
|
||||
|
@ -25,19 +25,29 @@ body {
|
|||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<jsp:include page="publiccontrol/leftmenubar.jsp"></jsp:include>
|
||||
<div class="span10">
|
||||
<div class="span10" id="devicePanel">
|
||||
<div class="booter ">
|
||||
<button type="button" class="btn btn-primary " id="add-device">Add</button>
|
||||
<button type="button" class="btn btn-primary " id="remove-device">Remove</button>
|
||||
<a class="action" id="to-behavior">To Configure Data Sender >></a>
|
||||
</div>
|
||||
<div id="devices"></div>
|
||||
|
||||
</div>
|
||||
<div class="span10" id="behaviorPanel">
|
||||
<div id="behaviors"></div>
|
||||
<div class="booter center">
|
||||
<button type="button" class="btn btn-primary " id="add-device">add</button>
|
||||
<button type="button" class="btn btn-primary " id="remove-device">remove</button>
|
||||
<a class="action">To Configure Data Sender >></a>
|
||||
<button type="button" class="btn btn-large btn-primary" id="start">Start To Test</button>
|
||||
<a class="action" id="to-device">Back to Configure Device >></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.3.min.js"></script>
|
||||
<script src="lib/HashMap/HashMap.js"></script>
|
||||
<script src="script/device/DataCollector.js"></script>
|
||||
<script src="script/device/EditorFactory.js"></script>
|
||||
<script src="script/device/ContainerFactory.js"></script>
|
||||
<script src="script/device/DeviceFactory.js"></script>
|
||||
<script src="script/device/device.js"></script>
|
||||
</body>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 6.0 KiB |
|
@ -0,0 +1,66 @@
|
|||
var ContainerFactory = function() {
|
||||
};
|
||||
ContainerFactory.prototype.createEditorContainer = function(header, id,
|
||||
containerInfo) {
|
||||
|
||||
var container = document.createElement("div");
|
||||
$(container).addClass("containerBox");
|
||||
if (id != null) {
|
||||
$(container).attr("id", id);
|
||||
}
|
||||
var containerHeader = document.createElement("p");
|
||||
$(containerHeader).addClass("header");
|
||||
var img = document.createElement("img");
|
||||
$(containerHeader).append(img);
|
||||
$(containerHeader).append(document.createTextNode(header));
|
||||
$(container).append(containerHeader);
|
||||
|
||||
for ( var i = 0; i < containerInfo.length; i++) {
|
||||
|
||||
if (containerInfo[i].children == null) {
|
||||
this.appendEdtiors(container, containerInfo[i].label,
|
||||
containerInfo[i].name, containerInfo[i].paramTypeModel);
|
||||
}
|
||||
else {
|
||||
$(container).append(
|
||||
|
||||
this.createEditorContainer(containerInfo[i].name, null,
|
||||
containerInfo[i].children));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return container;
|
||||
|
||||
};
|
||||
|
||||
ContainerFactory.prototype.appendEdtiors = function(container, label, name,
|
||||
editorInfo) {
|
||||
var editorFactory = new EditorFactory();
|
||||
|
||||
if (editorInfo.type.toLowerCase() == "field") {
|
||||
$(container).append(
|
||||
editorFactory.createField(label, name, editorInfo.size, name));
|
||||
|
||||
} else if (editorInfo.type.toLowerCase() == "nfield") {
|
||||
$(container).append(
|
||||
editorFactory.createMultiField(label, name, editorInfo.size,
|
||||
name));
|
||||
} else if (editorInfo.type.toLowerCase() == "table") {
|
||||
$(container).append(
|
||||
editorFactory.createTable(label, name, editorInfo.cols, name));
|
||||
|
||||
} else if (editorInfo.type.toLowerCase() == "file") {
|
||||
$(container).append(
|
||||
editorFactory.createFile(lable, name, editorInfo.size, name));
|
||||
} else if (editorInfo.type.toLowerCase() == "date") {
|
||||
$(container).append(
|
||||
editorFactory.createDate(label, name, editorInfo.size, name));
|
||||
} else if (editorInfo.type.toLowerCase() == "select") {
|
||||
$(container).append(
|
||||
editorFactory.createSelect(label, name, editorInfo.size,
|
||||
editorInfo.options, name));
|
||||
} else {
|
||||
alert("no such editor type:" + editorInfo.type);
|
||||
}
|
||||
};
|
|
@ -0,0 +1,164 @@
|
|||
var Parameter = function(key, value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
var DataCollector = function() {
|
||||
};
|
||||
DataCollector.prototype.fieldData = function(editor) {
|
||||
editor = $(editor.children('.field'));
|
||||
var name = editor.children("label").html();
|
||||
var value = editor.children("input").val();
|
||||
if (value == null || value == "") {
|
||||
alert("please input data in " + editor.attr("id"));
|
||||
return;
|
||||
}
|
||||
|
||||
return new Parameter(name, value);
|
||||
};
|
||||
DataCollector.prototype.dateData = function(editor) {
|
||||
var name = editor.children("label").html();
|
||||
var value = editor.children("input").val();
|
||||
if (value == null || value == "") {
|
||||
alert("please input data in " + editor.attr("id"));
|
||||
return;
|
||||
}
|
||||
|
||||
return new Parameter(name, value);
|
||||
};
|
||||
DataCollector.prototype.multiFieldData = function(editor) {
|
||||
var editorArray = editor.children(".field");
|
||||
if (ediotrArray.size == 0) {
|
||||
alert("please input data in " + editor.attr("id"));
|
||||
return;
|
||||
|
||||
}
|
||||
var name = editor.attr("id")
|
||||
var value = "";
|
||||
|
||||
for ( var i = 0; i < editorArray.length; i++) {
|
||||
var filedValue = $(editorArray[i]).children("input").val();
|
||||
if (filedValue == null || filedValue == "") {
|
||||
alert("please input data in" + editor.attr("id"));
|
||||
return;
|
||||
}
|
||||
|
||||
value += fieldVlaue + ";";
|
||||
}
|
||||
value = value.substring(0, value.length - 1);
|
||||
return new Parameter(name, value);
|
||||
|
||||
};
|
||||
|
||||
DataCollector.prototype.tableData = function(editor) {
|
||||
var editorArray = editor.find("tbody").children("tr");
|
||||
var name = editor.attr("id");
|
||||
var value = "";
|
||||
for ( var i = 0; i < editorArray.length; i++) {
|
||||
var tdArray = $(editorArray[i]).children("td");
|
||||
var trValue = "";
|
||||
for ( var j = 1; j < tdArray.length; j++) {
|
||||
trValue += $(tdArray[j]).children("input").val() + "|";
|
||||
}
|
||||
trValue = trValue.substring(0, trValue.length - 1);
|
||||
value += trValue + ";";
|
||||
}
|
||||
value = value.substring(0, value.length - 1);
|
||||
return new Parameter(name, value);
|
||||
|
||||
};
|
||||
DataCollector.prototype.selectData = function(editor) {
|
||||
var name = editor.attr("id");
|
||||
var value = editor.children("select").val();
|
||||
return new Parameter(name, value);
|
||||
};
|
||||
|
||||
DataCollector.prototype.getUnitParams = function(paramEditors) {
|
||||
var params = new Array();
|
||||
for ( var i = 0; i < paramEditors.length; i++) {
|
||||
var editor = $(paramEditors[i]);
|
||||
var editorType = editor.attr("editorType");
|
||||
if (editorType == "field") {
|
||||
params.push(this.fieldData(editor));
|
||||
} else if (editorType == "date") {
|
||||
params.push(this.dateData(editor));
|
||||
} else if (editorType == "multiField") {
|
||||
params.push(this.multiFieldData(deditor));
|
||||
} else if (editorType == "table") {
|
||||
params.push(this.tableData(editor));
|
||||
} else if (editorType == "select") {
|
||||
params.push(this.selectData(editor));
|
||||
}
|
||||
}
|
||||
return params;
|
||||
};
|
||||
|
||||
var BehaviorData = function(name, usePlugin, type, parameters) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.use = usePlugin;
|
||||
this.parameters = parameters;
|
||||
};
|
||||
function getBehaviorNames(usePlugins) {
|
||||
var behaviorNames = new Array();
|
||||
var behaviorName = "Send";
|
||||
for ( var i = 0; i < usePlugins.length; i++) {
|
||||
behaviorNames.push(usePlugins[i].id + "_" + behaviorName);
|
||||
|
||||
}
|
||||
return behaviorNames;
|
||||
|
||||
};
|
||||
|
||||
function getBehaviorDatas(behaviorNames) {
|
||||
var behaviors = new Array();
|
||||
var behaviorEditor = $("#behaviors").children(".containerBox");
|
||||
var type = "USERBEHAVIOR";
|
||||
for ( var i = 0; i < behaviorNames.length; i++) {
|
||||
behaviors.push(getBehaviorData(behaviorEditor, behaviorNames[i], type));
|
||||
}
|
||||
return behaviors;
|
||||
function getBehaviorData(editor, behaviorName, type) {
|
||||
var paramEditors = editor.find(".editor");
|
||||
var names = behaviorName.split("_");
|
||||
var usePlugin = names[0];
|
||||
var behavior = names[1];
|
||||
var dataCollector = new DataCollector();
|
||||
var params = dataCollector.getUnitParams(paramEditors);
|
||||
var behavior = new BehaviorData(behavior, usePlugin, type, params);
|
||||
return behavior;
|
||||
}
|
||||
;
|
||||
|
||||
};
|
||||
var PluginData = function(id, name, params) {
|
||||
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.parameters = params;
|
||||
}
|
||||
|
||||
function getPluginDatas() {
|
||||
var pluginContainers = $("#devices").children(".containerBox");
|
||||
var separators = $("#devices").children(".separator");
|
||||
var plugins = new Array();
|
||||
var pluginCount = -1;
|
||||
var pluginName = "hbase";
|
||||
for ( var i = 0; i < pluginContainers.length; i++) {
|
||||
var deviceSize = $(separators[i]).children("input").val();
|
||||
if (deviceSize == null || deviceSize == "") {
|
||||
alert("no device config");
|
||||
return [];
|
||||
}
|
||||
var dataCollector = new DataCollector();
|
||||
var params = dataCollector.getUnitParams($(pluginContainers[i]).find(".editor"));
|
||||
for ( var j = 1; j <= deviceSize; j++) {
|
||||
pluginCount++;
|
||||
var id=pluginName+pluginCount;
|
||||
plugins.push(new PluginData(id, pluginName,params));
|
||||
}
|
||||
|
||||
}
|
||||
return plugins;
|
||||
|
||||
|
||||
}
|
|
@ -1,18 +1,23 @@
|
|||
var DeviceFactory = function(deviceEditorInfo, container) {
|
||||
var DeviceFactory = function(deviceEditorInfo, container, behaviorEditorInfo) {
|
||||
this.deviceEditorInfo = deviceEditorInfo;
|
||||
this.container = container;
|
||||
this.behaviorEditorInfo = behaviorEditorInfo;
|
||||
};
|
||||
DeviceFactory.prototype.createDevice = function(header, id) {
|
||||
var deviceSizeConfig = this.createDeviceSizeConfig();
|
||||
var deviceContainer = this.createEditorContainer(header, id,
|
||||
this.deviceEditorInfo);
|
||||
this.container.append(deviceSizeConfig);
|
||||
|
||||
this.container.append(deviceContainer);
|
||||
var deviceSizeConfig = this.createDeviceSizeConfig();
|
||||
var containerFactory = new ContainerFactory();
|
||||
var deviceContainer = containerFactory.createEditorContainer(header, id,
|
||||
this.deviceEditorInfo);
|
||||
var behaviorFactory = new BehaviorFactory(this.container);
|
||||
behaviorFactory.createBehavior("Device Data Sender", "behavior",
|
||||
this.behaviorEditorInfo);
|
||||
|
||||
this.container.prepend(deviceContainer);
|
||||
this.container.prepend(deviceSizeConfig);
|
||||
|
||||
};
|
||||
DeviceFactory.prototype.createDeviceSizeConfig = function() {
|
||||
|
||||
var deviceSizeConfig = document.createElement("div");
|
||||
$(deviceSizeConfig).addClass("separator");
|
||||
var label = document.createElement("label");
|
||||
|
@ -22,71 +27,25 @@ DeviceFactory.prototype.createDeviceSizeConfig = function() {
|
|||
$(deviceSizeConfig).append(label);
|
||||
$(deviceSizeConfig).append(input);
|
||||
return deviceSizeConfig;
|
||||
|
||||
}
|
||||
|
||||
DeviceFactory.prototype.createEditorContainer = function(header, id,
|
||||
containerInfo) {
|
||||
|
||||
var container = document.createElement("div");
|
||||
$(container).addClass("containerBox");
|
||||
if (id != null) {
|
||||
$(container).attr("id", id);
|
||||
}
|
||||
var containerHeader = document.createElement("p");
|
||||
$(containerHeader).addClass("header");
|
||||
var img = document.createElement("img");
|
||||
$(containerHeader).append(img);
|
||||
$(containerHeader).append(document.createTextNode(header));
|
||||
$(container).append(containerHeader);
|
||||
|
||||
for ( var i = 0; i < containerInfo.length; i++) {
|
||||
|
||||
if (containerInfo[i].children == null) {
|
||||
this.appendEdtiors(container, containerInfo[i].label,
|
||||
containerInfo[i].name, containerInfo[i].paramTypeModel);
|
||||
}
|
||||
|
||||
else {
|
||||
$(container).append(
|
||||
|
||||
this.createEditorContainer(containerInfo[i].name, null,
|
||||
containerInfo[i].children));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return container;
|
||||
var BehaviorFactory = function(container) {
|
||||
this.container = container;
|
||||
|
||||
};
|
||||
BehaviorFactory.prototype.createBehavior = function(header, id, editorInfo) {
|
||||
var title = this.createTitle();
|
||||
var containerFactory = new ContainerFactory();
|
||||
var editorContainer = containerFactory.createEditorContainer(header, id,
|
||||
editorInfo);
|
||||
|
||||
DeviceFactory.prototype.appendEdtiors = function(container, label, name,
|
||||
editorInfo) {
|
||||
var editorFactory = new EditorFactory();
|
||||
|
||||
if (editorInfo.type.toLowerCase() == "field") {
|
||||
$(container).append(
|
||||
editorFactory.createField(label, name, editorInfo.size, name));
|
||||
|
||||
} else if (editorInfo.type.toLowerCase() == "nfield") {
|
||||
$(container).append(
|
||||
editorFactory.createMultiField(label, name, editorInfo.size,
|
||||
name));
|
||||
} else if (editorInfo.type.toLowerCase() == "table") {
|
||||
$(container).append(
|
||||
editorFactory.createTable(label, name, editorInfo.cols, name));
|
||||
|
||||
} else if (editorInfo.type.toLowerCase() == "file") {
|
||||
$(container).append(
|
||||
editorFactory.createFile(lable, name, editorInfo.size, name));
|
||||
} else if (editorInfo.type.toLowerCase() == "date") {
|
||||
$(container).append(
|
||||
editorFactory.createDate(label, name, editorInfo.size, name));
|
||||
} else if (editorInfo.type.toLowerCase() == "select") {
|
||||
$(container).append(
|
||||
editorFactory.createSelect(label, name, editorInfo.size,
|
||||
editorInfo.options, name));
|
||||
} else {
|
||||
alert("no such editor type:" + editorInfo.type);
|
||||
}
|
||||
this.container.prepend(editorContainer)
|
||||
this.container.prepend(title);
|
||||
};
|
||||
BehaviorFactory.prototype.createTitle = function() {
|
||||
var title = document.createElement("div");
|
||||
$(title).addClass("separator");
|
||||
$(title).attr("style", "color:#4183c4")
|
||||
$(title).html("Configure Device Data Sender")
|
||||
return title;
|
||||
}
|
||||
|
|
|
@ -21,11 +21,14 @@ EditorFactory.prototype.createBaseEditor = function(label, id) {
|
|||
|
||||
EditorFactory.prototype.createField = function(label, name, size, id) {
|
||||
var div = this.createBaseEditor(label, id);
|
||||
$(div).children(".editor").attr("editorType", "field");
|
||||
$(div).children(".editor").append(this.createFieldLine(size, name));
|
||||
return div;
|
||||
}
|
||||
EditorFactory.prototype.createMultiField = function(label, name, size, id) {
|
||||
var div = this.createField(label, name, size, id);
|
||||
var div = this.createBaseEditor(label, id);
|
||||
$(div).children(".editor").attr("editorType", "multiField");
|
||||
$(div).children(".editor").append(this.createFieldLine(size, name));
|
||||
var editorFactory = this;
|
||||
var addFieldButton = document.createElement("button");
|
||||
$(addFieldButton).html("add")
|
||||
|
@ -58,7 +61,7 @@ EditorFactory.prototype.createFieldLine = function(size, name) {
|
|||
var fieldDiv = document.createElement("div");
|
||||
$(fieldDiv).addClass("field");
|
||||
var fieldName = document.createElement("label");
|
||||
$(fieldName).html(name + ":");
|
||||
$(fieldName).html(name);
|
||||
var field = document.createElement("input");
|
||||
$(field).attr("type", "text");
|
||||
$(field).attr("style", "width:" + size + "px");
|
||||
|
@ -71,11 +74,11 @@ EditorFactory.prototype.createFile = function(label, name, size, id) {
|
|||
}
|
||||
|
||||
var div = this.createBaseEditor(label, id);
|
||||
|
||||
$(div).children(".editor").attr("editorType", "file");
|
||||
var fileEditor = document.createElement("div");
|
||||
|
||||
var fieldName = document.createElement("label");
|
||||
$(fieldName).html(name + ":");
|
||||
$(fieldName).html(name);
|
||||
var file = document.createElement("input");
|
||||
$(file).attr("type", "file");
|
||||
$(file).attr("style", "width:" + size + "px");
|
||||
|
@ -87,6 +90,7 @@ EditorFactory.prototype.createFile = function(label, name, size, id) {
|
|||
|
||||
EditorFactory.prototype.createTable = function(label, name, cols, id) {
|
||||
var div = this.createBaseEditor(label, id);
|
||||
$(div).children(".editor").attr("editorType", "table");
|
||||
var headers = getHeaders(cols);
|
||||
$(div).children(".editor").append(createTable(cols, name, headers));
|
||||
var addButton = document.createElement("button");
|
||||
|
@ -151,7 +155,7 @@ EditorFactory.prototype.createTable = function(label, name, cols, id) {
|
|||
var tr = document.createElement("tr");
|
||||
var td = document.createElement("td");
|
||||
$(td).attr("style", "width:" + 100 / headers.length + "%")
|
||||
$(td).html(name + ":");
|
||||
$(td).html(name);
|
||||
$(tr).append(td);
|
||||
for ( var i = 1; i < headers.length; i++) {
|
||||
var input = document.createElement("input");
|
||||
|
@ -176,8 +180,9 @@ EditorFactory.prototype.createSelect = function(label, name, size, options, id)
|
|||
}
|
||||
|
||||
var div = this.createBaseEditor(label, id);
|
||||
$(div).children(".editor").attr("editorType", "select");
|
||||
var nameLabel = document.createElement("label");
|
||||
$(nameLabel).html(name + ":");
|
||||
$(nameLabel).html(name);
|
||||
$(div).children(".editor").append(nameLabel);
|
||||
var select = document.createElement("select");
|
||||
$(select).attr("style", "width:" + size + "px");
|
||||
|
@ -196,6 +201,7 @@ EditorFactory.prototype.createDate = function(label, name, size, id) {
|
|||
size = 150
|
||||
}
|
||||
var div = this.createBaseEditor(label, id);
|
||||
$(div).children(".editor").attr("editorType","date");
|
||||
var dateLabel = document.createElement("label");
|
||||
$(dateLabel).html(name);
|
||||
var date = document.createElement("input");
|
||||
|
@ -203,7 +209,6 @@ EditorFactory.prototype.createDate = function(label, name, size, id) {
|
|||
$(div).children(".editor").append(dateLabel);
|
||||
$(div).children(".editor").append(date);
|
||||
return div;
|
||||
|
||||
}
|
||||
function createContainer(id, name) {
|
||||
|
||||
|
|
|
@ -26,40 +26,94 @@ function dataTransfer(serverData) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
function initDevice(){
|
||||
var pluginData;
|
||||
var behaviorData;
|
||||
var pluginName="hbase";
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url:"/getPlugin/" + pluginName,
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function (data) {
|
||||
if(data.success){
|
||||
pluginData=dataTransfer(data.pluginInfo );
|
||||
}
|
||||
else{
|
||||
alert(data.failedMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url:"loadBehaviorList/"+pluginName,
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function (data) {
|
||||
if(data.success){
|
||||
behaviorData=dataTransfer(data.behaviors[0]);
|
||||
}
|
||||
else{
|
||||
alert(data.failedMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
var deviceFactory=new DeviceFactory(pluginData,$("#devices"),behaviorData);
|
||||
deviceFactory.createDevice("device config",
|
||||
"device");
|
||||
return deviceFactory;
|
||||
|
||||
|
||||
}
|
||||
function createSeparator(){
|
||||
var div=document.create
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
var deviceFactory;
|
||||
$.get("/getPlugin/" + "hbase", {}, function(data) {
|
||||
$("#behaviorPanel").hide();
|
||||
var deviceFactory=initDevice();
|
||||
$("#add-device").click(
|
||||
{
|
||||
deviceFactory : deviceFactory,
|
||||
},
|
||||
function(event) {
|
||||
event.preventDefault();
|
||||
event.data.deviceFactory.createDevice("device config",
|
||||
"device");
|
||||
|
||||
if (data.success) {
|
||||
deviceFactory = new DeviceFactory(dataTransfer(data.pluginInfo),
|
||||
$("#devices"));
|
||||
deviceFactory.createDevice("device config", "device-0");
|
||||
$("#add-device").click(
|
||||
{
|
||||
deviceFactory : deviceFactory,
|
||||
},
|
||||
function(event) {
|
||||
event.preventDefault();
|
||||
event.data.deviceFactory.createDevice("device config",
|
||||
"device-1");
|
||||
|
||||
});
|
||||
$("#remove-device").click(function(event) {
|
||||
event.preventDefault();
|
||||
if ($("#devices").children(".containerBox").length <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$("#devices").children(".containerBox").last().remove();
|
||||
$("#devices").children(".separator").last().remove();
|
||||
|
||||
});
|
||||
|
||||
} else {
|
||||
alert(data.failedMessage);
|
||||
}
|
||||
});
|
||||
$("#remove-device").click(function(event) {
|
||||
event.preventDefault();
|
||||
if ($("#devices").children(".containerBox").length <= 1) {
|
||||
return;
|
||||
}
|
||||
$("#devices").children(".containerBox").last().remove();
|
||||
$("#devices").children(".separator").last().remove();
|
||||
|
||||
});
|
||||
|
||||
$("#start").click(function(event){
|
||||
var plugins=getPluginDatas();
|
||||
var behaviorNames=getBehaviorNames(plugins);
|
||||
var behaviors=getBehaviorDatas(behaviorNames);
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: 'deviceScript',
|
||||
dataType: "json",
|
||||
async: false,
|
||||
contentType:"application/json",
|
||||
data: JSON.stringify({usePlugins:plugins,behaviors:behaviors,name:"script"}),
|
||||
success: function (data) {
|
||||
if(data.success){
|
||||
return ;
|
||||
}
|
||||
else{
|
||||
alert(data.failedMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -2,13 +2,10 @@ package org.bench4q.web.test.masterMessager;
|
|||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.master.OrganizeRecordPortResponseModel;
|
||||
import org.bench4q.share.models.master.PortModel;
|
||||
|
@ -20,7 +17,6 @@ import org.junit.runner.RunWith;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
|
||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
||||
import com.github.tomakehurst.wiremock.client.WireMock;
|
||||
|
@ -28,12 +24,12 @@ import com.github.tomakehurst.wiremock.client.WireMock;
|
|||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "file:src/test/resources/bench4qweb-servlet.xml" })
|
||||
public class PortMessageTest extends MessagerTestBase {
|
||||
static private int portNumber=5;
|
||||
static private int portNumber = 5;
|
||||
private final int port = 7979;
|
||||
private RecordPortMessager recordPortMessager;
|
||||
private WireMockServer wireMockServer;
|
||||
private WireMock wireMock;
|
||||
|
||||
|
||||
public RecordPortMessager getRecordPortMessager() {
|
||||
return recordPortMessager;
|
||||
}
|
||||
|
@ -61,7 +57,7 @@ public class PortMessageTest extends MessagerTestBase {
|
|||
|
||||
@Test
|
||||
public void test_addPort() throws IOException, JAXBException {
|
||||
String resultWithoutPortList=PortMessageTest.loadWithoutPortList();
|
||||
String resultWithoutPortList = PortMessageTest.loadWithoutPortList();
|
||||
wireMock.register(post(urlEqualTo("/RecordPort/addPortToPortPool"))
|
||||
.withRequestBody(containing("port")).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
|
@ -71,9 +67,10 @@ public class PortMessageTest extends MessagerTestBase {
|
|||
.addPort(null, "8090");
|
||||
assertTrue(responseModel.isSuccess());
|
||||
}
|
||||
@Test
|
||||
public void test_deletePort() throws JAXBException{
|
||||
String resultWithoutPortList=PortMessageTest.loadWithoutPortList();
|
||||
|
||||
@Test
|
||||
public void test_deletePort() throws JAXBException {
|
||||
String resultWithoutPortList = PortMessageTest.loadWithoutPortList();
|
||||
wireMock.register(post(urlEqualTo("/RecordPort/removePortFromPool"))
|
||||
.withRequestBody(containing("port")).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
|
@ -82,10 +79,11 @@ public class PortMessageTest extends MessagerTestBase {
|
|||
OrganizeRecordPortResponseModel responseModel = recordPortMessager
|
||||
.deletePort(null, "8090");
|
||||
assertTrue(responseModel.isSuccess());
|
||||
}
|
||||
@Test
|
||||
public void test_loadPorts() throws JAXBException{
|
||||
String resultWithPortList=PortMessageTest.loadWithPortList();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_loadPorts() throws JAXBException {
|
||||
String resultWithPortList = PortMessageTest.loadWithPortList();
|
||||
wireMock.register(post(urlEqualTo("/RecordPort/loadPortList"))
|
||||
.willReturn(
|
||||
aResponse().withStatus(200)
|
||||
|
@ -94,28 +92,27 @@ public class PortMessageTest extends MessagerTestBase {
|
|||
OrganizeRecordPortResponseModel responseModel = recordPortMessager
|
||||
.loadPorts(null);
|
||||
assertTrue(responseModel.isSuccess());
|
||||
}
|
||||
|
||||
static public String loadWithPortList() throws JAXBException{
|
||||
List<PortModel> list=new ArrayList<PortModel>();
|
||||
for(int i=1;i<=portNumber;i++){
|
||||
PortModel portModel=new PortModel();
|
||||
portModel.setId(i);
|
||||
list.add(portModel);
|
||||
}
|
||||
OrganizeRecordPortResponseModel organizeRecordPortResponseModel=new OrganizeRecordPortResponseModel();
|
||||
}
|
||||
|
||||
static public String loadWithPortList() throws JAXBException {
|
||||
List<PortModel> list = new ArrayList<PortModel>();
|
||||
for (int i = 1; i <= portNumber; i++) {
|
||||
PortModel portModel = new PortModel();
|
||||
portModel.setId(i);
|
||||
list.add(portModel);
|
||||
}
|
||||
OrganizeRecordPortResponseModel organizeRecordPortResponseModel = new OrganizeRecordPortResponseModel();
|
||||
organizeRecordPortResponseModel.setSuccess(true);
|
||||
organizeRecordPortResponseModel.setFailCauseString("");
|
||||
organizeRecordPortResponseModel
|
||||
.setPortModels(list);
|
||||
organizeRecordPortResponseModel.setPortModels(list);
|
||||
String resultWithPortList = MarshalHelper.marshal(
|
||||
OrganizeRecordPortResponseModel.class,
|
||||
organizeRecordPortResponseModel);
|
||||
return resultWithPortList;
|
||||
}
|
||||
|
||||
static public String loadWithoutPortList() throws JAXBException{
|
||||
OrganizeRecordPortResponseModel organizeRecordPortResponseModel=new OrganizeRecordPortResponseModel();
|
||||
}
|
||||
|
||||
static public String loadWithoutPortList() throws JAXBException {
|
||||
OrganizeRecordPortResponseModel organizeRecordPortResponseModel = new OrganizeRecordPortResponseModel();
|
||||
organizeRecordPortResponseModel.setSuccess(true);
|
||||
organizeRecordPortResponseModel.setFailCauseString("");
|
||||
organizeRecordPortResponseModel
|
||||
|
@ -124,6 +121,6 @@ public class PortMessageTest extends MessagerTestBase {
|
|||
OrganizeRecordPortResponseModel.class,
|
||||
organizeRecordPortResponseModel);
|
||||
return resultWithoutPortList;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,86 +16,126 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "file:src/test/resources/bench4qweb-servlet.xml" })
|
||||
public class ScriptMessageTest extends MessagerTestBase{
|
||||
public class ScriptMessageTest extends MessagerTestBase {
|
||||
private ScriptMessager scriptMessager;
|
||||
private String accessToken;
|
||||
private RecordPortMessager recordPortMessager;
|
||||
private String scriptName="testScript";
|
||||
private String scriptName = "testScript";
|
||||
|
||||
@Autowired
|
||||
public void setRecordPortMessager(RecordPortMessager recordPortMessager){
|
||||
this.recordPortMessager=recordPortMessager;
|
||||
public void setRecordPortMessager(RecordPortMessager recordPortMessager) {
|
||||
this.recordPortMessager = recordPortMessager;
|
||||
}
|
||||
public RecordPortMessager getRecordPortMessager(){
|
||||
|
||||
public RecordPortMessager getRecordPortMessager() {
|
||||
return this.recordPortMessager;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setScriptMessager(ScriptMessager scriptMessager){
|
||||
this.scriptMessager=scriptMessager;
|
||||
public void setScriptMessager(ScriptMessager scriptMessager) {
|
||||
this.scriptMessager = scriptMessager;
|
||||
}
|
||||
public ScriptMessager getScriptMessager(){
|
||||
|
||||
public ScriptMessager getScriptMessager() {
|
||||
return this.scriptMessager;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void SetUp(){
|
||||
this.accessToken=this.login();
|
||||
public void SetUp() {
|
||||
this.accessToken = this.login();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_startScriptRecordServer() throws JAXBException{
|
||||
this.scriptMessager.stopScriptRecordServer(accessToken,"8090","");
|
||||
OperateScriptServerResponseModel operateScriptServerResponseModel=this.scriptMessager.startScriptRecordServer(accessToken);
|
||||
String xml=MarshalHelper.marshal(OperateScriptServerResponseModel.class, operateScriptServerResponseModel);
|
||||
public void test_startScriptRecordServer() throws JAXBException {
|
||||
this.scriptMessager.stopScriptRecordServer(accessToken, "8090", "");
|
||||
OperateScriptServerResponseModel operateScriptServerResponseModel = this.scriptMessager
|
||||
.startScriptRecordServer(accessToken);
|
||||
String xml = MarshalHelper.marshal(
|
||||
OperateScriptServerResponseModel.class,
|
||||
operateScriptServerResponseModel);
|
||||
System.out.println(xml);
|
||||
assertTrue(operateScriptServerResponseModel.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_stopScriptRecordServer(){
|
||||
OperateScriptServerResponseModel stopOperateScriptServerResponseModel=this.scriptMessager.stopScriptRecordServer(accessToken,"8090","");
|
||||
public void test_stopScriptRecordServer() {
|
||||
OperateScriptServerResponseModel stopOperateScriptServerResponseModel = this.scriptMessager
|
||||
.stopScriptRecordServer(accessToken, "8090", "");
|
||||
assertTrue(stopOperateScriptServerResponseModel.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_loadScript(){
|
||||
OperateScriptServerResponseModel beforeSave_operateScriptServerResponseModel=this.scriptMessager.loadScript(accessToken);
|
||||
public void test_loadScript() {
|
||||
OperateScriptServerResponseModel beforeSave_operateScriptServerResponseModel = this.scriptMessager
|
||||
.loadScript(accessToken);
|
||||
assertTrue(beforeSave_operateScriptServerResponseModel.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_saveAndDeleteScript(){
|
||||
int countBeforeSave=this.scriptMessager.loadScript(accessToken).getScriptModels().size();
|
||||
this.scriptMessager.stopScriptRecordServer(accessToken,"8090","");
|
||||
OperateScriptServerResponseModel startOperateScriptServerResponseModel=this.scriptMessager.startScriptRecordServer(accessToken);
|
||||
String port=Integer.toString(startOperateScriptServerResponseModel.getPort());
|
||||
String fileNameUUID=startOperateScriptServerResponseModel.getFileName();
|
||||
assertTrue(this.scriptMessager.saveScriptRecorded(accessToken, scriptName, port, fileNameUUID).isSuccess());
|
||||
int countAfterSave=this.scriptMessager.loadScript(accessToken).getScriptModels().size();
|
||||
assertEquals(countBeforeSave+1,countAfterSave);
|
||||
assertTrue(this.scriptMessager.queryScriptByName(accessToken, scriptName).isSuccess());
|
||||
ScriptModel scriptModel=this.scriptMessager.queryScriptByName(accessToken, scriptName).getScriptModels().get(0);
|
||||
String id=Integer.toString(scriptModel.getId());
|
||||
assertTrue(this.scriptMessager.deleteScript(accessToken, id).isSuccess());
|
||||
int countAfterDelete=this.scriptMessager.loadScript(accessToken).getScriptModels().size();
|
||||
assertEquals(countBeforeSave,countAfterDelete);
|
||||
public void test_saveAndDeleteScript() {
|
||||
int countBeforeSave = this.scriptMessager.loadScript(accessToken)
|
||||
.getScriptModels().size();
|
||||
this.scriptMessager.stopScriptRecordServer(accessToken, "8090", "");
|
||||
OperateScriptServerResponseModel startOperateScriptServerResponseModel = this.scriptMessager
|
||||
.startScriptRecordServer(accessToken);
|
||||
String port = Integer.toString(startOperateScriptServerResponseModel
|
||||
.getPort());
|
||||
String fileNameUUID = startOperateScriptServerResponseModel
|
||||
.getFileName();
|
||||
assertTrue(this.scriptMessager.saveScriptRecorded(accessToken,
|
||||
scriptName, port, fileNameUUID).isSuccess());
|
||||
int countAfterSave = this.scriptMessager.loadScript(accessToken)
|
||||
.getScriptModels().size();
|
||||
assertEquals(countBeforeSave + 1, countAfterSave);
|
||||
assertTrue(this.scriptMessager.queryScriptByName(accessToken,
|
||||
scriptName).isSuccess());
|
||||
ScriptModel scriptModel = this.scriptMessager
|
||||
.queryScriptByName(accessToken, scriptName).getScriptModels()
|
||||
.get(0);
|
||||
String id = Integer.toString(scriptModel.getId());
|
||||
assertTrue(this.scriptMessager.deleteScript(accessToken, id)
|
||||
.isSuccess());
|
||||
int countAfterDelete = this.scriptMessager.loadScript(accessToken)
|
||||
.getScriptModels().size();
|
||||
assertEquals(countBeforeSave, countAfterDelete);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_updateScript(){
|
||||
this.scriptMessager.stopScriptRecordServer(accessToken,"8090","");
|
||||
OperateScriptServerResponseModel startOperateScriptServerResponseModel=this.scriptMessager.startScriptRecordServer(accessToken);
|
||||
String port=Integer.toString(startOperateScriptServerResponseModel.getPort());
|
||||
String fileNameUUID=startOperateScriptServerResponseModel.getFileName();
|
||||
this.scriptMessager.saveScriptRecorded(accessToken, scriptName, port, fileNameUUID);
|
||||
String id=Integer.toString(this.scriptMessager.queryScriptByName(accessToken, scriptName).getScriptModels().get(0).getId());
|
||||
String scriptContent="testScriptContent";
|
||||
assertTrue(this.scriptMessager.updateScript(accessToken, id, scriptContent).isSuccess());
|
||||
public void test_updateScript() {
|
||||
this.scriptMessager.stopScriptRecordServer(accessToken, "8090", "");
|
||||
OperateScriptServerResponseModel startOperateScriptServerResponseModel = this.scriptMessager
|
||||
.startScriptRecordServer(accessToken);
|
||||
String port = Integer.toString(startOperateScriptServerResponseModel
|
||||
.getPort());
|
||||
String fileNameUUID = startOperateScriptServerResponseModel
|
||||
.getFileName();
|
||||
this.scriptMessager.saveScriptRecorded(accessToken, scriptName, port,
|
||||
fileNameUUID);
|
||||
String id = Integer.toString(this.scriptMessager
|
||||
.queryScriptByName(accessToken, scriptName).getScriptModels()
|
||||
.get(0).getId());
|
||||
String scriptContent = "testScriptContent";
|
||||
assertTrue(this.scriptMessager.updateScript(accessToken, id,
|
||||
scriptContent).isSuccess());
|
||||
this.scriptMessager.deleteScript(accessToken, id);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_queryScriptById(){
|
||||
this.scriptMessager.stopScriptRecordServer(accessToken,"8090","");
|
||||
OperateScriptServerResponseModel startOperateScriptServerResponseModel=this.scriptMessager.startScriptRecordServer(accessToken);
|
||||
String port=Integer.toString(startOperateScriptServerResponseModel.getPort());
|
||||
String fileNameUUID=startOperateScriptServerResponseModel.getFileName();
|
||||
this.scriptMessager.saveScriptRecorded(accessToken, scriptName, port, fileNameUUID);
|
||||
String id=Integer.toString(this.scriptMessager.queryScriptByName(accessToken, scriptName).getScriptModels().get(0).getId());
|
||||
assertTrue(this.scriptMessager.queryScriptById(accessToken, id).isSuccess());
|
||||
public void test_queryScriptById() {
|
||||
this.scriptMessager.stopScriptRecordServer(accessToken, "8090", "");
|
||||
OperateScriptServerResponseModel startOperateScriptServerResponseModel = this.scriptMessager
|
||||
.startScriptRecordServer(accessToken);
|
||||
String port = Integer.toString(startOperateScriptServerResponseModel
|
||||
.getPort());
|
||||
String fileNameUUID = startOperateScriptServerResponseModel
|
||||
.getFileName();
|
||||
this.scriptMessager.saveScriptRecorded(accessToken, scriptName, port,
|
||||
fileNameUUID);
|
||||
String id = Integer.toString(this.scriptMessager
|
||||
.queryScriptByName(accessToken, scriptName).getScriptModels()
|
||||
.get(0).getId());
|
||||
assertTrue(this.scriptMessager.queryScriptById(accessToken, id)
|
||||
.isSuccess());
|
||||
this.scriptMessager.deleteScript(accessToken, id);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue