View Javadoc
1   /*
2    * Copyright 2007 Kasper B. Graversen
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.supercsv.cellprocessor.joda;
17  
18  import java.util.Locale;
19  
20  import org.joda.time.format.DateTimeFormatter;
21  import org.joda.time.format.ISODateTimeFormat;
22  import org.junit.Test;
23  import org.supercsv.cellprocessor.ift.CellProcessor;
24  import org.supercsv.cellprocessor.joda.mock.IdentityTransform;
25  
26  /**
27   * Tests the AbstractJodaFormattingProcessor cell processor. This is purely for
28   * coverage of the constructors.
29   */
30  public class AbstractJodaFormattingProcessorTest {
31  
32  	@Test(expected = NullPointerException.class)
33  	public void testConstructor1WithNullJodaType() {
34  		new FmtNothing(null);
35  	}
36  
37  	@Test(expected = NullPointerException.class)
38  	public void testConstructor2WithNullJodaType() {
39  		new FmtNothing(null, new IdentityTransform());
40  	}
41  
42  	@Test(expected = NullPointerException.class)
43  	public void testConstructor3WithNullJodaType() {
44  		new FmtNothing(null, ISODateTimeFormat.dateTime());
45  	}
46  
47  	@Test(expected = NullPointerException.class)
48  	public void testConstructor4WithNullJodaType() {
49  		new FmtNothing(null, ISODateTimeFormat.dateTime(),
50  				new IdentityTransform());
51  	}
52  
53  	@Test(expected = NullPointerException.class)
54  	public void testConstructor5WithNullJodaType() {
55  		new FmtNothing(null, "some pattern");
56  	}
57  
58  	@Test(expected = NullPointerException.class)
59  	public void testConstructor6WithNullJodaType() {
60  		new FmtNothing(null, "some pattern", new IdentityTransform());
61  	}
62  
63  	@Test(expected = NullPointerException.class)
64  	public void testConstructor7WithNullJodaType() {
65  		new FmtNothing(null, "some pattern", Locale.ENGLISH);
66  	}
67  
68  	@Test(expected = NullPointerException.class)
69  	public void testConstructor8WithNullJodaType() {
70  		new FmtNothing(null, "some pattern", Locale.ENGLISH,
71  				new IdentityTransform());
72  	}
73  
74  	private class FmtNothing extends AbstractJodaFormattingProcessor<String> {
75  
76  		public FmtNothing(Class<String> jodaClass, CellProcessor next) {
77  			super(jodaClass, next);
78  		}
79  
80  		public FmtNothing(Class<String> jodaClass, DateTimeFormatter formatter,
81  				CellProcessor next) {
82  			super(jodaClass, formatter, next);
83  		}
84  
85  		public FmtNothing(Class<String> jodaClass, DateTimeFormatter formatter) {
86  			super(jodaClass, formatter);
87  		}
88  
89  		public FmtNothing(Class<String> jodaClass, String pattern,
90  				CellProcessor next) {
91  			super(jodaClass, pattern, next);
92  		}
93  
94  		public FmtNothing(Class<String> jodaClass, String pattern,
95  				Locale locale, CellProcessor next) {
96  			super(jodaClass, pattern, locale, next);
97  		}
98  
99  		public FmtNothing(Class<String> jodaClass, String pattern, Locale locale) {
100 			super(jodaClass, pattern, locale);
101 		}
102 
103 		public FmtNothing(Class<String> jodaClass, String pattern) {
104 			super(jodaClass, pattern);
105 		}
106 
107 		public FmtNothing(Class<String> jodaClass) {
108 			super(jodaClass);
109 		}
110 
111 		@Override
112 		protected String format(String jodaType, DateTimeFormatter formatter) {
113 			return null;
114 		}
115 
116 		@Override
117 		protected String format(String jodaType, String pattern, Locale locale) {
118 			return null;
119 		}
120 
121 		@Override
122 		protected String format(String jodaType) {
123 			return null;
124 		}
125 
126 	}
127 
128 }