Search in sources :

Example 1 with BindingCodecContext

use of org.opendaylight.mdsal.binding.dom.codec.impl.BindingCodecContext in project mdsal by opendaylight.

the class CurrentAdapterSerializerTest method fromNormalizedNode.

private static Entry<InstanceIdentifier<?>, DataObject> fromNormalizedNode(final NormalizedNode data, final EffectiveModelContext schemaCtx) {
    final CurrentAdapterSerializer codec = new CurrentAdapterSerializer(new BindingCodecContext(new DefaultBindingRuntimeContext(new DefaultBindingRuntimeGenerator().generateTypeMapping(schemaCtx), TestingModuleInfoSnapshot.INSTANCE)));
    final YangInstanceIdentifier path = YangInstanceIdentifier.create(NodeIdentifier.create(QName.create("urn:test", "2017-01-01", "cont")));
    return codec.fromNormalizedNode(path, data);
}
Also used : BindingCodecContext(org.opendaylight.mdsal.binding.dom.codec.impl.BindingCodecContext) DefaultBindingRuntimeGenerator(org.opendaylight.mdsal.binding.generator.impl.DefaultBindingRuntimeGenerator) DefaultBindingRuntimeContext(org.opendaylight.mdsal.binding.runtime.api.DefaultBindingRuntimeContext) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 2 with BindingCodecContext

use of org.opendaylight.mdsal.binding.dom.codec.impl.BindingCodecContext in project lighty-netconf-simulator by PANTHEONtech.

the class NetconfDeviceServicesImpl method createAdapterContext.

private AdapterContext createAdapterContext(Collection<YangModuleInfo> moduleInfos) {
    final YangParserFactory yangParserFactory = new DefaultYangParserFactory();
    ModuleInfoSnapshotResolver snapshotResolver = new ModuleInfoSnapshotResolver("netconf-simulator", yangParserFactory);
    snapshotResolver.registerModuleInfos(moduleInfos);
    ModuleInfoSnapshot moduleInfoSnapshot = snapshotResolver.takeSnapshot();
    final BindingRuntimeGenerator bindingRuntimeGenerator = new DefaultBindingRuntimeGenerator();
    final BindingRuntimeTypes bindingRuntimeTypes = bindingRuntimeGenerator.generateTypeMapping(moduleInfoSnapshot.getEffectiveModelContext());
    final DefaultBindingRuntimeContext bindingRuntimeContext = new DefaultBindingRuntimeContext(bindingRuntimeTypes, moduleInfoSnapshot);
    final BindingCodecContext bindingCodecContext = new BindingCodecContext(bindingRuntimeContext);
    return new ConstantAdapterContext(bindingCodecContext);
}
Also used : ModuleInfoSnapshot(org.opendaylight.mdsal.binding.runtime.api.ModuleInfoSnapshot) ConstantAdapterContext(org.opendaylight.mdsal.binding.dom.adapter.ConstantAdapterContext) DefaultBindingRuntimeGenerator(org.opendaylight.mdsal.binding.generator.impl.DefaultBindingRuntimeGenerator) BindingCodecContext(org.opendaylight.mdsal.binding.dom.codec.impl.BindingCodecContext) BindingRuntimeTypes(org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeTypes) DefaultYangParserFactory(org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory) ModuleInfoSnapshotResolver(org.opendaylight.mdsal.binding.runtime.spi.ModuleInfoSnapshotResolver) DefaultBindingRuntimeContext(org.opendaylight.mdsal.binding.runtime.api.DefaultBindingRuntimeContext) YangParserFactory(org.opendaylight.yangtools.yang.parser.api.YangParserFactory) DefaultYangParserFactory(org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory) DefaultBindingRuntimeGenerator(org.opendaylight.mdsal.binding.generator.impl.DefaultBindingRuntimeGenerator) BindingRuntimeGenerator(org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeGenerator)

Example 3 with BindingCodecContext

use of org.opendaylight.mdsal.binding.dom.codec.impl.BindingCodecContext in project mdsal by opendaylight.

