use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.
the class Graph method addNode.
private Node addNode(GraphCommon owner, ActivityImplementorVO nmi, int x, int y, boolean recordchange) {
String name = "New " + nmi.getLabel();
if (nmi.isManualTask()) {
if (owner instanceof SubGraph)
name = processVO.getProcessName() + " Fallout";
else
name = "New Task for " + processVO.getProcessName();
}
Long pActId = genNodeId();
String pDesc = null;
String pActImplClass = nmi.getImplementorClassName();
ArrayList<AttributeVO> pAttribs = new ArrayList<AttributeVO>();
if (nmi.isManualTask()) {
pAttribs.add(new AttributeVO(TaskActivity.ATTRIBUTE_TASK_NAME, name));
pAttribs.add(new AttributeVO(TaskActivity.ATTRIBUTE_TASK_CATEGORY, "COM"));
pAttribs.add(new AttributeVO(TaskActivity.ATTRIBUTE_TASK_VARIABLES, TaskVO.getVariablesAsString(processVO.getVariables(), null)));
}
ActivityVO nodet = new ActivityVO(pActId, name, pDesc, pActImplClass, pAttribs);
owner.getProcessVO().getActivities().add(nodet);
Node node = new Node(nodet, owner, metainfo);
String iconname = node.getIconName();
javax.swing.Icon icon = getIconFactory().getIcon(iconname);
if (nodestyle.equals(Node.NODE_STYLE_ICON)) {
node.w = icon.getIconWidth();
node.h = icon.getIconHeight();
} else {
if (icon instanceof ImageIcon) {
node.w = 100;
node.h = 60;
} else {
node.w = 60;
node.h = 40;
}
}
node.x = x;
node.y = y;
owner.nodes.add(node);
String xmldesc = nmi.getAttributeDescription();
if (xmldesc != null && xmldesc.length() > 0) {
FormatDom fmter = new FormatDom();
DomDocument doc = new DomDocument();
try {
fmter.load(doc, xmldesc);
MbengNode widget;
String default_value, attr_name;
for (widget = doc.getRootNode().getFirstChild(); widget != null; widget = widget.getNextSibling()) {
default_value = widget.getAttribute("DEFAULT");
if (default_value == null)
continue;
if (widget.getAttribute("UNITS_ATTR") != null)
continue;
attr_name = widget.getAttribute("NAME");
if (attr_name == null)
continue;
if (default_value.equals("$DefaultNotices")) {
node.setAttribute(attr_name, TaskVO.getDefaultNotices());
} else
node.setAttribute(attr_name, default_value);
}
} catch (MbengException e) {
}
}
if (recordchange)
node.getChanges().setChangeType(Changes.NEW);
setDirtyLevel(DIRTY);
return node;
}
use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.
the class GroovyTestCaseScript method xpath.
/**
* Matches according to MDW XPath.
*/
public Closure<Boolean> xpath(final String condition) throws TestException {
return new Closure<Boolean>(this, this) {
@Override
public Boolean call(Object request) {
try {
XmlPath xpath = new XmlPath(condition);
String v = xpath.evaluate(TestDataFilter.parseRequest(request.toString()));
return v != null;
} catch (MbengException ex) {
getTestCaseRun().log.println("Failed to parse request as XML/JSON. Stub response: " + AdapterActivity.MAKE_ACTUAL_CALL);
return false;
}
}
};
}
use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.
the class TestCaseRun method stubMatch.
protected boolean stubMatch(String condition, MbengDocument reqdoc) {
try {
if (condition.contains("$")) {
MbengRuleSet ruleset = new MyRuleSet("stub_condition", MbengRuleSet.RULESET_COND);
ruleset.parse(condition);
MbengRuntime runtime = new MbengRuntime(ruleset, new StreamLogger(System.out));
runtime.bind("$", reqdoc);
return runtime.verify();
} else {
XmlPath xpath = new XmlPath(condition);
String v = xpath.evaluate(reqdoc);
return v != null;
}
} catch (MbengException e) {
log.println("Exception in evaluating condition in stub: " + e.getMessage());
return false;
}
}
use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.
the class TestCaseRun method getStubResponse.
public String getStubResponse(String masterRequestId, String request, int run) throws JSONException, TestException {
if (request != null && request.startsWith("{\"ActivityRuntimeContext\":"))
// no activity stubbing in old-style test syntax
return "(EXECUTE_ACTIVITY)";
MbengDocument reqdoc;
if (verbose)
log.println("Stub request: " + request);
try {
reqdoc = TestDataFilter.parseRequest(request);
} catch (MbengException e1) {
log.println("Failed to parse request as XML/JSON. Stub response: " + AdapterActivity.MAKE_ACTUAL_CALL);
return AdapterActivity.MAKE_ACTUAL_CALL;
}
for (TestFileLine cmd : testcase.getCommands().getLines()) {
if (cmd.getCommand().equalsIgnoreCase(TestCase.STUB)) {
String condition = cmd.getWord(1);
if (stubMatch(condition, reqdoc)) {
int delay;
String response;
if (cmd.getWordCount() == 4) {
delay = Integer.parseInt(cmd.getWord(2));
response = cmd.getWord(3);
} else {
response = cmd.getWord(2);
delay = 0;
}
response = stubResponseFilter(response, masterRequestId, reqdoc, run);
response = "RESPONSE~" + delay + "~" + response;
if (verbose)
log.println("Stub response: " + response);
return response;
}
}
}
if (verbose)
log.println("Stub response: " + AdapterActivity.MAKE_ACTUAL_CALL);
return AdapterActivity.MAKE_ACTUAL_CALL;
}
use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.
the class TestCaseRun method executeVerifyResponse.
protected boolean executeVerifyResponse(String expected, String actual, String reference) throws TestException, IOException, DataAccessException, ParseException {
expected = expected.replaceAll("\r", "");
if (verbose)
log.println("comparing response...");
if (actual != null) {
actual = actual.replaceAll("\r", "");
Map<String, String> map = new HashMap<>();
map.put(TestDataFilter.MasterRequestId, this.masterRequestId);
map.put(TestDataFilter.RunNumber, Integer.toString(runNumber));
TestDataFilter filter = new TestDataFilter(expected, log, true);
MbengDocument refdoc;
if (reference != null) {
try {
refdoc = TestDataFilter.parseRequest(reference);
} catch (MbengException e) {
log.println("Failed to parse reference document as XML/JSON: " + e.getMessage());
refdoc = null;
}
} else
refdoc = null;
expected = filter.applyFilters(map, refdoc);
expected = filter.applyAnyNumberFilters(expected, actual);
}
if (!expected.equals(actual)) {
int firstDiffLine = TestCompare.matchRegex(expected, actual);
if (firstDiffLine != 0) {
passed = false;
message = "response differs from line: " + firstDiffLine;
if (!verbose) {
// otherwise it was logged previously
log.format("+++++ " + message + "\r%n");
log.format("Actual response: %s\r%n", actual);
}
throw new TestFailedException(message);
}
}
return passed;
}
Aggregations