1 package org.nuiton.validator.xwork2.field;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import org.junit.Test;
26 import org.nuiton.validator.model.Company;
27
28
29
30
31 public class FrenchSirenFieldValidatorTest extends AbstractFieldValidatorTest<Company> {
32
33 public FrenchSirenFieldValidatorTest() {
34 super(Company.class);
35 }
36
37 @Test
38 @Override
39 public void testValidator() throws Exception {
40
41 assertNull(bean.getSiren());
42
43
44 bean.setSiren("751700782");
45 assertFieldInError(Company.PROPERTY_SIREN, "company.siren.format",
46 false);
47
48
49 bean.setSiren("263903007");
50 assertFieldInError(Company.PROPERTY_SIREN, "company.siren.format",
51 false);
52
53
54 bean.setSiren("263903000");
55 assertFieldInError(Company.PROPERTY_SIREN, "company.siren.format",
56 true);
57
58
59 bean.setSiren("44211670");
60 assertFieldInError(Company.PROPERTY_SIREN, "company.siren.format",
61 true);
62
63
64 bean.setSiren("442116703000389");
65 assertFieldInError(Company.PROPERTY_SIREN, "company.siren.format",
66 true);
67
68
69 bean.setSiren("4421bf167");
70 assertFieldInError(Company.PROPERTY_SIREN, "company.siren.format",
71 true);
72
73
74 bean.setSiren("");
75 assertFieldInError(Company.PROPERTY_SIREN, "company.siren.format",
76 false);
77
78
79 bean.setSiren(null);
80 assertFieldInError(Company.PROPERTY_SIREN, "company.siren.format",
81 false);
82
83
84 bean.setSiren("535 198 188 ");
85 assertFieldInError(Company.PROPERTY_SIREN, "company.siren.format",
86 false);
87
88 }
89 }