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);
}
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);
}
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)));
}
Aggregations