How to use generateApplicationList method of org.cerberus.service.ciresult.impl.CIService class

Best Cerberus-source code snippet using org.cerberus.service.ciresult.impl.CIService.generateApplicationList

Source:CIService.java Github

copy

Full Screen

...70 jsonResponse.put("environment_List", generateEnvList(myList));71 jsonResponse.put("country_list", generateCountryList(myList));72 jsonResponse.put("robotdecli_list", generateRobotDecliList(myList));73 jsonResponse.put("system_list", generateSystemList(myList));74 jsonResponse.put("application_list", generateApplicationList(myList));75 jsonResponse.put("nb_of_retry", myList.stream().mapToInt(it -> it.getNbExecutions() - 1).sum());76 return jsonResponse;77 } catch (CerberusException | ParseException | JSONException ex) {78 LOG.error(ex, ex);79 }80 return null;81 }82 private JSONObject getCIResult(String tag, String campaign, List<TestCaseExecution> myList) {83 try {84 JSONObject jsonResponse = new JSONObject();85 int nbok = 0;86 int nbko = 0;87 int nbfa = 0;88 int nbpe = 0;89 int nbne = 0;90 int nbwe = 0;91 int nbna = 0;92 int nbca = 0;93 int nbqu = 0;94 int nbqe = 0;95 int nbtotal = 0;96 int nbkop1 = 0;97 int nbkop2 = 0;98 int nbkop3 = 0;99 int nbkop4 = 0;100 int nbkop5 = 0;101 long longStart = 0;102 long longEnd = 0;103 for (TestCaseExecution curExe : myList) {104 if (longStart == 0) {105 longStart = curExe.getStart();106 }107 if (curExe.getStart() < longStart) {108 longStart = curExe.getStart();109 }110 if (longEnd == 0) {111 longEnd = curExe.getEnd();112 }113 if (curExe.getEnd() > longEnd) {114 longEnd = curExe.getEnd();115 }116 nbtotal++;117 switch (curExe.getControlStatus()) {118 case TestCaseExecution.CONTROLSTATUS_KO:119 nbko++;120 break;121 case TestCaseExecution.CONTROLSTATUS_OK:122 nbok++;123 break;124 case TestCaseExecution.CONTROLSTATUS_FA:125 nbfa++;126 break;127 case TestCaseExecution.CONTROLSTATUS_NA:128 nbna++;129 break;130 case TestCaseExecution.CONTROLSTATUS_CA:131 nbca++;132 break;133 case TestCaseExecution.CONTROLSTATUS_PE:134 nbpe++;135 break;136 case TestCaseExecution.CONTROLSTATUS_NE:137 nbne++;138 break;139 case TestCaseExecution.CONTROLSTATUS_WE:140 nbwe++;141 break;142 case TestCaseExecution.CONTROLSTATUS_QU:143 nbqu++;144 break;145 case TestCaseExecution.CONTROLSTATUS_QE:146 nbqe++;147 break;148 }149 if (!curExe.getControlStatus().equals("OK") && !curExe.getControlStatus().equals("NE")150 && !curExe.getControlStatus().equals("PE") && !curExe.getControlStatus().equals("QU")) {151 switch (curExe.getTestCaseObj().getPriority()) {152 case 1:153 nbkop1++;154 break;155 case 2:156 nbkop2++;157 break;158 case 3:159 nbkop3++;160 break;161 case 4:162 nbkop4++;163 break;164 case 5:165 nbkop5++;166 break;167 }168 }169 }170 int pond1 = parameterService.getParameterIntegerByKey("cerberus_ci_okcoefprio1", "", 0);171 int pond2 = parameterService.getParameterIntegerByKey("cerberus_ci_okcoefprio2", "", 0);172 int pond3 = parameterService.getParameterIntegerByKey("cerberus_ci_okcoefprio3", "", 0);173 int pond4 = parameterService.getParameterIntegerByKey("cerberus_ci_okcoefprio4", "", 0);174 int pond5 = parameterService.getParameterIntegerByKey("cerberus_ci_okcoefprio5", "", 0);175 String result;176 // Getting threshold from parameter.177 int resultCalThreshold = parameterService.getParameterIntegerByKey("cerberus_ci_threshold", "", 100);178 // If tag is linked to campaign, we get the threshold from the campaign definition (if exist and can be converted to integer).179 if (!StringUtil.isNullOrEmpty(campaign)) {180 try {181 LOG.debug("Trying to get CIScoreThreshold from campaign : '" + campaign + "'");182 // Check campaign score here.183 Campaign mycampaign = campaignService.convert(campaignService.readByKey(campaign));184 if (!StringUtil.isNullOrEmpty(mycampaign.getCIScoreThreshold())) {185 try {186 resultCalThreshold = Integer.valueOf(mycampaign.getCIScoreThreshold());187 } catch (NumberFormatException ex) {188 LOG.error("Could not convert campaign CIScoreThreshold '" + mycampaign.getCIScoreThreshold() + "' to integer.", ex);189 }190 }191 } catch (CerberusException ex) {192 LOG.error("Could not find campaign when calculating CIScore.", ex);193 }194 }195 int resultCal = (nbkop1 * pond1) + (nbkop2 * pond2) + (nbkop3 * pond3) + (nbkop4 * pond4) + (nbkop5 * pond5);196 if ((nbtotal > 0) && nbqu + nbpe > 0) {197 result = "PE";198 } else {199 result = getFinalResult(resultCal, resultCalThreshold, nbtotal, nbok);200 }201 jsonResponse.put("messageType", "OK");202 jsonResponse.put("message", "CI result calculated with success.");203 jsonResponse.put("tag", tag);204 jsonResponse.put("CI_OK_prio1", pond1);205 jsonResponse.put("CI_OK_prio2", pond2);206 jsonResponse.put("CI_OK_prio3", pond3);207 jsonResponse.put("CI_OK_prio4", pond4);208 jsonResponse.put("CI_OK_prio5", pond5);209 jsonResponse.put("CI_finalResult", resultCal);210 jsonResponse.put("CI_finalResultThreshold", resultCalThreshold);211 jsonResponse.put("NonOK_prio1_nbOfExecution", nbkop1);212 jsonResponse.put("NonOK_prio2_nbOfExecution", nbkop2);213 jsonResponse.put("NonOK_prio3_nbOfExecution", nbkop3);214 jsonResponse.put("NonOK_prio4_nbOfExecution", nbkop4);215 jsonResponse.put("NonOK_prio5_nbOfExecution", nbkop5);216 jsonResponse.put("status_OK_nbOfExecution", nbok);217 jsonResponse.put("status_KO_nbOfExecution", nbko);218 jsonResponse.put("status_FA_nbOfExecution", nbfa);219 jsonResponse.put("status_PE_nbOfExecution", nbpe);220 jsonResponse.put("status_NA_nbOfExecution", nbna);221 jsonResponse.put("status_CA_nbOfExecution", nbca);222 jsonResponse.put("status_NE_nbOfExecution", nbne);223 jsonResponse.put("status_WE_nbOfExecution", nbwe);224 jsonResponse.put("status_QU_nbOfExecution", nbqu);225 jsonResponse.put("status_QE_nbOfExecution", nbqe);226 jsonResponse.put("TOTAL_nbOfExecution", nbtotal);227 jsonResponse.put("result", result);228 jsonResponse.put("ExecutionStart", String.valueOf(new Timestamp(longStart)));229 jsonResponse.put("ExecutionEnd", String.valueOf(new Timestamp(longEnd)));230 return jsonResponse;231 } catch (JSONException ex) {232 LOG.error(ex, ex);233 }234 return null;235 }236 @Override237 public String getFinalResult(int resultCal, int resultCalThreshold, int nbtotal, int nbok) {238 if ((resultCal < resultCalThreshold) && (nbtotal > 0) && nbok > 0) {239 return "OK";240 } else {241 return "KO";242 }243 }244 private JSONArray generateEnvList(List<TestCaseExecution> testCaseExecutions) throws JSONException {245 JSONArray jsonResult = new JSONArray();246 HashMap<String, String> statMap = new HashMap<String, String>();247 for (TestCaseExecution testCaseExecution : testCaseExecutions) {248 if (!StringUtil.isNullOrEmpty(testCaseExecution.getEnvironment())) {249 statMap.put(testCaseExecution.getEnvironment(), null);250 }251 }252 for (Map.Entry<String, String> entry : statMap.entrySet()) {253 String key = entry.getKey();254 String value = entry.getValue();255 jsonResult.put(key);256 }257 return jsonResult;258 }259 private JSONArray generateCountryList(List<TestCaseExecution> testCaseExecutions) throws JSONException {260 JSONArray jsonResult = new JSONArray();261 HashMap<String, String> statMap = new HashMap<String, String>();262 for (TestCaseExecution testCaseExecution : testCaseExecutions) {263 if (!StringUtil.isNullOrEmpty(testCaseExecution.getCountry())) {264 statMap.put(testCaseExecution.getCountry(), null);265 }266 }267 for (Map.Entry<String, String> entry : statMap.entrySet()) {268 String key = entry.getKey();269 String value = entry.getValue();270 jsonResult.put(key);271 }272 return jsonResult;273 }274 private JSONArray generateRobotDecliList(List<TestCaseExecution> testCaseExecutions) throws JSONException {275 JSONArray jsonResult = new JSONArray();276 HashMap<String, String> statMap = new HashMap<String, String>();277 for (TestCaseExecution testCaseExecution : testCaseExecutions) {278 if (!StringUtil.isNullOrEmpty(testCaseExecution.getRobotDecli())) {279 statMap.put(testCaseExecution.getRobotDecli(), null);280 }281 }282 for (Map.Entry<String, String> entry : statMap.entrySet()) {283 String key = entry.getKey();284 String value = entry.getValue();285 jsonResult.put(key);286 }287 return jsonResult;288 }289 private JSONArray generateSystemList(List<TestCaseExecution> testCaseExecutions) throws JSONException {290 JSONArray jsonResult = new JSONArray();291 HashMap<String, String> statMap = new HashMap<String, String>();292 for (TestCaseExecution testCaseExecution : testCaseExecutions) {293 if (!StringUtil.isNullOrEmpty(testCaseExecution.getSystem())) {294 statMap.put(testCaseExecution.getSystem(), null);295 }296 }297 for (Map.Entry<String, String> entry : statMap.entrySet()) {298 String key = entry.getKey();299 String value = entry.getValue();300 jsonResult.put(key);301 }302 return jsonResult;303 }304 private JSONArray generateApplicationList(List<TestCaseExecution> testCaseExecutions) throws JSONException {305 JSONArray jsonResult = new JSONArray();306 HashMap<String, String> statMap = new HashMap<String, String>();307 for (TestCaseExecution testCaseExecution : testCaseExecutions) {308 if (!StringUtil.isNullOrEmpty(testCaseExecution.getApplication())) {309 statMap.put(testCaseExecution.getApplication(), null);310 }311 }312 for (Map.Entry<String, String> entry : statMap.entrySet()) {313 String key = entry.getKey();314 String value = entry.getValue();315 jsonResult.put(key);316 }317 return jsonResult;318 }...

Full Screen

Full Screen

generateApplicationList

Using AI Code Generation

copy

Full Screen

1 def applicationList = new org.cerberus.service.ciresult.impl.CIService().generateApplicationList();2 def applicationListSize = applicationList.size();3 def applicationListSizeMinusOne = applicationListSize - 1;4 def applicationListSizeMinusTwo = applicationListSize - 2;5 def applicationListSizeMinusThree = applicationListSize - 3;6 def applicationListSizeMinusFour = applicationListSize - 4;7 def applicationListSizeMinusFive = applicationListSize - 5;8 def applicationListSizeMinusSix = applicationListSize - 6;9 def applicationListSizeMinusSeven = applicationListSize - 7;10 def applicationListSizeMinusEight = applicationListSize - 8;11 def applicationListSizeMinusNine = applicationListSize - 9;12 def applicationListSizeMinusTen = applicationListSize - 10;13 def applicationListSizeMinusEleven = applicationListSize - 11;14 def applicationListSizeMinusTwelve = applicationListSize - 12;15 def applicationListSizeMinusThirteen = applicationListSize - 13;16 def applicationListSizeMinusFourteen = applicationListSize - 14;17 def applicationListSizeMinusFifteen = applicationListSize - 15;18 def applicationListSizeMinusSixteen = applicationListSize - 16;19 def applicationListSizeMinusSeventeen = applicationListSize - 17;20 def applicationListSizeMinusEighteen = applicationListSize - 18;21 def applicationListSizeMinusNineteen = applicationListSize - 19;22 def applicationListSizeMinusTwenty = applicationListSize - 20;23 def applicationListSizeMinusTwentyOne = applicationListSize - 21;24 def applicationListSizeMinusTwentyTwo = applicationListSize - 22;25 def applicationListSizeMinusTwentyThree = applicationListSize - 23;26 def applicationListSizeMinusTwentyFour = applicationListSize - 24;27 def applicationListSizeMinusTwentyFive = applicationListSize - 25;28 def applicationListSizeMinusTwentySix = applicationListSize - 26;29 def applicationListSizeMinusTwentySeven = applicationListSize - 27;30 def applicationListSizeMinusTwentyEight = applicationListSize - 28;31 def applicationListSizeMinusTwentyNine = applicationListSize - 29;

Full Screen

Full Screen

generateApplicationList

Using AI Code Generation

copy

Full Screen

1 List<String> applicationList = ciService.generateApplicationList();2 model.addAttribute("applicationList", applicationList);3 return "ci/ci";4}5@GetMapping(value = "/getBuildList", produces = MediaType.APPLICATION_JSON_VALUE)6public List<String> getBuildList(@RequestParam String application) {7 return ciService.getBuildList(application);8}9@GetMapping(value = "/getRevisionList", produces = MediaType.APPLICATION_JSON_VALUE)10public List<String> getRevisionList(@RequestParam String application, @RequestParam String build) {11 return ciService.getRevisionList(application, build);12}13@GetMapping(value = "/getEnvironmentList", produces = MediaType.APPLICATION_JSON_VALUE)14public List<String> getEnvironmentList(@RequestParam String application) {

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