View Javadoc
1   /*
2    * Copyright (c) 2002-2020, Mairie de Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  
35  package fr.paris.lutece.plugins.bornecineraire.business;
36  
37  import java.sql.Date;
38  
39  import fr.paris.lutece.test.LuteceTestCase;
40  
41  /**
42   * This is the business class test for the object Defunt
43   */
44  public class DefuntBusinessTest extends LuteceTestCase
45  {
46      private static final String TRICIMETIERE1     = "TriCimetiere1";
47      private static final String TRICIMETIERE2     = "TriCimetiere2";
48      private static final int    IDPERSANKOU1      = 1;
49      private static final int    IDPERSANKOU2      = 2;
50      private static final String NOMPATRONYMIQUE1  = "NomPatronymique1";
51      private static final String NOMPATRONYMIQUE2  = "NomPatronymique2";
52      private static final String NOMMARITAL1       = "NomMarital1";
53      private static final String NOMMARITAL2       = "NomMarital2";
54      private static final String NOMUSAGE1         = "NomUsage1";
55      private static final String NOMUSAGE2         = "NomUsage2";
56      private static final String NOMCONCATENE1     = "NomConcatene1";
57      private static final String NOMCONCATENE2     = "NomConcatene2";
58      private static final String PRENOMUN1         = "PrenomUn1";
59      private static final String PRENOMUN2         = "PrenomUn2";
60      private static final String PRENOMDEUX1       = "PrenomDeux1";
61      private static final String PRENOMDEUX2       = "PrenomDeux2";
62      private static final String PRENOMTROIS1      = "PrenomTrois1";
63      private static final String PRENOMTROIS2      = "PrenomTrois2";
64      private static final String PRENOMCONCATENE1  = "PrenomConcatene1";
65      private static final String PRENOMCONCATENE2  = "PrenomConcatene2";
66      private static final Date   DATENAISSANCE1    = new Date( 1000000l );
67      private static final Date   DATENAISSANCE2    = new Date( 2000000l );
68      private static final int    JOURNAISSANCE1    = 1;
69      private static final int    JOURNAISSANCE2    = 2;
70      private static final int    MOISNAISSANCE1    = 1;
71      private static final int    MOISNAISSANCE2    = 2;
72      private static final int    ANNEENAISSANCE1   = 1901;
73      private static final int    ANNEENAISSANCE2   = 1902;
74      private static final Date   DATEDECES1        = new Date( 1000000l );
75      private static final Date   DATEDECES2        = new Date( 2000000l );
76      private static final int    JOURDECES1        = 1;
77      private static final int    JOURDECES2        = 2;
78      private static final int    MOISDECES1        = 1;
79      private static final int    MOISDECES2        = 2;
80      private static final int    ANNEEDECES1       = 1981;
81      private static final int    ANNEEDECES2       = 1982;
82      private static final Date   DATEINHUMATION1   = new Date( 1000000l );
83      private static final Date   DATEINHUMATION2   = new Date( 2000000l );
84      private static final int    JOURINHUMATION1   = 1;
85      private static final int    JOURINHUMATION2   = 2;
86      private static final int    MOISINHUMATION1   = 1;
87      private static final int    MOISINHUMATION2   = 2;
88      private static final int    ANNEEINHUMATION1  = 1991;
89      private static final int    ANNEEINHUMATION2  = 1992;
90      private static final Date   DATEDISPERSION1   = new Date( 1000000l );
91      private static final Date   DATEDISPERSION2   = new Date( 2000000l );
92      private static final int    JOURDISPERSION1   = 1;
93      private static final int    JOURDISPERSION2   = 2;
94      private static final int    MOISDISPERSION1   = 1;
95      private static final int    MOISDISPERSION2   = 2;
96      private static final int    ANNEEDISPERSION1  = 2001;
97      private static final int    ANNEEDISPERSION2  = 2002;
98      private static final String COMMUNEDECES1     = "CommuneDeces1";
99      private static final String COMMUNEDECES2     = "CommuneDeces2";
100     private static final String EMPLACEMENT1      = "Emplacement1";
101     private static final String EMPLACEMENT2      = "Emplacement2";
102     private static final String GEOLOCALISATION1  = "Geolocalisation1";
103     private static final String GEOLOCALISATION2  = "Geolocalisation2";
104     private static final String GEOLOCALISATIONX1 = "GeolocalisationX1";
105     private static final String GEOLOCALISATIONX2 = "GeolocalisationX2";
106     private static final String GEOLOCALISATIONY1 = "GeolocalisationY1";
107     private static final String GEOLOCALISATIONY2 = "GeolocalisationY2";
108 
109     /**
110      * test Defunt
111      */
112     public void testBusiness( )
113     {
114         // Initialize an object
115         Defunt defunt = new Defunt( );
116         defunt.setTriCimetiere( TRICIMETIERE1 );
117         defunt.setIdPersAnkou( IDPERSANKOU1 );
118         defunt.setNomPatronymique( NOMPATRONYMIQUE1 );
119         defunt.setNomMarital( NOMMARITAL1 );
120         defunt.setNomUsage( NOMUSAGE1 );
121         defunt.setNomConcatene( NOMCONCATENE1 );
122         defunt.setPrenomUn( PRENOMUN1 );
123         defunt.setPrenomDeux( PRENOMDEUX1 );
124         defunt.setPrenomTrois( PRENOMTROIS1 );
125         defunt.setPrenomConcatene( PRENOMCONCATENE1 );
126         defunt.setDateNaissance( DATENAISSANCE1 );
127         defunt.setJourNaissance( JOURNAISSANCE1 );
128         defunt.setMoisNaissance( MOISNAISSANCE1 );
129         defunt.setAnneeNaissance( ANNEENAISSANCE1 );
130         defunt.setDateDeces( DATEDECES1 );
131         defunt.setJourDeces( JOURDECES1 );
132         defunt.setMoisDeces( MOISDECES1 );
133         defunt.setAnneeDeces( ANNEEDECES1 );
134         defunt.setDateInhumation( DATEINHUMATION1 );
135         defunt.setJourInhumation( JOURINHUMATION1 );
136         defunt.setMoisInhumation( MOISINHUMATION1 );
137         defunt.setAnneeInhumation( ANNEEINHUMATION1 );
138         defunt.setDateDispersion( DATEDISPERSION1 );
139         defunt.setJourDispersion( JOURDISPERSION1 );
140         defunt.setMoisDispersion( MOISDISPERSION1 );
141         defunt.setAnneeDispersion( ANNEEDISPERSION1 );
142         defunt.setCommuneDeces( COMMUNEDECES1 );
143         defunt.setEmplacement( EMPLACEMENT1 );
144         defunt.setGeolocalisation( GEOLOCALISATION1 );
145         defunt.setGeolocalisationX( GEOLOCALISATIONX1 );
146         defunt.setGeolocalisationY( GEOLOCALISATIONY1 );
147 
148         // Create test
149         DefuntHome.create( defunt );
150         Defunt defuntStored = DefuntHome.findByPrimaryKey( defunt.getId( ) );
151         assertEquals( defuntStored.getTriCimetiere( ), defunt.getTriCimetiere( ) );
152         assertEquals( defuntStored.getIdPersAnkou( ), defunt.getIdPersAnkou( ) );
153         assertEquals( defuntStored.getNomPatronymique( ), defunt.getNomPatronymique( ) );
154         assertEquals( defuntStored.getNomMarital( ), defunt.getNomMarital( ) );
155         assertEquals( defuntStored.getNomUsage( ), defunt.getNomUsage( ) );
156         assertEquals( defuntStored.getNomConcatene( ), defunt.getNomConcatene( ) );
157         assertEquals( defuntStored.getPrenomUn( ), defunt.getPrenomUn( ) );
158         assertEquals( defuntStored.getPrenomDeux( ), defunt.getPrenomDeux( ) );
159         assertEquals( defuntStored.getPrenomTrois( ), defunt.getPrenomTrois( ) );
160         assertEquals( defuntStored.getPrenomConcatene( ), defunt.getPrenomConcatene( ) );
161         assertEquals( defuntStored.getDateNaissance( ), defunt.getDateNaissance( ) );
162         assertEquals( defuntStored.getJourNaissance( ), defunt.getJourNaissance( ) );
163         assertEquals( defuntStored.getMoisNaissance( ), defunt.getMoisNaissance( ) );
164         assertEquals( defuntStored.getAnneeNaissance( ), defunt.getAnneeNaissance( ) );
165         assertEquals( defuntStored.getDateDeces( ), defunt.getDateDeces( ) );
166         assertEquals( defuntStored.getJourDeces( ), defunt.getJourDeces( ) );
167         assertEquals( defuntStored.getMoisDeces( ), defunt.getMoisDeces( ) );
168         assertEquals( defuntStored.getAnneeDeces( ), defunt.getAnneeDeces( ) );
169         assertEquals( defuntStored.getDateInhumation( ), defunt.getDateInhumation( ) );
170         assertEquals( defuntStored.getJourInhumation( ), defunt.getJourInhumation( ) );
171         assertEquals( defuntStored.getMoisInhumation( ), defunt.getMoisInhumation( ) );
172         assertEquals( defuntStored.getAnneeInhumation( ), defunt.getAnneeInhumation( ) );
173         assertEquals( defuntStored.getDateDispersion( ), defunt.getDateDispersion( ) );
174         assertEquals( defuntStored.getJourDispersion( ), defunt.getJourDispersion( ) );
175         assertEquals( defuntStored.getMoisDispersion( ), defunt.getMoisDispersion( ) );
176         assertEquals( defuntStored.getAnneeDispersion( ), defunt.getAnneeDispersion( ) );
177         assertEquals( defuntStored.getCommuneDeces( ), defunt.getCommuneDeces( ) );
178         assertEquals( defuntStored.getEmplacement( ), defunt.getEmplacement( ) );
179         assertEquals( defuntStored.getGeolocalisation( ), defunt.getGeolocalisation( ) );
180         assertEquals( defuntStored.getGeolocalisationX( ), defunt.getGeolocalisationX( ) );
181         assertEquals( defuntStored.getGeolocalisationY( ), defunt.getGeolocalisationY( ) );
182 
183         // Update test
184         defunt.setTriCimetiere( TRICIMETIERE2 );
185         defunt.setIdPersAnkou( IDPERSANKOU2 );
186         defunt.setNomPatronymique( NOMPATRONYMIQUE2 );
187         defunt.setNomMarital( NOMMARITAL2 );
188         defunt.setNomUsage( NOMUSAGE2 );
189         defunt.setNomConcatene( NOMCONCATENE2 );
190         defunt.setPrenomUn( PRENOMUN2 );
191         defunt.setPrenomDeux( PRENOMDEUX2 );
192         defunt.setPrenomTrois( PRENOMTROIS2 );
193         defunt.setPrenomConcatene( PRENOMCONCATENE2 );
194         defunt.setDateNaissance( DATENAISSANCE2 );
195         defunt.setJourNaissance( JOURNAISSANCE2 );
196         defunt.setMoisNaissance( MOISNAISSANCE2 );
197         defunt.setAnneeNaissance( ANNEENAISSANCE2 );
198         defunt.setDateDeces( DATEDECES2 );
199         defunt.setJourDeces( JOURDECES2 );
200         defunt.setMoisDeces( MOISDECES2 );
201         defunt.setAnneeDeces( ANNEEDECES2 );
202         defunt.setDateInhumation( DATEINHUMATION2 );
203         defunt.setJourInhumation( JOURINHUMATION2 );
204         defunt.setMoisInhumation( MOISINHUMATION2 );
205         defunt.setAnneeInhumation( ANNEEINHUMATION2 );
206         defunt.setDateDispersion( DATEDISPERSION2 );
207         defunt.setJourDispersion( JOURDISPERSION2 );
208         defunt.setMoisDispersion( MOISDISPERSION2 );
209         defunt.setAnneeDispersion( ANNEEDISPERSION2 );
210         defunt.setCommuneDeces( COMMUNEDECES2 );
211         defunt.setEmplacement( EMPLACEMENT2 );
212         defunt.setGeolocalisation( GEOLOCALISATION2 );
213         defunt.setGeolocalisationX( GEOLOCALISATIONX2 );
214         defunt.setGeolocalisationY( GEOLOCALISATIONY2 );
215 
216         DefuntHome.update( defunt );
217         defuntStored = DefuntHome.findByPrimaryKey( defunt.getId( ) );
218         assertEquals( defuntStored.getTriCimetiere( ), defunt.getTriCimetiere( ) );
219         assertEquals( defuntStored.getIdPersAnkou( ), defunt.getIdPersAnkou( ) );
220         assertEquals( defuntStored.getNomPatronymique( ), defunt.getNomPatronymique( ) );
221         assertEquals( defuntStored.getNomMarital( ), defunt.getNomMarital( ) );
222         assertEquals( defuntStored.getNomUsage( ), defunt.getNomUsage( ) );
223         assertEquals( defuntStored.getNomConcatene( ), defunt.getNomConcatene( ) );
224         assertEquals( defuntStored.getPrenomUn( ), defunt.getPrenomUn( ) );
225         assertEquals( defuntStored.getPrenomDeux( ), defunt.getPrenomDeux( ) );
226         assertEquals( defuntStored.getPrenomTrois( ), defunt.getPrenomTrois( ) );
227         assertEquals( defuntStored.getPrenomConcatene( ), defunt.getPrenomConcatene( ) );
228         assertEquals( defuntStored.getDateNaissance( ), defunt.getDateNaissance( ) );
229         assertEquals( defuntStored.getJourNaissance( ), defunt.getJourNaissance( ) );
230         assertEquals( defuntStored.getMoisNaissance( ), defunt.getMoisNaissance( ) );
231         assertEquals( defuntStored.getAnneeNaissance( ), defunt.getAnneeNaissance( ) );
232         assertEquals( defuntStored.getDateDeces( ), defunt.getDateDeces( ) );
233         assertEquals( defuntStored.getJourDeces( ), defunt.getJourDeces( ) );
234         assertEquals( defuntStored.getMoisDeces( ), defunt.getMoisDeces( ) );
235         assertEquals( defuntStored.getAnneeDeces( ), defunt.getAnneeDeces( ) );
236         assertEquals( defuntStored.getDateInhumation( ), defunt.getDateInhumation( ) );
237         assertEquals( defuntStored.getJourInhumation( ), defunt.getJourInhumation( ) );
238         assertEquals( defuntStored.getMoisInhumation( ), defunt.getMoisInhumation( ) );
239         assertEquals( defuntStored.getAnneeInhumation( ), defunt.getAnneeInhumation( ) );
240         assertEquals( defuntStored.getDateDispersion( ), defunt.getDateDispersion( ) );
241         assertEquals( defuntStored.getJourDispersion( ), defunt.getJourDispersion( ) );
242         assertEquals( defuntStored.getMoisDispersion( ), defunt.getMoisDispersion( ) );
243         assertEquals( defuntStored.getAnneeDispersion( ), defunt.getAnneeDispersion( ) );
244         assertEquals( defuntStored.getCommuneDeces( ), defunt.getCommuneDeces( ) );
245         assertEquals( defuntStored.getEmplacement( ), defunt.getEmplacement( ) );
246         assertEquals( defuntStored.getGeolocalisation( ), defunt.getGeolocalisation( ) );
247         assertEquals( defuntStored.getGeolocalisationX( ), defunt.getGeolocalisationX( ) );
248         assertEquals( defuntStored.getGeolocalisationY( ), defunt.getGeolocalisationY( ) );
249 
250         // List test
251         DefuntHome.getDefuntsList( );
252 
253         // Delete test
254         DefuntHome.remove( defunt.getId( ) );
255         defuntStored = DefuntHome.findByPrimaryKey( defunt.getId( ) );
256         assertNull( defuntStored );
257 
258     }
259 
260 }