Subversion Repositories SmartDukaan

Rev

Rev 3029 | Go to most recent revision | Details | 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;
7
import in.shop2020.crm.domain.Ticket;
8
 
9
import java.util.Date;
10
import java.util.List;
11
 
12
import org.apache.thrift.TException;
13
import org.junit.Before;
14
import org.junit.Test;
15
import org.springframework.beans.factory.annotation.Autowired;
16
import org.springframework.context.ApplicationContext;
17
import org.springframework.context.support.ClassPathXmlApplicationContext;
18
 
19
/**
20
 * Unit test cases for TicketHandler
21
 *
22
 * @author mandeep
23
 */
24
public class TicketHandlerTest {
25
 
26
    @Autowired
27
    private TicketHandler ticketHandler;
28
 
29
    /**
30
     * @throws java.lang.Exception
31
     */
32
    @Before
33
    public void setUp() throws Exception
34
    {
35
        ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:context.xml");
36
        ticketHandler = ctx.getBean(TicketHandler.class);
37
    }
38
 
39
    /**
40
     * Test method for {@link in.shop2020.crm.handler.TicketHandler#fetchTickets(long, long)}.
41
     * @throws TException 
42
     */
43
    @Test
44
    public void testFetchTickets() throws TException {
45
        List<Ticket> tickets = ticketHandler.getTickets(123);
46
        assertEquals(5, tickets.size());
47
        tickets = ticketHandler.getTickets(123);
48
        assertEquals(4, tickets.size());
49
        tickets = ticketHandler.getTickets(123);
50
        assertEquals(9, tickets.size());
51
    }
52
 
53
    /**
54
     * Test method for {@link in.shop2020.crm.handler.TicketHandler#updateTicket(in.shop2020.crm.domain.Ticket)}.
55
     * @throws TException 
56
     */
57
    @Test
58
    public void testUpdateTicket() throws TException {
59
        List<Ticket> tickets = ticketHandler.getTickets(99);
60
        Ticket ticket = tickets.get(0);
61
        ticketHandler.updateTicket(ticket);
62
    }
63
 
64
    /**
65
     * Test method for {@link in.shop2020.crm.handler.TicketHandler#insertTicket(in.shop2020.crm.domain.Ticket)}.
66
     * @throws TException 
67
     */
68
    @Test
69
    public void testInsertTicket() throws TException {
70
        Ticket ticket = new Ticket();
71
        ticket.setCustomerId(0);
72
        ticket.setCloseDate(new Date());
73
        ticket.setOpenDate(new Date());
74
        ticketHandler.insertTicket(ticket);
75
 
76
        assertEquals(true, ticket.getId() > 10);
77
    }
78
}