import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
-import org.junit.Before;
+import java.util.Set;
import org.junit.Test;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTree;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode;
-import org.opendaylight.mdsal.binding.dom.codec.impl.DefaultBindingCodecTreeFactory;
-import org.opendaylight.mdsal.binding.generator.impl.DefaultBindingRuntimeGenerator;
-import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeContext;
-import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeGenerator;
-import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.ModulesState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.RevisionIdentifier;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.list.ModuleKey;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.util.BindingMap;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.model.parser.api.YangParserException;
-import org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl;
-
-public class LegacyYangLibraryFormatTest {
-
- private static final BindingRuntimeGenerator BINDING_RUNTIME_GENERATOR = new DefaultBindingRuntimeGenerator();
-
- private static final YangParserFactory YANG_PARSER_FACTORY = new YangParserFactoryImpl();
-
- private BindingRuntimeContext runtimeContext;
- private BindingCodecTree codecTree;
- private YangLibrarySupport yangLib;
-
- @Before
- public void setUp() throws YangParserException {
- runtimeContext = BindingRuntimeHelpers.createRuntimeContext();
- final DefaultBindingCodecTreeFactory codecFactory = new DefaultBindingCodecTreeFactory();
- yangLib = new YangLibrarySupport(YANG_PARSER_FACTORY, BINDING_RUNTIME_GENERATOR,
- codecFactory);
- codecTree = codecFactory.create(runtimeContext);
- }
+public class LegacyYangLibraryFormatTest extends AbstractYangLibraryTest {
@Test
public void testLegacyFormat() {
final BindingDataObjectCodecTreeNode<ModulesState> legacyCodec =
assertEquals(createControlModules(), modulesState.getModule());
}
- private Map<ModuleKey, Module> createControlModules() {
- final Map<ModuleKey, Module> modules = new HashMap<>();
- modules.put(new ModuleKey(new YangIdentifier("ietf-yang-library"),
- new Revision(new RevisionIdentifier("2019-01-04"))),
- createModule("ietf-yang-library", "urn:ietf:params:xml:ns:yang:ietf-yang-library", "2019-01-04"));
- modules.put(new ModuleKey(new YangIdentifier("ietf-inet-types"),
- new Revision(new RevisionIdentifier("2013-07-15"))),
- createModule("ietf-inet-types", "urn:ietf:params:xml:ns:yang:ietf-inet-types", "2013-07-15"));
- modules.put(new ModuleKey(new YangIdentifier("ietf-datastores"),
- new Revision(new RevisionIdentifier("2018-02-14"))),
- createModule("ietf-datastores", "urn:ietf:params:xml:ns:yang:ietf-datastores", "2018-02-14"));
- modules.put(new ModuleKey(new YangIdentifier("ietf-yang-types"),
- new Revision(new RevisionIdentifier("2013-07-15"))),
- createModule("ietf-yang-types", "urn:ietf:params:xml:ns:yang:ietf-yang-types", "2013-07-15"));
- return modules;
+ private static Map<ModuleKey, Module> createControlModules() {
+ return BindingMap.of(
+ createModule("ietf-yang-library", "urn:ietf:params:xml:ns:yang:ietf-yang-library", "2019-01-04"),
+ createModule("ietf-inet-types", "urn:ietf:params:xml:ns:yang:ietf-inet-types", "2013-07-15"),
+ createModule("ietf-datastores", "urn:ietf:params:xml:ns:yang:ietf-datastores", "2018-02-14"),
+ createModule("ietf-yang-types", "urn:ietf:params:xml:ns:yang:ietf-yang-types", "2013-07-15"));
}
private static Module createModule(final String name, final String namespace, final String revision) {
.setNamespace(new Uri(namespace))
.setRevision(new Revision(new RevisionIdentifier(revision)))
.setConformanceType(ConformanceType.Implement)
- .setFeature(Collections.emptyList())
+ .setFeature(Set.of())
.build();
}
}
\ No newline at end of file