use of org.cerberus.crud.entity.TestCaseExecution in project cerberus-source by cerberustesting.
the class GetReportData method getStatByEnvCountryBrowser.
private JSONObject getStatByEnvCountryBrowser(List<TestCaseExecution> testCaseExecutions, HashMap<String, SummaryStatisticsDTO> statMap, boolean env, boolean country, boolean browser, boolean app) throws JSONException {
SummaryStatisticsDTO total = new SummaryStatisticsDTO();
total.setEnvironment("Total");
for (TestCaseExecution testCaseExecution : testCaseExecutions) {
StringBuilder key = new StringBuilder();
key.append((env) ? testCaseExecution.getEnvironment() : "");
key.append("_");
key.append((country) ? testCaseExecution.getCountry() : "");
key.append("_");
key.append((browser) ? testCaseExecution.getBrowser() : "");
key.append("_");
key.append((app) ? testCaseExecution.getApplication() : "");
if (statMap.containsKey(key.toString())) {
statMap.get(key.toString()).updateStatisticByStatus(testCaseExecution.getControlStatus());
}
total.updateStatisticByStatus(testCaseExecution.getControlStatus());
}
return extractSummaryData(statMap, total);
}
use of org.cerberus.crud.entity.TestCaseExecution in project cerberus-source by cerberustesting.
the class GetNumberOfExecutions method processRequest.
/**
* Processes requests for both HTTP
* <code>GET</code> and
* <code>POST</code> methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
// Loading Services.
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
IApplicationService myApplicationService = appContext.getBean(ApplicationService.class);
IInvariantService myInvariantService = appContext.getBean(InvariantService.class);
// Calling Servlet Transversal Util.
ServletUtil.servletStart(request);
/**
* Adding Log entry.
*/
ILogEventService logEventService = appContext.getBean(LogEventService.class);
logEventService.createForPublicCalls("/GetNumberOfExecutions", "CALL", "GetNumberOfExecutions called : " + request.getRequestURL(), request);
// Parsing all parameters.
String environment = ParameterParserUtil.parseStringParam(request.getParameter("environment"), "PROD");
String test = ParameterParserUtil.parseStringParam(request.getParameter("test"), "");
String application = ParameterParserUtil.parseStringParam(request.getParameter("application"), "");
String country = ParameterParserUtil.parseStringParam(request.getParameter("country"), "");
String controlStatus = ParameterParserUtil.parseStringParam(request.getParameter("controlstatus"), "");
int NbMinutes = ParameterParserUtil.parseIntegerParam(request.getParameter("nbminuteshistory"), 0);
// Defining help message.
String helpMessage = "\nThis servlet return the number of execution performed on WORKING test cases that match the following criterias :\n" + "- nbminuteshistory [mandatory] : the number of minutes in the past from the moment the servlet is called. This parameter must be > 0. [" + NbMinutes + "]\n" + "- test : Executions done on the test. [" + test + "]\n" + "- environment : Environment where the execution happened. Default to PROD. [" + environment + "]\n" + "- country : Executions done on the country. [" + country + "]\n" + "- application : Executions done against that application. [" + application + "]\n" + "- controlstatus : execution that return the following status. [" + controlStatus + "]\n";
try {
// Checking the parameter validity. nbminuteshistory is a mandatory parameter.
boolean error = false;
if (NbMinutes == 0) {
out.println("Error - Parameter nbminuteshistory is mandatory. Please feed it in order to specify the elapsed time where the history should be considered.");
error = true;
}
// Checking the parameter validity. If application has been entered, does it exist ?
if (!application.equalsIgnoreCase("") && !myApplicationService.exist(application)) {
out.println("Error - Application does not exist : " + application);
error = true;
}
if (!country.equalsIgnoreCase("") && !myInvariantService.isInvariantExist("COUNTRY", country)) {
out.println("Warning - Country does not exist : " + country);
}
if (!environment.equalsIgnoreCase("") && !myInvariantService.isInvariantExist("ENVIRONMENT", environment)) {
out.println("Warning - Environment does not exist : " + environment);
}
if (!controlStatus.equalsIgnoreCase("") && !myInvariantService.isInvariantExist("TCESTATUS", controlStatus)) {
out.println("Warning - Control Status does not exist : " + controlStatus);
}
// Starting the request only if previous parameters exist.
if (!error) {
// Getting a timestamp to filter the executions based on the nb of minutes
String dateLimitFrom = DateUtil.getMySQLTimestampTodayDeltaMinutes(-NbMinutes);
ITestCaseExecutionService MyTestExecutionService = appContext.getBean(TestCaseExecutionService.class);
List<TestCaseExecution> myList;
// Getting the lists of test cases the follow the criterias.
try {
myList = MyTestExecutionService.findTCExecutionbyCriteria1(dateLimitFrom, test, "", application, country, environment, controlStatus, "WORKING");
out.println(myList.size());
} catch (CerberusException e) {
out.println("0");
}
} else {
// In case of errors, we displayu the help message.
out.println(helpMessage);
}
} catch (Exception e) {
LOG.warn(Infos.getInstance().getProjectNameAndVersion() + " - Exception catched.", e);
out.print("Error while Getting number of executions : ");
out.println(e.getMessage());
} finally {
out.close();
}
}
use of org.cerberus.crud.entity.TestCaseExecution in project cerberus-source by cerberustesting.
the class ReadTestCaseExecution method findExecutionListByTag.
private AnswerItem findExecutionListByTag(ApplicationContext appContext, HttpServletRequest request, String Tag) throws CerberusException, ParseException, JSONException {
AnswerItem answer = new AnswerItem(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK));
testCaseLabelService = appContext.getBean(ITestCaseLabelService.class);
int startPosition = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayStart"), "0"));
int length = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayLength"), "0"));
String searchParameter = ParameterParserUtil.parseStringParam(request.getParameter("sSearch"), "");
String sColumns = ParameterParserUtil.parseStringParam(request.getParameter("sColumns"), "test,testCase,application,priority,status,description,bugId,function");
String[] columnToSort = sColumns.split(",");
// Get Sorting information
int numberOfColumnToSort = Integer.parseInt(ParameterParserUtil.parseStringParam(request.getParameter("iSortingCols"), "1"));
int columnToSortParameter = 0;
String sort = "asc";
StringBuilder sortInformation = new StringBuilder();
for (int c = 0; c < numberOfColumnToSort; c++) {
columnToSortParameter = Integer.parseInt(ParameterParserUtil.parseStringParam(request.getParameter("iSortCol_" + c), "0"));
sort = ParameterParserUtil.parseStringParam(request.getParameter("sSortDir_" + c), "asc");
String columnName = columnToSort[columnToSortParameter];
sortInformation.append(columnName).append(" ").append(sort);
if (c != numberOfColumnToSort - 1) {
sortInformation.append(" , ");
}
}
Map<String, List<String>> individualSearch = new HashMap<String, List<String>>();
for (int a = 0; a < columnToSort.length; a++) {
if (null != request.getParameter("sSearch_" + a) && !request.getParameter("sSearch_" + a).isEmpty()) {
List<String> search = new ArrayList(Arrays.asList(request.getParameter("sSearch_" + a).split(",")));
individualSearch.put(columnToSort[a], search);
}
}
List<TestCaseExecution> testCaseExecutions = readExecutionByTagList(appContext, Tag, startPosition, length, sortInformation.toString(), searchParameter, individualSearch);
JSONArray executionList = new JSONArray();
JSONObject statusFilter = getStatusList(request);
JSONObject countryFilter = getCountryList(request, appContext);
LinkedHashMap<String, JSONObject> ttc = new LinkedHashMap<String, JSONObject>();
String globalStart = "";
String globalEnd = "";
String globalStatus = "Finished";
/**
* Find the list of labels
*/
AnswerList testCaseLabelList = testCaseLabelService.readByTestTestCase(null, null);
for (TestCaseExecution testCaseExecution : testCaseExecutions) {
try {
if (testCaseExecution.getStart() != 0) {
if ((globalStart.isEmpty()) || (globalStart.compareTo(String.valueOf(testCaseExecution.getStart())) > 0)) {
globalStart = String.valueOf(testCaseExecution.getStart());
}
}
if (testCaseExecution.getEnd() != 0) {
if ((globalEnd.isEmpty()) || (globalEnd.compareTo(String.valueOf(testCaseExecution.getEnd())) < 0)) {
globalEnd = String.valueOf(testCaseExecution.getEnd());
}
}
if (testCaseExecution.getControlStatus().equalsIgnoreCase("PE")) {
globalStatus = "Pending...";
}
String controlStatus = testCaseExecution.getControlStatus();
if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseExecution.getCountry()).equals("on")) {
JSONObject execution = testCaseExecutionToJSONObject(testCaseExecution);
String execKey = testCaseExecution.getEnvironment() + " " + testCaseExecution.getCountry() + " " + testCaseExecution.getBrowser();
String testCaseKey = testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase();
JSONObject execTab = new JSONObject();
executionList.put(testCaseExecutionToJSONObject(testCaseExecution));
JSONObject ttcObject = new JSONObject();
if (ttc.containsKey(testCaseKey)) {
ttcObject = ttc.get(testCaseKey);
execTab = ttcObject.getJSONObject("execTab");
execTab.put(execKey, execution);
ttcObject.put("execTab", execTab);
} else {
ttcObject.put("test", testCaseExecution.getTest());
ttcObject.put("testCase", testCaseExecution.getTestCase());
ttcObject.put("function", testCaseExecution.getTestCaseObj().getFunction());
ttcObject.put("shortDesc", testCaseExecution.getTestCaseObj().getDescription());
ttcObject.put("status", testCaseExecution.getStatus());
ttcObject.put("application", testCaseExecution.getApplication());
ttcObject.put("priority", testCaseExecution.getTestCaseObj().getPriority());
ttcObject.put("bugId", new JSONObject("{\"bugId\":\"" + testCaseExecution.getTestCaseObj().getBugID() + "\",\"bugTrackerUrl\":\"" + testCaseExecution.getApplicationObj().getBugTrackerUrl().replace("%BUGID%", testCaseExecution.getTestCaseObj().getBugID()) + "\"}"));
ttcObject.put("comment", testCaseExecution.getTestCaseObj().getComment());
execTab.put(execKey, execution);
ttcObject.put("execTab", execTab);
/**
* Iterate on the label retrieved and generate HashMap
* based on the key Test_TestCase
*/
LinkedHashMap<String, JSONArray> testCaseWithLabel = new LinkedHashMap();
for (TestCaseLabel label : (List<TestCaseLabel>) testCaseLabelList.getDataList()) {
String key = label.getTest() + "_" + label.getTestcase();
if (testCaseWithLabel.containsKey(key)) {
JSONObject jo = new JSONObject().put("name", label.getLabel().getLabel()).put("color", label.getLabel().getColor()).put("description", label.getLabel().getDescription());
testCaseWithLabel.get(key).put(jo);
} else {
JSONObject jo = new JSONObject().put("name", label.getLabel().getLabel()).put("color", label.getLabel().getColor()).put("description", label.getLabel().getDescription());
testCaseWithLabel.put(key, new JSONArray().put(jo));
}
}
ttcObject.put("labels", testCaseWithLabel.get(testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase()));
}
ttc.put(testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase(), ttcObject);
}
} catch (JSONException ex) {
LOG.warn(ex);
}
}
JSONObject jsonResponse = new JSONObject();
jsonResponse.put("globalEnd", globalEnd.toString());
jsonResponse.put("globalStart", globalStart.toString());
jsonResponse.put("globalStatus", globalStatus);
jsonResponse.put("testList", ttc.values());
jsonResponse.put("iTotalRecords", ttc.size());
jsonResponse.put("iTotalDisplayRecords", ttc.size());
answer.setItem(jsonResponse);
answer.setResultMessage(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK));
return answer;
}
use of org.cerberus.crud.entity.TestCaseExecution in project cerberus-source by cerberustesting.
the class ReadTestCaseExecution method findExecutionListBySystem.
private AnswerItem findExecutionListBySystem(String system, ApplicationContext appContext, HttpServletRequest request) throws ParseException, JSONException {
AnswerItem answer = new AnswerItem(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK));
/**
* Parse all parameters used in the search.
*/
String charset = request.getCharacterEncoding();
/**
* Parse parameters - list of values
*/
List<String> testList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("test"), null, charset);
List<String> applicationList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("application"), null, charset);
List<String> projectList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("project"), null, charset);
List<String> tcstatusList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("tcstatus"), null, charset);
List<String> groupList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("group"), null, charset);
List<String> tcactiveList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("tcactive"), null, charset);
List<String> priorityList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("priority"), null, charset);
List<String> targetsprintList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("targetsprint"), null, charset);
List<String> targetrevisionList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("targetrevision"), null, charset);
List<String> creatorList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("creator"), null, charset);
List<String> implementerList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("implementer"), null, charset);
List<String> environmentList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("environment"), null, charset);
List<String> buildList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("build"), null, charset);
List<String> revisionList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("revision"), null, charset);
List<String> countryList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("country"), null, charset);
List<String> browserList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("browser"), null, charset);
List<String> tcestatusList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("tcestatus"), null, charset);
// Sorts the lists
if (countryList != null) {
Collections.sort(countryList);
}
if (browserList != null) {
Collections.sort(browserList);
}
/**
* Parse parameters - free text
*/
String bugid = StringEscapeUtils.escapeHtml4(request.getParameter("bugid"));
String ticket = StringEscapeUtils.escapeHtml4(request.getParameter("ticket"));
String ip = StringEscapeUtils.escapeHtml4(request.getParameter("ip"));
String port = StringEscapeUtils.escapeHtml4(request.getParameter("port"));
String tag = StringEscapeUtils.escapeHtml4(request.getParameter("tag"));
String browserversion = StringEscapeUtils.escapeHtml4(request.getParameter("browserversion"));
String comment = StringEscapeUtils.escapeHtml4(request.getParameter("comment"));
/**
* Gets regular executions (not in queue)
*/
AnswerList answerExecutions = testCaseExecutionService.readBySystemByVarious(system, testList, applicationList, projectList, tcstatusList, groupList, tcactiveList, priorityList, targetsprintList, targetrevisionList, creatorList, implementerList, buildList, revisionList, environmentList, countryList, browserList, tcestatusList, ip, port, tag, browserversion, comment, bugid, ticket);
List<TestCaseExecution> testCaseExecutions = (List<TestCaseExecution>) answerExecutions.getDataList();
/**
* Get list of Execution in Queue by Tag
*/
ITestCaseExecutionQueueService testCaseExecutionInQueueService = appContext.getBean(ITestCaseExecutionQueueService.class);
AnswerList answerExecutionsInQueue = testCaseExecutionInQueueService.readBySystemByVarious(system, testList, applicationList, projectList, tcstatusList, groupList, tcactiveList, priorityList, targetsprintList, targetrevisionList, creatorList, implementerList, buildList, revisionList, environmentList, countryList, browserList, tcestatusList, ip, port, tag, browserversion, comment, bugid, ticket);
List<TestCaseExecutionQueue> testCaseExecutionsInQueue = (List<TestCaseExecutionQueue>) answerExecutionsInQueue.getDataList();
/**
* Merge Test Case Executions
*/
List<TestCaseExecution> allTestCaseExecutions = hashExecution(testCaseExecutions, testCaseExecutionsInQueue);
JSONArray executionList = new JSONArray();
LinkedHashMap<String, JSONObject> ttc = new LinkedHashMap<String, JSONObject>();
for (TestCaseExecution testCaseExecution : allTestCaseExecutions) {
try {
JSONObject execution = testCaseExecutionToJSONObject(testCaseExecution);
// the key is country and browser
String execKey = testCaseExecution.getCountry() + " " + testCaseExecution.getBrowser();
String testCaseKey = testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase();
JSONObject execTab = new JSONObject();
executionList.put(testCaseExecutionToJSONObject(testCaseExecution));
JSONObject ttcObject = new JSONObject();
if (ttc.containsKey(testCaseKey)) {
ttcObject = ttc.get(testCaseKey);
execTab = ttcObject.getJSONObject("execTab");
execTab.put(execKey, execution);
ttcObject.put("execTab", execTab);
} else {
ttcObject.put("test", testCaseExecution.getTest());
ttcObject.put("testCase", testCaseExecution.getTestCase());
ttcObject.put("function", testCaseExecution.getTestCaseObj().getFunction());
ttcObject.put("shortDesc", testCaseExecution.getTestCaseObj().getDescription());
ttcObject.put("status", testCaseExecution.getTestCaseObj().getStatus());
ttcObject.put("application", testCaseExecution.getApplication());
ttcObject.put("bugId", testCaseExecution.getTestCaseObj().getBugID());
ttcObject.put("ticket", testCaseExecution.getTestCaseObj().getTicket());
ttcObject.put("comment", testCaseExecution.getTestCaseObj().getComment());
ttcObject.put("priority", testCaseExecution.getTestCaseObj().getPriority());
ttcObject.put("status", testCaseExecution.getStatus());
ttcObject.put("group", testCaseExecution.getTestCaseObj().getGroup());
execTab.put(execKey, execution);
ttcObject.put("execTab", execTab);
}
ttc.put(testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase(), ttcObject);
} catch (JSONException ex) {
LOG.warn(ex);
}
}
JSONObject jsonResponse = new JSONObject();
jsonResponse.put("contentTable", ttc.values());
jsonResponse.put("iTotalRecords", ttc.size());
jsonResponse.put("iTotalDisplayRecords", ttc.size());
answer.setItem(jsonResponse);
answer.setResultMessage(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK));
return answer;
}
use of org.cerberus.crud.entity.TestCaseExecution in project cerberus-source by cerberustesting.
the class ReadTestCaseExecution method readExecutionByTagList.
private List<TestCaseExecution> readExecutionByTagList(ApplicationContext appContext, String Tag, int startPosition, int length, String sortInformation, String searchParameter, Map<String, List<String>> individualSearch) throws ParseException, CerberusException {
AnswerList<TestCaseExecution> testCaseExecution;
AnswerList<TestCaseExecutionQueue> testCaseExecutionInQueue;
ITestCaseExecutionService testCaseExecService = appContext.getBean(ITestCaseExecutionService.class);
ITestCaseExecutionQueueService testCaseExecutionInQueueService = appContext.getBean(ITestCaseExecutionQueueService.class);
/**
* Get list of execution by tag, env, country, browser
*/
testCaseExecution = testCaseExecService.readByTagByCriteria(Tag, startPosition, length, sortInformation, searchParameter, individualSearch);
List<TestCaseExecution> testCaseExecutions = testCaseExecution.getDataList();
/**
* Get list of Execution in Queue by Tag
*/
testCaseExecutionInQueue = testCaseExecutionInQueueService.readByTagByCriteria(Tag, startPosition, length, sortInformation, searchParameter, individualSearch);
List<TestCaseExecutionQueue> testCaseExecutionsInQueue = testCaseExecutionInQueue.getDataList();
/**
* Feed hash map with execution from the two list (to get only one by
* test,testcase,country,env,browser)
*/
testCaseExecutions = hashExecution(testCaseExecutions, testCaseExecutionsInQueue);
return testCaseExecutions;
}
Aggregations