m2u-upass-admin / test / AdminUserTest.java @ 99:310a683183a3
History | View | Annotate | Download (3.3 KB)
1 |
import java.util.Date; |
---|---|
2 |
|
3 |
import net.penril.ibss.core.AdminUserProfileDAO; |
4 |
import net.penril.ibss.core.hibernate.AdminSecurity; |
5 |
import net.penril.ibss.core.hibernate.AdminUserProfile; |
6 |
import net.penril.ibss.core.hibernate.IbUser; |
7 |
|
8 |
import org.junit.After; |
9 |
import org.junit.AfterClass; |
10 |
import org.junit.Before; |
11 |
import org.junit.BeforeClass; |
12 |
import org.junit.Test; |
13 |
|
14 |
import com.ib.ibss.hibernate.tables.DAOFactory; |
15 |
|
16 |
|
17 |
/**
|
18 |
* Copyright (M) 2009 Penril Datability (M) Sdn Bhd All rights reserved.
|
19 |
*
|
20 |
* This software is copyrighted. Under the copyright laws, this software
|
21 |
* may not be copied, in whole or in part, without prior written consent
|
22 |
* of Penril Datability (M) Sdn Bhd or its assignees. This software is
|
23 |
* provided under the terms of a license between Penril Datability (M)
|
24 |
* Sdn Bhd and the recipient, and its use is subject to the terms of that
|
25 |
* license.
|
26 |
*/
|
27 |
|
28 |
/**
|
29 |
* PROGRAMMER: Danniell
|
30 |
* CHANGE-NO:
|
31 |
* TASK-NO:
|
32 |
* DATE CREATED: Dec 5, 2010
|
33 |
* TAG AS:
|
34 |
* REASON(S):
|
35 |
* MODIFICATION:
|
36 |
*/
|
37 |
|
38 |
/**
|
39 |
* <Class description>
|
40 |
*/
|
41 |
public class AdminUserTest |
42 |
{ |
43 |
private static final String TESTER_USER = "tester-"+Long.toHexString(System.currentTimeMillis()); |
44 |
|
45 |
public static AdminUserProfileDAO dao; |
46 |
/**
|
47 |
* @throws java.lang.Exception
|
48 |
*/
|
49 |
@BeforeClass
|
50 |
public static void setUpBeforeClass() throws Exception |
51 |
{ |
52 |
|
53 |
} |
54 |
|
55 |
/**
|
56 |
* @throws java.lang.Exception
|
57 |
*/
|
58 |
@AfterClass
|
59 |
public static void tearDownAfterClass() throws Exception |
60 |
{ |
61 |
|
62 |
} |
63 |
|
64 |
/**
|
65 |
* @throws java.lang.Exception
|
66 |
*/
|
67 |
@Before
|
68 |
public void setUp() throws Exception |
69 |
{ |
70 |
DAOFactory factory = DAOFactory.instance (DAOFactory.HIBERNATE); |
71 |
dao = factory.getAdminUserProfileDAO (); |
72 |
} |
73 |
|
74 |
/**
|
75 |
* @throws java.lang.Exception
|
76 |
*/
|
77 |
@After
|
78 |
public void tearDown() throws Exception |
79 |
{ |
80 |
|
81 |
} |
82 |
|
83 |
@Test
|
84 |
public void testAddAdmin() throws Exception |
85 |
{ |
86 |
// long seq = dao.getNextSequenceNumber ("SQ_IB_USER");
|
87 |
long seq = dao.getNextSequenceNumber ("SEQ_USER_ID"); |
88 |
IbUser mainProfile = new IbUser();
|
89 |
mainProfile.setUserId(seq); |
90 |
|
91 |
AdminUserProfile profile = new AdminUserProfile();
|
92 |
mainProfile.setCreationDate (new Date()); |
93 |
mainProfile.setPassword ("");
|
94 |
mainProfile.setModifTime (new Date()); |
95 |
mainProfile.setUserState (0);
|
96 |
mainProfile.setUserAlias (TESTER_USER); |
97 |
mainProfile.setAccountId (seq); |
98 |
|
99 |
profile.setCreatedBy (0);
|
100 |
profile.setUpdatedBy (0);
|
101 |
profile.setUpdatedDate (new Date()); |
102 |
profile.setForceReset (0);
|
103 |
profile.setGroupId (1);
|
104 |
profile.setRoleId (1);
|
105 |
profile.setUserDob ("30021987");
|
106 |
profile.setUserEmail ("mail@main.com");
|
107 |
profile.setUserMobileNumber ("0128888888");
|
108 |
profile.setUserName ("Tester number 1");
|
109 |
profile.setUserGender ("M");
|
110 |
profile.setUserRace ("");
|
111 |
profile.setUserOfficeNumber ("0312345678");
|
112 |
profile.setMainProfile (mainProfile); |
113 |
profile.setUserId (seq); |
114 |
|
115 |
AdminSecurity security = new AdminSecurity();
|
116 |
security.setMainProfile(mainProfile); |
117 |
profile.setAdminSecurity(security); |
118 |
|
119 |
dao.createNewUser (profile); |
120 |
} |
121 |
|
122 |
@Test
|
123 |
public void testDeleteAdmin() throws Exception |
124 |
{ |
125 |
try
|
126 |
{ |
127 |
AdminUserProfile profile = dao.getUndeletedUserProfile (TESTER_USER); |
128 |
dao.updateUserDeleteStatus (profile.getUserId (), new Long(0)); |
129 |
} |
130 |
catch(Exception e) |
131 |
{ |
132 |
e.printStackTrace (); |
133 |
throw e;
|
134 |
} |
135 |
} |
136 |
} |