Sean Condon | 06613e9 | 2017-06-09 15:14:01 +0100 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Sean Condon | 06613e9 | 2017-06-09 15:14:01 +0100 | [diff] [blame] | 3 | * |
| 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 | */ |
| 16 | package org.onosproject.yang.serializers.xml; |
| 17 | |
Sean Condon | d911af9 | 2017-07-19 18:05:27 +0100 | [diff] [blame] | 18 | import org.onosproject.yang.MockMicrosemiRegistrator; |
Sean Condon | cf2751f | 2017-11-28 17:29:30 +0000 | [diff] [blame] | 19 | import org.onosproject.yang.MockYangRegistrator; |
Sean Condon | 06613e9 | 2017-06-09 15:14:01 +0100 | [diff] [blame] | 20 | import org.onosproject.yang.model.SchemaContext; |
| 21 | import org.onosproject.yang.runtime.Annotation; |
| 22 | import org.onosproject.yang.runtime.DefaultAnnotation; |
| 23 | import org.onosproject.yang.runtime.YangSerializerContext; |
| 24 | import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry; |
| 25 | |
Yuta HIGUCHI | 8dee145 | 2018-05-02 19:09:04 -0700 | [diff] [blame^] | 26 | import com.google.common.base.Supplier; |
| 27 | import com.google.common.base.Suppliers; |
| 28 | |
Sean Condon | 06613e9 | 2017-06-09 15:14:01 +0100 | [diff] [blame] | 29 | import java.util.LinkedList; |
| 30 | import java.util.List; |
| 31 | |
| 32 | public class MockYangSerializerContext implements YangSerializerContext { |
| 33 | |
Sean Condon | cf2751f | 2017-11-28 17:29:30 +0000 | [diff] [blame] | 34 | private static MockYangRegistrator schemaProviderYang = |
| 35 | new MockYangRegistrator(); |
Yuta HIGUCHI | 8dee145 | 2018-05-02 19:09:04 -0700 | [diff] [blame^] | 36 | |
| 37 | private static Supplier<MockMicrosemiRegistrator> schemaProviderMicrosemi = |
| 38 | Suppliers.memoize(() -> { |
| 39 | MockMicrosemiRegistrator r = new MockMicrosemiRegistrator(); |
| 40 | r.addAppInfo(schemaProviderYang.getAppInfo()); |
| 41 | r.activate(); |
| 42 | return r; |
| 43 | }); |
| 44 | |
Sean Condon | 06613e9 | 2017-06-09 15:14:01 +0100 | [diff] [blame] | 45 | private static final String NETCONF_NS = |
| 46 | "urn:ietf:params:xml:ns:netconf:base:1.0"; |
| 47 | private static final String XMNLS_NC = "xmlns:xc"; |
| 48 | |
Sean Condon | d911af9 | 2017-07-19 18:05:27 +0100 | [diff] [blame] | 49 | public MockYangSerializerContext() { |
Sean Condon | d911af9 | 2017-07-19 18:05:27 +0100 | [diff] [blame] | 50 | } |
Sean Condon | 06613e9 | 2017-06-09 15:14:01 +0100 | [diff] [blame] | 51 | |
| 52 | @Override |
| 53 | public SchemaContext getContext() { |
Yuta HIGUCHI | 8dee145 | 2018-05-02 19:09:04 -0700 | [diff] [blame^] | 54 | DefaultYangModelRegistry registry = (DefaultYangModelRegistry) schemaProviderMicrosemi.get().registry(); |
Sean Condon | 06613e9 | 2017-06-09 15:14:01 +0100 | [diff] [blame] | 55 | return registry; |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public List<Annotation> getProtocolAnnotations() { |
| 60 | Annotation annotation = new DefaultAnnotation(XMNLS_NC, NETCONF_NS); |
| 61 | List<Annotation> protocolAnnotation = new LinkedList<>(); |
| 62 | protocolAnnotation.add(annotation); |
| 63 | return protocolAnnotation; |
| 64 | } |
| 65 | } |