title: how do i write test cases for jsonparser, jsonmapping and io exception using mockito
body: <p>i want to mock this service in controller, so that i can test this. how do i mock coreservice.getRelatedInfo to throw the given exceptions to test them.
  i am trying to throw them but, i'm getting error. when i am testing for runtime exception it is working. </p>
  
  <pre><code>@PostMapping("/realtedcustomerinfo")
  public ResponseEntity&lt;List&lt;CustomerInfoDTO&gt;&gt; 
  getRelatedCustomerInfo(@RequestBody RelatedCustomerInfo 
  relatedCustomerInfo) {
      log.info("Start of getRelatedCustomerInfo() input {}", 
   relatedCustomerInfo);
      List&lt;CustomerInfoDTO&gt; customerInfoDTOs = null;
  
      try {
          customerInfoDTOs = 
   coreService.getRelatedCustomerInfo(relatedCustomerInfo);
      } catch (JsonParseException e) {
          log.error("Exception details", e);
      } catch (JsonMappingException e) {
          log.error("Exception details", e);
      } catch (IOException e) {
          log.error("Exception details", e);
      }
  
      if (null == customerInfoDTOs) {
          log.info("End of getRelatedCustomerInfo() return {}", customerInfoDTOs);
          return new ResponseEntity&lt;List&lt;CustomerInfoDTO&gt;&gt;(new ArrayList&lt;CustomerInfoDTO&gt;(), HttpStatus.OK);
      }
  
      log.info("End of getRelatedCustomerInfo() return {}", customerInfoDTOs);
      return new ResponseEntity&lt;List&lt;CustomerInfoDTO&gt;&gt;(customerInfoDTOs, HttpStatus.OK);
  }
  </code></pre>