How to use getEventHookEntryListFromParameter method of org.cerberus.servlet.crud.testcampaign.CreateCampaign class

Best Cerberus-source code snippet using org.cerberus.servlet.crud.testcampaign.CreateCampaign.getEventHookEntryListFromParameter

Source:CreateCampaign.java Github

copy

Full Screen

...152 if (request.getParameter("EventEntries") != null) {153 // Getting list of Schedule Entries from JSON Call154 JSONArray objApplicationArray = new JSONArray(request.getParameter("EventEntries"));155 List<EventHook> eventHookList = new ArrayList<>();156 eventHookList = getEventHookEntryListFromParameter(request, appContext, campaignName, objApplicationArray);157 if (!eventHookList.isEmpty()) {158 IEventHookService eventHookService = appContext.getBean(IEventHookService.class);159 schedAns = eventHookService.createList(eventHookList);160 if (!schedAns.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {161 finalAnswer = schedAns;162 }163 }164 }165 if (parameter != null) {166 JSONArray parameters = new JSONArray(parameter);167 ICampaignParameterService campaignParameterService = appContext.getBean(ICampaignParameterService.class);168 IFactoryCampaignParameter factoryCampaignParameter = appContext.getBean(IFactoryCampaignParameter.class);169 ans = campaignParameterService.deleteByCampaign(campaignName);170 int i = 0;171 while (i < parameters.length() && ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {172 JSONArray bat = parameters.getJSONArray(i);173 CampaignParameter co = factoryCampaignParameter.create(0, bat.getString(0), bat.getString(2), bat.getString(3));174 ans = campaignParameterService.create(co);175 i++;176 }177 if (ans != null && !ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {178 finalAnswer = ans;179 }180 }181 if (label != null) {182 JSONArray labels = new JSONArray(label);183 ICampaignLabelService campaignLabelService = appContext.getBean(ICampaignLabelService.class);184 IFactoryCampaignLabel factoryCampaignLabel = appContext.getBean(IFactoryCampaignLabel.class);185 ArrayList<CampaignLabel> arr = new ArrayList<>();186 for (int i = 0; i < labels.length(); i++) {187 JSONArray bat = labels.getJSONArray(i);188 CampaignLabel co = factoryCampaignLabel.create(0, bat.getString(0), Integer.valueOf(bat.getString(2)), request.getRemoteUser(), null, request.getRemoteUser(), null);189 arr.add(co);190 }191 ans = campaignLabelService.compareListAndUpdateInsertDeleteElements(campaignName, arr);192 if (ans != null && !ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {193 finalAnswer = ans;194 }195 }196 }197 }198 /**199 * Formating and returning the json result.200 */201 jsonResponse.put("messageType", finalAnswer.getResultMessage().getMessage().getCodeString());202 jsonResponse.put("message", finalAnswer.getResultMessage().getDescription());203 response.getWriter().print(jsonResponse);204 response.getWriter().flush();205 }206 private List<ScheduleEntry> getScheduleEntryListFromParameter(HttpServletRequest request, ApplicationContext appContext, String campaign, JSONArray json) throws JSONException {207 List<ScheduleEntry> scheList = new ArrayList<>();208 IScheduleEntryService scheService = appContext.getBean(IScheduleEntryService.class);209 IFactoryScheduleEntry scheFactory = appContext.getBean(IFactoryScheduleEntry.class);210 PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);211 String charset = request.getCharacterEncoding() == null ? "UTF-8" : request.getCharacterEncoding();212 for (int i = 0; i < json.length(); i++) {213 JSONObject tcsaJson = json.getJSONObject(i);214 // Parameter that are already controled by GUI (no need to decode) --> We SECURE them215 boolean delete = tcsaJson.getBoolean("toDelete");216 String cronExpression = policy.sanitize(tcsaJson.getString("cronDefinition"));217 String active = policy.sanitize(tcsaJson.getString("isActive"));218 String desc = policy.sanitize(tcsaJson.getString("description"));219 String strId = tcsaJson.getString("id");220 String type = "CAMPAIGN";221 String name = campaign;222 int id;223 if (strId.isEmpty()) {224 id = 0;225 } else {226 try {227 id = Integer.parseInt(strId);228 } catch (NumberFormatException e) {229 LOG.warn("Unable to parse pool size: " + strId + ". Applying default value");230 id = 0;231 }232 }233 Timestamp timestampfactice = new Timestamp(System.currentTimeMillis());234 if (!delete) {235 ScheduleEntry sch = scheFactory.create(id, type, name, cronExpression, timestampfactice, active, desc, request.getRemoteUser(), timestampfactice, request.getRemoteUser(), timestampfactice);236 scheList.add(sch);237 }238 }239 return scheList;240 }241 private List<EventHook> getEventHookEntryListFromParameter(HttpServletRequest request, ApplicationContext appContext, String campaign, JSONArray json) throws JSONException {242 List<EventHook> evtList = new ArrayList<>();243 IFactoryEventHook evtFactory = appContext.getBean(IFactoryEventHook.class);244 PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);245 String charset = request.getCharacterEncoding() == null ? "UTF-8" : request.getCharacterEncoding();246 for (int i = 0; i < json.length(); i++) {247 JSONObject objJson = json.getJSONObject(i);248 // Parameter that are already controled by GUI (no need to decode) --> We SECURE them249 boolean delete = objJson.getBoolean("toDelete");250 String objectKey1 = campaign;251 String hookConnector = policy.sanitize(objJson.getString("hookConnector"));252 String eventReference = policy.sanitize(objJson.getString("eventReference"));253 String hookRecipient = objJson.getString("hookRecipient");254 String description = policy.sanitize(objJson.getString("description"));255 boolean isActive = objJson.getBoolean("isActive");...

Full Screen

Full Screen

getEventHookEntryListFromParameter

Using AI Code Generation

copy

Full Screen

1This file has been truncated. [show original](github.com/cerberustesting/ce...) 2[github.com](github.com/cerberustesting/ce...) 3#### [cerberustesting/cerberus-source/blob/master/source/src/main/java/org/cerberus/servlet/crud/testcampaign/CreateCampaign.java#L130](github.com/cerberustesting/ce...)4 120. }5 122. if (useSameEventHook) {6 123. eventHookEntryList = getEventHookEntryListFromParameter(request.getParameter("eventHook"));7 124. }8 125. }9 126. }10 129. if (useSameEventHook) {11 130. eventHookEntryList = getEventHookEntryListFromParameter(request.getParameter("eventHook"));12 131. }13 134. if (useSameEventHook) {14 135. eventHookEntryList = getEventHookEntryListFromParameter(request.getParameter("eventHook"));15 136. }

Full Screen

Full Screen

getEventHookEntryListFromParameter

Using AI Code Generation

copy

Full Screen

1List<EventHookEntry> eventHookEntryList = CreateCampaign.getEventHookEntryListFromParameter("CREATECAMPAIGN");2for (EventHookEntry eventHookEntry : eventHookEntryList) {3 List<EventHook> eventHookList = EventHookService.readByEvent(eventHookEntry.getEvent());4 for (EventHook eventHook : eventHookList) {5 List<EventHookProperty> eventHookPropertyList = EventHookPropertyService.readByEventHook(eventHook.getId());6 String className = eventHook.getClassName();7 String methodName = eventHook.getMethodName();8 String parameters = eventHookEntry.getParameter();9 List<String> parameterList = new ArrayList<>();10 parameterList.add(parameters);11 for (EventHookProperty eventHookProperty : eventHookPropertyList) {12 parameterList.add(eventHookProperty.getValue());13 }14 MessageEvent messageEvent = ExecuteEventHook.executeHook(className, methodName, parameterList);

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