m2u-upass-admin / test / BusinessGroupTest.java @ 71:e268a6198394
History | View | Annotate | Download (2.7 KB)
1 |
import java.util.Date; |
---|---|
2 |
|
3 |
import net.penril.generic.hibernate.HibernateUtils; |
4 |
import net.penril.ib.navigation.GroupDAO; |
5 |
import net.penril.ib.navigation.hibernate.IbGroup; |
6 |
|
7 |
import org.junit.After; |
8 |
import org.junit.AfterClass; |
9 |
import org.junit.Before; |
10 |
import org.junit.BeforeClass; |
11 |
import org.junit.Test; |
12 |
|
13 |
import com.ib.ibss.hibernate.tables.DAOFactory; |
14 |
|
15 |
/**
|
16 |
* Copyright (M) 2009 Penril Datability (M) Sdn Bhd All rights reserved.
|
17 |
*
|
18 |
* This software is copyrighted. Under the copyright laws, this software
|
19 |
* may not be copied, in whole or in part, without prior written consent
|
20 |
* of Penril Datability (M) Sdn Bhd or its assignees. This software is
|
21 |
* provided under the terms of a license between Penril Datability (M)
|
22 |
* Sdn Bhd and the recipient, and its use is subject to the terms of that
|
23 |
* license.
|
24 |
*/
|
25 |
|
26 |
/**
|
27 |
* PROGRAMMER: Danniell
|
28 |
* CHANGE-NO:
|
29 |
* TASK-NO:
|
30 |
* DATE CREATED: Dec 5, 2010
|
31 |
* TAG AS:
|
32 |
* REASON(S):
|
33 |
* MODIFICATION:
|
34 |
*/
|
35 |
|
36 |
/**
|
37 |
* <Class description>
|
38 |
*/
|
39 |
public class BusinessGroupTest { |
40 |
|
41 |
private static final String TEST_GROUP = "TEST GROUP " |
42 |
+ Long.toHexString(System.currentTimeMillis()); |
43 |
|
44 |
public static GroupDAO dao; |
45 |
|
46 |
// public static long seq;
|
47 |
/**
|
48 |
* <Method description>
|
49 |
*
|
50 |
* @throws java.lang.Exception
|
51 |
*/
|
52 |
@BeforeClass
|
53 |
public static void setUpBeforeClass() throws Exception { |
54 |
} |
55 |
|
56 |
/**
|
57 |
* <Method description>
|
58 |
*
|
59 |
* @throws java.lang.Exception
|
60 |
*/
|
61 |
@AfterClass
|
62 |
public static void tearDownAfterClass() throws Exception { |
63 |
} |
64 |
|
65 |
/**
|
66 |
* <Method description>
|
67 |
*
|
68 |
* @throws java.lang.Exception
|
69 |
*/
|
70 |
@Before
|
71 |
public void setUp() throws Exception { |
72 |
DAOFactory factory = DAOFactory.instance(DAOFactory.HIBERNATE); |
73 |
dao = factory.getGroupDAO(); |
74 |
} |
75 |
|
76 |
/**
|
77 |
* <Method description>
|
78 |
*
|
79 |
* @throws java.lang.Exception
|
80 |
*/
|
81 |
@After
|
82 |
public void tearDown() throws Exception { |
83 |
} |
84 |
|
85 |
@Test
|
86 |
public void testAddGroup() throws Exception { |
87 |
// seq = dao.getNextSequenceNumber ("SQ_IB_GROUP");
|
88 |
|
89 |
IbGroup group = new IbGroup();
|
90 |
group.setCategory(new Long(1)); |
91 |
// group.setGroupId (seq);
|
92 |
group.setGroupCreatedBy(0);
|
93 |
group.setGroupCreationDate(new Date()); |
94 |
group.setGroupName(TEST_GROUP); |
95 |
group.setGroupUpdatedBy(0);
|
96 |
group.setGroupUpdatedDate(new Date()); |
97 |
group.setGroupDescription("Testing 123 business group");
|
98 |
|
99 |
dao.createNewGroup(group); |
100 |
} |
101 |
|
102 |
@Test
|
103 |
public void testDeleteGroup() throws Exception { |
104 |
// IbGroup group = dao.getGroupByIdentifier (seq);
|
105 |
Long id = (Long) HibernateUtils.currentSession()// |
106 |
.createQuery("SELECT groupId FROM IbGroup WHERE groupName = ?")// |
107 |
.setString(0, TEST_GROUP).uniqueResult();
|
108 |
IbGroup group = dao.getGroupByIdentifier(id); |
109 |
dao.deleteGroup(group); |
110 |
} |
111 |
} |