Home | History | Annotate | Download | only in util
      1 /*
      2  * Copyright (C) 2009 The Android Open Source Project
      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 
     17 package signature.comparator.util;
     18 
     19 import static org.junit.Assert.assertEquals;
     20 import static org.junit.Assert.assertNotNull;
     21 
     22 import org.junit.Before;
     23 
     24 import signature.compare.ApiComparator;
     25 import signature.compare.IApiComparator;
     26 import signature.compare.model.IApiDelta;
     27 import signature.compare.model.IClassDefinitionDelta;
     28 import signature.compare.model.IPackageDelta;
     29 import signature.converter.util.AbstractConvertTest;
     30 import signature.model.IApi;
     31 public abstract class AbstractComparatorTest extends AbstractConvertTest{
     32 
     33     private IApiComparator comparator;
     34 
     35     @Before
     36     public void setupComparator() {
     37         comparator = new ApiComparator();
     38     }
     39 
     40     public IApiDelta compare(IApi from, IApi to){
     41         return comparator.compare(from, to);
     42     }
     43 
     44     public IPackageDelta getSinglePackageDelta(IApiDelta apiDelta){
     45         assertNotNull(apiDelta);
     46         assertEquals(1, apiDelta.getPackageDeltas().size());
     47         return apiDelta.getPackageDeltas().iterator().next();
     48     }
     49 
     50     public IClassDefinitionDelta getSingleClassDelta(IApiDelta apiDelta){
     51         IPackageDelta packageDelta = getSinglePackageDelta(apiDelta);
     52         assertEquals(1, packageDelta.getClassDeltas().size());
     53         return packageDelta.getClassDeltas().iterator().next();
     54     }
     55 
     56 }
     57