Subversion Repositories SmartDukaan

Rev

Rev 3269 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3024 mandeep.dh 1
/**
2
 * 
3
 */
4
package in.shop2020.crm.handler;
5
 
6
import static org.junit.Assert.assertEquals;
3390 mandeep.dh 7
import in.shop2020.crm.domain.SearchFilter;
3024 mandeep.dh 8
import in.shop2020.crm.domain.Ticket;
9
 
10
import java.util.Date;
11
import java.util.List;
12
 
3390 mandeep.dh 13
import org.apache.commons.lang.builder.ToStringBuilder;
3024 mandeep.dh 14
import org.apache.thrift.TException;
15
import org.junit.Before;
3029 mandeep.dh 16
import org.junit.Ignore;
3024 mandeep.dh 17
import org.springframework.beans.factory.annotation.Autowired;
18
import org.springframework.context.ApplicationContext;
19
import org.springframework.context.support.ClassPathXmlApplicationContext;
20
 
21
/**
22
 * Unit test cases for TicketHandler
23
 *
24
 * @author mandeep
25
 */
26
public class TicketHandlerTest {
27
 
28
    @Autowired
29
    private TicketHandler ticketHandler;
30
 
31
    /**
32
     * @throws java.lang.Exception
33
     */
34
    @Before
35
    public void setUp() throws Exception
36
    {
37
        ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:context.xml");
38
        ticketHandler = ctx.getBean(TicketHandler.class);
39
    }
40
 
41
    /**
42
     * Test method for {@link in.shop2020.crm.handler.TicketHandler#fetchTickets(long, long)}.
43
     * @throws TException 
44
     */
3029 mandeep.dh 45
    @Ignore
3024 mandeep.dh 46
    public void testFetchTickets() throws TException {
3390 mandeep.dh 47
        SearchFilter s = new SearchFilter();
48
//        s.setTicketId(200l);
49
//        s.setTicketAssigneeIds(null);
50
//        s.setTicketAssigneeIds(new ArrayList<Long>());
51
//        s.setActivityCreatorIds(Collections.singletonList(2l));
52
//        s.setEndTimestamp(new Date());
53
        s.setCustomerEmailId("mandeepdhir@gmail.com");
54
        List<Ticket> tickets = ticketHandler.getTickets(s);
55
        assertEquals("", ToStringBuilder.reflectionToString(tickets));
3024 mandeep.dh 56
    }
57
 
58
    /**
59
     * Test method for {@link in.shop2020.crm.handler.TicketHandler#updateTicket(in.shop2020.crm.domain.Ticket)}.
60
     * @throws TException 
61
     */
3029 mandeep.dh 62
    @Ignore
3024 mandeep.dh 63
    public void testUpdateTicket() throws TException {
3390 mandeep.dh 64
        SearchFilter s = new SearchFilter();
65
        s.setTicketId(99l);
66
        List<Ticket> tickets = ticketHandler.getTickets(s);
3024 mandeep.dh 67
        Ticket ticket = tickets.get(0);
68
        ticketHandler.updateTicket(ticket);
69
    }
70
 
71
    /**
72
     * Test method for {@link in.shop2020.crm.handler.TicketHandler#insertTicket(in.shop2020.crm.domain.Ticket)}.
73
     * @throws TException 
74
     */
3029 mandeep.dh 75
    @Ignore
3024 mandeep.dh 76
    public void testInsertTicket() throws TException {
77
        Ticket ticket = new Ticket();
3269 mandeep.dh 78
        ticket.setCustomerId(0l);
3024 mandeep.dh 79
        ticket.setCloseDate(new Date());
80
        ticket.setOpenDate(new Date());
81
        ticketHandler.insertTicket(ticket);
82
 
83
        assertEquals(true, ticket.getId() > 10);
84
    }
85
}