import java.util.Set;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.opendaylight.yangtools.concepts.SemVer;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
import org.opendaylight.yangtools.yang.model.api.Module;
revision2 = SimpleDateFormatUtil.getRevisionFormat().parse("2015-01-15");
}
- private SchemaContext mockSchema(Module... module) {
-
+ private static SchemaContext mockSchema(final Module... module) {
SchemaContext mock = mock(SchemaContext.class);
doReturn(Sets.newHashSet(module)).when(mock).getModules();
return mock;
* CFG(R)
* | \
* | \
- * M2 <- M3
+ * M2 <- M3
* </pre>
*/
@Test
* No root or additional modules
* | \
* | \
- * M2 <- M3
+ * M2 <- M3
* </pre>
*/
@Test
* Config
* | \ (NR)
* | \
- * M2 <- M3
+ * M2 <- M3
* </pre>
*/
@Test
* CFG(R)
* | \
* | \
- * M2<-(NullRev)M3
+ * M2<-(NullRev)M3
* </pre>
*/
@Test
* CFG(R)
* |
* |
- * M2 <- M3
+ * M2 <- M3
* </pre>
*/
@Test
* CFG(R)
* |
* |
- * M2 -> M3 -> M4 -> M5
+ * M2 -> M3 -> M4 -> M5
* </pre>
*/
@Test
* CFG(R)
* |
* |
- * M2 -> M3 <- M4
+ * M2 -> M3 <- M4
* </pre>
*/
@Test
* CFG(R)
* | \
* | \
- * M2 <- M3 M4=M3(Different revision)
+ * M2 <- M3 M4=M3(Different revision)
* </pre>
*/
@Test
* <pre>
* CFG(R)
* |
- * M2 -(no revision)-> M3(R2) ... M3(R1)
+ * M2 -(no revision)-> M3(R2) ... M3(R1)
* </pre>
*/
@Test
- public void testImportNoRevision() throws Exception {
+ public void testImportNoRevision() {
Module moduleConfig = mockModule(CONFIG_NAME, revision);
Module module2 = mockModule(MODULE2_NAME, revision);
* CFG(R)
* | \
* | \
- * | M2 -> M3
+ * | M2 -> M3
* |
- * M41(S) => M4
+ * M41(S) => M4
* </pre>
*/
@Test
- public void testBasicSubmodule() throws Exception {
+ public void testBasicSubmodule() {
Module moduleConfig = mockModule(CONFIG_NAME);
Module module2 = mockModule(MODULE2_NAME);
Module module3 = mockModule(MODULE3_NAME);
/**
* <pre>
*
- * M2 -> M3 -> M4 -> M5
+ * M2 -> M3 -> M4 -> M5
*
* </pre>
*/
* | M5
* M2
*
- * M3 -> M4
+ * M3 -> M4
*
* </pre>
*/
assertProxyContext(filteringSchemaContextProxy, moduleConfig, module2, module3, module4);
}
- private void assertProxyContext(FilteringSchemaContextProxy filteringSchemaContextProxy, Module... expected) {
+ private static void assertProxyContext(final FilteringSchemaContextProxy filteringSchemaContextProxy, final Module... expected) {
Set<Module> modSet = Sets.newHashSet();
- if(expected!=null) {
+ if (expected!=null) {
modSet = Sets.newHashSet(expected);
}
assertEquals(modSet, modSetFiltering);
//asserting collections
- if(expected!=null) {
+ if (expected!=null) {
for (final Module module : expected) {
assertEquals(module, filteringSchemaContextProxy.findModuleByName(module.getName(), module.getRevision()));
}
}
- private FilteringSchemaContextProxy createProxySchemaCtx(SchemaContext schemaContext, Set<Module> additionalModules, Module... modules) {
+ private static FilteringSchemaContextProxy createProxySchemaCtx(final SchemaContext schemaContext,
+ final Set<Module> additionalModules, final Module... modules) {
- Set<Module> modulesSet = new HashSet();
+ Set<Module> modulesSet = new HashSet<>();
- if(modules!=null) {
+ if (modules!=null) {
modulesSet = Sets.newHashSet(modules);
return new FilteringSchemaContextProxy(schemaContext, createModuleIds(modulesSet) , createModuleIds(additionalModules));
}
- private Set<ModuleId> createModuleIds(Set<Module> modules) {
+ private static Set<ModuleId> createModuleIds(final Set<Module> modules) {
Set<ModuleId> moduleIds = Sets.newHashSet();
- if(modules!=null && modules.size()>0) {
+ if (modules!=null && modules.size()>0) {
for (Module module : modules) {
return moduleIds;
}
- private void mockSubmodules(Module mainModule, Module... submodules){
+ private static void mockSubmodules(final Module mainModule, final Module... submodules) {
Set<Module> submodulesSet = new HashSet<>();
submodulesSet.addAll(Arrays.asList(submodules));
doReturn(submodulesSet).when(mainModule).getSubmodules();
}
- private void mockModuleImport(Module importer, Module... imports) {
+ private static void mockModuleImport(final Module importer, final Module... imports) {
Set<ModuleImport> mockedImports = Sets.newHashSet();
for (final Module module : imports) {
mockedImports.add(new ModuleImport() {
return module.getName();
}
+ @Override
+ public SemVer getSemanticVersion() {
+ return module.getSemanticVersion();
+ }
+
@Override
public String toString() {
}
//mock module with revision
- private Module mockModule(String name, final Date rev){
+ private static Module mockModule(final String name, final Date rev) {
final Module mod = mockModule(name);
}
//mock module with default revision
- private Module mockModule(String mName) {
+ private static Module mockModule(final String mName) {
Module mockedModule = mock(Module.class);
doReturn(mName).when(mockedModule).getName();