use of com.qwest.mbeng.MbengDocument 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.MbengDocument 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;
}
use of com.qwest.mbeng.MbengDocument 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.MbengDocument in project mdw-designer by CenturyLinkCloud.
the class AttributesTableContainer method createTableEditor.
private void createTableEditor(Composite parent) {
FormatXml fmter = new FormatXml();
MbengDocument mbengDocument = new MbengDocumentClass();
try {
fmter.load(mbengDocument, pageletTable.xmlText());
} catch (Exception ex) {
ex.printStackTrace();
}
tableEditor = new TableEditor(null, mbengDocument.getRootNode());
// label was already rendered
tableEditor.setLabel(null);
tableEditor.setModelUpdater(new TableModelUpdater() {
public Object create() {
int i = 1;
String attrName = "New Field";
while (getAttribute(attrName) != null) attrName = "New Field (" + i++ + ")";
return new AttributeVO(attrName, null);
}
@SuppressWarnings("rawtypes")
public void updateModelValue(List tableValue) {
fireDirtyStateChange(true);
}
});
tableEditor.setCellModifier(new AttributeCellModifier());
tableEditor.setContentProvider(new AttributeContentProvider());
tableEditor.setLabelProvider(new AttributeLabelProvider());
tableEditor.addValueChangeListener(new ValueChangeListener() {
public void propertyValueChanged(Object newValue) {
// value changed
}
});
tableEditor.render(parent, true);
}
Aggregations