How to use recordServiceCall method of org.cerberus.engine.execution.impl.RecorderService class

Best Cerberus-source code snippet using org.cerberus.engine.execution.impl.RecorderService.recordServiceCall

Source:DataLibService.java Github

copy

Full Screen

...698 //if the call returns success then we can process the soap ressponse699 if (msg.getCode() == MessageEventEnum.ACTION_SUCCESS_CALLSERVICE.getCode()) {700 appService = (AppService) ai.getItem();701 //Record result in filessytem.702// testCaseExecutionData.addFileList(recorderService.recordServiceCall(tCExecution, null, 0, testCaseExecutionData.getProperty(), appService));703 recorderService.recordServiceCall(tCExecution, null, 0, testCaseExecutionData.getProperty(), appService);704 // Call successful so we can start to parse the result and build RawData per columns from subdata entries.705 /**706 * This Step will calculate hashTemp1 : Hash of List from707 * the Service response.708 */709 // Will contain the nb of row of the target list of Hash.710 int finalnbRow = 0;711 // Will contain the result of the XML parsing.712 HashMap<String, List<String>> hashTemp1 = new HashMap<>();713 if (columnList.isEmpty()) { // No subdata could be found on the testdatalib.714 msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_SERVICE_NOSUBDATA);715 msg.setDescription(msg.getDescription()716 .replace("%ENTRY%", lib.getName())717 .replace("%ENTRYID%", lib.getTestDataLibID().toString()));...

Full Screen

Full Screen

Source:RecorderService.java Github

copy

Full Screen

