Statistics
| Branch: | Revision:

m2u-upass-admin / test / AdminAccessTest.java @ 146:acbff7ec018d

History | View | Annotate | Download (3.83 KB)

1 0:ea666cc7880e hadi
2
import java.util.ArrayList;
3
import java.util.Date;
4
import java.util.HashSet;
5
import java.util.List;
6
import java.util.Map;
7
import java.util.Set;
8
9
import net.penril.generic.hibernate.HibernateUtils;
10
import net.penril.ibss.core.AdminGroupDAO;
11
import net.penril.ibss.core.AdminNavigationDAO;
12
import net.penril.ibss.core.AdminNavigationGroupDAO;
13
import net.penril.ibss.core.hibernate.AdminGroup;
14
import net.penril.ibss.core.hibernate.AdminNavigationGroup;
15
16
import org.junit.After;
17
import org.junit.AfterClass;
18
import org.junit.Before;
19
import org.junit.BeforeClass;
20
import org.junit.Test;
21
22
import com.ib.ibss.hibernate.tables.DAOFactory;
23
24
/**
25
 * Copyright (M) 2009 Penril Datability (M) Sdn Bhd All rights reserved.
26
 *
27
 * This software is copyrighted. Under the copyright laws, this software
28
 * may not be copied, in whole or in part, without prior written consent
29
 * of Penril Datability (M) Sdn Bhd or its assignees. This software is
30
 * provided under the terms of a license between Penril Datability (M)
31
 * Sdn Bhd and the recipient, and its use is subject to the terms of that
32
 * license.
33
 */
34
35
/**
36
 * PROGRAMMER: Danniell
37
 * CHANGE-NO:
38
 * TASK-NO:
39
 * DATE CREATED: Dec 5, 2010
40
 * TAG AS:
41
 * REASON(S):
42
 * MODIFICATION:
43
 */
44
45
/**
46
 * <Class description>
47
 */
48
public class AdminAccessTest
49
{
50
        public static AdminGroupDAO gdao;
51
        public static AdminNavigationDAO ndao;
52
        public static AdminNavigationGroupDAO ngdao;
53
        public static long seq;
54
55
        /**
56
         * <Method description>
57
         *
58
         * @throws java.lang.Exception
59
         */
60
        @BeforeClass
61
        public static void setUpBeforeClass () throws Exception
62
        {
63
        }
64
65
        /**
66
         * <Method description>
67
         *
68
         * @throws java.lang.Exception
69
         */
70
        @AfterClass
71
        public static void tearDownAfterClass () throws Exception
72
        {
73
        }
74
75
        /**
76
         * <Method description>
77
         *
78
         * @throws java.lang.Exception
79
         */
80
        @Before
81
        public void setUp () throws Exception
82
        {
83
                DAOFactory factory = DAOFactory.instance (DAOFactory.HIBERNATE);
84
                gdao = factory.getAdminGroupDAO ();
85
                ndao = factory.getAdminNavigationDAO ();
86
                ngdao = factory.getAdminNavigationGroupDAO ();
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 testEditAccess() throws Exception
101
        {
102
                try
103
                {
104
                        Set<AdminNavigationGroup> navis = new HashSet<AdminNavigationGroup>();
105
                        AdminGroup group = gdao.getGroupByIdentifier (new Long(1));
106
                        AdminNavigationGroup navGroup = new AdminNavigationGroup();
107
                        Map<Long, String> map = ndao.getNodeCodeByCategory (new Long(0));
108
                        navGroup.setGroupId (group.getGroupId ());
109
                        navGroup.setNavigationId (new Long(11));
110
                        navGroup.setIsEdit (0);
111
                        navGroup.setIsView (0);
112
                        navis.add (navGroup);
113
                        group.setGroupNavigations (navis);
114
                        gdao.updateGroup (group);
115
                }
116
                catch(Exception e)
117
                {
118
                        e.printStackTrace ();
119
                        throw e;
120
                }
121
        }
122
123
        @Test
124
        public void testAddGroupWithAccess() throws Exception
125
        {
126
//                seq = gdao.getNextSequenceNumber ("SQ_ADMIN_GROUP");
127
128
                AdminGroup group = new AdminGroup();
129
                group.setCategory (new Long(1));
130
//                group.setGroupId (seq);
131
                group.setGroupCreatedBy (0);
132
                group.setGroupCreationDate (new Date());
133
                group.setGroupName ("NEW ADD GROUP");
134
                group.setGroupUpdatedBy (0);
135
                group.setGroupUpdatedDate (new Date());
136
                group.setGroupDescription ("Testing 1234 group");
137
138
                Set<AdminNavigationGroup> navis = new HashSet<AdminNavigationGroup>();
139
                AdminNavigationGroup navGroup = new AdminNavigationGroup();
140
                Map<Long, String> map = ndao.getNodeCodeByCategory (new Long(0));
141
142
                gdao.createNewGroup(group);
143
                navGroup.setGroupId (group.getGroupId ());
144
                navGroup.setNavigationId (new Long(11));
145
                navGroup.setIsEdit (0);
146
                navGroup.setIsView (0);
147
                navis.add (navGroup);
148
                group.setGroupNavigations (navis);
149
                gdao.createNewGroup (group);
150
        }
151
}