use of org.cerberus.crud.entity.TestCaseCountry in project cerberus-source by cerberustesting.
the class FactoryTestCaseCountry method create.
@Override
public TestCaseCountry create(String test, String testCase, String country) {
TestCaseCountry testCaseCountry = new TestCaseCountry();
testCaseCountry.setTest(test);
testCaseCountry.setTestCase(testCase);
testCaseCountry.setCountry(country);
return testCaseCountry;
}
use of org.cerberus.crud.entity.TestCaseCountry 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.TestCaseCountry 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;
}
use of org.cerberus.crud.entity.TestCaseCountry in project cerberus-source by cerberustesting.
the class UpdateTestCaseWithDependencies 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
* @throws org.cerberus.exception.CerberusException
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, CerberusException {
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
String initialTest = request.getParameter("informationInitialTest");
String initialTestCase = request.getParameter("informationInitialTestCase");
String test = request.getParameter("informationTest");
String testCase = request.getParameter("informationTestCase");
TestCase tc = getTestCaseFromParameter(request, appContext, test, testCase);
boolean duplicate = false;
ITestService tService = appContext.getBean(ITestService.class);
ITestCaseService tcService = appContext.getBean(ITestCaseService.class);
ITestCaseCountryService tccService = appContext.getBean(ITestCaseCountryService.class);
ITestCaseCountryPropertiesService tccpService = appContext.getBean(ITestCaseCountryPropertiesService.class);
ITestCaseStepService tcsService = appContext.getBean(ITestCaseStepService.class);
ITestCaseStepActionService tcsaService = appContext.getBean(ITestCaseStepActionService.class);
ITestCaseStepActionControlService tcsacService = appContext.getBean(ITestCaseStepActionControlService.class);
IInvariantService invariantService = appContext.getBean(IInvariantService.class);
IUserService userService = appContext.getBean(IUserService.class);
IUserGroupService userGroupService = appContext.getBean(IUserGroupService.class);
/**
* Get User and Groups of this user
*/
User user = userService.findUserByKey(request.getUserPrincipal().getName());
// List<UserGroup> userGroupList = groupService.findGroupByUser(user);
List<UserGroup> userGroupList = userGroupService.convert(userGroupService.readByUser(user.getLogin()));
List<String> groupList = new ArrayList();
for (UserGroup group : userGroupList) {
groupList.add(group.getGroup());
}
/**
* Verify the Test is the same than initialTest If it is the same > Do
* nothing If it is not the same > Verify if test already exists If not
* exist > create it If exist > do nothing
*/
if (!tc.getTest().equals(initialTest)) {
if (tService.findTestByKey(tc.getTest()) == null) {
if (groupList.contains("TestAdmin")) {
Test newTest = tService.findTestByKey(initialTest);
newTest.setTest(tc.getTest());
tService.convert(tService.create(newTest));
} else {
response.sendError(403, MessageGeneralEnum.GUI_TEST_CREATION_NOT_HAVE_RIGHT.getDescription());
return;
}
}
}
if (!tc.getTest().equals(initialTest) || !tc.getTestCase().equals(initialTestCase)) {
duplicate = true;
}
/**
* If the testcase is a duplication, set the creator as the one which
* duplicate the testcase and the status in the initial one.
*/
if (duplicate) {
tc.setUsrCreated(user.getLogin());
// TODO: handle if the response does not turn ok
AnswerList answer = invariantService.readByIdname("TCSTATUS");
tc.setStatus(((List<Invariant>) answer.getDataList()).get(0).getValue());
}
/**
* If not duplicate and test in Working status and user with no admin
* right, raise an error
*/
if (!duplicate && "WORKING".equals(tc.getStatus()) && !groupList.contains("TestAdmin")) {
response.sendError(403, MessageGeneralEnum.GUI_TESTCASE_NON_ADMIN_SAVE_WORKING_TESTCASE.getDescription());
return;
}
/**
* Verify testcase is the same than initialTestCase If it is the same >
* update If it is not the same, > verify if testcase already exist If
* it already exist > Send Error If it do not already exists > Create it
*/
if (!duplicate) {
tcService.updateTestCase(tc);
} else if (tcService.findTestCaseByKey(tc.getTest(), tc.getTestCase()) != null) {
response.sendError(403, MessageGeneralEnum.GUI_TESTCASE_DUPLICATION_ALREADY_EXISTS.getDescription());
return;
} else {
tcService.createTestCase(tc);
}
/**
* For the list of testcase country verify it exists. If it does not
* exists > create it If it exist, verify if it's the
*/
List<TestCaseCountry> tccFromPage = getTestCaseCountryFromParameter(request, appContext, test, testCase);
List<TestCaseCountry> tccFromDtb = tccService.findTestCaseCountryByTestTestCase(initialTest, initialTestCase);
/**
* Iterate on (TestCaseCountry From Page - TestCaseCountry From
* Database) If TestCaseCountry in Database has same key : Update and
* remove from the list. If TestCaseCountry in database does ot exist :
* Insert it.
*/
List<TestCaseCountry> tccToUpdateOrInsert = new ArrayList(tccFromPage);
tccToUpdateOrInsert.removeAll(tccFromDtb);
List<TestCaseCountry> tccToUpdateOrInsertToIterate = new ArrayList(tccToUpdateOrInsert);
for (TestCaseCountry tccDifference : tccToUpdateOrInsertToIterate) {
for (TestCaseCountry tccInDatabase : tccFromDtb) {
if (tccDifference.hasSameKey(tccInDatabase)) {
tccToUpdateOrInsert.remove(tccDifference);
}
}
}
tccService.insertListTestCaseCountry(tccToUpdateOrInsert);
/**
* Iterate on (TestCaseCountry From Database - TestCaseCountry From
* Page). If TestCaseCountry in Page has same key : remove from the
* list. Then delete the list of TestCaseCountry
*/
if (!duplicate) {
List<TestCaseCountry> tccToDelete = new ArrayList(tccFromDtb);
tccToDelete.removeAll(tccFromPage);
List<TestCaseCountry> tccToDeleteToIterate = new ArrayList(tccToDelete);
for (TestCaseCountry tccDifference : tccToDeleteToIterate) {
for (TestCaseCountry tccInPage : tccFromPage) {
if (tccDifference.hasSameKey(tccInPage)) {
tccToDelete.remove(tccDifference);
}
}
}
tccService.deleteListTestCaseCountry(tccToDelete);
}
/**
* For the list of testcase country verify it exists. If it does not
* exists > create it If it exist, verify if it's the
*/
List<TestCaseCountryProperties> tccpFromPage = getTestCaseCountryPropertiesFromParameter(request, appContext, test, testCase);
List<TestCaseCountryProperties> tccpFromDtb = tccpService.findListOfPropertyPerTestTestCase(initialTest, initialTestCase);
/**
* Iterate on (TestCaseCountryProperties From Page -
* TestCaseCountryProperties From Database) If TestCaseCountryProperties
* in Database has same key : Update and remove from the list. If
* TestCaseCountryProperties in database does ot exist : Insert it.
*/
List<TestCaseCountryProperties> tccpToUpdateOrInsert = new ArrayList(tccpFromPage);
tccpToUpdateOrInsert.removeAll(tccpFromDtb);
List<TestCaseCountryProperties> tccpToUpdateOrInsertToIterate = new ArrayList(tccpToUpdateOrInsert);
for (TestCaseCountryProperties tccpDifference : tccpToUpdateOrInsertToIterate) {
for (TestCaseCountryProperties tccpInDatabase : tccpFromDtb) {
if (tccpDifference.hasSameKey(tccpInDatabase)) {
tccpService.updateTestCaseCountryProperties(tccpDifference);
tccpToUpdateOrInsert.remove(tccpDifference);
}
}
}
tccpService.insertListTestCaseCountryProperties(tccpToUpdateOrInsert);
/**
* Iterate on (TestCaseCountryProperties From Database -
* TestCaseCountryProperties From Page). If TestCaseCountryProperties in
* Page has same key : remove from the list. Then delete the list of
* TestCaseCountryProperties
*/
if (!duplicate) {
List<TestCaseCountryProperties> tccpToDelete = new ArrayList(tccpFromDtb);
tccpToDelete.removeAll(tccpFromPage);
List<TestCaseCountryProperties> tccpToDeleteToIterate = new ArrayList(tccpToDelete);
for (TestCaseCountryProperties tccpDifference : tccpToDeleteToIterate) {
for (TestCaseCountryProperties tccpInPage : tccpFromPage) {
if (tccpDifference.hasSameKey(tccpInPage)) {
tccpToDelete.remove(tccpDifference);
}
}
}
tccpService.deleteListTestCaseCountryProperties(tccpToDelete);
}
/*
* Get steps, actions and controls from page by:
* - generating a new step, action or control number,
* - setting the correct related step and action for action or control
*/
List<TestCaseStep> tcsFromPage = getTestCaseStepFromParameter(request, appContext, test, testCase, duplicate);
List<TestCaseStepAction> tcsaFromPage = new ArrayList();
List<TestCaseStepActionControl> tcsacFromPage = new ArrayList();
int nextStepNumber = getMaxStepNumber(tcsFromPage);
for (TestCaseStep tcs : tcsFromPage) {
if (tcs.getStep() == -1) {
tcs.setStep(++nextStepNumber);
}
if (tcs.getTestCaseStepAction() != null) {
int nextSequenceNumber = getMaxSequenceNumber(tcs.getTestCaseStepAction());
for (TestCaseStepAction tcsa : tcs.getTestCaseStepAction()) {
if (tcsa.getSequence() == -1) {
tcsa.setSequence(++nextSequenceNumber);
}
tcsa.setStep(tcs.getStep());
if (tcsa.getTestCaseStepActionControl() != null) {
int nextControlNumber = getMaxControlNumber(tcsa.getTestCaseStepActionControl());
for (TestCaseStepActionControl tscac : tcsa.getTestCaseStepActionControl()) {
if (tscac.getControlSequence() == -1) {
tscac.setControlSequence(++nextControlNumber);
}
tscac.setStep(tcs.getStep());
tscac.setSequence(tcsa.getSequence());
}
tcsacFromPage.addAll(tcsa.getTestCaseStepActionControl());
}
}
tcsaFromPage.addAll(tcs.getTestCaseStepAction());
}
}
/*
* Create, update or delete step, action and control according to the needs
*/
List<TestCaseStep> tcsFromDtb = new ArrayList(tcsService.getListOfSteps(initialTest, initialTestCase));
tcsService.compareListAndUpdateInsertDeleteElements(tcsFromPage, tcsFromDtb, duplicate);
List<TestCaseStepAction> tcsaFromDtb = new ArrayList(tcsaService.findTestCaseStepActionbyTestTestCase(initialTest, initialTestCase));
tcsaService.compareListAndUpdateInsertDeleteElements(tcsaFromPage, tcsaFromDtb, duplicate);
List<TestCaseStepActionControl> tcsacFromDtb = new ArrayList(tcsacService.findControlByTestTestCase(initialTest, initialTestCase));
tcsacService.compareListAndUpdateInsertDeleteElements(tcsacFromPage, tcsacFromDtb, duplicate);
/**
* Adding Log entry.
*/
ILogEventService logEventService = appContext.getBean(LogEventService.class);
logEventService.createForPrivateCalls("/UpdateTestCase", "UPDATE", "Update testcase : ['" + tc.getTest() + "'|'" + tc.getTestCase() + "']", request);
String encodedTest = URLEncoder.encode(tc.getTest(), "UTF-8");
String encodedTestCase = URLEncoder.encode(tc.getTestCase(), "UTF-8");
response.sendRedirect(response.encodeRedirectURL("TestCase.jsp?Load=Load&Test=" + encodedTest + "&TestCase=" + encodedTestCase));
}
use of org.cerberus.crud.entity.TestCaseCountry in project cerberus-source by cerberustesting.
the class GetTestCase method doGet.
@Override
protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
try {
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
ITestCaseService testService = appContext.getBean(ITestCaseService.class);
// TODO pass DAO to Service
ITestCaseCountryPropertiesDAO testCaseDAO = appContext.getBean(TestCaseCountryPropertiesDAO.class);
ILoadTestCaseService loadTestCaseService = appContext.getBean(ILoadTestCaseService.class);
PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
String test = policy.sanitize(httpServletRequest.getParameter("test"));
String testcase = policy.sanitize(httpServletRequest.getParameter("testcase"));
TestCase tcInfo = testService.findTestCaseByKeyWithDependency(test, testcase);
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("origin", tcInfo.getOrigine());
jsonObject.put("refOrigin", tcInfo.getRefOrigine());
jsonObject.put("creator", tcInfo.getUsrCreated());
jsonObject.put("implementer", tcInfo.getImplementer());
jsonObject.put("lastModifier", tcInfo.getUsrModif());
jsonObject.put("project", tcInfo.getProject());
jsonObject.put("ticket", tcInfo.getTicket());
jsonObject.put("application", tcInfo.getApplication());
jsonObject.put("runQA", tcInfo.getActiveQA());
jsonObject.put("runUAT", tcInfo.getActiveUAT());
jsonObject.put("runPROD", tcInfo.getActivePROD());
jsonObject.put("priority", tcInfo.getPriority());
jsonObject.put("group", tcInfo.getGroup());
jsonObject.put("status", tcInfo.getStatus());
JSONArray countryList = new JSONArray();
for (TestCaseCountry tcc : tcInfo.getTestCaseCountry()) {
countryList.put(tcc.getCountry());
}
jsonObject.put("countriesList", countryList);
jsonObject.put("shortDescription", tcInfo.getDescription());
jsonObject.put("description", tcInfo.getBehaviorOrValueExpected());
jsonObject.put("howTo", tcInfo.getHowTo());
jsonObject.put("active", tcInfo.getTcActive());
jsonObject.put("fromSprint", tcInfo.getFromBuild());
jsonObject.put("fromRevision", tcInfo.getFromRev());
jsonObject.put("toSprint", tcInfo.getToBuild());
jsonObject.put("toRevision", tcInfo.getToRev());
jsonObject.put("lastExecutionStatus", tcInfo.getLastExecutionStatus());
jsonObject.put("bugID", tcInfo.getBugID());
jsonObject.put("targetSprint", tcInfo.getTargetBuild());
jsonObject.put("targetRevision", tcInfo.getTargetRev());
jsonObject.put("comment", tcInfo.getComment());
jsonObject.put("test", tcInfo.getTest());
jsonObject.put("testcase", tcInfo.getTestCase());
JSONArray propertyList = new JSONArray();
List<TestCaseCountryProperties> properties = testCaseDAO.findDistinctPropertiesOfTestCase(test, testcase);
for (TestCaseCountryProperties prop : properties) {
JSONObject property = new JSONObject();
property.put("property", prop.getProperty());
property.put("description", prop.getDescription());
property.put("type", prop.getType());
property.put("database", prop.getDatabase());
property.put("value1", prop.getValue1());
property.put("value2", prop.getValue2());
property.put("length", prop.getLength());
property.put("rowLimit", prop.getRowLimit());
property.put("nature", prop.getNature());
List<String> countriesSelected = testCaseDAO.findCountryByProperty(prop);
for (TestCaseCountry tcc : tcInfo.getTestCaseCountry()) {
if (!(countriesSelected == null) && (countriesSelected.contains(tcc.getCountry()))) {
property.put(tcc.getCountry(), true);
} else {
property.put(tcc.getCountry(), false);
}
}
propertyList.put(property);
}
jsonObject.put("properties", propertyList);
List<TestCaseStep> tcs = loadTestCaseService.loadTestCaseStep(tcInfo);
JSONArray list = new JSONArray();
for (TestCaseStep step : tcs) {
JSONObject stepObject = new JSONObject();
stepObject.put("number", step.getStep());
stepObject.put("name", step.getDescription());
int i = 1;
JSONArray actionList = new JSONArray();
JSONArray controlList = new JSONArray();
JSONArray sequenceList = new JSONArray();
for (TestCaseStepAction action : step.getTestCaseStepAction()) {
JSONObject actionObject = new JSONObject();
actionObject.put("sequence", i);
actionObject.put("action", action.getAction());
actionObject.put("object", action.getValue1());
actionObject.put("property", action.getValue2());
actionObject.put("fatal", "");
actionList.put(actionObject);
sequenceList.put(actionObject);
for (TestCaseStepActionControl control : action.getTestCaseStepActionControl()) {
JSONObject controlObject = new JSONObject();
controlObject.put("step", control.getStep());
controlObject.put("sequence", control.getSequence());
controlObject.put("order", control.getControlSequence());
controlObject.put("action", control.getControl());
controlObject.put("object", control.getValue2());
controlObject.put("property", control.getValue1());
controlObject.put("fatal", control.getFatal());
controlList.put(controlObject);
// test
controlObject = new JSONObject();
controlObject.put("sequence", i);
controlObject.put("action", control.getControl());
controlObject.put("object", control.getValue2());
controlObject.put("property", control.getValue1());
controlObject.put("fatal", control.getFatal());
sequenceList.put(controlObject);
}
i++;
}
stepObject.put("actions", actionList);
stepObject.put("controls", controlList);
stepObject.put("sequences", sequenceList);
list.put(stepObject);
}
// jsonObject.put("actions", actionList);
// jsonObject.put("controls", controlList);
jsonObject.put("list", list);
httpServletResponse.setContentType("application/json");
httpServletResponse.getWriter().print(jsonObject.toString());
} catch (JSONException exception) {
LOG.warn(exception.toString());
}
} catch (CerberusException ex) {
LOG.warn(ex);
}
}
Aggregations