### Question:
FAQSController { @RequestMapping(path = "/v1/faqs", method = RequestMethod.GET) public ResponseEntity<Object> getFAQSByWidget( @RequestParam("widgetId") String widgetId, @RequestParam(name = "domainId", required = false) String domainId) { if (Strings.isNullOrEmpty(widgetId)) { return ResponseUtils.buildFailureResponse(new Exception( "WidgetId is Mandatory")); } ResponseDTO response=null; try { response = new ResponseDTO(faqService.getFAQSByWidget(widgetId, domainId)); } catch (ServiceException e) { LOGGER.error(e.getMessage()); return complianceService.formatException(e); } return ResponseUtils.buildSucessResponse(response); }  @RequestMapping(path = "/v1/faqs", method = RequestMethod.GET) ResponseEntity<Object> getFAQSByWidget(
            @RequestParam("widgetId") String widgetId,
            @RequestParam(name = "domainId", required = false) String domainId);  }### Answer:
@Test public void getFAQSByWidgetTest() throws Exception { when(faqService.getFAQSByWidget(anyString(),anyString())).thenReturn(CommonTestUtil.getMapObject()); assertThat(fagsController.getFAQSByWidget("widgetId","domainId"), is(notNullValue())); assertThat(fagsController.getFAQSByWidget("", ""), is(notNullValue())); when(faqService.getFAQSByWidget(anyString(),anyString())).thenThrow(new ServiceException()); when(complianceService.formatException(anyObject())).thenReturn(ResponseUtils.buildFailureResponse(new ServiceException())); ResponseEntity<Object> responseObj = fagsController.getFAQSByWidget("widgetId","domainId"); assertTrue(responseObj.getStatusCode() == HttpStatus.EXPECTATION_FAILED); }