@Test
  public void testGetCouponServletWithEmptyCoupon() throws Exception {
    StringWriter stringWriter = new StringWriter();
    PrintWriter writer = new PrintWriter(stringWriter);

    when(request.getParameter(Constants.COUPON_CODE)).thenReturn("");
    when(response.getWriter()).thenReturn(writer);
    when(request.getPathInfo()).thenReturn(Constants.GET_COUPON_PATH.toString());
    when(request.getMethod()).thenReturn("GET");

    servletRouter.doGet(request, response);

    assertTrue(stringWriter.toString().contains("Coupon code is empty or not valid"));
  }
  @Test
  public void testGetCouponServletWithSQLException()
      throws IOException, SQLException, ServletException {
    StringWriter stringWriter = new StringWriter();
    PrintWriter writer = new PrintWriter(stringWriter);

    when(response.getWriter()).thenReturn(writer);
    when(request.getParameter(Constants.COUPON_CODE)).thenReturn(Constants.COUPON_TEST_CODE);
    when(couponPluginApi.getCouponByCode(anyString())).thenThrow(SQLException.class);
    when(request.getPathInfo()).thenReturn(Constants.GET_COUPON_PATH.toString());
    when(request.getMethod()).thenReturn("GET");

    servletRouter.doGet(request, response);

    assertTrue(stringWriter.toString().contains("SQL Exception"));
  }
  @Test
  public void testGetCouponServletWithNullCoupon() throws Exception {
    StringWriter stringWriter = new StringWriter();
    PrintWriter writer = new PrintWriter(stringWriter);

    when(request.getParameter(Constants.COUPON_CODE)).thenReturn(Constants.COUPON_TEST_CODE);
    when(couponPluginApi.getCouponByCode(anyString())).thenReturn(null);
    when(couponPluginApi.getProductsOfCoupon(anyString())).thenReturn(new ArrayList());
    when(response.getWriter()).thenReturn(writer);
    when(request.getPathInfo()).thenReturn(Constants.GET_COUPON_PATH.toString());
    when(request.getMethod()).thenReturn("GET");

    servletRouter.doGet(request, response);

    assertTrue(stringWriter.toString().contains("Coupon not found in the DB"));
  }