1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.jdtaus.banking.spi.it;
22
23 import java.util.Currency;
24 import java.util.Date;
25 import junit.framework.Assert;
26 import org.jdtaus.banking.it.CurrencyDirectoryTest;
27 import org.jdtaus.banking.spi.CurrencyMapper;
28 import org.jdtaus.banking.spi.UnsupportedCurrencyException;
29
30
31
32
33
34
35
36 public class CurrencyMapperTest extends CurrencyDirectoryTest
37 {
38
39
40 private CurrencyMapper mapper;
41
42
43
44
45
46
47 public CurrencyMapper getCurrencyMapper()
48 {
49 return this.mapper;
50 }
51
52
53
54
55
56
57 public final void setCurrencyMapper( final CurrencyMapper value )
58 {
59 this.setCurrencyDirectory( value );
60 this.mapper = value;
61 }
62
63
64
65
66
67 public void testGetDtausCode() throws Exception
68 {
69 assert this.getCurrencyMapper() != null;
70
71 try
72 {
73 this.getCurrencyMapper().getDtausCode( null, new Date() );
74 throw new AssertionError();
75 }
76 catch ( NullPointerException e )
77 {
78 Assert.assertNotNull( e.getMessage() );
79 System.out.println( e.toString() );
80 }
81
82 try
83 {
84 this.getCurrencyMapper().getDtausCode( Currency.getInstance( "EUR" ), null );
85 throw new AssertionError();
86 }
87 catch ( NullPointerException e )
88 {
89 Assert.assertNotNull( e.getMessage() );
90 System.out.println( e.toString() );
91 }
92
93 try
94 {
95 this.getCurrencyMapper().getDtausCode( Currency.getInstance( "DEM" ), new Date() );
96 throw new AssertionError();
97 }
98 catch ( UnsupportedCurrencyException e )
99 {
100 Assert.assertNotNull( e.getMessage() );
101 System.out.println( e.toString() );
102 }
103
104 Assert.assertTrue( this.getCurrencyMapper().getDtausCode( Currency.getInstance( "EUR" ), new Date() ) == '1' );
105 }
106
107
108
109
110
111 public void testGetDtausCurrency() throws Exception
112 {
113 assert this.getCurrencyMapper() != null;
114
115 try
116 {
117 this.getCurrencyMapper().getDtausCurrency( '1', null );
118 throw new AssertionError();
119 }
120 catch ( NullPointerException e )
121 {
122 Assert.assertNotNull( e.getMessage() );
123 System.out.println( e.toString() );
124 }
125
126
127 Assert.assertEquals( this.getCurrencyMapper().getDtausCurrency( '1', new Date() ),
128 Currency.getInstance( "EUR" ) );
129
130 }
131
132 }