How to use AnswerItem class of org.cerberus.util.answer package

Best Cerberus-source code snippet using org.cerberus.util.answer.AnswerItem

Source:ReadTestCaseV2.java Github

copy

Full Screen

...59import org.cerberus.engine.entity.MessageEvent;60import org.cerberus.enums.MessageEventEnum;61import org.cerberus.exception.CerberusException;62import org.cerberus.util.ParameterParserUtil;63import org.cerberus.util.answer.AnswerItem;64import org.cerberus.util.answer.AnswerList;65import org.cerberus.util.answer.AnswerUtil;66import org.cerberus.util.servlet.ServletUtil;67import org.json.JSONArray;68import org.json.JSONException;69import org.json.JSONObject;70import org.owasp.html.PolicyFactory;71import org.owasp.html.Sanitizers;72import org.springframework.beans.factory.annotation.Autowired;73/**74 *75 * @author mlombard76 */77@WebServlet(name = "ReadTestCaseV2", urlPatterns = {"/ReadTestCaseV2"})78public class ReadTestCaseV2 extends AbstractCrudTestCase {79 @Autowired80 private ITestCaseService testCaseService;81 @Autowired82 private ITestCaseCountryService testCaseCountryService;83 @Autowired84 private ITestCaseDepService testCaseDepService;85 @Autowired86 private ITestCaseStepService testCaseStepService;87 @Autowired88 private ITestCaseStepActionService testCaseStepActionService;89 @Autowired90 private ITestCaseStepActionControlService testCaseStepActionControlService;91 @Autowired92 private ITestCaseLabelService testCaseLabelService;93 @Autowired94 private ICampaignParameterService campaignParameterService;95 @Autowired96 private ITestCaseCountryPropertiesService testCaseCountryPropertiesService;97 @Autowired98 private ILabelService labelService;99 @Autowired100 private IInvariantService invariantService;101 @Autowired102 private IApplicationService applicationService;103 private static final Logger LOG = LogManager.getLogger(ReadTestCase.class);104 private AnswerList<TestCaseCountry> answerTestCaseCountries;105 private List<TestCaseDep> testCaseDependencies;106 private AnswerList<TestCaseLabel> answerTestCaseLabels;107 private List<Invariant> countryInvariants;108 /**109 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>110 * methods.111 *112 * @param request servlet request113 * @param response servlet response114 * @throws ServletException if a servlet-specific error occurs115 * @throws IOException if an I/O error occurs116 */117 protected void processRequest(HttpServletRequest request, HttpServletResponse response)118 throws ServletException, IOException {119 int sEcho = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("sEcho"), "0"));120 PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);121 response.setContentType("application/json");122 response.setCharacterEncoding("utf8");123 // Calling Servlet Transversal Util.124 ServletUtil.servletStart(request);125 // Default message to unexpected error.126 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);127 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));128 //Parsing and securing all required parameters.129 String test = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("test"), "");130 List<String> system = ParameterParserUtil.parseListParamAndDecodeAndDeleteEmptyValue(request.getParameterValues("system"), Arrays.asList("DEFAULT"), "UTF-8");131 String testCase = ParameterParserUtil.parseStringParam(request.getParameter("testCase"), null);132 String campaign = ParameterParserUtil.parseStringParam(request.getParameter("campaign"), "");133 boolean getMaxTC = ParameterParserUtil.parseBooleanParam(request.getParameter("getMaxTC"), false);134 boolean filter = ParameterParserUtil.parseBooleanParam(request.getParameter("filter"), false);135 boolean withSteps = ParameterParserUtil.parseBooleanParam(request.getParameter("withSteps"), false);136 String columnName = ParameterParserUtil.parseStringParam(request.getParameter("columnName"), "");137 // Init Answer with potencial error from Parsing parameter.138 AnswerItem answer = new AnswerItem<>(msg);139 JSONObject jsonResponse = new JSONObject();140 try {141 if (!Strings.isNullOrEmpty(test) && testCase != null) {142 answer = findTestCaseByTestTestCase(test, testCase, request, withSteps);143 } else if (!Strings.isNullOrEmpty(test) && getMaxTC) {144 String max = testCaseService.getMaxNumberTestCase(test) == null ? "0" : testCaseService.getMaxNumberTestCase(test);145 jsonResponse.put("maxTestCase", Integer.valueOf(max));146 answer.setResultMessage(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK));147 } else if (filter) {148 answer = findTestCaseByVarious(request);149 } else if (!Strings.isNullOrEmpty(campaign)) {150 answer = findTestCaseByCampaign(campaign, withSteps);151 } else if (!Strings.isNullOrEmpty(columnName)) {152 //If columnName is present, then return the distinct value of this column.153 answer = findDistinctValuesOfColumn(system, test, request, columnName);154 } else {155 // Page TestCaseList156 answer = findTestCaseByTest(system, test, request, withSteps);157 }158 if (!getMaxTC) {159 jsonResponse = answer.getItem() == null ? new JSONObject() : (JSONObject) answer.getItem();160 }161 jsonResponse.put("messageType", answer.getResultMessage().getMessage().getCodeString());162 jsonResponse.put("message", answer.getResultMessage().getDescription());163 jsonResponse.put("sEcho", sEcho);164 response.getWriter().print(jsonResponse.toString());165 } catch (JSONException e) {166 LOG.warn(e, e);167 //returns a default error message with the json format that is able to be parsed by the client-side168 response.getWriter().print(AnswerUtil.createGenericErrorAnswer());169 } catch (CerberusException | IOException | NumberFormatException ex) {170 LOG.error(ex, ex);171 // TODO return to the gui172 }173 // TODO return to the gui174 }175 private AnswerItem<JSONObject> findTestCaseByTest(List<String> system, String test, HttpServletRequest request, boolean withSteps) throws JSONException, CerberusException {176 AnswerItem<JSONObject> answerItem = new AnswerItem<>();177 JSONObject jsonResponse = new JSONObject();178 int startPosition = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayStart"), "0"));179 int length = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayLength"), "0"));180 String searchParameter = ParameterParserUtil.parseStringParam(request.getParameter("sSearch"), "");181 String sColumns = ParameterParserUtil.parseStringParam(request.getParameter("sColumns"), "tec.test,tec.testcase,tec.application,project,ticket,description,detailedDescription,readonly,bugtrackernewurl,deploytype,mavengroupid");182 String columnToSort[] = sColumns.split(",");183 List<String> individualLike = new ArrayList<>(Arrays.asList(ParameterParserUtil.parseStringParam(request.getParameter("sLike"), "").split(",")));184 StringBuilder sortInformation = getSortingInformation(columnToSort, request);185 Map<String, List<String>> individualSearch = getIndivualSearch(request, columnToSort, individualLike);186 AnswerList<TestCase> testCases = testCaseService.readByTestByCriteria(system, test, startPosition, length, sortInformation.toString(), searchParameter, individualSearch);187 this.answerTestCaseCountries = testCaseCountryService.readByTestTestCase(system, test, null, testCases.getDataList());188 this.testCaseDependencies = testCaseDepService.readByTestAndTestCase(testCases.getDataList());189 this.answerTestCaseLabels = testCaseLabelService.readByTestTestCase(test, null, testCases.getDataList());190 this.countryInvariants = invariantService.readByIdName("COUNTRY");191 //jsonResponse.put("contentTable", getTestCases(testCases.getDataList(), withSteps));192 jsonResponse.put("hasPermissionsCreate", testCaseService.hasPermissionsCreate(null, request));193 jsonResponse.put("iTotalRecords", testCases.getTotalRows());194 jsonResponse.put("iTotalDisplayRecords", testCases.getTotalRows());195 answerItem.setItem(jsonResponse);196 answerItem.setResultMessage(testCases.getResultMessage());197 return answerItem;198 }199 private AnswerItem<JSONObject> findTestCaseByTestTestCase(String test, String testCase, HttpServletRequest request, boolean withSteps) throws JSONException, CerberusException {200 AnswerItem<JSONObject> answerItem = new AnswerItem<>();201 JSONObject jsonResponse = new JSONObject();202 AnswerItem<TestCase> answerTestCase;203 answerTestCase = testCaseService.findTestCaseByKeyWithDependencies(test, testCase, withSteps);204 if (answerTestCase.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && answerTestCase.getItem() != null) {205 TestCase tc = answerTestCase.getItem();206 if (withSteps) {207 jsonResponse.put("hasPermissionsStepLibrary", (request.isUserInRole("TestStepLibrary")));208 }209 jsonResponse.put("hasPermissionsUpdate", testCaseService.hasPermissionsUpdate(tc, request));210 jsonResponse.put("hasPermissionsDelete", testCaseService.hasPermissionsDelete(tc, request));211 jsonResponse.put("contentTable", new JSONArray().put(tc.toJson()));212 } else {213 answerItem.setResultMessage(new MessageEvent(MessageEventEnum.DATA_OPERATION_NOT_FOUND_OR_NOT_AUTHORIZE));214 return answerItem;215 }216 answerItem.setItem(jsonResponse);217 answerItem.setResultMessage(answerTestCase.getResultMessage());218 return answerItem;219 }220 private AnswerItem findTestCaseByCampaign(String campaign, boolean withSteps) throws JSONException, CerberusException {221 AnswerItem<JSONObject> answerItem = new AnswerItem<>();222 JSONObject jsonResponse = new JSONObject();223 final AnswerItem<Map<String, List<String>>> parsedCampaignParameters = campaignParameterService.parseParametersByCampaign(campaign);224 List<String> countries = parsedCampaignParameters.getItem().get(CampaignParameter.COUNTRY_PARAMETER);225 AnswerList<TestCase> testCases = null;226 if (countries != null && !countries.isEmpty()) {227 testCases = testCaseService.findTestCaseByCampaignNameAndCountries(campaign, countries.toArray(new String[countries.size()]));228 } else {229 testCases = testCaseService.findTestCaseByCampaignNameAndCountries(campaign, null);230 }231 if (testCases.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {//the service was able to perform the query, then we should get all values232 //jsonResponse.put("contentTable", getTestCases(testCases.getDataList(), withSteps));233 }234 answerItem.setItem(jsonResponse);235 answerItem.setResultMessage(testCases.getResultMessage());236 return answerItem;237 }238 private AnswerItem<JSONObject> findTestCaseByVarious(HttpServletRequest request) throws JSONException {239 AnswerItem<JSONObject> item = new AnswerItem<>();240 JSONObject object = new JSONObject();241 JSONArray dataArray = new JSONArray();242 String[] test = request.getParameterValues("test");243 String[] idProject = request.getParameterValues("project");244 String[] app = request.getParameterValues("application");245 String[] creator = request.getParameterValues("creator");246 String[] implementer = request.getParameterValues("implementer");247 String[] system = request.getParameterValues("system");248 String[] campaign = request.getParameterValues("campaign");249 String[] priority = request.getParameterValues("priority");250 String[] type = request.getParameterValues("type");251 String[] status = request.getParameterValues("status");252 String[] labelid = request.getParameterValues("labelid");253 List<Integer> labels = new ArrayList<>();254 if (labelid != null) {255 for (int i = 0; i < labelid.length; i++) {256 String string = labelid[i];257 labels.add(Integer.valueOf(string));258 }259 labels = labelService.enrichWithChild(labels);260 }261 int length = ParameterParserUtil.parseIntegerParam(request.getParameter("length"), -1);262 AnswerList<TestCase> answer = testCaseService.readByVarious(test, app, creator, implementer, system, campaign, labels, priority, type, status, length);263 if (answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {264 for (TestCase tc : (List<TestCase>) answer.getDataList()) {265 JSONObject value = tc.toJson();266 dataArray.put(value);267 }268 }269 object.put("contentTable", dataArray);270 item.setItem(object);271 item.setResultMessage(answer.getResultMessage());272 return item;273 }274 private AnswerItem<JSONObject> findDistinctValuesOfColumn(List<String> system, String test, HttpServletRequest request, String columnName) throws JSONException {275 AnswerItem<JSONObject> answerItem = new AnswerItem<>();276 JSONObject jsonResponse = new JSONObject();277 String searchParameter = ParameterParserUtil.parseStringParam(request.getParameter("sSearch"), "");278 String sColumns = ParameterParserUtil.parseStringParam(request.getParameter("sColumns"), "tec.test,tec.testcase,application,project,ticket,description,detailedDescription,readonly,bugtrackernewurl,deploytype,mavengroupid");279 String columnToSort[] = sColumns.split(",");280 List<String> individualLike = new ArrayList<>(Arrays.asList(ParameterParserUtil.parseStringParam(request.getParameter("sLike"), "").split(",")));281 Map<String, List<String>> individualSearch = getIndivualSearch(request, columnToSort, individualLike);282 AnswerList testCases = testCaseService.readDistinctValuesByCriteria(system, test, searchParameter, individualSearch, columnName);283 jsonResponse.put("distinctValues", testCases.getDataList());284 answerItem.setItem(jsonResponse);285 answerItem.setResultMessage(testCases.getResultMessage());286 return answerItem;287 }288 private StringBuilder getSortingInformation(String columnToSort[], HttpServletRequest request) {289 int numberOfColumnToSort = Integer.parseInt(ParameterParserUtil.parseStringParam(request.getParameter("iSortingCols"), "1"));...

