How to use getTestCaseCountryPropertiesFromParameter method of org.cerberus.servlet.crud.test.UpdateTestCaseWithDependencies class

Best Cerberus-source code snippet using org.cerberus.servlet.crud.test.UpdateTestCaseWithDependencies.getTestCaseCountryPropertiesFromParameter

Source:UpdateTestCaseWithDependencies.java Github

copy

Full Screen

...146 // Test Case exist and we can update it so Global update start here //147 /**148 * TestcaseCountryProperties Update.149 */150 List<TestCaseCountryProperties> tccpFromPage = getTestCaseCountryPropertiesFromParameter(request, appContext, test, testCase, properties);151 tccpService.compareListAndUpdateInsertDeleteElements(initialTest, initialTestCase, tccpFromPage);152 /*153 * Get steps, actions and controls from page by:154 * - generating a new step, action or control number,155 * - setting the correct related step and action for action or control156 */157 List<TestCaseStep> tcsFromPage = getTestCaseStepFromParameter(request, appContext, test, testCase, duplicate, stepArray);158 List<TestCaseStepAction> tcsaFromPage = new ArrayList<>();159 List<TestCaseStepActionControl> tcsacFromPage = new ArrayList<>();160 int nextStepNumber = getMaxStepNumber(tcsFromPage);161 for (TestCaseStep tcs : tcsFromPage) {162 if (tcs.getStep() == -1) {163 tcs.setStep(++nextStepNumber);164 }165 if (tcs.getActions() != null) {166 int nextSequenceNumber = getMaxSequenceNumber(tcs.getActions());167 for (TestCaseStepAction tcsa : tcs.getActions()) {168 if (tcsa.getSequence() == -1) {169 tcsa.setSequence(++nextSequenceNumber);170 }171 tcsa.setStep(tcs.getStep());172 if (tcsa.getControls() != null) {173 int nextControlNumber = getMaxControlNumber(tcsa.getControls());174 for (TestCaseStepActionControl tscac : tcsa.getControls()) {175 if (tscac.getControlSequence() == -1) {176 tscac.setControlSequence(++nextControlNumber);177 }178 tscac.setStep(tcs.getStep());179 tscac.setSequence(tcsa.getSequence());180 }181 tcsacFromPage.addAll(tcsa.getControls());182 }183 }184 tcsaFromPage.addAll(tcs.getActions());185 }186 }187 /*188 * Create, update or delete step, action and control according to the needs189 */190 List<TestCaseStep> tcsFromDtb = new ArrayList<>(tcsService.getListOfSteps(initialTest, initialTestCase));191 tcsService.compareListAndUpdateInsertDeleteElements(tcsFromPage, tcsFromDtb, duplicate);192 List<TestCaseStepAction> tcsaFromDtb = new ArrayList<>(tcsaService.findTestCaseStepActionbyTestTestCase(initialTest, initialTestCase));193 tcsaService.compareListAndUpdateInsertDeleteElements(tcsaFromPage, tcsaFromDtb, duplicate);194 List<TestCaseStepActionControl> tcsacFromDtb = new ArrayList<>(tcsacService.findControlByTestTestCase(initialTest, initialTestCase));195 tcsacService.compareListAndUpdateInsertDeleteElements(tcsacFromPage, tcsacFromDtb, duplicate);196 tc.setUsrModif(request.getUserPrincipal().getName());197 tc.setVersion(tc.getVersion() + 1);198 testCaseService.update(tc.getTest(), tc.getTestCase(), tc);199 /**200 * Adding Log entry.201 */202 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {203 /**204 * Update was successful. Adding Log entry.205 */206 ILogEventService logEventService = appContext.getBean(LogEventService.class);207 logEventService.createForPrivateCalls("/UpdateTestCaseWithDependencies", "UPDATE", "Update TestCase Script : ['" + tc.getTest() + "'|'" + tc.getTestCase() + "'] version : " + tc.getVersion(), request);208 }209 }210 }211 /**212 * Formating and returning the json result.213 */214 jsonResponse.put("messageType", ans.getResultMessage().getMessage().getCodeString());215 jsonResponse.put("message", ans.getResultMessage().getDescription());216 response.getWriter().print(jsonResponse);217 response.getWriter().flush();218 }219 /**220 * Get the highest step number from the given steps221 *222 * @param steps a collection of steps from which get the highest step number223 * @return the highest step number from the given steps224 */225 private int getMaxStepNumber(Collection<TestCaseStep> steps) {226 int nextStepNumber = 0;227 if (steps != null) {228 for (TestCaseStep step : steps) {229 if (nextStepNumber < step.getStep()) {230 nextStepNumber = step.getStep();231 }232 }233 }234 return nextStepNumber;235 }236 /**237 * Get the highest action sequence from the given actions238 *239 * @param actions a collection of actions from which get the highest action240 * sequence241 * @return the highest action sequence from the given actions242 */243 private int getMaxSequenceNumber(Collection<TestCaseStepAction> actions) {244 int nextSequenceNumber = 0;245 if (actions != null) {246 for (TestCaseStepAction action : actions) {247 if (nextSequenceNumber < action.getSequence()) {248 nextSequenceNumber = action.getSequence();249 }250 }251 }252 return nextSequenceNumber;253 }254 /**255 * Get the highest control number from the given controls256 *257 * @param controls a collection of controls from which get the highest258 * control number259 * @return the highest control number from the given controls260 */261 private int getMaxControlNumber(Collection<TestCaseStepActionControl> controls) {262 int nextControlNumber = 0;263 if (controls != null) {264 for (TestCaseStepActionControl control : controls) {265 if (nextControlNumber < control.getControlSequence()) {266 nextControlNumber = control.getControlSequence();267 }268 }269 }270 return nextControlNumber;271 }272 private List<TestCaseCountryProperties> getTestCaseCountryPropertiesFromParameter(HttpServletRequest request, ApplicationContext appContext, String test, String testCase, JSONArray properties) throws JSONException {273 List<TestCaseCountryProperties> testCaseCountryProp = new ArrayList<>();274// String[] testcase_properties_increment = getParameterValuesIfExists(request, "property_increment");275 IFactoryTestCaseCountryProperties testCaseCountryPropertiesFactory = appContext.getBean(IFactoryTestCaseCountryProperties.class);276 for (int i = 0; i < properties.length(); i++) {277 JSONObject propJson = properties.getJSONObject(i);278 boolean delete = propJson.getBoolean("toDelete");279 String property = propJson.getString("property");280 String description = propJson.getString("description");281 int cacheExpire = propJson.getInt("cacheExpire");282 String type = propJson.getString("type");283 String value = propJson.getString("value1");284 String value2 = propJson.getString("value2");285 String length = propJson.getString("length");286 int rowLimit = propJson.getInt("rowLimit");...

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.

Run Cerberus-source automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful