1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.myportal.business;
35
36 import fr.paris.lutece.test.LuteceTestCase;
37
38
39
40
41
42
43 public class WidgetTest extends LuteceTestCase
44 {
45 private static final String CONFIGDATA1 = "ConfigData1";
46 private static final String CONFIGDATA2 = "ConfigData2";
47 private static final String DESCRIPTION1 = "Description1";
48 private static final String DESCRIPTION2 = "Description2";
49 private static final int IDICON1 = 1;
50 private static final int IDICON2 = 2;
51 private static final int IDCATEGORY1 = 1;
52 private static final int IDCATEGORY2 = 2;
53 private static final int IDSTYLE1 = 0;
54 private static final int IDSTYLE2 = 1;
55 private static final boolean ISESSENTIAL1 = true;
56 private static final boolean ISESSENTIAL2 = false;
57 private static final boolean ISNEW1 = true;
58 private static final boolean ISNEW2 = false;
59 private static final String NAME1 = "Name1";
60 private static final String NAME2 = "Name2";
61 private static final int STATUS1 = 1;
62 private static final int STATUS2 = 2;
63 private static final String WIDGETTYPE1 = "WIDGETTYPE1";
64 private static final String WIDGETTYPE2 = "WIDGETTYPE2";
65
66
67
68
69 public void testBusiness( )
70 {
71
72 Widget widget = new Widget( );
73 widget.setIdWidget( WidgetHome.newPrimaryKey( ) );
74 widget.setConfigData( CONFIGDATA1 );
75 widget.setDescription( DESCRIPTION1 );
76 widget.setIdIcon( IDICON1 );
77 widget.setIdCategory( IDCATEGORY1 );
78 widget.setIdStyle( IDSTYLE1 );
79 widget.setIsEssential( ISESSENTIAL1 );
80 widget.setIsNew( ISNEW1 );
81 widget.setName( NAME1 );
82 widget.setStatus( STATUS1 );
83 widget.setWidgetType( WIDGETTYPE1 );
84
85
86 WidgetHome.create( widget );
87
88 Widget widgetStored = WidgetHome.findByPrimaryKey( widget.getIdWidget( ) );
89 assertEquals( widgetStored.getIdWidget( ), widget.getIdWidget( ) );
90 assertEquals( widgetStored.getConfigData( ), widget.getConfigData( ) );
91 assertEquals( widgetStored.getDescription( ), widget.getDescription( ) );
92 assertEquals( widgetStored.getIdIcon( ), widget.getIdIcon( ) );
93 assertEquals( widgetStored.getIdCategory( ), widget.getIdCategory( ) );
94 assertEquals( widgetStored.getIdStyle( ), widget.getIdStyle( ) );
95 assertEquals( widgetStored.getIsEssential( ), widget.getIsEssential( ) );
96 assertEquals( widgetStored.getIsNew( ), widget.getIsNew( ) );
97 assertEquals( widgetStored.getName( ), widget.getName( ) );
98 assertEquals( widgetStored.getStatus( ), widget.getStatus( ) );
99 assertEquals( widgetStored.getName( ), widget.getName( ) );
100 assertEquals( widgetStored.getWidgetType( ), widget.getWidgetType( ) );
101
102
103 widget.setConfigData( CONFIGDATA2 );
104 widget.setDescription( DESCRIPTION2 );
105 widget.setIdIcon( IDICON2 );
106 widget.setIdCategory( IDCATEGORY2 );
107 widget.setIdStyle( IDSTYLE2 );
108 widget.setIsEssential( ISESSENTIAL2 );
109 widget.setIsNew( ISNEW2 );
110 widget.setName( NAME2 );
111 widget.setStatus( STATUS2 );
112 widget.setWidgetType( WIDGETTYPE2 );
113 WidgetHome.update( widget );
114 widgetStored = WidgetHome.findByPrimaryKey( widget.getIdWidget( ) );
115 assertEquals( widgetStored.getIdWidget( ), widget.getIdWidget( ) );
116 assertEquals( widgetStored.getConfigData( ), widget.getConfigData( ) );
117 assertEquals( widgetStored.getDescription( ), widget.getDescription( ) );
118 assertEquals( widgetStored.getIdIcon( ), widget.getIdIcon( ) );
119 assertEquals( widgetStored.getIdCategory( ), widget.getIdCategory( ) );
120 assertEquals( widgetStored.getIdStyle( ), widget.getIdStyle( ) );
121 assertEquals( widgetStored.getIsEssential( ), widget.getIsEssential( ) );
122 assertEquals( widgetStored.getIsNew( ), widget.getIsNew( ) );
123 assertEquals( widgetStored.getName( ), widget.getName( ) );
124 assertEquals( widgetStored.getStatus( ), widget.getStatus( ) );
125 assertEquals( widgetStored.getName( ), widget.getName( ) );
126 assertEquals( widgetStored.getWidgetType( ), widget.getWidgetType( ) );
127
128
129 WidgetHome.getWidgetsList( );
130
131
132 WidgetHome.remove( widget.getIdWidget( ) );
133 widgetStored = WidgetHome.findByPrimaryKey( widget.getIdWidget( ) );
134 assertNull( widgetStored );
135 }
136 }