Full Screen

Full Screen

Source:ICampaignService.java Github

copy

Full Screen

...23import org.cerberus.crud.entity.Campaign;24import org.cerberus.crud.entity.CampaignParameter;25import org.cerberus.exception.CerberusException;26import org.cerberus.util.answer.Answer;27import org.cerberus.util.answer.AnswerItem;28import org.cerberus.util.answer.AnswerList;29/**30 * @author memiks31 */32public interface ICampaignService {33 List<CampaignParameter> findCampaignParametersByCampaignName(String campaign) throws CerberusException;34 /**35 * Get the {@link Campaign} List of the given {@link System} with the given36 * Criteria37 *38 * @param startPosition the start index to look for39 * @param length the number of {@link Campaign} to get40 * @param columnName the Column name to sort41 * @param sort42 * @param searchParameter the string to search in the {@link Campaign}43 * @param individualSearch the string to search for each column44 * @return45 */46 AnswerList<Campaign> readByCriteria(int startPosition, int length, String columnName, String sort, String searchParameter, Map<String, List<String>> individualSearch);47 /**48 * Get the {@link Campaign} with the given {@link System} and the given key49 *50 * @param key the key of the {@link Campaign}51 * @return52 */53 AnswerItem<Campaign> readByKey(String key);54 /**55 * Get the {@link Campaign} with the given {@link System} and the given key56 *57 * @param key the key of the {@link Campaign}58 * @return59 */60 AnswerItem<Campaign> readByKeyTech(int key);61 /**62 * @param searchParameter63 * @param individualSearch64 * @param columnName65 * @return66 */67 public AnswerList<String> readDistinctValuesByCriteria(String searchParameter, Map<String, List<String>> individualSearch, String columnName);68 /**69 * @param object the {@link Campaign} to Create70 * @return {@link AnswerItem}71 */72 Answer create(Campaign object);73 /**74 * @param object the {@link Campaign} to Update75 * @return {@link AnswerItem}76 */77 Answer update(Campaign object);78 /**79 * @param object the {@link Campaign} to Delete80 * @return {@link AnswerItem}81 */82 Answer delete(Campaign object);83 /**84 *85 * @param answerItem86 * @return87 * @throws CerberusException88 */89 Campaign convert(AnswerItem<Campaign> answerItem) throws CerberusException;90 /**91 *92 * @param answerList93 * @return94 * @throws CerberusException95 */96 List<Campaign> convert(AnswerList<Campaign> answerList) throws CerberusException;97 /**98 *99 * @param answer100 * @throws CerberusException101 */102 void convert(Answer answer) throws CerberusException;103}...

