Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 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 | */ |
Thomas Vachuska | 6b33126 | 2015-04-27 11:09:07 -0700 | [diff] [blame] | 16 | package org.onlab.jdvue; |
| 17 | |
| 18 | import org.junit.Test; |
| 19 | import org.onlab.jdvue.Catalog; |
| 20 | import org.onlab.jdvue.JavaPackage; |
| 21 | import org.onlab.jdvue.JavaSource; |
| 22 | |
| 23 | import java.io.IOException; |
| 24 | |
| 25 | import static org.junit.Assert.assertEquals; |
| 26 | import static org.junit.Assert.assertNotNull; |
| 27 | |
| 28 | /** |
| 29 | * Unit test for the source catalog. |
| 30 | * |
| 31 | * @author Thomas Vachuska |
| 32 | */ |
| 33 | public class CatalogTest { |
| 34 | |
| 35 | @Test |
| 36 | public void basics() throws IOException { |
| 37 | Catalog cat = new Catalog(); |
| 38 | cat.load("src/test/resources/catalog.db"); |
| 39 | cat.analyze(); |
| 40 | |
| 41 | assertEquals("incorrect package count", 12, cat.getPackages().size()); |
| 42 | assertEquals("incorrect source count", 14, cat.getSources().size()); |
| 43 | |
| 44 | JavaPackage pkg = cat.getPackage("k"); |
| 45 | assertNotNull("package should be found", pkg); |
| 46 | |
| 47 | JavaSource src = cat.getSource("k.K"); |
| 48 | assertNotNull("source should be found", src); |
| 49 | |
| 50 | assertEquals("incorrect package source count", 1, pkg.getSources().size()); |
| 51 | assertEquals("incorrect package dependency count", 1, pkg.getDependencies().size()); |
| 52 | assertEquals("incorrect package cycle count", 3, cat.getPackageCycles(pkg).size()); |
| 53 | |
| 54 | assertEquals("incorrect segment count", 11, cat.getCycleSegments().size()); |
| 55 | assertEquals("incorrect cycle count", 5, cat.getCycles().size()); |
| 56 | } |
| 57 | |
| 58 | } |