Statistics
| Branch: | Revision:

m2u-upass-admin / test / AdminNavigationTest.java @ 68:b376781d30ff

History | View | Annotate | Download (3.63 KB)

1 0:ea666cc7880e hadi
2
import java.util.Date;
3
import java.util.HashSet;
4
import java.util.Iterator;
5
import java.util.List;
6
import java.util.Set;
7
8
import net.penril.ibss.core.AdminNavigationDAO;
9
import net.penril.ibss.core.hibernate.AdminNavigation;
10
11
import org.junit.After;
12
import org.junit.AfterClass;
13
import org.junit.Before;
14
import org.junit.BeforeClass;
15
import org.junit.Test;
16
17
import com.ib.ibss.hibernate.tables.DAOFactory;
18
19
/**
20
 * Copyright (M) 2009 Penril Datability (M) Sdn Bhd All rights reserved.
21
 *
22
 * This software is copyrighted. Under the copyright laws, this software
23
 * may not be copied, in whole or in part, without prior written consent
24
 * of Penril Datability (M) Sdn Bhd or its assignees. This software is
25
 * provided under the terms of a license between Penril Datability (M)
26
 * Sdn Bhd and the recipient, and its use is subject to the terms of that
27
 * license.
28
 */
29
30
/**
31
 * PROGRAMMER: Danniell
32
 * CHANGE-NO:
33
 * TASK-NO:
34
 * DATE CREATED: Dec 5, 2010
35
 * TAG AS:
36
 * REASON(S):
37
 * MODIFICATION:
38
 */
39
40
/**
41
 * <Class description>
42
 */
43
public class AdminNavigationTest
44
{
45
        public static AdminNavigationDAO dao;
46
        public static long seq;
47
48
        /**
49
         * <Method description>
50
         *
51
         * @throws java.lang.Exception
52
         */
53
        @BeforeClass
54
        public static void setUpBeforeClass () throws Exception
55
        {
56
        }
57
58
        /**
59
         * <Method description>
60
         *
61
         * @throws java.lang.Exception
62
         */
63
        @AfterClass
64
        public static void tearDownAfterClass () throws Exception
65
        {
66
        }
67
68
        /**
69
         * <Method description>
70
         *
71
         * @throws java.lang.Exception
72
         */
73
        @Before
74
        public void setUp () throws Exception
75
        {
76
                DAOFactory factory = DAOFactory.instance (DAOFactory.HIBERNATE);
77
                dao = factory.getAdminNavigationDAO ();
78
        }
79
80
        /**
81
         * <Method description>
82
         *
83
         * @throws java.lang.Exception
84
         */
85
        @After
86
        public void tearDown () throws Exception
87
        {
88
        }
89
90
//        @Test
91
        public void createNavigation() throws Exception
92
        {
93
                try
94
                {
95
                        AdminNavigation navigation = new AdminNavigation();
96
                        navigation.setCategory (new Long(0));
97
                        navigation.setNodeCode ("TESTCODE");
98
                        navigation.setNodeCreatedBy (new Long(0));
99
                        navigation.setNodeCreationDate (new Date());
100
                        navigation.setNodeDescription ("Test Navigation Description");
101
                        navigation.setNodeDisplayOrder (new Long(1));
102
                        navigation.setNodeName ("Navigation Name");
103
                        navigation.setNodeType ("0");
104
                        navigation.setParentId (new Long(0));
105
                        navigation.setPagePath ("/lol.do");
106
107
                        Set<AdminNavigation> navs = new HashSet<AdminNavigation>();
108
                        AdminNavigation subNav = new AdminNavigation();
109
                        subNav.setCategory (new Long(0));
110
                        subNav.setNodeCode ("SUBNCODE");
111
                        subNav.setNodeCreatedBy (new Long(0));
112
                        subNav.setNodeCreationDate (new Date());
113
                        subNav.setNodeDescription ("Test Sub Navigation Description");
114
                        subNav.setNodeDisplayOrder (new Long(7));
115
                        subNav.setNodeName ("Sub Navigation Name");
116
                        subNav.setNodeType ("0");
117
                        subNav.setParentId (navigation.getNodeId ());
118
                        subNav.setPagePath ("/lol.do");
119
                        subNav.setParentNavigation (navigation);
120
                        navs.add (subNav);
121
                        navigation.setSubNavigations (navs);
122
123
                        dao.createNewNavigation (navigation);
124
                }
125
                catch(Exception e)
126
                {
127
                        e.printStackTrace ();
128
                        throw e;
129
                }
130
        }
131
132
        @Test
133
        public void testGetNavigation() throws Exception
134
        {
135
                try
136
                {
137
                        List<AdminNavigation> navigations = dao.getOnlineNavigationByCategory (new Long(1));
138
139
                        for(Iterator<AdminNavigation> it = navigations.iterator();it.hasNext();)
140
                        {
141
                                AdminNavigation navigation = it.next();
142
                                System.out.println ("LVL 1: "+navigation.getNodeCode ());
143
                        }
144
                }
145
                catch(Exception e)
146
                {
147
                        e.printStackTrace ();
148
                        throw e;
149
                }
150
        }
151
}