Full Screen

Full Screen

AnswerItem

Using AI Code Generation

copy

Full Screen

1package org.cerberus.util.answer;2import org.cerberus.util.answer.AnswerItem;3public class AnswerItemTest {4 public static void main(String[] args) {5 AnswerItem answerItem = new AnswerItem();6 answerItem.setItem("item1");7 answerItem.setValue("value1");8 System.out.println(answerItem.getItem());9 System.out.println(answerItem.getValue());10 }11}12package org.cerberus.util.answer;13import org.cerberus.util.answer.AnswerList;14public class AnswerListTest {15 public static void main(String[] args) {16 AnswerList answerList = new AnswerList();17 answerList.setData("data1");18 answerList.setResultMessage("resultMessage1");19 answerList.setTotalRows(1);20 System.out.println(answerList.getData());21 System.out.println(answerList.getResultMessage());22 System.out.println(answerList.getTotalRows());23 }24}25package org.cerberus.util.answer;26import org.cerberus.util.answer.AnswerObject;27public class AnswerObjectTest {28 public static void main(String[] args) {29 AnswerObject answerObject = new AnswerObject();30 answerObject.setData("data1");31 answerObject.setResultMessage("resultMessage1");32 System.out.println(answerObject.getData());33 System.out.println(answerObject.getResultMessage());34 }35}36package org.cerberus.util.answer;37import org.cerberus.util.answer.AnswerUtil;38public class AnswerUtilTest {39 public static void main(String[] args) {40 System.out.println(AnswerUtil.buildAnswerFromException(new Exception("Exception1")));41 System.out.println(AnswerUtil.buildAnswerFromException(new Exception("Exception1"), "message1"));42 }43}

