Subversion Repositories SmartDukaan

Rev

Rev 3269 | 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.SearchFilter;
import in.shop2020.crm.domain.Ticket;

import java.util.Date;
import java.util.List;

import org.apache.commons.lang.builder.ToStringBuilder;
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 {
        SearchFilter s = new SearchFilter();
//        s.setTicketId(200l);
//        s.setTicketAssigneeIds(null);
//        s.setTicketAssigneeIds(new ArrayList<Long>());
//        s.setActivityCreatorIds(Collections.singletonList(2l));
//        s.setEndTimestamp(new Date());
        s.setCustomerEmailId("mandeepdhir@gmail.com");
        List<Ticket> tickets = ticketHandler.getTickets(s);
        assertEquals("", ToStringBuilder.reflectionToString(tickets));
    }

    /**
     * Test method for {@link in.shop2020.crm.handler.TicketHandler#updateTicket(in.shop2020.crm.domain.Ticket)}.
     * @throws TException 
     */
    @Ignore
    public void testUpdateTicket() throws TException {
        SearchFilter s = new SearchFilter();
        s.setTicketId(99l);
        List<Ticket> tickets = ticketHandler.getTickets(s);
        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);
    }
}