...161 //Record the Request and Response.162 AppService se = (AppService) testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getLastServiceCalled();163 if (se != null) { // No Calls were performed previously164 List<TestCaseExecutionFile> objectFileSOAPList = new ArrayList<TestCaseExecutionFile>();165 objectFileSOAPList = this.recordServiceCall(myExecution, testCaseStepActionExecution, controlNumber, null, se);166 if (objectFileSOAPList.isEmpty() != true) {167 for (TestCaseExecutionFile testCaseExecutionFile : objectFileSOAPList) {168 objectFileList.add(testCaseExecutionFile);169 }170 }171 }172 }173 return objectFileList;174 }175 @Override176 public AnswerItem recordManuallyFile(TestCaseStepActionExecution testCaseStepActionExecution, TestCaseStepActionControlExecution testCaseStepActionControlExecution, String extension, String desc, FileItem file, Integer id, String fileName, Integer fileID) {177 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED).resolveDescription("DESCRIPTION",178 "Can't upload file");179 AnswerItem a = new AnswerItem();180 TestCaseExecutionFile object = null;181 String returnCode;182 Integer controlNumber = 0;183 String test = "";184 String testCase = "";185 String step = "";186 String index = "";187 String sequence = "";188 String controlString = "";189 Integer myExecution = id;190 if (testCaseStepActionControlExecution == null) {191 test = testCaseStepActionExecution.getTest();192 testCase = testCaseStepActionExecution.getTestCase();193 step = String.valueOf(testCaseStepActionExecution.getStep());194 index = String.valueOf(testCaseStepActionExecution.getIndex());195 sequence = String.valueOf(testCaseStepActionExecution.getSequence());196 controlString = controlNumber.equals(0) ? null : String.valueOf(controlNumber);197 returnCode = testCaseStepActionExecution.getReturnCode();198 } else {199 returnCode = testCaseStepActionControlExecution.getReturnCode();200 controlNumber = testCaseStepActionControlExecution.getControlSequence();201 test = testCaseStepActionControlExecution.getTest();202 testCase = testCaseStepActionControlExecution.getTestCase();203 step = String.valueOf(testCaseStepActionControlExecution.getStep());204 index = String.valueOf(testCaseStepActionControlExecution.getIndex());205 sequence = String.valueOf(testCaseStepActionControlExecution.getSequence());206 controlString = controlNumber.equals(0) ? null : String.valueOf(controlNumber);207 }208 // Used for logging purposes209 String logPrefix = Infos.getInstance().getProjectNameAndVersion() + " - [" + test + " - " + testCase + " - step: " + step + " action: " + sequence + "] ";210 try {211 Recorder recorder = new Recorder();212 String name = "";213 File dir = null;214 if (file != null) {215 name = file.getName();216 extension = name.substring(name.lastIndexOf('.') + 1, name.length());217 extension = extension.toUpperCase();218 extension = testCaseExecutionFileService.checkExtension(name, extension);219 recorder = this.initFilenames(myExecution, test, testCase, step, index, sequence, controlString, null, 0, name.substring(0, name.lastIndexOf('.')), extension, true);220 dir = new File(recorder.getFullPath());221 } else {222 name = fileName;223 extension = testCaseExecutionFileService.checkExtension(name, extension);224 if (name.contains(".")) {225 recorder = this.initFilenames(myExecution, test, testCase, step, index, sequence, controlString, null, 0, name.substring(0, name.lastIndexOf('.')), extension, true);226 dir = new File(recorder.getFullPath());227 } else {228 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);229 msg.setDescription(msg.getDescription().replace("%ITEM%", "manual testcase execution file")230 .replace("%OPERATION%", "Create")231 .replace("%REASON%", "file is missing!"));232 a.setResultMessage(msg);233 return a;234 }235 }236 if (!dir.exists()) {237 try {238 boolean isCreated = dir.mkdirs();239 if (!isCreated) {240 throw new SecurityException();241 }242 } catch (SecurityException se) {243 LOG.warn("Unable to create manual execution file dir: " + se.getMessage());244 msg = new MessageEvent(MessageEventEnum.FILE_ERROR).resolveDescription("DESCRIPTION",245 se.toString()).resolveDescription("MORE", "Please check the parameter cerberus_exemanualmedia_path");246 a.setResultMessage(msg);247 return a;248 }249 }250 if (file != null) {251 AnswerItem<TestCaseExecutionFile> current = testCaseExecutionFileService.readByKey(myExecution, recorder.getLevel(), desc);252 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);253 if (current.getItem() != null) {254 try {255 File temp = new File(recorder.getRootFolder() + current.getItem().getFileName());256 temp.delete();257 } catch (SecurityException se) {258 LOG.warn("Unable to create manual execution file dir: " + se.getMessage());259 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED).resolveDescription("DESCRIPTION",260 se.toString());261 }262 }263 try {264 file.write(new File(recorder.getFullFilename()));265 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK).resolveDescription("DESCRIPTION",266 "Manual Execution File uploaded");267 msg.setDescription(msg.getDescription().replace("%ITEM%", "Manual Execution File").replace("%OPERATION%", "Upload"));268 LOG.debug(logPrefix + "Copy file finished with success - source: " + file.getName() + " destination: " + recorder.getRelativeFilenameURL());269 object = testCaseExecutionFileFactory.create(fileID, myExecution, recorder.getLevel(), desc, recorder.getRelativeFilenameURL(), extension, "", null, "", null);270 } catch (Exception e) {271 LOG.warn("Unable to upload Manual Execution File: " + e.getMessage());272 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED).resolveDescription("DESCRIPTION",273 e.toString());274 }275 } else {276 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK).resolveDescription("DESCRIPTION",277 "Manual Execution File updated");278 msg.setDescription(msg.getDescription().replace("%ITEM%", "Manual Execution File").replace("%OPERATION%", "updated"));279 LOG.debug(logPrefix + "Updated test case manual file finished with success");280 object = testCaseExecutionFileFactory.create(fileID, myExecution, recorder.getLevel(), desc, name, extension, "", null, "", null);281 }282 testCaseExecutionFileService.saveManual(object);283 } catch (CerberusException e) {284 LOG.error(logPrefix + e.toString());285 }286 a.setResultMessage(msg);287 a.setItem(object);288 return a;289 }290 @Override291 public TestCaseExecutionFile recordScreenshot(TestCaseExecution testCaseExecution, TestCaseStepActionExecution testCaseStepActionExecution, Integer control) {292 TestCaseExecutionFile object = null;293 String test = testCaseStepActionExecution.getTest();294 String testCase = testCaseStepActionExecution.getTestCase();295 String step = String.valueOf(testCaseStepActionExecution.getStep());296 String index = String.valueOf(testCaseStepActionExecution.getIndex());297 String sequence = String.valueOf(testCaseStepActionExecution.getSequence());298 String controlString = control.equals(0) ? null : String.valueOf(control);299 long runId = testCaseExecution.getId();300 String applicationType = testCaseExecution.getApplicationObj().getType();301 // Used for logging purposes302 String logPrefix = Infos.getInstance().getProjectNameAndVersion() + " - [" + test + " - " + testCase + " - step: " + step + " action: " + sequence + "] ";303 LOG.debug(logPrefix + "Doing screenshot.");304 /**305 * Take Screenshot and write it306 */307 File newImage = null;308 if (applicationType.equals(Application.TYPE_GUI)309 || applicationType.equals(Application.TYPE_APK)310 || applicationType.equals(Application.TYPE_IPA)) {311 newImage = this.webdriverService.takeScreenShotFile(testCaseExecution.getSession());312 } else if (applicationType.equals(Application.TYPE_FAT)) {313 newImage = this.sikuliService.takeScreenShotFile(testCaseExecution.getSession());314 }315 if (newImage != null) {316 try {317 Recorder recorder = this.initFilenames(runId, test, testCase, step, index, sequence, controlString, null, 0, "screenshot", "png", false);318 LOG.debug(logPrefix + "FullPath " + recorder.getFullPath());319 File dir = new File(recorder.getFullPath());320 if (!dir.exists()) {321 LOG.debug(logPrefix + "Create directory for execution " + recorder.getFullPath());322 dir.mkdirs();323 }324 // Getting the max size of the screenshot.325 long maxSizeParam = parameterService.getParameterIntegerByKey("cerberus_screenshot_max_size", "", 1048576);326 if (maxSizeParam < newImage.length()) {327 LOG.warn(logPrefix + "Screen-shot size exceeds the maximum defined in configurations " + newImage.getName() + " destination: " + recorder.getRelativeFilenameURL());328 }329 //copies the temp file to the execution file330 FileUtils.copyFile(newImage, new File(recorder.getFullFilename()));331 LOG.debug(logPrefix + "Copy file finished with success - source: " + newImage.getName() + " destination: " + recorder.getRelativeFilenameURL());332 // Index file created to database.333 object = testCaseExecutionFileFactory.create(0, testCaseExecution.getId(), recorder.getLevel(), "Screenshot", recorder.getRelativeFilenameURL(), "PNG", "", null, "", null);334 testCaseExecutionFileService.save(object);335 //deletes the temporary file336 FileUtils.forceDelete(newImage);337 LOG.debug(logPrefix + "Temp file deleted with success " + newImage.getName());338 LOG.debug(logPrefix + "Screenshot done in : " + recorder.getRelativeFilenameURL());339 } catch (IOException ex) {340 LOG.error(logPrefix + ex.toString());341 } catch (CerberusException ex) {342 LOG.error(logPrefix + ex.toString());343 }344 } else {345 LOG.warn(logPrefix + "Screenshot returned null.");346 }347 return object;348 }349 @Override350 public TestCaseExecutionFile recordPageSource(TestCaseExecution testCaseExecution, TestCaseStepActionExecution testCaseStepActionExecution, Integer control) {351 // Used for logging purposes352 String logPrefix = Infos.getInstance().getProjectNameAndVersion() + " - ";353 LOG.debug(logPrefix + "Starting to save Page Source File.");354 TestCaseExecutionFile object = null;355 String test = testCaseExecution.getTest();356 String testCase = testCaseExecution.getTestCase();357 String step = String.valueOf(testCaseStepActionExecution.getStep());358 String index = String.valueOf(testCaseStepActionExecution.getIndex());359 String sequence = String.valueOf(testCaseStepActionExecution.getSequence());360 String controlString = control.equals(0) ? null : String.valueOf(control);361 try {362 Recorder recorder = this.initFilenames(testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getId(), test, testCase, step, index, sequence, controlString, null, 0, "pagesource", "html", false);363 File dir = new File(recorder.getFullPath());364 dir.mkdirs();365 File file = new File(recorder.getFullFilename());366 try(FileOutputStream fileOutputStream = new FileOutputStream(file);) {367 fileOutputStream.write(this.webdriverService.getPageSource(testCaseExecution.getSession()).getBytes());368 fileOutputStream.close();369 // Index file created to database.370 object = testCaseExecutionFileFactory.create(0, testCaseExecution.getId(), recorder.getLevel(), "Page Source", recorder.getRelativeFilenameURL(), "HTML", "", null, "", null);371 testCaseExecutionFileService.save(object);372 } catch (FileNotFoundException ex) {373 LOG.error(logPrefix + ex.toString());374 } catch (IOException ex) {375 LOG.error(logPrefix + ex.toString());376 }377 LOG.debug(logPrefix + "Page Source file saved in : " + recorder.getRelativeFilenameURL());378 } catch (CerberusException ex) {379 LOG.error(logPrefix + ex.toString());380 }381 return object;382 }383 @Override384 public List<TestCaseExecutionFile> recordServiceCall(TestCaseExecution testCaseExecution, TestCaseStepActionExecution testCaseStepActionExecution,385 Integer control, String property, AppService se) {386 // Used for logging purposes387 String logPrefix = Infos.getInstance().getProjectNameAndVersion() + " - ";388 List<TestCaseExecutionFile> objectFileList = new ArrayList<TestCaseExecutionFile>();389 TestCaseExecutionFile object = null;390 String test = null;391 String testCase = null;392 String step = null;393 String index = null;394 String sequence = null;395 if (testCaseStepActionExecution != null) {396 test = testCaseExecution.getTest();397 testCase = testCaseExecution.getTestCase();398 step = String.valueOf(testCaseStepActionExecution.getStep());...