Full Screen

Full Screen

AnswerItem

Using AI Code Generation

copy

Full Screen

1package org.cerberus.util.answer;2import java.util.ArrayList;3import java.util.List;4public class AnswerItem<T> {5 private T item;6 private List<AnswerMessage> message = new ArrayList<AnswerMessage>();7 private int code;8 public AnswerItem() {9 }10 public AnswerItem(T item) {11 this.item = item;12 }13 public T getItem() {14 return item;15 }16 public void setItem(T item) {17 this.item = item;18 }19 public List<AnswerMessage> getMessage() {20 return message;21 }22 public void setMessage(List<AnswerMessage> message) {23 this.message = message;24 }25 public int getCode() {26 return code;27 }28 public void setCode(int code) {29 this.code = code;30 }31}32package org.cerberus.util.answer;33import java.util.ArrayList;34import java.util.List;35public class AnswerList<T> {36 private List<T> data;37 private List<AnswerMessage> message = new ArrayList<AnswerMessage>();38 private int totalRows;39 public AnswerList() {40 }41 public List<T> getData() {42 return data;43 }44 public void setData(List<T> data) {45 this.data = data;46 }47 public List<AnswerMessage> getMessage() {48 return message;49 }50 public void setMessage(List<AnswerMessage> message) {51 this.message = message;52 }53 public int getTotalRows() {54 return totalRows;55 }56 public void setTotalRows(int totalRows) {57 this.totalRows = totalRows;58 }59}60package org.cerberus.util.answer;61public class AnswerMessage {62 private String message;63 private String code;64 public AnswerMessage() {65 }66 public AnswerMessage(String message, String code) {67 this.message = message;68 this.code = code;69 }70 public String getMessage() {71 return message;72 }73 public void setMessage(String message) {74 this.message = message;75 }76 public String getCode() {77 return code;78 }79 public void setCode(String code) {80 this.code = code;81 }

Full Screen

Full Screen

AnswerItem

Using AI Code Generation

copy

Full Screen

1package org.cerberus.util.answer;2import org.cerberus.util.answer.AnswerItem;3public class AnswerItemTest {4 public static void main(String[] args) {5 AnswerItem item = new AnswerItem("hello", "world");6 System.out.println(item.getItem());7 System.out.println(item.getValue());8 }9}10package org.cerberus.util.answer;11public class AnswerItem {12 private String item;13 private String value;14 public AnswerItem(String item, String value) {15 this.item = item;16 this.value = value;17 }18 public String getItem() {19 return item;20 }21 public void setItem(String item) {22 this.item = item;23 }24 public String getValue() {25 return value;26 }27 public void setValue(String value) {28 this.value = value;29 }30}

Full Screen

Full Screen

AnswerItem

Using AI Code Generation

copy

Full Screen

1import org.cerberus.util.answer.*;2import org.cerberus.util.*;3import java.util.*;4import java.io.*;5public class 3{6 public static void main(String[] args) {7 AnswerItem answerItem = new AnswerItem();8 answerItem.setItem("item");9 System.out.println(answerItem.getItem());10 answerItem.setObject("object");11 System.out.println(answerItem.getObject());12 answerItem.setMessage("message");13 System.out.println(answerItem.getMessage());14 answerItem.setResultMessage("resultMessage");15 System.out.println(answerItem.getResultMessage());16 answerItem.setTotalRows(1);17 System.out.println(answerItem.getTotalRows());18 answerItem.setTotalRows(2);19 System.out.println(answerItem.getTotalRows());20 answerItem.setDataTable(new DataTable());21 System.out.println(answerItem.getDataTable());22 answerItem.setTotalRows(3);23 System.out.println(answerItem.getTotalRows());24 answerItem.setDataTable(new DataTable());25 System.out.println(answerItem.getDataTable());26 answerItem.setDataList(new ArrayList());27 System.out.println(answerItem.getDataList());28 answerItem.setTotalRows(4);29 System.out.println(answerItem.getTotalRows());30 answerItem.setDataList(new ArrayList());31 System.out.println(answerItem.getDataList());32 answerItem.setAnswerList(new ArrayList());33 System.out.println(answerItem.getAnswerList());34 answerItem.setTotalRows(5);35 System.out.println(answerItem.getTotalRows());36 answerItem.setAnswerList(new ArrayList());37 System.out.println(answerItem.getAnswerList());38 answerItem.setTotalRows(6);39 System.out.println(answerItem.getTotalRows());40 answerItem.setTotalRows(7);41 System.out.println(answerItem.getTotalRows());42 answerItem.setTotalRows(8);43 System.out.println(answerItem.getTotalRows());44 answerItem.setTotalRows(9);45 System.out.println(answerItem.getTotalRows());46 answerItem.setTotalRows(10);47 System.out.println(answerItem.getTotalRows());48 answerItem.setTotalRows(11);49 System.out.println(answerItem.getTotalRows());50 answerItem.setTotalRows(12);51 System.out.println(answerItem.getTotalRows());52 answerItem.setTotalRows(13);53 System.out.println(answerItem.getTotalRows());54 answerItem.setTotalRows(14);55 System.out.println(answerItem.getTotalRows());56 answerItem.setTotalRows(15);57 System.out.println(answerItem.getTotalRows());58 answerItem.setTotalRows(16

Full Screen

Full Screen

AnswerItem

Using AI Code Generation

copy

Full Screen

1import org.cerberus.util.answer.*;2public class 3{3public static void main(String[] args){4AnswerItem answerItem = new AnswerItem();5answerItem.setItem(1);6answerItem.setMessage("This is the first message");7System.out.println(answerItem.getItem());8System.out.println(answerItem.getMessage());9}10}11import org.cerberus.util.answer.*;12public class 4{13public static void main(String[] args){14AnswerList answerList = new AnswerList();15AnswerItem answerItem = new AnswerItem();16answerItem.setItem(1);17answerItem.setMessage("This is the first message");18answerList.setDataList(answerItem);19System.out.println(answerList.getDataList().get(0).getItem());20System.out.println(answerList.getDataList().get(0).getMessage());21}22}23import org.cerberus.util.answer.*;24public class 5{25public static void main(String[] args){26AnswerItem answerItem = new AnswerItem();27answerItem.setItem(1);28answerItem.setMessage("This is the first message");29AnswerUtil answerUtil = new AnswerUtil();30answerUtil.setData(answerItem);31System.out.println(answerUtil.getData().getItem());32System.out.println(answerUtil.getData().getMessage());33}34}

Full Screen

Full Screen

AnswerItem

Using AI Code Generation

copy

Full Screen

1package org.cerberus.util.answer;2import java.util.ArrayList;3import java.util.List;4import javax.servlet.http.HttpSession;5import org.apache.struts2.ServletActionContext;6import com.opensymphony.xwork2.ActionSupport;7public class AnswerItemAction extends ActionSupport {8 private List<AnswerItem> answerItems;9 private String message;10 public AnswerItemAction(){11 answerItems = new ArrayList<AnswerItem>();12 }13 public List<AnswerItem> getAnswerItems() {14 return answerItems;15 }16 public void setAnswerItems(List<AnswerItem> answerItems) {17 this.answerItems = answerItems;18 }19 public String getMessage() {20 return message;21 }22 public void setMessage(String message) {23 this.message = message;24 }25 public String createList(){26 AnswerItem item1 = new AnswerItem();27 item1.setQuestion("What is the capital of India?");28 item1.setAnswer("Delhi");29 answerItems.add(item1);30 AnswerItem item2 = new AnswerItem();31 item2.setQuestion("What is the capital of China?");32 item2.setAnswer("Beijing");33 answerItems.add(item2);34 AnswerItem item3 = new AnswerItem();35 item3.setQuestion("What is the capital of France?");36 item3.setAnswer("Paris");37 answerItems.add(item3);38 message = "List of AnswerItem objects created successfully";39 return SUCCESS;40 }41 public String storeInSession(){42 HttpSession session = ServletActionContext.getRequest().getSession();43 session.setAttribute("answerItems", answerItems);44 message = "List of AnswerItem objects stored in session successfully";45 return SUCCESS;46 }47 public String retrieveFromSession(){48 HttpSession session = ServletActionContext.getRequest().getSession();49 answerItems = (List<AnswerItem>) session.getAttribute("answerItems");

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.

Most used methods in AnswerItem

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful