1
+ /*
2
+ * #%L
3
+ * ACS AEM Tools Bundle
4
+ * %%
5
+ * Copyright (C) 2015 Adobe
6
+ * %%
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ * #L%
19
+ */
20
+
21
+ package com .adobe .acs .tools .csv_asset_importer .impl ;
22
+
23
+
24
+ import org .junit .Assert ;
25
+ import org .junit .Test ;
26
+
27
+ public class ColumnTest {
28
+
29
+ @ Test
30
+ public void testGetData () throws Exception {
31
+ Column col ;
32
+
33
+ // Default (String)
34
+ col = new Column ("title" , 0 );
35
+ Assert .assertEquals ("test" , col .getData ("test" ));
36
+
37
+ // String
38
+ col = new Column ("title {{ String }}" , 0 );
39
+ Assert .assertEquals ("test" , col .getData ("test" ));
40
+
41
+ // String (true value)
42
+ col = new Column ("title {{ String }}" , 0 );
43
+ Assert .assertEquals ("true" , col .getData ("true" ));
44
+
45
+ // Long
46
+ col = new Column ("title {{ Long }}" , 0 );
47
+ Assert .assertEquals (100L , col .getData ("100" ));
48
+
49
+ // Int
50
+ col = new Column ("title {{ Int }}" , 0 );
51
+ Assert .assertEquals (100L , col .getData ("100" ));
52
+
53
+ // Integer
54
+ col = new Column ("title {{ Integer }}" , 0 );
55
+ Assert .assertEquals (100L , col .getData ("100" ));
56
+
57
+ // Double
58
+ col = new Column ("title {{ Double }}" , 0 );
59
+ Assert .assertEquals (100.001D , col .getData ("100.001" ));
60
+
61
+ // Boolean
62
+ col = new Column ("title {{ Boolean }}" , 0 );
63
+ Assert .assertEquals (true , col .getData ("true" ));
64
+
65
+ col = new Column ("title {{ Boolean }}" , 0 );
66
+ Assert .assertEquals (false , col .getData ("FALSE" ));
67
+ }
68
+
69
+ @ Test
70
+ public void testToObjectType () throws Exception {
71
+ Column col ;
72
+
73
+ // Default (String)
74
+ col = new Column ("title" , 0 );
75
+ Assert .assertEquals ("test" , col .toObjectType ("test" , String .class ));
76
+
77
+ // String (true value)
78
+ col = new Column ("title {{ String }}" , 0 );
79
+ Assert .assertEquals ("true" , col .toObjectType ("true" , String .class ));
80
+ }
81
+
82
+ @ Test
83
+ public void testGetPropertyName () throws Exception {
84
+ Column col ;
85
+
86
+ col = new Column ("title" , 0 );
87
+ Assert .assertEquals ("title" , col .getPropertyName ());
88
+
89
+ col = new Column ("title {{ String }}" , 0 );
90
+ Assert .assertEquals ("title" , col .getPropertyName ());
91
+
92
+ col = new Column ("title {{ String : multi }}" , 0 );
93
+ Assert .assertEquals ("title" , col .getPropertyName ());
94
+
95
+ col = new Column ("title {{String}}" , 0 );
96
+ Assert .assertEquals ("title" , col .getPropertyName ());
97
+
98
+ col = new Column ("title {{String:multi}}" , 0 );
99
+ Assert .assertEquals ("title" , col .getPropertyName ());
100
+ }
101
+ }
0 commit comments