View Javadoc
1   package org.nuiton.validator.xwork2.field;
2   
3   /*
4    * #%L
5    * Nuiton Validator
6    * %%
7    * Copyright (C) 2013 - 2014 Code Lutin, Tony Chemit
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU Lesser General Public License as 
11   * published by the Free Software Foundation, either version 3 of the 
12   * License, or (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Lesser Public License for more details.
18   * 
19   * You should have received a copy of the GNU General Lesser Public 
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
22   * #L%
23   */
24  
25  import org.junit.Test;
26  import org.nuiton.validator.model.HealthEstablishment;
27  
28  /**
29   * @author Sylvain Bavencoff - bavencoff@codelutin.com
30   */
31  public class FrenchFinessFieldValidatorTest extends AbstractFieldValidatorTest<HealthEstablishment> {
32  
33      public FrenchFinessFieldValidatorTest() {
34          super(HealthEstablishment.class);
35      }
36  
37      @Test
38      @Override
39      public void testValidator() throws Exception {
40          assertNull(bean.getFiness());
41  
42          // Valid Finess
43          bean.setFiness("440012664");
44          assertFieldInError(HealthEstablishment.PROPERTY_FINESS, "healthEstablishment.finess.format",
45                             false);
46  
47          // Valid Finess
48          bean.setFiness("310001177");
49          assertFieldInError(HealthEstablishment.PROPERTY_FINESS, "healthEstablishment.finess.format",
50                  false);
51  
52          // Valid Finess
53          bean.setFiness("2A0002879");
54          assertFieldInError(HealthEstablishment.PROPERTY_FINESS, "healthEstablishment.finess.format",
55                  false);
56  
57          // Valid Finess
58          bean.setFiness("2B0000236");
59          assertFieldInError(HealthEstablishment.PROPERTY_FINESS, "healthEstablishment.finess.format",
60                             false);
61  
62          // not Valid Finess
63          bean.setFiness("2B01");
64          assertFieldInError(HealthEstablishment.PROPERTY_FINESS, "healthEstablishment.finess.format",
65                             true);
66  
67          // not Valid Finess
68          bean.setFiness("4402345636");
69          assertFieldInError(HealthEstablishment.PROPERTY_FINESS, "healthEstablishment.finess.format",
70                             true);
71  
72          // not Valid Finess
73          bean.setFiness("CC0123456");
74          assertFieldInError(HealthEstablishment.PROPERTY_FINESS, "healthEstablishment.finess.format",
75                             true);
76  
77          // not Valid Finess
78          bean.setFiness("000123456");
79          assertFieldInError(HealthEstablishment.PROPERTY_FINESS, "healthEstablishment.finess.format",
80                             true);
81  
82          // not Valid Finess
83          bean.setFiness("441B23456");
84          assertFieldInError(HealthEstablishment.PROPERTY_FINESS, "healthEstablishment.finess.format",
85                             true);
86  
87          // not Valid Finess
88          bean.setFiness("4402345F6");
89          assertFieldInError(HealthEstablishment.PROPERTY_FINESS, "healthEstablishment.finess.format",
90                             true);
91  
92          // not Valid Finess
93          bean.setFiness("440012666");
94          assertFieldInError(HealthEstablishment.PROPERTY_FINESS, "healthEstablishment.finess.format",
95                  true);
96  
97      }
98  }