Full Screen

Full Screen

recordServiceCall

Using AI Code Generation

copy

Full Screen

1import org.cerberus.engine.execution.impl.RecorderService;2import org.cerberus.engine.entity.MessageEvent;3public class 3 {4 public static void main(String[] args) {5 RecorderService recorder = new RecorderService();6 MessageEvent message = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB);7 recorder.recordServiceCall("test", "test", "test", message, 1, "test", "test", "test", "test", "test", "test", "test", "test", "test");8 }9}10import org.cerberus.engine.execution.impl.RecorderService;11import org.cerberus.engine.entity.MessageEvent;12public class 4 {13 public static void main(String[] args) {14 RecorderService recorder = new RecorderService();15 MessageEvent message = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB);16 recorder.recordServiceCall("test", "test", "test", message, 1, "test", "test", "test", "test", "test", "test", "test", "test", "test", "test");17 }18}19import org.cerberus.engine.execution.impl.RecorderService;20import org.cerberus.engine.entity.MessageEvent;21public class 5 {22 public static void main(String[] args) {23 RecorderService recorder = new RecorderService();24 MessageEvent message = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB);

Full Screen

Full Screen

recordServiceCall

Using AI Code Generation

copy

Full Screen

1package org.cerberus.engine.execution.impl;2import java.util.HashMap;3import java.util.Map;4import org.cerberus.engine.entity.MessageEvent;5import org.cerberus.engine.entity.MessageGeneral;6import org.cerberus.engine.entity.MessageEventEnum;

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful