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;
17  
18  import static org.junit.Assert.assertEquals;
19  
20  import org.junit.Test;
21  import org.supercsv.mock.IdentityTransform;
22  
23  /**
24   * Tests the CellProcessorAdaptor abstract processor.
25   * 
26   * @author James Bassett
27   */
28  public class CellProcessorAdaptorTest {
29  	
30  	@Test
31  	public void testToString() {
32  		assertEquals("org.supercsv.mock.IdentityTransform", new IdentityTransform().toString());
33  	}
34  	
35  	/**
36  	 * Tests construction of an unchained processor.
37  	 */
38  	@Test
39  	public void testValidUnchained() {
40  		IdentityTransform processor = new IdentityTransform();
41  		assertEquals("org.supercsv.cellprocessor.CellProcessorAdaptor$NullObjectPattern", processor.next.getClass()
42  			.getName());
43  		
44  	}
45  	
46  	/**
47  	 * Tests construction of an processor chain.
48  	 */
49  	@Test
50  	public void testValidChained() {
51  		ConvertNullTo processor = new ConvertNullTo("null");
52  		IdentityTransform processorChain = new IdentityTransform(processor);
53  		assertEquals(processor, processorChain.next);
54  	}
55  	
56  	/**
57  	 * Tests construction of a processor chain with a null processor (should throw an Exception).
58  	 */
59  	@Test(expected = NullPointerException.class)
60  	public void testChainedWithNull() {
61  		new IdentityTransform(null);
62  	}
63  	
64  }