1+ /** 
2+  * Copyright (c) 2012, 2014, Credit Suisse (Anatole Tresch), Werner Keil and others by the @author tag. 
3+  * 
4+  * Licensed under the Apache License, Version 2.0 (the "License"); you may not 
5+  * use this file except in compliance with the License. You may obtain a copy of 
6+  * 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, WITHOUT 
12+  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
13+  * License for the specific language governing permissions and limitations under 
14+  * the License. 
15+  */ 
16+ package  org .javamoney .moneta .internal ;
17+ 
18+ import  org .javamoney .moneta .spi .ServicePriority ;
19+ import  org .testng .annotations .Test ;
20+ 
21+ import  static  org .testng .Assert .assertTrue ;
22+ 
23+ /** 
24+  * Tests for DefaultMonetaryAmountsSingletonSpi. 
25+  * 
26+  * @author cm-rudolph 
27+  */ 
28+ public  class  DefaultMonetaryAmountsSingletonSpiTest {
29+ 
30+     /** 
31+      * Test method for 
32+      * {@link org.javamoney.moneta.internal.DefaultMonetaryAmountsSingletonSpi#comparePriority(Object, Object)} 
33+      * . 
34+      */ 
35+     @ Test 
36+     public  void  testComparePriority (){
37+         Object  service1  = new  Service1 ();
38+         Object  service2  = new  Service2 ();
39+         assertTrue (DefaultMonetaryAmountsSingletonSpi .comparePriority (service1 , service2 ) > 0 );
40+         assertTrue (DefaultMonetaryAmountsSingletonSpi .comparePriority (service1 , service1 ) == 0 );
41+         assertTrue (DefaultMonetaryAmountsSingletonSpi .comparePriority (service2 , service1 ) < 0 );
42+         assertTrue (DefaultMonetaryAmountsSingletonSpi .comparePriority (null , service2 ) > 0 );
43+     }
44+ 
45+     /** 
46+      * Test class used, with prio 1. 
47+      */ 
48+     @ ServicePriority (1 )
49+     private  static  class  Service1 {}
50+ 
51+     /** 
52+      * Test class used with prio 2. 
53+      */ 
54+     @ ServicePriority (2 )
55+     private  static  class  Service2 {}
56+ }
0 commit comments