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
35 package fr.paris.lutece.plugins.transparency.business;
36
37 import fr.paris.lutece.test.LuteceTestCase;
38
39 import java.sql.Date;
40 import java.util.Calendar;
41 import org.apache.commons.lang.time.DateUtils;
42
43 public class AppointmentBusinessTest extends LuteceTestCase
44 {
45 private final static String TITLE1 = "Title1";
46 private final static String TITLE2 = "Title2";
47 private final static String DESCRIPTION1 = "Description1";
48 private final static String DESCRIPTION2 = "Description2";
49 private final static Date STARTDATE1 = new Date( 1000000l );
50 private final static Date STARTDATE2 = new Date( 2000000l );
51 private final static Date ENDDATE1 = new Date( 1000000l );
52 private final static Date ENDDATE2 = new Date( 2000000l );
53 private final static int TYPEID1 = 1;
54 private final static int TYPEID2 = 2;
55 private final static String TYPELABEL1 = "TypeLabel1";
56 private final static String TYPELABEL2 = "TypeLabel2";
57 private final static String URL1 = "Url1";
58 private final static String URL2 = "Url2";
59
60 public void testBusiness( )
61 {
62
63 Appointment appointment = new Appointment( );
64 appointment.setTitle( TITLE1 );
65 appointment.setDescription( DESCRIPTION1 );
66 appointment.setStartDate( STARTDATE1 );
67 appointment.setEndDate( ENDDATE1 );
68 appointment.setTypeId( TYPEID1 );
69 appointment.setTypeLabel( TYPELABEL1 );
70 appointment.setUrl( URL1 );
71
72
73 AppointmentHome.create( appointment );
74 Appointment appointmentStored = AppointmentHome.findByPrimaryKey( appointment.getId( ) );
75 assertEquals( appointmentStored.getTitle( ), appointment.getTitle( ) );
76 assertEquals( appointmentStored.getDescription( ), appointment.getDescription( ) );
77 assertEquals( DateUtils.truncate(appointmentStored.getStartDate( ),Calendar.DATE),
78 DateUtils.truncate(appointment.getStartDate( ),Calendar.DATE) );
79 assertEquals( DateUtils.truncate(appointmentStored.getEndDate( ),Calendar.DATE),
80 DateUtils.truncate(appointment.getEndDate( ),Calendar.DATE) );
81 assertEquals( appointmentStored.getTypeId( ), appointment.getTypeId( ) );
82 assertEquals( appointmentStored.getTypeLabel( ), appointment.getTypeLabel( ) );
83 assertEquals( appointmentStored.getUrl( ), appointment.getUrl( ) );
84
85
86 appointment.setTitle( TITLE2 );
87 appointment.setDescription( DESCRIPTION2 );
88 appointment.setStartDate( STARTDATE2 );
89 appointment.setEndDate( ENDDATE2 );
90 appointment.setTypeId( TYPEID2 );
91 appointment.setTypeLabel( TYPELABEL2 );
92 appointment.setUrl( URL2 );
93 AppointmentHome.update( appointment );
94 appointmentStored = AppointmentHome.findByPrimaryKey( appointment.getId( ) );
95 assertEquals( appointmentStored.getTitle( ), appointment.getTitle( ) );
96 assertEquals( appointmentStored.getDescription( ), appointment.getDescription( ) );
97 assertEquals( DateUtils.truncate(appointmentStored.getStartDate( ),Calendar.DATE),
98 DateUtils.truncate(appointment.getStartDate( ),Calendar.DATE) );
99 assertEquals( DateUtils.truncate(appointmentStored.getEndDate( ),Calendar.DATE),
100 DateUtils.truncate(appointment.getEndDate( ),Calendar.DATE) );
101 assertEquals( appointmentStored.getTypeId( ), appointment.getTypeId( ) );
102 assertEquals( appointmentStored.getTypeLabel( ), appointment.getTypeLabel( ) );
103 assertEquals( appointmentStored.getUrl( ), appointment.getUrl( ) );
104
105
106 AppointmentHome.getAppointmentsList( );
107
108
109 AppointmentHome.remove( appointment.getId( ) );
110 appointmentStored = AppointmentHome.findByPrimaryKey( appointment.getId( ) );
111 assertNull( appointmentStored );
112
113 }
114
115 }