Rev 3029 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
/****/package in.shop2020.crm.handler;import static org.junit.Assert.assertEquals;import in.shop2020.crm.domain.Ticket;import java.util.Date;import java.util.List;import org.apache.thrift.TException;import org.junit.Before;import org.junit.Test;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;/*** Unit test cases for TicketHandler** @author mandeep*/public class TicketHandlerTest {@Autowiredprivate TicketHandler ticketHandler;/*** @throws java.lang.Exception*/@Beforepublic void setUp() throws Exception{ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:context.xml");ticketHandler = ctx.getBean(TicketHandler.class);}/*** Test method for {@link in.shop2020.crm.handler.TicketHandler#fetchTickets(long, long)}.* @throws TException*/@Testpublic void testFetchTickets() throws TException {List<Ticket> tickets = ticketHandler.getTickets(123);assertEquals(5, tickets.size());tickets = ticketHandler.getTickets(123);assertEquals(4, tickets.size());tickets = ticketHandler.getTickets(123);assertEquals(9, tickets.size());}/*** Test method for {@link in.shop2020.crm.handler.TicketHandler#updateTicket(in.shop2020.crm.domain.Ticket)}.* @throws TException*/@Testpublic void testUpdateTicket() throws TException {List<Ticket> tickets = ticketHandler.getTickets(99);Ticket ticket = tickets.get(0);ticketHandler.updateTicket(ticket);}/*** Test method for {@link in.shop2020.crm.handler.TicketHandler#insertTicket(in.shop2020.crm.domain.Ticket)}.* @throws TException*/@Testpublic void testInsertTicket() throws TException {Ticket ticket = new Ticket();ticket.setCustomerId(0);ticket.setCloseDate(new Date());ticket.setOpenDate(new Date());ticketHandler.insertTicket(ticket);assertEquals(true, ticket.getId() > 10);}}