2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.parser.util;
10 import static com.google.common.collect.ImmutableList.of;
11 import static org.junit.Assert.assertEquals;
12 import static org.mockito.Mockito.doReturn;
14 import com.google.common.collect.ImmutableSet;
16 import java.util.List;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.junit.runner.RunWith;
20 import org.mockito.Mock;
21 import org.mockito.runners.MockitoJUnitRunner;
22 import org.opendaylight.yangtools.yang.common.QNameModule;
23 import org.opendaylight.yangtools.yang.model.api.Module;
25 @RunWith(MockitoJUnitRunner.class)
26 public class ModuleDependencySortTest {
27 private static final QNameModule TEST = QNameModule.create(URI.create("foo"), null);
30 private Module fooNoRev;
33 public void before() {
34 doReturn(ImmutableSet.of()).when(fooNoRev).getImports();
35 doReturn("foo").when(fooNoRev).getName();
36 doReturn(TEST).when(fooNoRev).getQNameModule();
37 doReturn(TEST.getNamespace()).when(fooNoRev).getNamespace();
38 doReturn(TEST.getRevision()).when(fooNoRev).getRevision();
42 public void testSimpleModules() {
43 assertSortedTo(of(fooNoRev), fooNoRev);
46 private static void assertSortedTo(final List<Module> expected, final Module... modules) {
47 assertEquals(expected, ModuleDependencySort.sort(modules));