blob: bb931f0459804a6e64a1a3177a8d613a1fb6d316 [file] [log] [blame]
Sean Condon06613e92017-06-09 15:14:01 +01001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Sean Condon06613e92017-06-09 15:14:01 +01003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.yang.serializers.xml;
17
Sean Condond911af92017-07-19 18:05:27 +010018import org.onosproject.yang.MockMicrosemiRegistrator;
Sean Condoncf2751f2017-11-28 17:29:30 +000019import org.onosproject.yang.MockYangRegistrator;
Sean Condon06613e92017-06-09 15:14:01 +010020import org.onosproject.yang.model.SchemaContext;
21import org.onosproject.yang.runtime.Annotation;
22import org.onosproject.yang.runtime.DefaultAnnotation;
23import org.onosproject.yang.runtime.YangSerializerContext;
24import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
25
26import java.util.LinkedList;
27import java.util.List;
28
29public class MockYangSerializerContext implements YangSerializerContext {
30
Sean Condoncf2751f2017-11-28 17:29:30 +000031 private static MockMicrosemiRegistrator schemaProviderMicrosemi =
Sean Condond911af92017-07-19 18:05:27 +010032 new MockMicrosemiRegistrator();
Sean Condoncf2751f2017-11-28 17:29:30 +000033 private static MockYangRegistrator schemaProviderYang =
34 new MockYangRegistrator();
Sean Condon06613e92017-06-09 15:14:01 +010035 private static final String NETCONF_NS =
36 "urn:ietf:params:xml:ns:netconf:base:1.0";
37 private static final String XMNLS_NC = "xmlns:xc";
38
Sean Condond911af92017-07-19 18:05:27 +010039 public MockYangSerializerContext() {
Sean Condoncf2751f2017-11-28 17:29:30 +000040 schemaProviderMicrosemi.addAppInfo(schemaProviderYang.getAppInfo());
41 schemaProviderMicrosemi.activate();
Sean Condond911af92017-07-19 18:05:27 +010042 }
Sean Condon06613e92017-06-09 15:14:01 +010043
44 @Override
45 public SchemaContext getContext() {
Sean Condoncf2751f2017-11-28 17:29:30 +000046 DefaultYangModelRegistry registry = (DefaultYangModelRegistry) schemaProviderMicrosemi.registry();
Sean Condon06613e92017-06-09 15:14:01 +010047 return registry;
48 }
49
50 @Override
51 public List<Annotation> getProtocolAnnotations() {
52 Annotation annotation = new DefaultAnnotation(XMNLS_NC, NETCONF_NS);
53 List<Annotation> protocolAnnotation = new LinkedList<>();
54 protocolAnnotation.add(annotation);
55 return protocolAnnotation;
56 }
57}