use of org.cerberus.crud.entity.TestCaseExecutionFile in project cerberus-source by cerberustesting.
the class RecorderService method recordTestDataLibProperty.
@Override
public TestCaseExecutionFile recordTestDataLibProperty(Long runId, String property, int propertyIndex, List<HashMap<String, String>> result) {
TestCaseExecutionFile object = null;
// Used for logging purposes
String logPrefix = Infos.getInstance().getProjectNameAndVersion() + " - ";
try {
JSONArray jsonResult = null;
jsonResult = dataLibService.convertToJSONObject(result);
// RESULT.
Recorder recorder = this.initFilenames(runId, null, null, null, null, null, null, property, propertyIndex, "result", "json", false);
recordFile(recorder.getFullPath(), recorder.getFileName(), jsonResult.toString());
// Index file created to database.
object = testCaseExecutionFileFactory.create(0, runId, recorder.getLevel(), "Result", recorder.getRelativeFilenameURL(), "JSON", "", null, "", null);
testCaseExecutionFileService.save(object);
} catch (CerberusException | JSONException ex) {
LOG.error(logPrefix + "TestDataLib file was not saved due to unexpected error." + ex.toString());
}
return object;
}
use of org.cerberus.crud.entity.TestCaseExecutionFile in project cerberus-source by cerberustesting.
the class RecorderService method recordPageSource.
@Override
public TestCaseExecutionFile recordPageSource(TestCaseExecution testCaseExecution, TestCaseStepActionExecution testCaseStepActionExecution, Integer control) {
// Used for logging purposes
String logPrefix = Infos.getInstance().getProjectNameAndVersion() + " - ";
LOG.debug(logPrefix + "Starting to save Page Source File.");
TestCaseExecutionFile object = null;
String test = testCaseExecution.getTest();
String testCase = testCaseExecution.getTestCase();
String step = String.valueOf(testCaseStepActionExecution.getStep());
String index = String.valueOf(testCaseStepActionExecution.getIndex());
String sequence = String.valueOf(testCaseStepActionExecution.getSequence());
String controlString = control.equals(0) ? null : String.valueOf(control);
try {
Recorder recorder = this.initFilenames(testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getId(), test, testCase, step, index, sequence, controlString, null, 0, "pagesource", "html", false);
File dir = new File(recorder.getFullPath());
dir.mkdirs();
File file = new File(recorder.getFullFilename());
try (FileOutputStream fileOutputStream = new FileOutputStream(file)) {
fileOutputStream.write(this.webdriverService.getPageSource(testCaseExecution.getSession()).getBytes());
fileOutputStream.close();
// Index file created to database.
object = testCaseExecutionFileFactory.create(0, testCaseExecution.getId(), recorder.getLevel(), "Page Source", recorder.getRelativeFilenameURL(), "HTML", "", null, "", null);
testCaseExecutionFileService.save(object);
} catch (FileNotFoundException ex) {
LOG.error(logPrefix + ex.toString());
} catch (IOException ex) {
LOG.error(logPrefix + ex.toString());
}
LOG.debug(logPrefix + "Page Source file saved in : " + recorder.getRelativeFilenameURL());
} catch (CerberusException ex) {
LOG.error(logPrefix + ex.toString());
}
return object;
}
use of org.cerberus.crud.entity.TestCaseExecutionFile in project cerberus-source by cerberustesting.
the class RecorderService method recordSeleniumLog.
@Override
public TestCaseExecutionFile recordSeleniumLog(TestCaseExecution testCaseExecution) {
TestCaseExecutionFile object = null;
// Used for logging purposes
String logPrefix = Infos.getInstance().getProjectNameAndVersion() + " - ";
if (testCaseExecution.getApplicationObj().getType().equals(Application.TYPE_GUI)) {
if (testCaseExecution.getSeleniumLog() == 2 || (testCaseExecution.getSeleniumLog() == 1 && !testCaseExecution.getControlStatus().equals("OK"))) {
LOG.debug(logPrefix + "Starting to save Selenium log file.");
try {
Recorder recorder = this.initFilenames(testCaseExecution.getId(), null, null, null, null, null, null, null, 0, "selenium_log", "txt", false);
File dir = new File(recorder.getFullPath());
dir.mkdirs();
File file = new File(recorder.getFullFilename());
try (FileOutputStream fileOutputStream = new FileOutputStream(file)) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(baos);
for (String element : this.webdriverService.getSeleniumLog(testCaseExecution.getSession())) {
out.writeBytes(element);
}
byte[] bytes = baos.toByteArray();
fileOutputStream.write(bytes);
out.close();
baos.close();
fileOutputStream.close();
// Index file created to database.
object = testCaseExecutionFileFactory.create(0, testCaseExecution.getId(), recorder.getLevel(), "Selenium log", recorder.getRelativeFilenameURL(), "TXT", "", null, "", null);
testCaseExecutionFileService.save(object);
} catch (FileNotFoundException ex) {
LOG.error(logPrefix + ex.toString());
} catch (IOException ex) {
LOG.error(logPrefix + ex.toString());
}
LOG.debug(logPrefix + "Selenium log recorded in : " + recorder.getRelativeFilenameURL());
} catch (CerberusException ex) {
LOG.error(logPrefix + ex.toString());
}
}
} else {
LOG.debug(logPrefix + "Selenium Log not recorded because test on non GUI application");
}
return object;
}
use of org.cerberus.crud.entity.TestCaseExecutionFile in project cerberus-source by cerberustesting.
the class TestCaseStepActionExecutionService method readByVarious1WithDependency.
@Override
public AnswerList readByVarious1WithDependency(long executionId, String test, String testcase, int step, int index) {
AnswerList actions = this.readByVarious1(executionId, test, testcase, step, index);
AnswerList response = null;
List<TestCaseStepActionExecution> tcsaeList = new ArrayList();
for (Object action : actions.getDataList()) {
TestCaseStepActionExecution tcsae = (TestCaseStepActionExecution) action;
AnswerList controls = testCaseStepActionControlExecutionService.readByVarious1WithDependency(executionId, test, testcase, step, index, tcsae.getSequence());
tcsae.setTestCaseStepActionControlExecutionList((List<TestCaseStepActionControlExecution>) controls.getDataList());
AnswerList files = testCaseExecutionFileService.readByVarious(executionId, tcsae.getTest() + "-" + tcsae.getTestCase() + "-" + tcsae.getStep() + "-" + tcsae.getIndex() + "-" + tcsae.getSequence());
tcsae.setFileList((List<TestCaseExecutionFile>) files.getDataList());
tcsaeList.add(tcsae);
}
response = new AnswerList(tcsaeList, actions.getTotalRows());
return response;
}
use of org.cerberus.crud.entity.TestCaseExecutionFile in project cerberus-source by cerberustesting.
the class TestCaseStepExecutionService method readByVarious1WithDependency.
@Override
public AnswerList readByVarious1WithDependency(long executionId, String test, String testcase) {
AnswerList steps = this.readByVarious1(executionId, test, testcase);
AnswerList response = null;
List<TestCaseStepExecution> tcseList = new ArrayList();
for (Object step : steps.getDataList()) {
TestCaseStepExecution tces = (TestCaseStepExecution) step;
AnswerList actions = testCaseStepActionExecutionService.readByVarious1WithDependency(executionId, tces.getTest(), tces.getTestCase(), tces.getStep(), tces.getIndex());
tces.setTestCaseStepActionExecutionList((List<TestCaseStepActionExecution>) actions.getDataList());
AnswerList files = testCaseExecutionFileService.readByVarious(executionId, tces.getTest() + "-" + tces.getTestCase() + "-" + tces.getStep() + "-" + tces.getIndex());
tces.setFileList((List<TestCaseExecutionFile>) files.getDataList());
tcseList.add(tces);
}
response = new AnswerList(tcseList, steps.getTotalRows());
return response;
}
Aggregations