@Test
  public void testGetTicketsByUser() throws Exception {

    User user = new User();
    Mockito.when(ticketDao.findTicketsByUserOwner(user)).thenReturn(ticketList);
    List<Ticket> result = ticketService.getTicketsByUser(user);

    assertEquals(result, ticketList);
  }
  @Test
  public void testGetTicketById() throws Exception {

    Ticket ticket = new Ticket();
    ticket.setTicketId(1);
    Mockito.when(ticketDao.findTicketById(ticket.getTicketId())).thenReturn(ticket);
    ticket = ticketService.getTicketById(ticket);

    assertEquals(ticket.getTicketId(), 1);
  }
  @Test
  public void testCreateTicket() throws Exception {

    Ticket ticket = new Ticket();
    ticket.setTicketId(1);
    Mockito.when(ticketDao.createTicket(ticket)).thenReturn(ticket);
    Mockito.doCallRealMethod().when(emailSenderService).newTicketCreated(ticket.getEmail());

    MessageResponse messageResponse = ticketService.createTicket(ticket);
    assertTrue(messageResponse.getCode() == 1);
  }
  @Test
  @PrepareForTest({UtilsHibernate.class})
  public void testGetAllTickets() throws Exception {

    PowerMockito.mockStatic(UtilsHibernate.class);

    Mockito.when(ticketDao.getAllTickets(10, 0, UtilsHibernate.getOrderByString("ticketId", "ASC")))
        .thenReturn(ticketList);

    List<Ticket> results = ticketService.getAllTickets(10, 0, "ticketId", "ASC");

    assertTrue(results.get(0).getTitle().length() < 50);
  }
  @Test
  public void testRemoveTicket() throws Exception {

    Ticket ticket = new Ticket();
    ticket.setTicketId(1);
    ticket.setIsDeleted(true);

    Mockito.when(ticketDao.removeTicket(ticket.getTicketId())).thenReturn(ticket);

    MessageResponse messageResponse = ticketService.removeTicket(1);

    assertEquals(messageResponse.getCode(), 1);
  }
  @Test
  @PrepareForTest({UtilsHibernate.class})
  public void testGetAllTicketsAdmin() throws Exception {

    PowerMockito.mockStatic(UtilsHibernate.class);

    Mockito.when(
            ticketDao.getAllTicketsAdmin(10, 0, UtilsHibernate.getOrderByString("ASC", "status")))
        .thenReturn(ticketList);

    List<Ticket> resultTicket = ticketService.getAllTicketsAdmin(10, 0, "ASC", "status");

    assertEquals(resultTicket, ticketList);
  }