the class ActionLookupTest method testActionPath.

@Test
public void testActionPath() {
    CurrentAdapterSerializer codec = new CurrentAdapterSerializer(new BindingCodecContext(BindingRuntimeHelpers.createRuntimeContext()));
    assertEquals(Absolute.of(Cont.QNAME, Foo.QNAME), codec.getActionPath(ActionSpec.builder(Cont.class).build(Foo.class)));
    assertEquals(Absolute.of(Grpcont.QNAME, Bar.QNAME), codec.getActionPath(ActionSpec.builder(Grpcont.class).build(Bar.class)));
    assertEquals(Absolute.of(Othercont.QNAME, Bar.QNAME), codec.getActionPath(ActionSpec.builder(Othercont.class).build(org.opendaylight.yang.gen.v1.urn.odl.actions.norev.othercont.Bar.class)));
    assertEquals(Absolute.of(Nestedcont.QNAME, Baz.QNAME, Bar.QNAME), codec.getActionPath(ActionSpec.builder(Nestedcont.class).withPathChild(Baz.class).build(org.opendaylight.yang.gen.v1.urn.odl.actions.norev.nested.baz.Bar.class)));
    assertEquals(Absolute.of(Lstio.QNAME, Fooio.QNAME), codec.getActionPath(ActionSpec.builder(Lstio.class).build(Fooio.class)));
    assertEquals(Absolute.of(Grplst.QNAME, Bar.QNAME), codec.getActionPath(ActionSpec.builder(Grplst.class).build(org.opendaylight.yang.gen.v1.urn.odl.actions.norev.grplst.Bar.class)));
}
Also used : BindingCodecContext(org.opendaylight.mdsal.binding.dom.codec.impl.BindingCodecContext) Grplst(org.opendaylight.yang.gen.v1.urn.odl.actions.norev.Grplst) Grpcont(org.opendaylight.yang.gen.v1.urn.odl.actions.norev.Grpcont) Cont(org.opendaylight.yang.gen.v1.urn.odl.actions.norev.Cont) Lstio(org.opendaylight.yang.gen.v1.urn.odl.actions.norev.Lstio) Baz(org.opendaylight.yang.gen.v1.urn.odl.actions.norev.nested.Baz) Othercont(org.opendaylight.yang.gen.v1.urn.odl.actions.norev.Othercont) Test(org.junit.Test)

Aggregations

BindingCodecContext (org.opendaylight.mdsal.binding.dom.codec.impl.BindingCodecContext)3 DefaultBindingRuntimeGenerator (org.opendaylight.mdsal.binding.generator.impl.DefaultBindingRuntimeGenerator)2 DefaultBindingRuntimeContext (org.opendaylight.mdsal.binding.runtime.api.DefaultBindingRuntimeContext)2 Test (org.junit.Test)1 ConstantAdapterContext (org.opendaylight.mdsal.binding.dom.adapter.ConstantAdapterContext)1 BindingRuntimeGenerator (org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeGenerator)1 BindingRuntimeTypes (org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeTypes)1 ModuleInfoSnapshot (org.opendaylight.mdsal.binding.runtime.api.ModuleInfoSnapshot)1 ModuleInfoSnapshotResolver (org.opendaylight.mdsal.binding.runtime.spi.ModuleInfoSnapshotResolver)1 Cont (org.opendaylight.yang.gen.v1.urn.odl.actions.norev.Cont)1 Grpcont (org.opendaylight.yang.gen.v1.urn.odl.actions.norev.Grpcont)1 Grplst (org.opendaylight.yang.gen.v1.urn.odl.actions.norev.Grplst)1 Lstio (org.opendaylight.yang.gen.v1.urn.odl.actions.norev.Lstio)1 Othercont (org.opendaylight.yang.gen.v1.urn.odl.actions.norev.Othercont)1 Baz (org.opendaylight.yang.gen.v1.urn.odl.actions.norev.nested.Baz)1 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)1 YangParserFactory (org.opendaylight.yangtools.yang.parser.api.YangParserFactory)1 DefaultYangParserFactory (org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory)1