use of org.cerberus.crud.entity.TestCase in project cerberus-source by cerberustesting.
the class TestCaseExecutionService method createAllTestCaseExecution.
@Override
public List<TestCaseExecution> createAllTestCaseExecution(List<TestCase> testCaseList, List<String> envList, List<String> countryList) {
List<TestCaseExecution> result = new ArrayList<TestCaseExecution>();
for (TestCase tc : testCaseList) {
for (String environment : envList) {
for (String country : countryList) {
TestCaseExecution execution = new TestCaseExecution();
execution.setTest(tc.getTest());
execution.setTestCase(tc.getTestCase());
execution.setEnvironment(environment);
execution.setCountry(country);
result.add(execution);
}
}
}
return result;
}
use of org.cerberus.crud.entity.TestCase in project cerberus-source by cerberustesting.
the class TestCaseExecutionService method readByKeyWithDependency.
@Override
public AnswerItem readByKeyWithDependency(long executionId) {
AnswerItem tce = this.readByKey(executionId);
TestCaseExecution testCaseExecution = (TestCaseExecution) tce.getItem();
AnswerItem<TestCase> ai = testCaseService.readByKeyWithDependency(testCaseExecution.getTest(), testCaseExecution.getTestCase());
testCaseExecution.setTestCaseObj(ai.getItem());
AnswerList a = testCaseExecutionDataService.readByIdWithDependency(executionId);
for (Object object : a.getDataList()) {
TestCaseExecutionData tced = (TestCaseExecutionData) object;
if (tced.getIndex() == 1) {
testCaseExecution.getTestCaseExecutionDataMap().put(tced.getProperty(), tced);
}
}
// We frist add the 'Pres Testing' testcase execution steps.
AnswerList preTestCaseSteps = testCaseStepExecutionService.readByVarious1WithDependency(executionId, "Pre Testing", null);
testCaseExecution.setTestCaseStepExecutionList(preTestCaseSteps.getDataList());
// Then we add the steps from the main testcase.
AnswerList steps = testCaseStepExecutionService.readByVarious1WithDependency(executionId, testCaseExecution.getTest(), testCaseExecution.getTestCase());
testCaseExecution.addTestCaseStepExecutionList(steps.getDataList());
AnswerList files = testCaseExecutionFileService.readByVarious(executionId, "");
testCaseExecution.setFileList((List<TestCaseExecutionFile>) files.getDataList());
AnswerItem response = new AnswerItem(testCaseExecution, tce.getResultMessage());
return response;
}
use of org.cerberus.crud.entity.TestCase in project cerberus-source by cerberustesting.
the class TestCaseService method findTestCaseActiveAutomatedBySystem.
@Override
public List<TestCase> findTestCaseActiveAutomatedBySystem(String test, String system) {
TestCase tCase = factoryTCase.create(test, null, null, null, null, null, null, null, null, null, null, null, null, null, -1, null, null, null, null, null, "Y", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
List<TestCase> result = new ArrayList();
List<TestCase> testCases = findTestCaseByAllCriteria(tCase, null, system);
for (TestCase testCase : testCases) {
if (!testCase.getGroup().equals("PRIVATE")) {
result.add(testCase);
}
}
return result;
}
use of org.cerberus.crud.entity.TestCase in project cerberus-source by cerberustesting.
the class TestCaseService method findTestCaseByKeyWithDependency.
@Override
public TestCase findTestCaseByKeyWithDependency(String test, String testCase) throws CerberusException {
TestCase newTcase;
newTcase = findTestCaseByKey(test, testCase);
if (newTcase == null) {
// TODO:FN temporary debug messages
LOG.warn("test case is null - test: " + test + " testcase: " + testCase);
} else {
List<TestCaseCountry> testCaseCountry = testCaseCountryService.findTestCaseCountryByTestTestCase(test, testCase);
List<TestCaseCountry> testCaseCountryToAdd = new ArrayList();
for (TestCaseCountry tcc : testCaseCountry) {
List<TestCaseCountryProperties> properties = testCaseCountryPropertiesService.findListOfPropertyPerTestTestCaseCountry(test, testCase, tcc.getCountry());
tcc.setTestCaseCountryProperty(properties);
testCaseCountryToAdd.add(tcc);
}
newTcase.setTestCaseCountry(testCaseCountryToAdd);
String initialTest = test;
String initialTc = testCase;
List<TestCaseStep> tcs = testCaseStepService.getListOfSteps(test, testCase);
List<TestCaseStep> tcsToAdd = new ArrayList();
for (TestCaseStep step : tcs) {
int stepNumber = step.getStep();
int initialStep = step.getStep();
if (step.getUseStep().equals("Y")) {
test = step.getUseStepTest();
testCase = step.getUseStepTestCase();
stepNumber = step.getUseStepStep();
}
List<TestCaseStepAction> tcsa = testCaseStepActionService.getListOfAction(test, testCase, stepNumber);
List<TestCaseStepAction> tcsaToAdd = new ArrayList();
for (TestCaseStepAction action : tcsa) {
List<TestCaseStepActionControl> tcsac = testCaseStepActionControlService.findControlByTestTestCaseStepSequence(test, testCase, stepNumber, action.getSequence());
List<TestCaseStepActionControl> tcsacToAdd = new ArrayList();
for (TestCaseStepActionControl control : tcsac) {
control.setTest(initialTest);
control.setTestCase(initialTc);
control.setStep(initialStep);
tcsacToAdd.add(control);
}
action.setTestCaseStepActionControl(tcsacToAdd);
action.setTest(initialTest);
action.setTestCase(initialTc);
action.setStep(initialStep);
tcsaToAdd.add(action);
}
step.setTestCaseStepAction(tcsaToAdd);
tcsToAdd.add(step);
}
newTcase.setTestCaseStep(tcsToAdd);
}
return newTcase;
}
use of org.cerberus.crud.entity.TestCase in project cerberus-source by cerberustesting.
the class ReadTestCase method findTestCaseWithStep.
private AnswerItem findTestCaseWithStep(ApplicationContext appContext, HttpServletRequest request, String test, String testCase) throws JSONException {
AnswerItem item = new AnswerItem();
JSONObject object = new JSONObject();
HashMap<String, JSONObject> hashProp = new HashMap<String, JSONObject>();
JSONObject jsonResponse = new JSONObject();
testCaseService = appContext.getBean(ITestCaseService.class);
testCaseCountryService = appContext.getBean(ITestCaseCountryService.class);
testCaseStepService = appContext.getBean(ITestCaseStepService.class);
testCaseStepActionService = appContext.getBean(ITestCaseStepActionService.class);
testCaseStepActionControlService = appContext.getBean(ITestCaseStepActionControlService.class);
ITestCaseCountryPropertiesService testCaseCountryPropertiesService = appContext.getBean(ITestCaseCountryPropertiesService.class);
// finds the testcase
AnswerItem answer = testCaseService.readByKey(test, testCase);
AnswerList testCaseCountryList = testCaseCountryService.readByTestTestCase(null, test, testCase);
AnswerList testCaseStepList = testCaseStepService.readByTestTestCase(test, testCase);
AnswerList testCaseStepActionList = testCaseStepActionService.readByTestTestCase(test, testCase);
AnswerList testCaseStepActionControlList = testCaseStepActionControlService.readByTestTestCase(test, testCase);
if (answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {
// if the service returns an OK message then we can get the item and convert it to JSONformat
TestCase tc = (TestCase) answer.getItem();
object = convertToJSONObject(tc);
object.put("countryList", new JSONObject());
jsonResponse.put("hasPermissionsDelete", testCaseService.hasPermissionsDelete(tc, request));
jsonResponse.put("hasPermissionsUpdate", testCaseService.hasPermissionsUpdate(tc, request));
jsonResponse.put("hasPermissionsStepLibrary", (request.isUserInRole("TestStepLibrary")));
}
for (TestCaseCountry country : (List<TestCaseCountry>) testCaseCountryList.getDataList()) {
object.getJSONObject("countryList").put(country.getCountry(), country.getCountry());
}
JSONArray stepList = new JSONArray();
Gson gson = new Gson();
for (TestCaseStep step : (List<TestCaseStep>) testCaseStepList.getDataList()) {
step = testCaseStepService.modifyTestCaseStepDataFromUsedStep(step);
JSONObject jsonStep = new JSONObject(gson.toJson(step));
// Fill JSON with step info
jsonStep.put("objType", "step");
// Add a JSON array for Action List from this step
jsonStep.put("actionList", new JSONArray());
if (step.getUseStep().equals("Y")) {
// If this step is imported from library, we call the service to retrieve actions
TestCaseStep usedStep = testCaseStepService.findTestCaseStep(step.getUseStepTest(), step.getUseStepTestCase(), step.getUseStepStep());
List<TestCaseStepAction> actionList = testCaseStepActionService.getListOfAction(step.getUseStepTest(), step.getUseStepTestCase(), step.getUseStepStep());
List<TestCaseStepActionControl> controlList = testCaseStepActionControlService.findControlByTestTestCaseStep(step.getUseStepTest(), step.getUseStepTestCase(), step.getUseStepStep());
List<TestCaseCountryProperties> properties = testCaseCountryPropertiesService.findDistinctPropertiesOfTestCase(step.getUseStepTest(), step.getUseStepTestCase());
// Get the used step sort
jsonStep.put("useStepStepSort", usedStep.getSort());
// retrieve the inherited properties
for (TestCaseCountryProperties prop : properties) {
JSONObject propertyFound = new JSONObject();
propertyFound.put("fromTest", prop.getTest());
propertyFound.put("fromTestCase", prop.getTestCase());
propertyFound.put("property", prop.getProperty());
propertyFound.put("description", prop.getDescription());
propertyFound.put("type", prop.getType());
propertyFound.put("database", prop.getDatabase());
propertyFound.put("value1", prop.getValue1());
propertyFound.put("value2", prop.getValue2());
propertyFound.put("length", prop.getLength());
propertyFound.put("rowLimit", prop.getRowLimit());
propertyFound.put("nature", prop.getNature());
List<String> countriesSelected = testCaseCountryPropertiesService.findCountryByProperty(prop);
JSONArray countries = new JSONArray();
for (String country : countriesSelected) {
countries.put(country);
}
propertyFound.put("country", countries);
hashProp.put(prop.getTest() + "_" + prop.getTestCase() + "_" + prop.getProperty(), propertyFound);
}
for (TestCaseStepAction action : actionList) {
if (action.getStep() == step.getUseStepStep()) {
JSONObject jsonAction = new JSONObject(gson.toJson(action));
jsonAction.put("objType", "action");
jsonAction.put("controlList", new JSONArray());
// We fill the action with the corresponding controls
for (TestCaseStepActionControl control : controlList) {
if (control.getStep() == step.getUseStepStep() && control.getSequence() == action.getSequence()) {
JSONObject jsonControl = new JSONObject(gson.toJson(control));
jsonControl.put("objType", "control");
jsonAction.getJSONArray("controlList").put(jsonControl);
}
}
// we put the action in the actionList for the corresponding step
jsonStep.getJSONArray("actionList").put(jsonAction);
}
}
} else {
// else, we fill the actionList with the action from this step
for (TestCaseStepAction action : (List<TestCaseStepAction>) testCaseStepActionList.getDataList()) {
if (action.getStep() == step.getStep()) {
JSONObject jsonAction = new JSONObject(gson.toJson(action));
jsonAction.put("objType", "action");
jsonAction.put("controlList", new JSONArray());
// We fill the action with the corresponding controls
for (TestCaseStepActionControl control : (List<TestCaseStepActionControl>) testCaseStepActionControlList.getDataList()) {
if (control.getStep() == step.getStep() && control.getSequence() == action.getSequence()) {
JSONObject jsonControl = new JSONObject(gson.toJson(control));
jsonControl.put("objType", "control");
jsonAction.getJSONArray("controlList").put(jsonControl);
}
}
// we put the action in the actionList for the corresponding step
jsonStep.getJSONArray("actionList").put(jsonAction);
}
}
}
stepList.put(jsonStep);
}
jsonResponse.put("info", object);
jsonResponse.put("stepList", stepList);
jsonResponse.put("inheritedProp", hashProp.values());
item.setItem(jsonResponse);
item.setResultMessage(answer.getResultMessage());
return item;
}
Aggregations