blob: 0bc4db95a2b2440c2da12f3fbd10fe88b23772e2 [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuska58de4162015-09-10 16:15:33 -07003 *
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 Vachuska6b331262015-04-27 11:09:07 -070016package org.onlab.jdvue;
17
18import org.junit.Test;
19import org.onlab.jdvue.DependencyCycle;
20import org.onlab.jdvue.JavaPackage;
21
22import java.util.Arrays;
23
24import static org.junit.Assert.*;
25
26/**
27 * Unit test for the dependency cycle entity.
28 *
29 * @author Thomas Vachuska
30 */
31public class DependencyCycleTest {
32
33 @Test
34 public void normalize() {
35 JavaPackage x = new JavaPackage("x");
36 JavaPackage y = new JavaPackage("y");
37 JavaPackage z = new JavaPackage("z");
38
39 DependencyCycle a = new DependencyCycle(Arrays.asList(new JavaPackage[] {x, y, z}), x);
40 DependencyCycle b = new DependencyCycle(Arrays.asList(new JavaPackage[] {y, z, x}), y);
41 DependencyCycle c = new DependencyCycle(Arrays.asList(new JavaPackage[] {z, x, y}), z);
42
43 assertEquals("incorrect normalization", a, b);
44 assertEquals("incorrect normalization", a, c);
45 }
46
47 @Test
48 public void testToString() {
49 JavaPackage x = new JavaPackage("x");
50 JavaPackage y = new JavaPackage("y");
51 JavaPackage z = new JavaPackage("z");
52
53 DependencyCycle a = new DependencyCycle(Arrays.asList(new JavaPackage[] {x, y, z}), x);
54 assertEquals("incorrect toString", "[x, y, z]", a.toShortString());
55 assertEquals("incorrect toString",
56 "DependencyCycle{cycle=[" +
57 "JavaPackage{name=x, sources=0, dependencies=0}, " +
58 "JavaPackage{name=y, sources=0, dependencies=0}, " +
59 "JavaPackage{name=z, sources=0, dependencies=0}]}",
60 a.toString());
61 }
62}