How to use getTestcaseCountries method of org.cerberus.crud.entity.TestCaseCountryProperties class

Best Cerberus-source code snippet using org.cerberus.crud.entity.TestCaseCountryProperties.getTestcaseCountries

Source:TestCaseService.java Github

copy

Full Screen

1/**2 * Cerberus Copyright (C) 2013 - 2017 cerberustesting3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4 *5 * This file is part of Cerberus.6 *7 * Cerberus is free software: you can redistribute it and/or modify8 * it under the terms of the GNU General Public License as published by9 * the Free Software Foundation, either version 3 of the License, or10 * (at your option) any later version.11 *12 * Cerberus is distributed in the hope that it will be useful,13 * but WITHOUT ANY WARRANTY; without even the implied warranty of14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15 * GNU General Public License for more details.16 *17 * You should have received a copy of the GNU General Public License18 * along with Cerberus. If not, see <http://www.gnu.org/licenses/>.19 */20package org.cerberus.crud.service.impl;21import org.apache.logging.log4j.LogManager;22import org.apache.logging.log4j.Logger;23import org.cerberus.api.exceptions.EntityNotFoundException;24import org.cerberus.api.exceptions.FailedInsertOperationException;25import org.cerberus.api.exceptions.InvalidRequestException;26import org.cerberus.crud.dao.ITestCaseDAO;27import org.cerberus.crud.entity.CampaignLabel;28import org.cerberus.crud.entity.CampaignParameter;29import org.cerberus.crud.entity.EventHook;30import org.cerberus.crud.entity.Invariant;31import org.cerberus.crud.entity.Label;32import org.cerberus.crud.entity.TestCase;33import org.cerberus.crud.entity.TestCaseCountry;34import org.cerberus.crud.entity.TestCaseCountryProperties;35import org.cerberus.crud.entity.TestCaseDep;36import org.cerberus.crud.entity.TestCaseLabel;37import org.cerberus.crud.entity.TestCaseStep;38import org.cerberus.crud.entity.TestCaseStepAction;39import org.cerberus.crud.entity.TestCaseStepActionControl;40import org.cerberus.crud.factory.IFactoryTest;41import org.cerberus.crud.factory.IFactoryTestCase;42import org.cerberus.crud.service.ICampaignLabelService;43import org.cerberus.crud.service.ICampaignParameterService;44import org.cerberus.crud.service.IInvariantService;45import org.cerberus.crud.service.ILabelService;46import org.cerberus.crud.service.IParameterService;47import org.cerberus.crud.service.ITestCaseCountryPropertiesService;48import org.cerberus.crud.service.ITestCaseCountryService;49import org.cerberus.crud.service.ITestCaseDepService;50import org.cerberus.crud.service.ITestCaseLabelService;51import org.cerberus.crud.service.ITestCaseService;52import org.cerberus.crud.service.ITestCaseStepActionControlService;53import org.cerberus.crud.service.ITestCaseStepActionService;54import org.cerberus.crud.service.ITestCaseStepService;55import org.cerberus.crud.service.ITestService;56import org.cerberus.dto.TestCaseListDTO;57import org.cerberus.dto.TestListDTO;58import org.cerberus.engine.entity.MessageEvent;59import org.cerberus.engine.entity.MessageGeneral;60import org.cerberus.engine.execution.IExecutionCheckService;61import org.cerberus.enums.MessageEventEnum;62import org.cerberus.enums.MessageGeneralEnum;63import org.cerberus.event.IEventService;64import org.cerberus.exception.CerberusException;65import org.cerberus.util.answer.Answer;66import org.cerberus.util.answer.AnswerItem;67import org.cerberus.util.answer.AnswerList;68import org.springframework.beans.factory.annotation.Autowired;69import org.springframework.stereotype.Service;70import javax.servlet.http.HttpServletRequest;71import java.util.ArrayList;72import java.util.Collections;73import java.util.Date;74import java.util.HashMap;75import java.util.HashSet;76import java.util.List;77import java.util.Map;78import java.util.Set;79import java.util.stream.Collectors;80/**81 * @author bcivel82 * @author tbernardes83 */84@Service85public class TestCaseService implements ITestCaseService {86 private static final Logger LOG = LogManager.getLogger(TestCaseService.class);87 @Autowired88 private ITestCaseDAO testCaseDao;89 @Autowired90 private ITestService testService;91 @Autowired92 private IFactoryTest factoryTest;93 @Autowired94 private ITestCaseCountryService testCaseCountryService;95 @Autowired96 private IInvariantService invariantService;97 @Autowired98 private ITestCaseCountryPropertiesService testCaseCountryPropertiesService;99 @Autowired100 private ITestCaseStepService testCaseStepService;101 @Autowired102 private ITestCaseStepActionService testCaseStepActionService;103 @Autowired104 private ITestCaseStepActionControlService testCaseStepActionControlService;105 @Autowired106 private IFactoryTestCase factoryTCase;107 @Autowired108 private ICampaignLabelService campaignLabelService;109 @Autowired110 private ILabelService labelService;111 @Autowired112 private ICampaignParameterService campaignParameterService;113 @Autowired114 private IParameterService parameterService;115 @Autowired116 private IExecutionCheckService executionCheckService;117 @Autowired118 private ITestCaseDepService testCaseDepService;119 @Autowired120 private ITestCaseLabelService testCaseLabelService;121 @Autowired122 private IEventService eventService;123 @Override124 public TestCase findTestCaseByKey(String test, String testCase) throws CerberusException {125 return testCaseDao.findTestCaseByKey(test, testCase);126 }127 @Override128 public TestCase findTestCaseByKeyWithDependency(String test, String testCase) throws CerberusException {129 TestCase newTcase;130 newTcase = findTestCaseByKey(test, testCase);131 if (newTcase == null) {132 //TODO:FN temporary debug messages133 LOG.warn("test case is null - test: " + test + " testcase: " + testCase);134 } else {135 List<TestCaseCountry> testCaseCountry = testCaseCountryService.findTestCaseCountryByTestTestCase(test, testCase);136 List<TestCaseCountry> testCaseCountryToAdd = new ArrayList<>();137 for (TestCaseCountry tcc : testCaseCountry) {138 List<TestCaseCountryProperties> properties = testCaseCountryPropertiesService.findListOfPropertyPerTestTestCaseCountry(test, testCase, tcc.getCountry());139 tcc.setTestCaseCountryProperty(properties);140 testCaseCountryToAdd.add(tcc);141 }142 newTcase.setTestCaseCountries(testCaseCountryToAdd);143 List<TestCaseStep> tcs = testCaseStepService.getListOfSteps(test, testCase);144 List<TestCaseStep> tcsToAdd = new ArrayList<>();145 for (TestCaseStep step : tcs) {146 List<TestCaseStepAction> tcsaToAdd = new ArrayList<>();147 if (!step.isUsingLibraryStep()) {148 List<TestCaseStepAction> tcsa = testCaseStepActionService.getListOfAction(step.getTest(), step.getTestcase(), step.getStepId());149 for (TestCaseStepAction action : tcsa) {150 List<TestCaseStepActionControl> tcsacToAdd = new ArrayList<>();151 List<TestCaseStepActionControl> tcsac = testCaseStepActionControlService.findControlByTestTestCaseStepIdActionId(action.getTest(), action.getTestcase(), action.getStepId(), action.getActionId());152 for (TestCaseStepActionControl control : tcsac) {153 tcsacToAdd.add(control);154 }155 action.setControls(tcsacToAdd);156 tcsaToAdd.add(action);157 }158 }159 step.setActions(tcsaToAdd);160 tcsToAdd.add(step);161 }162 newTcase.setSteps(tcsToAdd);163 List<TestCaseDep> testCaseDependendies = testCaseDepService.readByTestAndTestcase(test, testCase);164 newTcase.setDependencies(testCaseDependendies);165 List<TestCaseLabel> testCaseLabel = testCaseLabelService.readByTestTestCase(test, testCase, null).getDataList();166 newTcase.setTestCaseLabels(testCaseLabel);167 }168 return newTcase;169 }170 @Override171 public AnswerItem<TestCase> findTestCaseByKeyWithDependencies(String test, String testCase, boolean withSteps) throws CerberusException {172 HashMap<String, TestCaseCountry> testCaseCountries;173 HashMap<String, Invariant> countryInvariants;174 AnswerItem<TestCase> answerTestCase = this.readByKey(test, testCase);175 if (answerTestCase.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && answerTestCase.getItem() != null) {176 testCaseCountries = testCaseCountryService.readByTestTestCaseToHashCountryAsKey(test, testCase);177 countryInvariants = (HashMap<String, Invariant>) invariantService.readByIdNameToHash("COUNTRY");178 answerTestCase.getItem().setInvariantCountries(invariantService.convertCountryPropertiesToCountryInvariants(testCaseCountries, countryInvariants));179 answerTestCase.getItem().setDependencies(testCaseDepService.readByTestAndTestcase(answerTestCase.getItem().getTest(), answerTestCase.getItem().getTestcase()));180 answerTestCase.getItem().setLabels(labelService.findLabelsFromTestCase(test, testCase, null).get(test + "##" + testCase));181 List<TestCase> testcases = new ArrayList<>();182 testcases.add(factoryTCase.create(test, testCase));183 answerTestCase.getItem().setTestCaseCountryProperties(testCaseCountryPropertiesService.findDistinctPropertiesOfTestCaseFromTestcaseList(testcases, countryInvariants));184 if (withSteps) {185 answerTestCase.getItem().setSteps(testCaseStepService.readByTestTestCaseStepsWithDependencies(test, testCase).getDataList());186 answerTestCase.getItem().setTestCaseInheritedProperties(testCaseCountryPropertiesService.findDistinctInheritedPropertiesOfTestCase(answerTestCase.getItem(), countryInvariants));187 }188 }189 return answerTestCase;190 }191 @Override192 public List<TestCase> findTestCaseByTest(String test) {193 return testCaseDao.findTestCaseByTest(test);194 }195 @Override196 public AnswerList<TestCase> findTestCasesByTestByCriteriaWithDependencies(List<String> system, String test, int startPosition, int length, String sortInformation, String searchParameter, Map<String, List<String>> individualSearch, boolean isCalledFromListPage) throws CerberusException {197 AnswerList<TestCase> testCases = this.readByTestByCriteria(system, test, startPosition, length, sortInformation, searchParameter, individualSearch);198 if (testCases.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && !testCases.getDataList().isEmpty() && isCalledFromListPage) {//the service was able to perform the query, then we should get all values199 HashMap<String, Invariant> countryInvariants = (HashMap<String, Invariant>) invariantService.readByIdNameToHash("COUNTRY");200 List<TestCaseCountry> testCaseCountries = testCaseCountryService.readByTestTestCase(system, test, null, testCases.getDataList()).getDataList();201 HashMap<String, HashMap<String, TestCaseCountry>> testCaseCountryHash = testCaseCountryService.convertListToHashMapTestTestCaseAsKey(testCaseCountries);202 List<TestCaseDep> testCaseDependencies = testCaseDepService.readByTestAndTestcase(testCases.getDataList());203 HashMap<String, List<TestCaseDep>> testCaseDependenciesHash = testCaseDepService.convertTestCaseDependencyListToHash(testCaseDependencies);204 HashMap<String, List<Label>> labelsHash = labelService.findLabelsFromTestCase(test, null, testCases.getDataList());205 for (TestCase testCase : testCases.getDataList()) {206 if (testCaseCountryHash.containsKey(testCase.getKey())) {207 testCase.setInvariantCountries(invariantService.convertCountryPropertiesToCountryInvariants(testCaseCountryHash.get(testCase.getKey()), countryInvariants));208 }209 if (labelsHash.containsKey(testCase.getTest() + "##" + testCase.getTestcase())) {210 testCase.setLabels(labelsHash.get(testCase.getTest() + "##" + testCase.getTestcase()));211 }212 if (testCaseDependenciesHash.containsKey(testCase.getTestcase())) {213 testCase.setDependencies(testCaseDependenciesHash.get(testCase.getTestcase()));214 }215 }216 }217 return testCases;218 }219 @Override220 public List<TestCase> findTestCaseByTestSystem(String test, String system) {221 return testCaseDao.findTestCaseByTestSystem(test, system);222 }223 @Override224 public List<TestCase> findTestCaseByApplication(final String application) {225 return testCaseDao.findTestCaseByApplication(application);226 }227 @Override228 public boolean updateTestCaseInformation(TestCase testCase) {229 return testCaseDao.updateTestCaseInformation(testCase);230 }231 @Override232 public List<TestCase> getTestCaseForPrePostTesting(String test, String application, String country, String system, String build, String revision) {233 List<TestCase> tmpTests = testCaseDao.findTestCaseByCriteria(test, application, country, "Y");234 List<TestCase> resultTests = new ArrayList<>();235 for (TestCase tmpTest : tmpTests) {236 // We check here if build/revision is compatible.237 if (executionCheckService.checkRangeBuildRevision(tmpTest, build, revision, system)) {238 resultTests.add(tmpTest);239 }240 }241 return resultTests;242 }243 @Override244 public List<TestCase> findTestCaseByAllCriteria(TestCase tCase, String text, String system) {245 return this.testCaseDao.findTestCaseByCriteria(tCase, text, system);246 }247 @Override248 public AnswerList<TestCase> readByVarious(String[] test, String[] app, String[] creator, String[] implementer, String[] system,249 String[] campaign, List<Integer> labelid, String[] priority, String[] type, String[] status, int length) {250 return testCaseDao.readByVarious(test, app, creator, implementer, system, campaign, labelid, priority, type, status, length);251 }252 /**253 * @param column254 * @return255 * @since 0.9.1256 */257 @Override258 public List<String> findUniqueDataOfColumn(String column) {259 return this.testCaseDao.findUniqueDataOfColumn(column);260 }261 @Override262 public List<String> findTestWithTestCaseActiveAutomatedBySystem(String system) {263 TestCase tCase = factoryTCase.create(null, null, null, null, null, null, null, null,264 null, true, true, false, -1, null, null, null, null, true, null, null,265 null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);266 List<String> result = new ArrayList<>();267 List<TestCase> testCases = findTestCaseByAllCriteria(tCase, null, system);268 for (TestCase testCase : testCases) {269 if (!testCase.getType().equals("PRIVATE")) {270 result.add(testCase.getTest());271 }272 }273 Set<String> uniqueResult = new HashSet<>(result);274 result = new ArrayList<>();275 result.addAll(uniqueResult);276 Collections.sort(result);277 return result;278 }279 @Override280 public List<TestCase> findTestCaseActiveAutomatedBySystem(String test, String system) {281 TestCase tCase = factoryTCase.create(test, null, null, null, null, null, null, null,282 null, true, true, false, -1, null, null, null, null, true, null, null,283 null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);284 List<TestCase> result = new ArrayList<>();285 List<TestCase> testCases = findTestCaseByAllCriteria(tCase, null, system);286 for (TestCase testCase : testCases) {287 if (!testCase.getType().equals("PRIVATE")) {288 result.add(testCase);289 }290 }291 return result;292 }293 @Override294 public String getNextAvailableTestcaseId(String test) {295 String result = testCaseDao.getMaxTestcaseIdByTestFolder(test);296 if (result == null) {297 return "0001A";298 }299 int resultInt = 0;300 try {301 resultInt = Integer.valueOf(result);302 } catch (NumberFormatException e) {303 LOG.debug("Could not convert '" + result + "' to Integer.");304 }305 resultInt++;306 return String.format("%04dA", resultInt);307 }308 @Override309 public AnswerList<TestCase> findTestCaseByCampaign(String campaign) {310 final AnswerItem<Map<String, List<String>>> parsedCampaignParameters = campaignParameterService.parseParametersByCampaign(campaign);311 List<String> countries = parsedCampaignParameters.getItem().get(CampaignParameter.COUNTRY_PARAMETER);312 AnswerList<TestCase> testCases = null;313 if (countries != null && !countries.isEmpty()) {314 testCases = this.findTestCaseByCampaignNameAndCountries(campaign, countries.toArray(new String[countries.size()]));315 } else {316 testCases = this.findTestCaseByCampaignNameAndCountries(campaign, null);317 }318 return testCases;319 }320 @Override321 public AnswerList<TestCase> findTestCaseByCampaignNameAndCountries(String campaign, String[] countries) {322 AnswerList<TestCase> result;323 String[] status = null;324 String[] system = null;325 String[] application = null;326 String[] priority = null;327 String[] type = null;328 AnswerItem<Map<String, List<String>>> parameters = campaignParameterService.parseParametersByCampaign(campaign);329 for (Map.Entry<String, List<String>> entry : parameters.getItem().entrySet()) {330 String cle = entry.getKey();331 List<String> valeur = entry.getValue();332 switch (cle) {333 case CampaignParameter.PRIORITY_PARAMETER:334 priority = valeur.toArray(new String[valeur.size()]);335 break;336 case CampaignParameter.STATUS_PARAMETER:337 status = valeur.toArray(new String[valeur.size()]);338 break;339 case CampaignParameter.SYSTEM_PARAMETER:340 system = valeur.toArray(new String[valeur.size()]);341 break;342 case CampaignParameter.APPLICATION_PARAMETER:343 application = valeur.toArray(new String[valeur.size()]);344 break;345 case CampaignParameter.TYPE_PARAMETER:346 type = valeur.toArray(new String[valeur.size()]);347 break;348 }349 }350 AnswerList<CampaignLabel> label = campaignLabelService.readByVarious(campaign);351 List<Integer> labelIdList = new ArrayList<>();352 List<CampaignLabel> labelList = label.getDataList();353 for (CampaignLabel campaignLabel : labelList) {354 labelIdList.add(campaignLabel.getLabelId());355 }356 labelIdList = labelService.enrichWithChild(labelIdList);357 Integer maxReturn = parameterService.getParameterIntegerByKey("cerberus_campaign_maxtestcase", "", 1000);358 result = testCaseDao.findTestCaseByCampaignNameAndCountries(campaign, countries, labelIdList, status, system, application, priority, type, maxReturn);359 return result;360 }361 @Override362 public List<TestCase> findUseTestCaseList(String test, String testCase) throws CerberusException {363 List<TestCase> result = new ArrayList<>();364 List<TestCaseStep> tcsList = testCaseStepService.getListOfSteps(test, testCase);365 for (TestCaseStep tcs : tcsList) {366 if (tcs.isUsingLibraryStep()) {367 /**368 * We prepend the TestCase in order to leave at the end of the369 * list the testcase with the higher prio (which correspond to370 * the 1st Use Step found) #1907. That way, if inside the same371 * testcase, you import 2 use Step that define a property that372 * has the same name, the 1st step imported will define the373 * property value.374 */375 result.add(0, this.findTestCaseByKey(tcs.getLibraryStepTest(), tcs.getLibraryStepTestcase()));376 }377 }378 return result;379 }380 @Override381 public List<TestCase> findByCriteria(String[] test, String[] app, String[] active, String[] priority, String[] status, String[] type, String[] targetMajor, String[] targetMinor, String[] creator, String[] implementer, String[] campaign, String[] battery) {382 return testCaseDao.findTestCaseByCriteria(test, app, active, priority, status, type, targetMajor, targetMinor, creator, implementer, campaign);383 }384 @Override385 public String findSystemOfTestCase(String test, String testcase) throws CerberusException {386 return testCaseDao.findSystemOfTestCase(test, testcase);387 }388 @Override389 public AnswerList<TestListDTO> findTestCasesThatUseTestDataLib(int testDataLibId, String name, String country) {390 return testCaseCountryPropertiesService.findTestCaseCountryPropertiesByValue1(testDataLibId, name, country, TestCaseCountryProperties.TYPE_GETFROMDATALIB);391 }392 public boolean containsTestCase(final List<TestCaseListDTO> list, final String number) {393 return list.stream().anyMatch(testCaseListDTO -> testCaseListDTO.getTestCaseNumber().equals(number));394 }395 @Override396 public AnswerList<TestListDTO> findTestCasesThatUseService(String service) {397 AnswerList<TestListDTO> testCaseByServiceByDataLib = testCaseDao.findTestCaseByServiceByDataLib(service);398 AnswerList<TestListDTO> testCaseByService = testCaseDao.findTestCaseByService(service);399 List<TestListDTO> listOfTestCaseByDataLib = testCaseByServiceByDataLib.getDataList();400 List<TestListDTO> listOfTestCaseByService = testCaseByService.getDataList();401 List<TestListDTO> newTestCase = new ArrayList<>();402 if (!listOfTestCaseByDataLib.isEmpty()) {403 for (TestListDTO datalibList : listOfTestCaseByDataLib) {404 for (TestListDTO serviceList : listOfTestCaseByService) {405 if (datalibList.getTest().equals(serviceList.getTest())) {406 List<TestCaseListDTO> testCaseDataLibList = datalibList.getTestCaseList();407 for (TestCaseListDTO testCaseService : serviceList.getTestCaseList()) {408 if (!containsTestCase(testCaseDataLibList, testCaseService.getTestCaseNumber())) {409 testCaseDataLibList.add(testCaseService);410 }411 }412 } else {413 newTestCase.add(serviceList);414 }415 }416 }417 listOfTestCaseByDataLib.addAll(newTestCase);418 testCaseByServiceByDataLib.setDataList(listOfTestCaseByDataLib);419 return testCaseByServiceByDataLib;420 } else {421 return testCaseByService;422 }423 }424 @Override425 public AnswerList readTestCaseByStepsInLibrary(String test) {426 return testCaseDao.readTestCaseByStepsInLibrary(test);427 }428 @Override429 public AnswerList<TestCase> readByTestByCriteria(List<String> system, String test, int start, int amount, String sortInformation, String searchTerm, Map<String, List<String>> individualSearch) {430 return testCaseDao.readByTestByCriteria(system, test, start, amount, sortInformation, searchTerm, individualSearch);431 }432 @Override433 public AnswerItem<TestCase> readByKey(String test, String testCase) {434 return testCaseDao.readByKey(test, testCase);435 }436 @Override437 public AnswerItem<TestCase> readByKeyWithDependency(String test, String testCase) {438 AnswerItem<TestCase> answer = new AnswerItem<>(new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED));439 AnswerItem<TestCase> ai = testCaseDao.readByKey(test, testCase);440 if (ai.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && ai.getItem() != null) {441 TestCase tc = ai.getItem();442 AnswerList<TestCaseStep> al = testCaseStepService.readByTestTestCaseStepsWithDependencies(tc.getTest(), tc.getTestcase());443 if (al.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && al.getDataList() != null) {444 tc.setSteps(al.getDataList());445 }446 answer.setResultMessage(al.getResultMessage());447 answer.setItem(tc);448 }449 return answer;450 }451 @Override452 public AnswerList<String> readDistinctValuesByCriteria(List<String> system, String test, String searchParameter, Map<String, List<String>> individualSearch, String columnName) {453 return testCaseDao.readDistinctValuesByCriteria(system, test, searchParameter, individualSearch, columnName);454 }455 @Override456 public AnswerList<TestCase> readStatsBySystem(List<String> system, Date to) {457 return testCaseDao.readStatsBySystem(system, to);458 }459 @Override460 public Answer update(String keyTest, String keyTestcase, TestCase testcase) {461 // We first create the corresponding test if it doesn,'t exist.462 if (testcase.getTest() != null && !testService.exist(testcase.getTest())) {463 testService.create(factoryTest.create(testcase.getTest(), "", true, null, testcase.getUsrModif(), null, "", null));464 }465 Answer ans = testCaseDao.update(keyTest, keyTestcase, testcase);466 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {467 eventService.triggerEvent(EventHook.EVENTREFERENCE_TESTCASE_UPDATE, testcase, keyTest, keyTestcase, null);468 }469 return ans;470 }471 @Override472 public Answer create(TestCase testCase) {473 // We first create the corresponding test if it doesn,'t exist.474 if (testCase.getTest() != null && !testService.exist(testCase.getTest())) {475 testService.create(factoryTest.create(testCase.getTest(), "", true, null, testCase.getUsrCreated(), null, "", null));476 }477 Answer ans = testCaseDao.create(testCase);478 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {479 eventService.triggerEvent(EventHook.EVENTREFERENCE_TESTCASE_CREATE, testCase, null, null, null);480 }481 return ans;482 }483 @Override484 public Answer createAPI(TestCase testCase) {485 // We first create the corresponding test if it doesn,'t exist.486 if (testCase.getTest() != null && !testService.exist(testCase.getTest())) {487 testService.create(factoryTest.create(testCase.getTest(), "", true, null, testCase.getUsrCreated(), null, "", null));488 }489 return testCaseDao.create(testCase);490 }491 @Override492 public Answer delete(TestCase testCase) {493 Answer ans = testCaseDao.delete(testCase);494 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {495 eventService.triggerEvent(EventHook.EVENTREFERENCE_TESTCASE_DELETE, testCase, null, null, null);496 }497 return ans;498 }499 @Override500 public TestCase convert(AnswerItem<TestCase> answerItem) throws CerberusException {501 if (answerItem.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {502 //if the service returns an OK message then we can get the item503 return answerItem.getItem();504 }505 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));506 }507 @Override508 public List<TestCase> convert(AnswerList<TestCase> answerList) throws CerberusException {509 if (answerList.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {510 //if the service returns an OK message then we can get the item511 return answerList.getDataList();512 }513 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));514 }515 @Override516 public void convert(Answer answer) throws CerberusException {517 if (answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {518 //if the service returns an OK message then we can get the item519 return;520 }521 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));522 }523 @Override524 public boolean hasPermissionsRead(TestCase testCase, HttpServletRequest request) {525 // Access right calculation.526 return true;527 }528 @Override529 public boolean hasPermissionsUpdate(TestCase testCase, HttpServletRequest request) {530 // Access right calculation.531 if (testCase.getStatus().equalsIgnoreCase("WORKING")) { // If testcase is WORKING only TestAdmin can update it532 return request.isUserInRole("TestAdmin");533 } else {534 return request.isUserInRole("Test");535 }536 }537 @Override538 public boolean hasPermissionsCreate(TestCase testCase, HttpServletRequest request) {539 // Access right calculation.540 return request.isUserInRole("Test");541 }542 @Override543 public boolean hasPermissionsDelete(TestCase testCase, HttpServletRequest request) {544 // Access right calculation.545 return request.isUserInRole("TestAdmin");546 }547 @Override548 public void createTestcaseWithDependencies(TestCase testCase) throws CerberusException {549 //TODO ------------------------550 //Check Cerberus version compatibility. If not stop551 //-------------------------------552 //insert testcase553 Answer newTestcase = this.create(testCase);554 if (!newTestcase.getResultMessage().getSource().equals(MessageEventEnum.DATA_OPERATION_OK)) {555 MessageGeneral msg = new MessageGeneral(MessageGeneralEnum.GENERIC_ERROR);556 msg.setDescription(newTestcase.getResultMessage().getDescription());557 throw new CerberusException(msg);558 }559 //for tcstep, insert steps560 for (TestCaseStep tcs : testCase.getSteps()) {561 tcs.setTest(testCase.getTest());562 tcs.setTestcase(testCase.getTestcase());563 Answer newTestcaseStep = testCaseStepService.create(tcs);564 if (!newTestcaseStep.getResultMessage().getSource().equals(MessageEventEnum.DATA_OPERATION_OK)) {565 throw new CerberusException(new MessageGeneral(newTestcaseStep.getResultMessage().getMessage()));566 }567 for (TestCaseStepAction tcsa : tcs.getActions()) {568 tcsa.setTest(testCase.getTest());569 tcsa.setTestcase(testCase.getTestcase());570 Answer newTestcaseStepAction = testCaseStepActionService.create(tcsa);571 if (!newTestcaseStepAction.getResultMessage().getSource().equals(MessageEventEnum.DATA_OPERATION_OK)) {572 throw new CerberusException(new MessageGeneral(newTestcaseStepAction.getResultMessage().getMessage()));573 }574 for (TestCaseStepActionControl tcsac : tcsa.getControls()) {575 tcsac.setTest(testCase.getTest());576 tcsac.setTestcase(testCase.getTestcase());577 Answer newTestcaseStepActionControl = testCaseStepActionControlService.create(tcsac);578 if (!newTestcaseStepActionControl.getResultMessage().getSource().equals(MessageEventEnum.DATA_OPERATION_OK)) {579 throw new CerberusException(new MessageGeneral(newTestcaseStepActionControl.getResultMessage().getMessage()));580 }581 }582 }583 }584 //insert tccountry, insert countries585 for (TestCaseCountry tcc : testCase.getTestCaseCountries()) {586 tcc.setTest(testCase.getTest());587 tcc.setTestcase(testCase.getTestcase());588 Answer newTestcaseCountry = testCaseCountryService.create(tcc);589 if (!newTestcaseCountry.getResultMessage().getSource().equals(MessageEventEnum.DATA_OPERATION_OK)) {590 throw new CerberusException(new MessageGeneral(newTestcaseCountry.getResultMessage().getMessage()));591 }592 for (TestCaseCountryProperties tccp : tcc.getTestCaseCountryProperty()) {593 tccp.setTest(testCase.getTest());594 tccp.setTestcase(testCase.getTestcase());595 Answer newTestcaseCountryProperties = testCaseCountryPropertiesService.create(tccp);596 if (!newTestcaseCountryProperties.getResultMessage().getSource().equals(MessageEventEnum.DATA_OPERATION_OK)) {597 throw new CerberusException(new MessageGeneral(newTestcaseCountryProperties.getResultMessage().getMessage()));598 }599 }600 }601 //insert testcasedependencies602 for (TestCaseDep tcd : testCase.getDependencies()) {603 tcd.setTest(testCase.getTest());604 tcd.setTestcase(testCase.getTestcase());605 testCaseDepService.create(tcd);606 }607 //insert testcaselabel608 for (TestCaseLabel tcl : testCase.getTestCaseLabels()) {609 tcl.setTest(testCase.getTest());610 tcl.setTestcase(testCase.getTestcase());611 testCaseLabelService.create(tcl);612 }613 }614 @Override615 public TestCase createTestcaseWithDependenciesAPI(TestCase newTestcase) throws CerberusException {616 final String FAILED_TO_INSERT = "Failed to insert the testcase in the database";617 if (newTestcase.getTest() == null || newTestcase.getTest().isEmpty()) {618 throw new InvalidRequestException("testFolderId required to create Testcase");619 }620 if (newTestcase.getApplication() == null || newTestcase.getApplication().isEmpty()) {621 throw new InvalidRequestException("application is required to create a Testcase");622 }623 if (newTestcase.getTestcase() != null) {624 throw new InvalidRequestException("testcaseId forbidden to create Testcase");625 }626 newTestcase.setTestcase(this.getNextAvailableTestcaseId(newTestcase.getTest()));627 Answer testcaseCreationAnswer = this.create(newTestcase);628 if (!testcaseCreationAnswer.getResultMessage().getSource().equals(MessageEventEnum.DATA_OPERATION_OK)) {629 throw new FailedInsertOperationException(FAILED_TO_INSERT);630 }631 //for tcstep, insert steps632 if (newTestcase.getSteps() != null) {633 int stepId = 0;634 for (TestCaseStep step : newTestcase.getSteps()) {635 step.setTest(newTestcase.getTest());636 step.setTestcase(newTestcase.getTestcase());637 step.setStepId(stepId++);638 Answer newTestcaseStep = testCaseStepService.create(step);639 if (!newTestcaseStep.getResultMessage().getSource().equals(MessageEventEnum.DATA_OPERATION_OK)) {640 throw new FailedInsertOperationException(FAILED_TO_INSERT);641 }642 if (step.getActions() != null && !step.isUsingLibraryStep()) {643 int actionId = 0;644 for (TestCaseStepAction action : step.getActions()) {645 action.setTest(newTestcase.getTest());646 action.setTestcase(newTestcase.getTestcase());647 action.setStepId(step.getStepId());648 action.setActionId(actionId++);649 Answer newTestcaseStepAction = testCaseStepActionService.create(action);650 if (!newTestcaseStepAction.getResultMessage().getSource().equals(MessageEventEnum.DATA_OPERATION_OK)) {651 throw new FailedInsertOperationException(FAILED_TO_INSERT);652 }653 if (action.getControls() != null) {654 int controlId = 0;655 for (TestCaseStepActionControl control : action.getControls()) {656 control.setTest(newTestcase.getTest());657 control.setTestcase(newTestcase.getTestcase());658 control.setStepId(step.getStepId());659 control.setActionId(action.getActionId());660 control.setControlId(controlId++);661 Answer newTestcaseStepActionControl = testCaseStepActionControlService.create(control);662 if (!newTestcaseStepActionControl.getResultMessage().getSource().equals(MessageEventEnum.DATA_OPERATION_OK)) {663 throw new FailedInsertOperationException(FAILED_TO_INSERT);664 }665 }666 }667 }668 }669 }670 }671 this.fillTestcaseCountriesFromInvariantsCountry(newTestcase);672 if (newTestcase.getTestCaseCountryProperties() != null && !newTestcase.getTestCaseCountryProperties().isEmpty()) {673 newTestcase.setTestCaseCountryProperties(674 this.testCaseCountryPropertiesService.getFlatListOfTestCaseCountryPropertiesFromAggregate(675 newTestcase.getTestCaseCountryProperties()676 )677 );678 }679 for (TestCaseCountry tcc : newTestcase.getTestCaseCountries()) {680 tcc.setTest(newTestcase.getTest());681 tcc.setTestcase(newTestcase.getTestcase());682 Answer newTestcaseCountry = testCaseCountryService.create(tcc);683 if (!newTestcaseCountry.getResultMessage().getSource().equals(MessageEventEnum.DATA_OPERATION_OK)) {684 throw new FailedInsertOperationException(FAILED_TO_INSERT);685 }686 if (tcc.getTestCaseCountryProperty() != null) {687 for (TestCaseCountryProperties tccp : tcc.getTestCaseCountryProperty()) {688 tccp.setTest(newTestcase.getTest());689 tccp.setTestcase(newTestcase.getTestcase());690 Answer newTestcaseCountryProperties = testCaseCountryPropertiesService.create(tccp);691 if (!newTestcaseCountryProperties.getResultMessage().getSource().equals(MessageEventEnum.DATA_OPERATION_OK)) {692 throw new FailedInsertOperationException(FAILED_TO_INSERT);693 }694 }695 }696 }697 //insert testcasedependencies698 if (newTestcase.getDependencies() != null) {699 for (TestCaseDep tcd : newTestcase.getDependencies()) {700 tcd.setTest(newTestcase.getTest());701 tcd.setTestcase(newTestcase.getTestcase());702 try {703 testCaseDepService.create(tcd);704 } catch (CerberusException ex) {705 throw new FailedInsertOperationException(ex.getMessage());706 }707 }708 }709 //insert testcaselabel710 if (newTestcase.getLabels() != null && !newTestcase.getLabels().isEmpty()) {711 newTestcase.setTestCaseLabels(712 this.getTestcaseLabelsFromLabels(713 newTestcase.getLabels(), newTestcase.getTest(), newTestcase.getTestcase(), newTestcase.getUsrCreated()714 )715 );716 this.testCaseLabelService.createList(newTestcase.getTestCaseLabels());717 }718 return this.findTestCaseByKeyWithDependencies(newTestcase.getTest(), newTestcase.getTestcase(), true).getItem();719 }720 public TestCase updateTestcaseAPI(String testFolderId, String testcaseId, TestCase newTestcaseVersion) throws CerberusException {721 if (testFolderId == null || testFolderId.isEmpty()) {722 throw new InvalidRequestException("testFolderId is required to update a testcase");723 }724 if (testcaseId == null || testcaseId.isEmpty()) {725 throw new InvalidRequestException("testcaseId is required to update a testcase");726 }727 TestCase oldTestcaseVersion = new TestCase();728 try {729 oldTestcaseVersion = this.findTestCaseByKeyWithDependencies(newTestcaseVersion.getTest(), newTestcaseVersion.getTestcase(), true).getItem();730 if (oldTestcaseVersion == null) {731 throw new EntityNotFoundException(TestCase.class, "testcaseFolderId", newTestcaseVersion.getTest(), "testcaseId", newTestcaseVersion.getTestcase());732 }733 } catch (CerberusException e) {734 LOG.warn(e.getMessage());735 }736 if (!newTestcaseVersion.equals(oldTestcaseVersion)) {737 newTestcaseVersion.setVersion(newTestcaseVersion.getVersion() + 1);738 LOG.debug(this.updateTestCaseInformation(newTestcaseVersion));739 }740 if (newTestcaseVersion.getSteps() != null && !newTestcaseVersion.getSteps().isEmpty()) {741 this.testCaseStepService.compareListAndUpdateInsertDeleteElements(newTestcaseVersion.getSteps(), oldTestcaseVersion.getSteps(), false);742 List<TestCaseStepAction> newActions = this.getAllActionsFromTestcase(newTestcaseVersion);743 List<TestCaseStepAction> oldActions = this.testCaseStepActionService.readByTestTestCase(testFolderId, testcaseId).getDataList();744 this.testCaseStepActionService.compareListAndUpdateInsertDeleteElements(newActions, oldActions, false);745 List<TestCaseStepActionControl> newControls = this.getAllControlsFromTestcase(newTestcaseVersion);746 List<TestCaseStepActionControl> oldControls = this.testCaseStepActionControlService.findControlByTestTestCase(testFolderId, testcaseId);747 this.testCaseStepActionControlService.compareListAndUpdateInsertDeleteElements(newControls, oldControls, false);748 }749 this.fillTestcaseCountriesFromInvariantsCountry(newTestcaseVersion);750 this.testCaseCountryService.compareListAndUpdateInsertDeleteElements(751 newTestcaseVersion.getTest(),752 newTestcaseVersion.getTestcase(),753 newTestcaseVersion.getTestCaseCountries()754 );755 if (newTestcaseVersion.getTestCaseCountryProperties() != null && !newTestcaseVersion.getTestCaseCountryProperties().isEmpty()) {756 newTestcaseVersion.setTestCaseCountryProperties(757 this.testCaseCountryPropertiesService758 .getFlatListOfTestCaseCountryPropertiesFromAggregate(newTestcaseVersion.getTestCaseCountryProperties())759 );760 }761 LOG.debug(newTestcaseVersion.getTestCaseCountryProperties());762 if (newTestcaseVersion.getTestCaseCountryProperties() != null && !newTestcaseVersion.getTestCaseCountryProperties().isEmpty()) {763 this.testCaseCountryPropertiesService.compareListAndUpdateInsertDeleteElements(764 newTestcaseVersion.getTest(),765 newTestcaseVersion.getTestcase(),766 newTestcaseVersion.getTestCaseCountryProperties()767 );768 }769 if (newTestcaseVersion.getDependencies() != null && !newTestcaseVersion.getDependencies().isEmpty()) {770 this.testCaseDepService.compareListAndUpdateInsertDeleteElements(771 newTestcaseVersion.getTest(),772 newTestcaseVersion.getTestcase(),773 newTestcaseVersion.getDependencies()774 );775 }776 if (newTestcaseVersion.getLabels() != null && !newTestcaseVersion.getLabels().isEmpty()) {777 newTestcaseVersion.setTestCaseLabels(778 this.getTestcaseLabelsFromLabels(779 newTestcaseVersion.getLabels(), newTestcaseVersion.getTest(), newTestcaseVersion.getTestcase(), newTestcaseVersion.getUsrCreated()780 )781 );782 this.testCaseLabelService.compareListAndUpdateInsertDeleteElements(783 newTestcaseVersion.getTest(),784 newTestcaseVersion.getTestcase(),785 newTestcaseVersion.getTestCaseLabels()786 );787 }788 return this.findTestCaseByKeyWithDependencies(newTestcaseVersion.getTest(), newTestcaseVersion.getTestcase(), true).getItem();789 }790 private void fillTestcaseCountriesFromInvariantsCountry(TestCase testcase) {791 if (testcase.getInvariantCountries() == null || testcase.getInvariantCountries().isEmpty()) {792 try {793 testcase.setInvariantCountries(this.invariantService.readByIdName("COUNTRY"));794 } catch (CerberusException e) {795 LOG.warn("Unable to retrieve countries from invariant table" + e);796 }797 }798 testcase.getInvariantCountries()799 .forEach(invariantCountry -> testcase.appendTestCaseCountries(800 TestCaseCountry.builder()801 .test(testcase.getTest())802 .testcase(testcase.getTestcase())803 .country(invariantCountry.getValue())804 .build()805 ));806 }807 private List<TestCaseLabel> getTestcaseLabelsFromLabels(List<Label> labels, String testFolderId, String testcaseId, String userCreated) {808 return labels809 .stream()810 .map(label -> TestCaseLabel.builder()811 .test(testFolderId)812 .testcase(testcaseId)813 .labelId(label.getId())814 .usrCreated(userCreated)815 .label(label)816 .build())817 .collect(Collectors.toList());818 }819 private List<TestCaseStepAction> getAllActionsFromTestcase(TestCase testcase) {820 return testcase.getSteps()821 .stream()822 .filter(step -> !step.isUsingLibraryStep())823 .flatMap(testCaseStep -> testCaseStep.getActions().stream())824 .collect(Collectors.toList());825 }826 private List<TestCaseStepActionControl> getAllControlsFromTestcase(TestCase testcase) {827 return testcase.getSteps()828 .stream()829 .filter(step -> !step.isUsingLibraryStep())830 .flatMap(testCaseStep -> testCaseStep.getActions()831 .stream()832 .flatMap(testCaseStepAction -> testCaseStepAction.getControls().stream())833 )834 .collect(Collectors.toList());835 }836}...

Full Screen

Full Screen

Source:GetTestCase.java Github

copy

Full Screen

1/**2 * Cerberus Copyright (C) 2013 - 2017 cerberustesting3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4 *5 * This file is part of Cerberus.6 *7 * Cerberus is free software: you can redistribute it and/or modify8 * it under the terms of the GNU General Public License as published by9 * the Free Software Foundation, either version 3 of the License, or10 * (at your option) any later version.11 *12 * Cerberus is distributed in the hope that it will be useful,13 * but WITHOUT ANY WARRANTY; without even the implied warranty of14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15 * GNU General Public License for more details.16 *17 * You should have received a copy of the GNU General Public License18 * along with Cerberus. If not, see <http://www.gnu.org/licenses/>.19 */20package org.cerberus.servlet.crud.test;21import java.io.IOException;22import java.util.List;23import javax.servlet.ServletException;24import javax.servlet.annotation.WebServlet;25import javax.servlet.http.HttpServlet;26import javax.servlet.http.HttpServletRequest;27import javax.servlet.http.HttpServletResponse;28import org.apache.logging.log4j.LogManager;29import org.apache.logging.log4j.Logger;30import org.cerberus.crud.dao.ITestCaseCountryPropertiesDAO;31import org.cerberus.crud.dao.impl.TestCaseCountryPropertiesDAO;32import org.cerberus.crud.entity.TestCase;33import org.cerberus.crud.entity.TestCaseCountry;34import org.cerberus.crud.entity.TestCaseCountryProperties;35import org.cerberus.crud.entity.TestCaseStep;36import org.cerberus.crud.entity.TestCaseStepAction;37import org.cerberus.crud.entity.TestCaseStepActionControl;38import org.cerberus.exception.CerberusException;39import org.cerberus.crud.service.ILoadTestCaseService;40import org.cerberus.crud.service.ITestCaseService;41import org.json.JSONArray;42import org.json.JSONException;43import org.json.JSONObject;44import org.owasp.html.PolicyFactory;45import org.owasp.html.Sanitizers;46import org.springframework.context.ApplicationContext;47import org.springframework.web.context.support.WebApplicationContextUtils;48/**49 * {Insert class description here}50 *51 * @author Benoit CIVEL52 * @version 1.0, 07/02/201353 * @since 0.9.054 */55@WebServlet(name = "GetTestCase", urlPatterns = {"/GetTestCase"})56public class GetTestCase extends HttpServlet {57 private static final Logger LOG = LogManager.getLogger(GetTestCase.class);58 @Override59 protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {60 try {61 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());62 ITestCaseService testService = appContext.getBean(ITestCaseService.class);63 //TODO pass DAO to Service64 ITestCaseCountryPropertiesDAO testCaseDAO = appContext.getBean(TestCaseCountryPropertiesDAO.class);65 ILoadTestCaseService loadTestCaseService = appContext.getBean(ILoadTestCaseService.class);66 PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);67 String test = policy.sanitize(httpServletRequest.getParameter("test"));68 String testcase = policy.sanitize(httpServletRequest.getParameter("testcase"));69 TestCase tcInfo = testService.findTestCaseByKeyWithDependency(test, testcase);70 JSONObject jsonObject = new JSONObject();71 try {72 jsonObject.put("origin", tcInfo.getOrigine());73 jsonObject.put("refOrigin", tcInfo.getRefOrigine());74 jsonObject.put("creator", tcInfo.getUsrCreated());75 jsonObject.put("implementer", tcInfo.getImplementer());76 jsonObject.put("executor", tcInfo.getExecutor());77 jsonObject.put("lastModifier", tcInfo.getUsrModif());78 jsonObject.put("application", tcInfo.getApplication());79 jsonObject.put("isActiveQA", tcInfo.isActiveQA());80 jsonObject.put("isActiveUAT", tcInfo.isActiveUAT());81 jsonObject.put("isActivePROD", tcInfo.isActivePROD());82 jsonObject.put("priority", tcInfo.getPriority());83 jsonObject.put("group", tcInfo.getType());84 jsonObject.put("status", tcInfo.getStatus());85 JSONArray countryList = new JSONArray();86 for (TestCaseCountry tcc : tcInfo.getTestCaseCountries()) {87 countryList.put(tcc.getCountry());88 }89 jsonObject.put("countries", countryList);90 jsonObject.put("description", tcInfo.getDescription());91 jsonObject.put("detailedDescription", tcInfo.getDetailedDescription());92 jsonObject.put("isActive", tcInfo.isActive());93 jsonObject.put("fromMajor", tcInfo.getFromMajor());94 jsonObject.put("fromMinor", tcInfo.getFromMinor());95 jsonObject.put("toMajor", tcInfo.getToMajor());96 jsonObject.put("toMinor", tcInfo.getToMinor());97 jsonObject.put("lastExecutionStatus", tcInfo.getLastExecutionStatus());98 jsonObject.put("bugs", tcInfo.getBugs());99 jsonObject.put("targetMajor", tcInfo.getTargetMajor());100 jsonObject.put("targetMinor", tcInfo.getTargetMinor());101 jsonObject.put("comment", tcInfo.getComment());102 jsonObject.put("test", tcInfo.getTest());103 jsonObject.put("testcase", tcInfo.getTestCase());104 JSONArray propertyList = new JSONArray();105 List<TestCaseCountryProperties> properties = testCaseDAO.findDistinctPropertiesOfTestCase(test, testcase);106 for (TestCaseCountryProperties prop : properties) {107 JSONObject property = new JSONObject();108 property.put("property", prop.getProperty());109 property.put("description", prop.getDescription());110 property.put("type", prop.getType());111 property.put("database", prop.getDatabase());112 property.put("value1", prop.getValue1());113 property.put("value2", prop.getValue2());114 property.put("length", prop.getLength());115 property.put("rowLimit", prop.getRowLimit());116 property.put("nature", prop.getNature());117 List<String> countriesSelected = testCaseDAO.findCountryByProperty(prop);118 for (TestCaseCountry tcc : tcInfo.getTestCaseCountries()) {119 if (!(countriesSelected == null) && (countriesSelected.contains(tcc.getCountry()))) {120 property.put(tcc.getCountry(), true);121 } else {122 property.put(tcc.getCountry(), false);123 }124 }125 propertyList.put(property);126 }127 jsonObject.put("properties", propertyList);128 List<TestCaseStep> tcs = loadTestCaseService.loadTestCaseStep(tcInfo);129 JSONArray list = new JSONArray();130 for (TestCaseStep step : tcs) {131 JSONObject stepObject = new JSONObject();132 stepObject.put("number", step.getStep());133 stepObject.put("name", step.getDescription());134 int i = 1;135 JSONArray actionList = new JSONArray();136 JSONArray controlList = new JSONArray();137 JSONArray sequenceList = new JSONArray();138 for (TestCaseStepAction action : step.getActions()) {139 JSONObject actionObject = new JSONObject();140 actionObject.put("sequence", i);141 actionObject.put("action", action.getAction());142 actionObject.put("object", action.getValue1());143 actionObject.put("property", action.getValue2());144 actionObject.put("fatal", "");145 actionList.put(actionObject);146 sequenceList.put(actionObject);147 for (TestCaseStepActionControl control : action.getControls()) {148 JSONObject controlObject = new JSONObject();149 controlObject.put("step", control.getStep());150 controlObject.put("sequence", control.getSequence());151 controlObject.put("order", control.getControlSequence());152 controlObject.put("action", control.getControl());153 controlObject.put("object", control.getValue2());154 controlObject.put("property", control.getValue1());155 controlObject.put("fatal", control.getFatal());156 controlList.put(controlObject);157 //test158 controlObject = new JSONObject();159 controlObject.put("sequence", i);160 controlObject.put("action", control.getControl());161 controlObject.put("object", control.getValue2());162 controlObject.put("property", control.getValue1());163 controlObject.put("fatal", control.getFatal());164 sequenceList.put(controlObject);165 }166 i++;167 }168 stepObject.put("actions", actionList);169 stepObject.put("controls", controlList);170 stepObject.put("sequences", sequenceList);171 list.put(stepObject);172 }173// jsonObject.put("actions", actionList);174// jsonObject.put("controls", controlList);175 jsonObject.put("list", list);176 httpServletResponse.setContentType("application/json");177 httpServletResponse.getWriter().print(jsonObject.toString());178 } catch (JSONException exception) {179 LOG.warn(exception.toString());180 }181 } catch (CerberusException ex) {182 LOG.warn(ex);183 }184 }185}...

Full Screen

Full Screen

getTestcaseCountries

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import java.util.ArrayList;3import java.util.List;4import org.cerberus.crud.entity.TestCaseCountryProperties;5import org.cerberus.crud.entity.TestCaseCountry;6import org.cerberus.crud.entity.TestCase;7import org.cerberus.crud.entity.Country;8public class TestCaseCountryProperties {9 private long id;10 private String test;11 private String testCase;12 private String country;13 private String property;14 private String value;15 private String description;16 private String type;17 private String database;18 private String servicePath;19 private String service;20 private String method;21 private String envelope;22 private String application;23 private String length;24 private String rowLimit;25 private String nature;26 private int retryNb;27 private int retryPeriod;28 private String parsingAnswer;29 private String parsingAnswerElement;30 private String parsingAnswerProperty;31 private String parsingDependencies;32 private String servicePathDependencies;33 private String serviceDependencies;34 private String methodDependencies;35 private String envelopeDependencies;36 private String applicationDependencies;37 private String lengthDependencies;38 private String rowLimitDependencies;39 private String natureDependencies;40 private String parsingDependenciesElement;41 private String parsingDependenciesProperty;42 private String usrCreated;43 private String dateCreated;44 private String usrModif;45 private String dateModif;46 private String system;47 private String countryList;48 public TestCaseCountryProperties() {49 }50 public TestCaseCountryProperties(long id, String test, String testCase, String country, String property, String value, String description, String type, String database, String servicePath, String service, String method, String envelope, String application, String length, String rowLimit, String nature, int retryNb, int retryPeriod, String parsingAnswer, String parsingAnswerElement, String parsingAnswerProperty, String parsingDependencies, String servicePathDependencies, String serviceDependencies, String methodDependencies, String envelopeDependencies, String applicationDependencies, String lengthDependencies, String rowLimitDependencies, String natureDependencies, String parsingDependenciesElement, String parsingDependenciesProperty, String usrCreated, String dateCreated, String usrModif, String dateModif, String system, String countryList) {51 this.id = id;52 this.test = test;53 this.testCase = testCase;54 this.country = country;55 this.property = property;

Full Screen

Full Screen

getTestcaseCountries

Using AI Code Generation

copy

Full Screen

1import java.util.List;2import org.cerberus.crud.entity.TestCaseCountryProperties;3import org.cerberus.crud.factory.IFactoryTestCaseCountryProperties;4import org.cerberus.crud.factory.impl.FactoryTestCaseCountryProperties;5import org.cerberus.crud.service.ITestCaseCountryPropertiesService;6import org.cerberus.crud.service.impl.TestCaseCountryPropertiesService;7import org.springframework.context.ApplicationContext;8import org.springframework.context.support.ClassPathXmlApplicationContext;9public class TestCaseCountryPropertiesServiceTest {10 public static void main(String[] args) {11 ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml");12 ITestCaseCountryPropertiesService testCaseCountryPropertiesService = appContext.getBean(TestCaseCountryPropertiesService.class);13 IFactoryTestCaseCountryProperties factoryTestCaseCountryProperties = appContext.getBean(FactoryTestCaseCountryProperties.class);

Full Screen

Full Screen

getTestcaseCountries

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import java.util.ArrayList;3import java.util.List;4public class TestCaseCountryProperties {5 private long id;6 private String test;7 private String testcase;8 private String country;9 private String property;10 private String value;11 private String type;12 private String database;13 private String description;14 private String usrCreated;15 private String dateCreated;16 private String usrModif;17 private String dateModif;18 public long getId() {19 return id;20 }21 public void setId(long id) {22 this.id = id;23 }24 public String getTest() {25 return test;26 }27 public void setTest(String test) {28 this.test = test;29 }30 public String getTestcase() {31 return testcase;32 }33 public void setTestcase(String testcase) {34 this.testcase = testcase;35 }36 public String getCountry() {37 return country;38 }39 public void setCountry(String country) {40 this.country = country;41 }42 public String getProperty() {43 return property;44 }45 public void setProperty(String property) {46 this.property = property;47 }48 public String getValue() {49 return value;50 }51 public void setValue(String value) {52 this.value = value;53 }54 public String getType() {55 return type;56 }57 public void setType(String type) {58 this.type = type;59 }60 public String getDatabase() {61 return database;62 }63 public void setDatabase(String database) {64 this.database = database;65 }66 public String getDescription() {67 return description;68 }69 public void setDescription(String description) {70 this.description = description;71 }72 public String getUsrCreated() {73 return usrCreated;74 }75 public void setUsrCreated(String usrCreated) {76 this.usrCreated = usrCreated;77 }78 public String getDateCreated() {79 return dateCreated;80 }81 public void setDateCreated(String dateCreated) {82 this.dateCreated = dateCreated;83 }84 public String getUsrModif() {85 return usrModif;86 }87 public void setUsrModif(String usrModif) {88 this.usrModif = usrModif;89 }90 public String getDateModif() {

Full Screen

Full Screen

getTestcaseCountries

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import java.util.List;3public class TestCaseCountryProperties {4 private String test;5 private String testCase;6 private String country;7 private String property;8 private String type;9 private String database;10 private String value1;11 private String value2;12 private String length;13 private String rowLimit;14 private String nature;15 private String retryNb;16 private String retryPeriod;17 private String database1;18 private String database2;19 private String natureDB1;20 private String natureDB2;21 private String value1Init;22 private String value2Init;23 private String value1End;24 private String value2End;25 private String property1;26 private String property2;27 private String property3;28 private String property4;29 private String property5;30 private String property6;31 private String property7;32 private String property8;33 private String property9;34 private String property10;35 private String property11;36 private String property12;37 private String property13;38 private String property14;39 private String property15;40 private String property16;41 private String property17;42 private String property18;43 private String property19;44 private String property20;45 private String description;46 private String usrCreated;47 private String dateCreated;48 private String usrModif;49 private String dateModif;50 private String propertyType;51 private String propertyDatabase;52 private String propertyNature;53 private String propertyRetryNb;54 private String propertyRetryPeriod;55 private String propertyDatabase1;56 private String propertyDatabase2;57 private String propertyNatureDB1;58 private String propertyNatureDB2;59 private String propertyValue1Init;60 private String propertyValue2Init;61 private String propertyValue1End;62 private String propertyValue2End;63 private String property1Type;64 private String property2Type;65 private String property3Type;66 private String property4Type;67 private String property5Type;68 private String property6Type;69 private String property7Type;70 private String property8Type;71 private String property9Type;72 private String property10Type;73 private String property11Type;74 private String property12Type;75 private String property13Type;76 private String property14Type;

Full Screen

Full Screen

getTestcaseCountries

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import java.util.ArrayList;3import java.util.List;4public class TestCaseCountryProperties {5 private int id;6 private String test;7 private String testCase;8 private int countryId;9 private String country;10 private String property;11 private String value;12 private String type;13 private String database;14 private String description;15 private int length;16 private int rowLimit;17 private String nature;18 private String retryNb;19 private String retryPeriod;20 private String servicePath;21 private String service;22 private String method;23 private String envelope;24 private String parsingAnswer;25 private String parsingCrtieria;26 private String parsingCrtieriaExclude;27 private String application;28 private String isInvariant;29 private String isFromLibrary;30 private String usrCreated;31 private String dateCreated;32 private String usrModif;33 private String dateModif;34 private String system;35 public TestCaseCountryProperties() {36 }37 public TestCaseCountryProperties(int id, String test, String testCase, int countryId, String country, String property, String value, String type, String database, String description, int length, int rowLimit, String nature, String retryNb, String retryPeriod, String servicePath, String service, String method, String envelope, String parsingAnswer, String parsingCrtieria, String parsingCrtieriaExclude, String application, String isInvariant, String isFromLibrary, String usrCreated, String dateCreated, String usrModif, String dateModif, String system) {38 this.id = id;39 this.test = test;40 this.testCase = testCase;41 this.countryId = countryId;42 this.country = country;43 this.property = property;44 this.value = value;45 this.type = type;46 this.database = database;47 this.description = description;48 this.length = length;49 this.rowLimit = rowLimit;50 this.nature = nature;51 this.retryNb = retryNb;52 this.retryPeriod = retryPeriod;53 this.servicePath = servicePath;54 this.service = service;55 this.method = method;56 this.envelope = envelope;57 this.parsingAnswer = parsingAnswer;58 this.parsingCrtieria = parsingCrtieria;59 this.parsingCrtieriaExclude = parsingCrtieriaExclude;

Full Screen

Full Screen

getTestcaseCountries

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import java.util.List;3public class TestCaseCountryProperties {4 private String test;5 private String testCase;6 private String country;7 private String environment;8 private String browser;9 private String version;10 private String platform;11 private String description;12 private String usrCreated;13 private String dateCreated;14 private String usrModif;15 private String dateModif;16 private String active;17 private String manualExecution;18 private String screenshot;19 private String verbose;20 private String pageSource;21 private String seleniumLog;22 private String retries;23 private String timeout;24 private String pageSourceOnException;25 private String seleniumLogOnException;26 private String manualURL;27 private String manualHost;28 private String manualContextRoot;29 private String manualLoginRelativeURL;30 private String manualEnvData;31 private String manualExecutionDeactivated;32 private String manualURLDisabled;33 private String manualHostDisabled;34 private String manualContextRootDisabled;35 private String manualLoginRelativeURLDisabled;36 private String manualEnvDataDisabled;37 private String fromMajor;38 private String fromMinor;39 private String toMajor;40 private String toMinor;41 private String bugId;42 private String targetBuild;43 private String targetRev;44 private String comment;45 private String bugStatus;46 private String ticket;47 private String lastExecutionStatus;48 private String lastExecutionResultMessage;49 private String lastExecutionTime;50 private String lastExecutionEnvironment;51 private String lastExecutionCountry;52 private String lastExecutionRobot;53 private String lastExecutionRobotDecli;54 private String lastExecutionRobotIP;55 private String lastExecutionRobotPort;56 private String lastExecutionTag;57 private String lastExecutionControlStatus;58 private String lastExecutionControlMessage;59 private String lastExecutionControlProperty;60 private String lastExecutionStart;61 private String lastExecutionEnd;62 private String lastExecutionQueueID;63 private String lastExecutionID;64 private String lastExecutionQueueState;65 private String lastExecutionBattery;66 private String lastExecutionSubBattery;67 private String lastExecutionTestCase;68 private String lastExecutionTest;69 private String lastExecutionApplication;70 private String lastExecutionSystem;71 private String lastExecutionEnvironmentData;72 private String lastExecutionCountryEnvironmentParameters;73 private String lastExecutionControlStatusExecuted;

Full Screen

Full Screen

getTestcaseCountries

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.controller;2import java.util.List;3import org.cerberus.crud.entity.TestCaseCountryProperties;4import org.cerberus.crud.service.ITestCaseCountryPropertiesService;5import org.springframework.beans.factory.annotation.Autowired;6import org.springframework.stereotype.Controller;7import org.springframework.web.bind.annotation.RequestMapping;8import org.springframework.web.bind.annotation.RequestMethod;9import org.springframework.web.bind.annotation.RequestParam;10import org.springframework.web.servlet.ModelAndView;11@RequestMapping(value = "/TestCaseCountryProperties")12public class TestCaseCountryPropertiesController {13 private ITestCaseCountryPropertiesService testCaseCountryPropertiesService;14 @RequestMapping(value = "/GetTestcaseCountries", method = RequestMethod.GET)15 public ModelAndView getTestcaseCountries(@RequestParam String test, @RequestParam String testcase) {16 ModelAndView model = new ModelAndView();17 List<TestCaseCountryProperties> testCaseCountryProperties = testCaseCountryPropertiesService.getTestcaseCountries(test, testcase);18 model.addObject("testCaseCountryProperties", testCaseCountryProperties);19 model.setViewName("TestCaseCountryProperties");20 return model;21 }22}23package org.cerberus.crud.controller;24import java.util.List;25import org.cerberus.crud.entity.TestCaseCountryProperties;26import org.cerberus.crud.service.ITestCaseCountryPropertiesService;27import org.springframework.beans.factory.annotation.Autowired;28import org.springframework.stereotype.Controller;29import org.springframework.web.bind.annotation.RequestMapping;30import org.springframework.web.bind.annotation.RequestMethod;31import org.springframework.web.bind.annotation.RequestParam;32import org.springframework.web.servlet.ModelAndView;33@RequestMapping(value = "/TestCaseCountryProperties")34public class TestCaseCountryPropertiesController {35 private ITestCaseCountryPropertiesService testCaseCountryPropertiesService;36 @RequestMapping(value = "/GetScriptTestCaseCountryProperties", method = RequestMethod.GET)37 public ModelAndView getScriptTestCaseCountryProperties(@RequestParam String test, @

Full Screen

Full Screen

getTestcaseCountries

Using AI Code Generation

copy

Full Screen

1package com.cerberus.testcases;2import java.util.List;3import org.cerberus.crud.entity.TestCaseCountryProperties;4public class TestClass {5 public static void main(String[] args) {6 TestCaseCountryProperties tc = new TestCaseCountryProperties();7 List<String> countryList = tc.getTestcaseCountries("TC1", "T1", 1);8 System.out.println(countryList);9 }10}11 private String country;12 private String property;13 private String value;14 private String type;15 private String database;16 private String description;17 private int length;18 private int rowLimit;19 private String nature;20 private String retryNb;21 private String retryPeriod;22 private String servicePath;23 private String service;24 private String method;25 private String envelope;26 private String parsingAnswer;27 private String parsingCrtieria;28 private String parsingCrtieriaExclude;29 private String application;30 private String isInvariant;31 private String isFromLibrary;32 private String usrCreated;33 private String dateCreated;34 private String usrModif;35 private String dateModif;36 private String system;37 public TestCaseCountryProperties() {38 }39 public TestCaseCountryProperties(int id, String test, String testCase, int countryId, String country, String property, String value, String type, String database, String description, int length, int rowLimit, String nature, String retryNb, String retryPeriod, String servicePath, String service, String method, String envelope, String parsingAnswer, String parsingCrtieria, String parsingCrtieriaExclude, String application, String isInvariant, String isFromLibrary, String usrCreated, String dateCreated, String usrModif, String dateModif, String system) {40 this.id = id;41 this.test = test;42 this.testCase = testCase;43 this.countryId = countryId;44 this.country = country;45 this.property = property;46 this.value = value;47 this.type = type;48 this.database = database;49 this.description = description;50 this.length = length;51 this.rowLimit = rowLimit;52 this.nature = nature;53 this.retryNb = retryNb;54 this.retryPeriod = retryPeriod;55 this.servicePath = servicePath;56 this.service = service;57 this.method = method;58 this.envelope = envelope;59 this.parsingAnswer = parsingAnswer;60 this.parsingCrtieria = parsingCrtieria;61 this.parsingCrtieriaExclude = parsingCrtieriaExclude;

Full Screen

Full Screen

getTestcaseCountries

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.controller;2import java.util.List;3import org.cerberus.crud.entity.TestCaseCountryProperties;4import org.cerberus.crud.service.ITestCaseCountryPropertiesService;5import org.springframework.beans.factory.annotation.Autowired;6import org.springframework.stereotype.Controller;7import org.springframework.web.bind.annotation.RequestMapping;8import org.springframework.web.bind.annotation.RequestMethod;9import org.springframework.web.bind.annotation.RequestParam;10import org.springframework.web.servlet.ModelAndView;11@RequestMapping(value = "/TestCaseCountryProperties")12public class TestCaseCountryPropertiesController {13 private ITestCaseCountryPropertiesService testCaseCountryPropertiesService;14 @RequestMapping(value = "/GetTestcaseCountries", method = RequestMethod.GET)15 public ModelAndView getTestcaseCountries(@RequestParam String test, @RequestParam String testcase) {16 ModelAndView model = new ModelAndView();17 List<TestCaseCountryProperties> testCaseCountryProperties = testCaseCountryPropertiesService.getTestcaseCountries(test, testcase);18 model.addObject("testCaseCountryProperties", testCaseCountryProperties);19 model.setViewName("TestCaseCountryProperties");20 return model;21 }22}23package org.cerberus.crud.controller;24import java.util.List;25import org.cerberus.crud.entity.TestCaseCountryProperties;26import org.cerberus.crud.service.ITestCaseCountryPropertiesService;27import org.springframework.beans.factory.annotation.Autowired;28import org.springframework.stereotype.Controller;29import org.springframework.web.bind.annotation.RequestMapping;30import org.springframework.web.bind.annotation.RequestMethod;31import org.springframework.web.bind.annotation.RequestParam;32import org.springframework.web.servlet.ModelAndView;33@RequestMapping(value = "/TestCaseCountryProperties")34public class TestCaseCountryPropertiesController {35 private ITestCaseCountryPropertiesService testCaseCountryPropertiesService;36 @RequestMapping(value = "/GetScriptTestCaseCountryProperties", method = RequestMethod.GET)37 public ModelAndView getScriptTestCaseCountryProperties(@RequestParam String test, @38public class TestCaseCountryProperties {39 private long id;40 private String test;41 private String testcase;42 private String country;43 private String property;44 private String value;45 private String type;46 private String database;47 private String description;48 private String usrCreated;49 private String dateCreated;50 private String usrModif;51 private String dateModif;52 public long getId() {53 return id;54 }55 public void setId(long id) {56 this.id = id;57 }58 public String getTest() {59 return test;60 }61 public void setTest(String test) {62 this.test = test;63 }64 public String getTestcase() {65 return testcase;66 }67 public void setTestcase(String testcase) {68 this.testcase = testcase;69 }70 public String getCountry() {71 return country;72 }73 public void setCountry(String country) {74 this.country = country;75 }76 public String getProperty() {77 return property;78 }79 public void setProperty(String property) {80 this.property = property;81 }82 public String getValue() {83 return value;84 }85 public void setValue(String value) {86 this.value = value;87 }88 public String getType() {89 return type;90 }91 public void setType(String type) {92 this.type = type;93 }94 public String getDatabase() {95 return database;96 }97 public void setDatabase(String database) {98 this.database = database;99 }100 public String getDescription() {101 return description;102 }103 public void setDescription(String description) {104 this.description = description;105 }106 public String getUsrCreated() {107 return usrCreated;108 }109 public void setUsrCreated(String usrCreated) {110 this.usrCreated = usrCreated;111 }112 public String getDateCreated() {113 return dateCreated;114 }115 public void setDateCreated(String dateCreated) {116 this.dateCreated = dateCreated;117 }118 public String getUsrModif() {119 return usrModif;120 }121 public void setUsrModif(String usrModif) {122 this.usrModif = usrModif;123 }124 public String getDateModif() {

Full Screen

Full Screen

getTestcaseCountries

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import java.util.ArrayList;3import java.util.List;4public class TestCaseCountryProperties {5 private int id;6 private String test;7 private String testCase;8 private int countryId;9 private String country;10 private String property;11 private String value;12 private String type;13 private String database;14 private String description;15 private int length;16 private int rowLimit;17 private String nature;18 private String retryNb;19 private String retryPeriod;20 private String servicePath;21 private String service;22 private String method;23 private String envelope;24 private String parsingAnswer;25 private String parsingCrtieria;26 private String parsingCrtieriaExclude;27 private String application;28 private String isInvariant;29 private String isFromLibrary;30 private String usrCreated;31 private String dateCreated;32 private String usrModif;33 private String dateModif;34 private String system;35 public TestCaseCountryProperties() {36 }37 public TestCaseCountryProperties(int id, String test, String testCase, int countryId, String country, String property, String value, String type, String database, String description, int length, int rowLimit, String nature, String retryNb, String retryPeriod, String servicePath, String service, String method, String envelope, String parsingAnswer, String parsingCrtieria, String parsingCrtieriaExclude, String application, String isInvariant, String isFromLibrary, String usrCreated, String dateCreated, String usrModif, String dateModif, String system) {38 this.id = id;39 this.test = test;40 this.testCase = testCase;41 this.countryId = countryId;42 this.country = country;43 this.property = property;44 this.value = value;45 this.type = type;46 this.database = database;47 this.description = description;48 this.length = length;49 this.rowLimit = rowLimit;50 this.nature = nature;51 this.retryNb = retryNb;52 this.retryPeriod = retryPeriod;53 this.servicePath = servicePath;54 this.service = service;55 this.method = method;56 this.envelope = envelope;57 this.parsingAnswer = parsingAnswer;58 this.parsingCrtieria = parsingCrtieria;59 this.parsingCrtieriaExclude = parsingCrtieriaExclude;

Full Screen

Full Screen

getTestcaseCountries

Using AI Code Generation

copy

Full Screen

1package com.cerberus.testcases;2import java.util.List;3import org.cerberus.crud.entity.TestCaseCountryProperties;4public class TestClass {5 public static void main(String[] args) {6 TestCaseCountryProperties tc = new TestCaseCountryProperties();7 List<String> countryList = tc.getTestcaseCountries("TC1", "T1", 1);8 System.out.println(countryList);9 }10}

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