From: Robert Varga Date: Thu, 12 Apr 2018 22:31:26 +0000 (+0200) Subject: Add ModuleDependencyInfoTest X-Git-Tag: release/carbon-sr4~2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F82%2F70982%2F2;p=yangtools.git Add ModuleDependencyInfoTest We are missing an explicit test suite, start one. Change-Id: I93e17df5c178d134a5d5a3bd586b398f93b0c4f3 Signed-off-by: Robert Varga (cherry picked from commit 7af7d75cdda87b6a94b5b0f42bc3151ad46984a3) (cherry picked from commit a215c6c7533ab4bce93c11a82ed08bec7f18341e) --- diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/util/ModuleDependencySortTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/util/ModuleDependencySortTest.java new file mode 100644 index 0000000000..7fce89f3d1 --- /dev/null +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/util/ModuleDependencySortTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2018 Pantheon Technologies, s.r.o. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.yangtools.yang.parser.util; + +import static com.google.common.collect.ImmutableList.of; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doReturn; + +import com.google.common.collect.ImmutableSet; +import java.net.URI; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.model.api.Module; + +@RunWith(MockitoJUnitRunner.class) +public class ModuleDependencySortTest { + private static final QNameModule TEST = QNameModule.create(URI.create("foo"), null); + + @Mock + private Module fooNoRev; + + @Before + public void before() { + doReturn(ImmutableSet.of()).when(fooNoRev).getImports(); + doReturn("foo").when(fooNoRev).getName(); + doReturn(TEST).when(fooNoRev).getQNameModule(); + doReturn(TEST.getNamespace()).when(fooNoRev).getNamespace(); + doReturn(TEST.getRevision()).when(fooNoRev).getRevision(); + } + + @Test + public void testSimpleModules() { + assertSortedTo(of(fooNoRev), fooNoRev); + } + + private static void assertSortedTo(final List expected, final Module... modules) { + assertEquals(expected, ModuleDependencySort.sort(modules)); + } +}