m2u-upass-admin / test / BusinessUserTest.java @ 91:37fde9e2b025
History | View | Annotate | Download (4.5 KB)
1 |
|
---|---|
2 |
import java.util.ArrayList; |
3 |
import java.util.Date; |
4 |
import java.util.HashSet; |
5 |
import java.util.List; |
6 |
import java.util.Set; |
7 |
|
8 |
import net.penril.ib.navigation.hibernate.IbGroup; |
9 |
import net.penril.ibss.core.OrganizationDAO; |
10 |
import net.penril.ibss.core.UserProfileDAO; |
11 |
import net.penril.ibss.core.hibernate.IbCategory; |
12 |
import net.penril.ibss.core.hibernate.IbCustAccounts; |
13 |
import net.penril.ibss.core.hibernate.IbCustProfile; |
14 |
import net.penril.ibss.core.hibernate.IbOrganization; |
15 |
import net.penril.ibss.core.hibernate.IbRole; |
16 |
import net.penril.ibss.core.hibernate.IbUser; |
17 |
|
18 |
import org.junit.After; |
19 |
import org.junit.AfterClass; |
20 |
import org.junit.Before; |
21 |
import org.junit.BeforeClass; |
22 |
import org.junit.Test; |
23 |
|
24 |
import com.ib.ibss.hibernate.tables.DAOFactory; |
25 |
|
26 |
/**
|
27 |
* Copyright (M) 2009 Penril Datability (M) Sdn Bhd All rights reserved.
|
28 |
*
|
29 |
* This software is copyrighted. Under the copyright laws, this software
|
30 |
* may not be copied, in whole or in part, without prior written consent
|
31 |
* of Penril Datability (M) Sdn Bhd or its assignees. This software is
|
32 |
* provided under the terms of a license between Penril Datability (M)
|
33 |
* Sdn Bhd and the recipient, and its use is subject to the terms of that
|
34 |
* license.
|
35 |
*/
|
36 |
|
37 |
/**
|
38 |
* PROGRAMMER: Danniell
|
39 |
* CHANGE-NO:
|
40 |
* TASK-NO:
|
41 |
* DATE CREATED: Dec 5, 2010
|
42 |
* TAG AS:
|
43 |
* REASON(S):
|
44 |
* MODIFICATION:
|
45 |
*/
|
46 |
|
47 |
/**
|
48 |
* <Class description>
|
49 |
*/
|
50 |
public class BusinessUserTest |
51 |
{ |
52 |
public static UserProfileDAO dao; |
53 |
public static OrganizationDAO orgDao; |
54 |
public static long seq; |
55 |
|
56 |
/**
|
57 |
* <Method description>
|
58 |
*
|
59 |
* @throws java.lang.Exception
|
60 |
*/
|
61 |
@BeforeClass
|
62 |
public static void setUpBeforeClass () throws Exception |
63 |
{ |
64 |
} |
65 |
|
66 |
/**
|
67 |
* <Method description>
|
68 |
*
|
69 |
* @throws java.lang.Exception
|
70 |
*/
|
71 |
@AfterClass
|
72 |
public static void tearDownAfterClass () throws Exception |
73 |
{ |
74 |
} |
75 |
|
76 |
/**
|
77 |
* <Method description>
|
78 |
*
|
79 |
* @throws java.lang.Exception
|
80 |
*/
|
81 |
@Before
|
82 |
public void setUp () throws Exception |
83 |
{ |
84 |
DAOFactory factory = DAOFactory.instance (DAOFactory.HIBERNATE); |
85 |
dao = factory.getUserProfileDAO (); |
86 |
orgDao = factory.getOrganizationDAO (); |
87 |
} |
88 |
|
89 |
/**
|
90 |
* <Method description>
|
91 |
*
|
92 |
* @throws java.lang.Exception
|
93 |
*/
|
94 |
@After
|
95 |
public void tearDown () throws Exception |
96 |
{ |
97 |
} |
98 |
|
99 |
// @Test
|
100 |
public void createUserBusinessUser() throws Exception |
101 |
{ |
102 |
try
|
103 |
{ |
104 |
// long seq = dao.getNextSequenceNumber ("SQ_IB_USER");
|
105 |
long seq = dao.getNextSequenceNumber ("SEQ_USER_ID"); |
106 |
IbOrganization organization = new IbOrganization();
|
107 |
IbUser mainProfile = new IbUser();
|
108 |
IbCustProfile profile = new IbCustProfile();
|
109 |
IbCategory category = new IbCategory();
|
110 |
IbRole role = new IbRole();
|
111 |
IbGroup group = new IbGroup();
|
112 |
|
113 |
category.setCategoryId (new Long(2)); |
114 |
role.setRoleId (new Long(1)); |
115 |
group.setGroupId (new Long(1)); |
116 |
|
117 |
organization.setOrgCreationDate (new Date()); |
118 |
organization.setOrgDescription ("Demo Organization");
|
119 |
organization.setOrgName ("Demo");
|
120 |
organization.setOrgUpdatedBy (0L);
|
121 |
organization.setOrgUpdatedDate (new Date()); |
122 |
|
123 |
mainProfile.setAccountId (seq); |
124 |
mainProfile.setCreationDate (new Date()); |
125 |
mainProfile.setModifTime (new Date()); |
126 |
mainProfile.setUserState (new Long(0)); |
127 |
mainProfile.setUserAlias ("business1");
|
128 |
|
129 |
profile.setUserId (seq); |
130 |
profile.setUpdatedBy (new Long(0)); |
131 |
profile.setUpdatedDate (new Date()); |
132 |
profile.setUserAccessNo ("123456789");
|
133 |
profile.setUserName ("Business User");
|
134 |
profile.setUserEmail ("business@mail.com");
|
135 |
profile.setUserDobBrd ("88888800");
|
136 |
profile.setUserGender ("M");
|
137 |
profile.setUserRace ("PHI");
|
138 |
profile.setUserType ("02");
|
139 |
profile.setUserTacPhone ("012345678790");
|
140 |
|
141 |
profile.setIbGroup (group); |
142 |
profile.setIbOrganization (organization); |
143 |
profile.setIbRole (role); |
144 |
mainProfile.setUserId (profile.getUserId ()); |
145 |
profile.setMainProfile (mainProfile); |
146 |
orgDao.makePersistent (organization); |
147 |
dao.createNewUser (profile); |
148 |
} |
149 |
catch(Exception e) |
150 |
{ |
151 |
e.printStackTrace (); |
152 |
throw e;
|
153 |
} |
154 |
} |
155 |
|
156 |
@Test
|
157 |
public void testGetCustomers() throws Exception |
158 |
{ |
159 |
try
|
160 |
{ |
161 |
dao.getUsersByCustomerType ("01");
|
162 |
} |
163 |
catch(Exception e) |
164 |
{ |
165 |
e.printStackTrace (); |
166 |
throw e;
|
167 |
} |
168 |
} |
169 |
|
170 |
public void testSaveCustomerAccount() throws Exception |
171 |
{ |
172 |
IbCustProfile profile = new IbCustProfile(); //get from session |
173 |
|
174 |
Set<IbCustAccounts> accounts = new HashSet<IbCustAccounts>(); //set before update |
175 |
|
176 |
profile.setIbAccount (accounts); |
177 |
dao.updateUser (profile); |
178 |
} |
179 |
} |