use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.
the class TestCaseRun method sendMessage.
protected String sendMessage(TestCaseAsset testCaseAsset, String protocol, String msg, String reference) throws IOException, DataAccessException {
TestDataFilter filter = new TestDataFilter(msg, log, true);
Map<String, String> map = new HashMap<>();
map.put(TestDataFilter.MasterRequestId, this.masterRequestId);
map.put(TestDataFilter.RunNumber, Integer.toString(runNumber));
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;
// TODO: XLSX asset instead of CSV
File mapfile;
if (testcase.isLegacy())
mapfile = new File(testcase.getCaseDirectory().getPath() + "/" + TestCase.PLACEHOLDER_MAP_FILENAME);
else
mapfile = new File(testCaseAsset.getPackageDir() + "/" + TestCase.PLACEHOLDER_MAP_FILENAME);
TestDataFilter.loadPlaceHolderMap(mapfile, map, runNumber);
msg = filter.applyFilters(map, refdoc);
String server = getNextServer();
if (server == null)
return dao.sendMessage(protocol, msg, getDefaultMessageHeaders());
else
return dao.engineCall(dao.getPeerServerUrl(server), msg, getDefaultMessageHeaders());
}
use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.
the class TestDataFilter method evaluateExpression.
private String evaluateExpression(String exp, MbengDocument refdata) {
try {
if (exp.startsWith("/")) {
// assuming XPath expression
XmlPath xpathobj = new XmlPath(exp);
MbengNode node = xpathobj.findNode(refdata);
return node == null ? null : node.getValue();
} else {
MbengRuleSet ruleset = new MyRuleSet("filter_exp", MbengRuleSet.RULESET_EXPR);
ruleset.parse(exp);
MbengRuntime runtime = new MbengRuntime(ruleset, new StreamLogger(System.out));
runtime.bind("$", refdata);
return runtime.evaluate();
}
} catch (MbengException e) {
log.println("Exception in evaluating expression in test data filter " + exp + ": " + e.getMessage());
return null;
}
}
use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.
the class SwingFormGenerator method evaluateCondition.
private boolean evaluateCondition(String name, String cond) {
try {
if (cond == null || cond.length() == 0)
return true;
MbengRuleSet ruleset = new MyRuleSet(name, MbengRuleSet.RULESET_COND);
ruleset.parse(cond);
MbengRuntime runtime = new MbengRuntime(ruleset, new StreamLogger(System.out));
runtime.bind("$", dataxml);
return runtime.verify();
} catch (MbengException e) {
e.printStackTrace();
return false;
}
}
use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.
the class BamMonitoringSection method saveOverrideAttributes.
@Override
protected void saveOverrideAttributes() {
// remove empty bam defs
Map<String, BamMessageDefinition> defs = new HashMap<String, BamMessageDefinition>();
for (String key : bamEventDefs.keySet()) {
BamMessageDefinition def = bamEventDefs.get(key);
def.setAttributes(removeEmpty(def.getAttributes()));
if (!def.isEmpty())
defs.put(key, def);
}
bamEventDefs = defs;
// sync attributes
for (String overrideAttr : getOverrideAttributes().keySet()) {
if (!bamEventDefs.containsKey(overrideAttr))
// to delete
element.setAttribute(overrideAttr, null);
}
try {
for (String key : bamEventDefs.keySet()) element.setAttribute(key, bamEventDefs.get(key).format());
String msg = bamEvtVal.validateBamEventAttributes(bamEventDefs);
if (msg.length() > 0) {
msg += "\n Please correct the above errors before you continue.";
MessageDialog.openError(getShell(), "Save Monitoring Attributes", msg);
} else {
super.saveOverrideAttributes();
}
} catch (MbengException ex) {
PluginMessages.uiError(getShell(), ex, "Save Monitoring Attributes", element.getProject());
}
}
use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.
the class BindingsSection method findBindingsNode.
private MbengNode findBindingsNode(Activity activity) {
String attrXml = activity.getActivityImpl().getAttrDescriptionXml();
FormatXml formatter = new FormatXml();
MbengDocumentClass mbengDocument = new MbengDocumentClass();
try {
formatter.load(mbengDocument, attrXml);
for (MbengNode currentNode = mbengDocument.getRootNode().getFirstChild(); currentNode != null; currentNode = currentNode.getNextSibling()) {
if (MappingEditor.TYPE_MAPPING.equals(currentNode.getName()) && PropertyEditor.SECTION_BINDINGS.equals(currentNode.getAttribute("SECTION")))
return currentNode;
}
} catch (MbengException ex) {
PluginMessages.uiError(getShell(), ex, "Parse Attr XML");
}
return null;
}
Aggregations