Vidyashree Rama | 6160be1 | 2016-11-24 13:43:31 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Vidyashree Rama | 6160be1 | 2016-11-24 13:43:31 +0530 | [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 | |
| 17 | package org.onosproject.yms.app.yab; |
| 18 | |
| 19 | import org.onosproject.yms.app.ydt.YangRequestWorkBench; |
| 20 | import org.onosproject.yms.app.ysr.TestYangSchemaNodeProvider; |
| 21 | import org.onosproject.yms.app.ysr.YangSchemaRegistry; |
| 22 | import org.onosproject.yms.ych.YangCodecHandler; |
| 23 | import org.onosproject.yms.ych.YangDataTreeCodec; |
| 24 | import org.onosproject.yms.ych.YangProtocolEncodingFormat; |
| 25 | import org.onosproject.yms.ydt.YdtBuilder; |
| 26 | import org.onosproject.yms.ydt.YdtResponse; |
| 27 | import org.onosproject.yms.ydt.YdtWalker; |
| 28 | import org.onosproject.yms.ydt.YmsOperationType; |
| 29 | import org.onosproject.yms.ymsm.YmsService; |
| 30 | import org.onosproject.yms.ynh.YangNotificationService; |
| 31 | import org.onosproject.yms.ysr.YangModuleIdentifier; |
| 32 | import org.onosproject.yms.ysr.YangModuleLibrary; |
| 33 | |
| 34 | import java.util.List; |
| 35 | |
| 36 | /** |
| 37 | * Represents implementation of YANG application management system manager. |
| 38 | */ |
| 39 | public class MockYmsManager |
| 40 | implements YmsService { |
| 41 | |
| 42 | YangSchemaRegistry schemaRegistry; |
| 43 | TestYangSchemaNodeProvider testYangSchemaNodeProvider = |
| 44 | new TestYangSchemaNodeProvider(); |
| 45 | |
| 46 | @Override |
| 47 | public YdtBuilder getYdtBuilder(String logicalRootName, |
| 48 | String rootNamespace, |
| 49 | YmsOperationType operationType) { |
| 50 | testYangSchemaNodeProvider.processSchemaRegistry(new TestManager()); |
| 51 | schemaRegistry = testYangSchemaNodeProvider.getDefaultYangSchemaRegistry(); |
| 52 | return new YangRequestWorkBench(logicalRootName, rootNamespace, |
| 53 | operationType, schemaRegistry, false); |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public YdtBuilder getYdtBuilder(String logicalRootName, |
| 58 | String rootNamespace, |
| 59 | YmsOperationType operationType, |
| 60 | Object schemaRegistryForYdt) { |
| 61 | return null; |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public YdtWalker getYdtWalker() { |
| 66 | return null; |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public YdtResponse executeOperation(YdtBuilder operationRequest) { |
| 71 | YangApplicationBroker requestBroker = |
| 72 | new YangApplicationBroker(schemaRegistry); |
| 73 | switch (operationRequest.getYmsOperationType()) { |
| 74 | case EDIT_CONFIG_REQUEST: |
| 75 | try { |
| 76 | return requestBroker.processEdit(operationRequest); |
| 77 | } catch (CloneNotSupportedException e) { |
| 78 | } |
| 79 | break; |
| 80 | case QUERY_CONFIG_REQUEST: |
| 81 | case QUERY_REQUEST: |
| 82 | return requestBroker.processQuery(operationRequest); |
| 83 | case RPC_REQUEST: |
| 84 | return requestBroker.processOperation(operationRequest); |
| 85 | default: |
| 86 | } |
| 87 | return null; |
| 88 | } |
| 89 | |
| 90 | @Override |
| 91 | public YangNotificationService getYangNotificationService() { |
| 92 | return null; |
| 93 | } |
| 94 | |
| 95 | @Override |
| 96 | public void registerService(Object appManager, Class<?> yangService, |
| 97 | List<String> supportedFeatureList) { |
| 98 | } |
| 99 | |
| 100 | @Override |
| 101 | public void unRegisterService(Object appManager, Class<?> yangService) { |
| 102 | |
| 103 | } |
| 104 | |
| 105 | @Override |
| 106 | public YangModuleLibrary getYangModuleLibrary() { |
| 107 | return null; |
| 108 | } |
| 109 | |
| 110 | @Override |
| 111 | public String getYangFile(YangModuleIdentifier moduleIdentifier) { |
| 112 | return null; |
| 113 | } |
| 114 | |
| 115 | @Override |
| 116 | public void registerDefaultCodec(YangDataTreeCodec defaultCodec, |
| 117 | YangProtocolEncodingFormat dataFormat) { |
| 118 | } |
| 119 | |
| 120 | @Override |
| 121 | public YangCodecHandler getYangCodecHandler() { |
| 122 | return null; |
| 123 | } |
| 124 | } |