@Test public void testExecuteJobErrCndtn() { EventJobDTO eventDTO = createEventJobDTO(); eventDTO.getEventMonkeyList().get(0).setMonkeyScriptType(""); EventJobDTO returnDTO = (EventJobDTO) eventJobController.executeJob(eventDTO).getBody(); System.out.println("return "); assertEquals("Monkey Script Type is blank for Monkey Strategy : "+ eventDTO.getEventMonkeyList().get(0).getMonkeyStrategy() +" . So Scenario Execution is terminated.", returnDTO.getEventMonkeyList().get(0).getExecStatus()); assertEquals("000", returnDTO.getEventMonkeyList().get(0).getReturnCode()); eventDTO = createEventJobDTO(); eventDTO.getEventMonkeyList().get(0).setMonkeyScriptContent(""); returnDTO = (EventJobDTO) eventJobController.executeJob(eventDTO).getBody(); assertEquals("Monkey Script Content is empty for Monkey Strategy : "+ eventDTO.getEventMonkeyList().get(0).getMonkeyStrategy() +" . So Scenario Execution is terminated.", returnDTO.getEventMonkeyList().get(0).getExecStatus()); assertEquals("000", returnDTO.getEventMonkeyList().get(0).getReturnCode()); }
@ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO) { StringBuilder errorMsg = new StringBuilder(); if (validateEventJobDTO(eventJobDTO, errorMsg)) { logger.error(errorMsg.toString()); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { eventMonkeyDTO.setReturnCode("000"); eventMonkeyDTO.setExecStatus(errorMsg.toString()); }); eventData.put(eventJobDTO.getEventId(), errorMsg + completeString); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } eventJobDTO.setExecStatus(startString); eventData.put(eventJobDTO.getEventId(), startString); eventJobDTO.getEventMonkeyList().forEach( eventMonkeyDTO -> eventMonkeyDTO.setExecStatus(startString + eventMonkeyDTO.getMonkeyStrategy())); eventJobService.executeJob(eventJobDTO, eventData); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { if (eventMonkeyDTO.getExecStatus() != null) { int maxLength = (eventMonkeyDTO.getExecStatus().length() < 32765) ? eventMonkeyDTO.getExecStatus().length() : 32765; eventMonkeyDTO.setExecStatus(eventMonkeyDTO.getExecStatus().substring(0, maxLength)); } }); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); }
EventJobExecutionController { @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO) { StringBuilder errorMsg = new StringBuilder(); if (validateEventJobDTO(eventJobDTO, errorMsg)) { logger.error(errorMsg.toString()); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { eventMonkeyDTO.setReturnCode("000"); eventMonkeyDTO.setExecStatus(errorMsg.toString()); }); eventData.put(eventJobDTO.getEventId(), errorMsg + completeString); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } eventJobDTO.setExecStatus(startString); eventData.put(eventJobDTO.getEventId(), startString); eventJobDTO.getEventMonkeyList().forEach( eventMonkeyDTO -> eventMonkeyDTO.setExecStatus(startString + eventMonkeyDTO.getMonkeyStrategy())); eventJobService.executeJob(eventJobDTO, eventData); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { if (eventMonkeyDTO.getExecStatus() != null) { int maxLength = (eventMonkeyDTO.getExecStatus().length() < 32765) ? eventMonkeyDTO.getExecStatus().length() : 32765; eventMonkeyDTO.setExecStatus(eventMonkeyDTO.getExecStatus().substring(0, maxLength)); } }); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } }
EventJobExecutionController { @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO) { StringBuilder errorMsg = new StringBuilder(); if (validateEventJobDTO(eventJobDTO, errorMsg)) { logger.error(errorMsg.toString()); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { eventMonkeyDTO.setReturnCode("000"); eventMonkeyDTO.setExecStatus(errorMsg.toString()); }); eventData.put(eventJobDTO.getEventId(), errorMsg + completeString); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } eventJobDTO.setExecStatus(startString); eventData.put(eventJobDTO.getEventId(), startString); eventJobDTO.getEventMonkeyList().forEach( eventMonkeyDTO -> eventMonkeyDTO.setExecStatus(startString + eventMonkeyDTO.getMonkeyStrategy())); eventJobService.executeJob(eventJobDTO, eventData); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { if (eventMonkeyDTO.getExecStatus() != null) { int maxLength = (eventMonkeyDTO.getExecStatus().length() < 32765) ? eventMonkeyDTO.getExecStatus().length() : 32765; eventMonkeyDTO.setExecStatus(eventMonkeyDTO.getExecStatus().substring(0, maxLength)); } }); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); }  }
EventJobExecutionController { @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO) { StringBuilder errorMsg = new StringBuilder(); if (validateEventJobDTO(eventJobDTO, errorMsg)) { logger.error(errorMsg.toString()); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { eventMonkeyDTO.setReturnCode("000"); eventMonkeyDTO.setExecStatus(errorMsg.toString()); }); eventData.put(eventJobDTO.getEventId(), errorMsg + completeString); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } eventJobDTO.setExecStatus(startString); eventData.put(eventJobDTO.getEventId(), startString); eventJobDTO.getEventMonkeyList().forEach( eventMonkeyDTO -> eventMonkeyDTO.setExecStatus(startString + eventMonkeyDTO.getMonkeyStrategy())); eventJobService.executeJob(eventJobDTO, eventData); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { if (eventMonkeyDTO.getExecStatus() != null) { int maxLength = (eventMonkeyDTO.getExecStatus().length() < 32765) ? eventMonkeyDTO.getExecStatus().length() : 32765; eventMonkeyDTO.setExecStatus(eventMonkeyDTO.getExecStatus().substring(0, maxLength)); } }); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); }  @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO); @ApiOperation(value = "This API streams real time Event Job status for given Event ID", response = ResponseBodyEmitter.class) @RequestMapping(value = "/eventStatus/{eventId}", method = RequestMethod.GET) ResponseBodyEmitter getEventStream(@PathVariable("eventId") String eventId); }
EventJobExecutionController { @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO) { StringBuilder errorMsg = new StringBuilder(); if (validateEventJobDTO(eventJobDTO, errorMsg)) { logger.error(errorMsg.toString()); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { eventMonkeyDTO.setReturnCode("000"); eventMonkeyDTO.setExecStatus(errorMsg.toString()); }); eventData.put(eventJobDTO.getEventId(), errorMsg + completeString); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } eventJobDTO.setExecStatus(startString); eventData.put(eventJobDTO.getEventId(), startString); eventJobDTO.getEventMonkeyList().forEach( eventMonkeyDTO -> eventMonkeyDTO.setExecStatus(startString + eventMonkeyDTO.getMonkeyStrategy())); eventJobService.executeJob(eventJobDTO, eventData); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { if (eventMonkeyDTO.getExecStatus() != null) { int maxLength = (eventMonkeyDTO.getExecStatus().length() < 32765) ? eventMonkeyDTO.getExecStatus().length() : 32765; eventMonkeyDTO.setExecStatus(eventMonkeyDTO.getExecStatus().substring(0, maxLength)); } }); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); }  @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO); @ApiOperation(value = "This API streams real time Event Job status for given Event ID", response = ResponseBodyEmitter.class) @RequestMapping(value = "/eventStatus/{eventId}", method = RequestMethod.GET) ResponseBodyEmitter getEventStream(@PathVariable("eventId") String eventId); static final Logger logger; }