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.crm.business.demand;
35
36 import fr.paris.lutece.test.LuteceTestCase;
37 import fr.paris.lutece.util.date.DateUtil;
38
39 import java.util.Date;
40 import java.util.Locale;
41
42
43
44
45
46
47 public class DemandTypeTest extends LuteceTestCase
48 {
49 private static final String DATE_BEGIN1 = "01/09/2011";
50 private static final String DATE_BEGIN2 = "02/10/2011";
51 private static final String DATE_END1 = "10/09/2011";
52 private static final String DATE_END2 = "11/10/2011";
53 private static final int ID_CATEGORY1 = 1;
54 private static final int ID_CATEGORY2 = 2;
55 private static final String LABEL1 = "Label1";
56 private static final String LABEL2 = "Label2";
57 private static final int ORDER1 = 1;
58 private static final int ORDER2 = 2;
59 private static final String ROLE1 = "Role1";
60 private static final String ROLE2 = "Role2";
61 private static final String URL_CONTACT1 = "UrlContact1";
62 private static final String URL_CONTACT2 = "UrlContact2";
63 private static final String URL_INFO1 = "UrlInfo1";
64 private static final String URL_INFO2 = "UrlInfo2";
65 private static final String URL_RESOURCE1 = "UrlResource1";
66 private static final String URL_RESOURCE2 = "UrlResource2";
67 private static final String WORKGROUP1 = "Workgroup1";
68 private static final String WORKGROUP2 = "Workgroup2";
69 private static Locale _locale = Locale.getDefault( );
70
71
72
73
74 public void testBusiness( )
75 {
76
77 DemandType demandType = new DemandType( );
78 Date dateBegin = DateUtil.formatDateLongYear( DATE_BEGIN1, _locale );
79 Date dateEnd = DateUtil.formatDateLongYear( DATE_END1, _locale );
80 demandType.setDateBegin( dateBegin );
81 demandType.setDateEnd( dateEnd );
82 demandType.setIdCategory( ID_CATEGORY1 );
83 demandType.setLabel( LABEL1 );
84 demandType.setOrder( ORDER1 );
85 demandType.setRole( ROLE1 );
86 demandType.setUrlContact( URL_CONTACT1 );
87 demandType.setUrlInfo( URL_INFO1 );
88 demandType.setUrlResource( URL_RESOURCE1 );
89 demandType.setWorkgroup( WORKGROUP1 );
90
91
92 DemandTypeHome.create( demandType );
93
94 DemandType demandTypeStored = DemandTypeHome.findByPrimaryKey( demandType.getIdDemandType( ) );
95 assertEquals( demandType.getIdDemandType( ), demandTypeStored.getIdDemandType( ) );
96 assertEquals( demandType.getDateBegin( ), demandTypeStored.getDateBegin( ) );
97 assertEquals( demandType.getDateEnd( ), demandTypeStored.getDateEnd( ) );
98 assertEquals( demandType.getIdCategory( ), demandTypeStored.getIdCategory( ) );
99 assertEquals( demandType.getLabel( ), demandTypeStored.getLabel( ) );
100 assertEquals( demandType.getOrder( ), demandTypeStored.getOrder( ) );
101 assertEquals( demandType.getRole( ), demandTypeStored.getRole( ) );
102 assertEquals( demandType.getUrlContact( ), demandTypeStored.getUrlContact( ) );
103 assertEquals( demandType.getUrlInfo( ), demandTypeStored.getUrlInfo( ) );
104 assertEquals( demandType.getUrlResource( ), demandTypeStored.getUrlResource( ) );
105 assertEquals( demandType.getWorkgroup( ), demandTypeStored.getWorkgroup( ) );
106
107
108 dateBegin = DateUtil.formatDateLongYear( DATE_BEGIN2, _locale );
109 dateEnd = DateUtil.formatDateLongYear( DATE_END2, _locale );
110 demandType.setDateBegin( dateBegin );
111 demandType.setDateEnd( dateEnd );
112 demandType.setIdCategory( ID_CATEGORY2 );
113 demandType.setLabel( LABEL2 );
114 demandType.setOrder( ORDER2 );
115 demandType.setRole( ROLE2 );
116 demandType.setUrlContact( URL_CONTACT2 );
117 demandType.setUrlInfo( URL_INFO2 );
118 demandType.setUrlResource( URL_RESOURCE2 );
119 demandType.setWorkgroup( WORKGROUP2 );
120 DemandTypeHome.update( demandType );
121 demandTypeStored = DemandTypeHome.findByPrimaryKey( demandType.getIdDemandType( ) );
122 assertEquals( demandType.getIdDemandType( ), demandTypeStored.getIdDemandType( ) );
123 assertEquals( demandType.getDateBegin( ), demandTypeStored.getDateBegin( ) );
124 assertEquals( demandType.getDateEnd( ), demandTypeStored.getDateEnd( ) );
125 assertEquals( demandType.getIdCategory( ), demandTypeStored.getIdCategory( ) );
126 assertEquals( demandType.getLabel( ), demandTypeStored.getLabel( ) );
127 assertEquals( demandType.getOrder( ), demandTypeStored.getOrder( ) );
128 assertEquals( demandType.getRole( ), demandTypeStored.getRole( ) );
129 assertEquals( demandType.getUrlContact( ), demandTypeStored.getUrlContact( ) );
130 assertEquals( demandType.getUrlInfo( ), demandTypeStored.getUrlInfo( ) );
131 assertEquals( demandType.getUrlResource( ), demandTypeStored.getUrlResource( ) );
132 assertEquals( demandType.getWorkgroup( ), demandTypeStored.getWorkgroup( ) );
133
134
135 DemandTypeFilter dtFilter = new DemandTypeFilter( );
136 DemandTypeHome.findByFilter( dtFilter );
137 dtFilter.setDateBegin( dateBegin );
138 dtFilter.setDateEnd( dateEnd );
139 dtFilter.setIdCategory( ID_CATEGORY2 );
140 dtFilter.setLabel( LABEL2 );
141 dtFilter.setOrder( ORDER2 );
142 dtFilter.setRole( ROLE2 );
143 dtFilter.setUrlResource( URL_RESOURCE2 );
144 dtFilter.setWorkgroup( WORKGROUP2 );
145 DemandTypeHome.findAll( );
146 DemandTypeHome.findDemandTypes( );
147 DemandTypeHome.findMaxOrder( );
148 DemandTypeHome.findByIdCategoryAndDate( ID_CATEGORY2, new Date( ) );
149 DemandTypeHome.findByOrder( ORDER2 );
150
151
152 DemandTypeHome.remove( demandType.getIdDemandType( ) );
153 demandTypeStored = DemandTypeHome.findByPrimaryKey( demandType.getIdDemandType( ) );
154 assertNull( demandTypeStored );
155 }
156 }