Subversion Repositories SmartDukaan

Rev

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.Ignore;
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 {

    @Autowired
    private TicketHandler ticketHandler;

    /**
     * @throws java.lang.Exception
     */
    @Before
    public 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 
     */
    @Ignore
    public 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 
     */
    @Ignore
    public 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 
     */
    @Ignore
    public void testInsertTicket() throws TException {
        Ticket ticket = new Ticket();
        ticket.setCustomerId(0l);
        ticket.setCloseDate(new Date());
        ticket.setOpenDate(new Date());
        ticketHandler.insertTicket(ticket);
        
        assertEquals(true, ticket.getId() > 10);
    }
}