4233ccccf638c38bb42c58f1eccc41841eb0d807
[appc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.appc.dg.netconf.impl;
25
26 import org.onap.appc.adapter.netconf.NetconfClient;
27 import org.onap.appc.adapter.netconf.NetconfConnectionDetails;
28 import org.onap.appc.exceptions.APPCException;
29
30
31 public class NetconfClientJschMock implements NetconfClient {
32
33     private boolean connection;
34     private String lastMessage;
35     private String answer = "answer";
36     private String configuration;
37     private NetconfConnectionDetails lastConnectionDetails;
38
39     public boolean isConnection() {
40         return connection;
41     }
42
43     public String getLastMessage() {
44         return lastMessage;
45     }
46
47     public String getAnswer() {
48         return answer;
49     }
50
51     public String getConf() {
52         return configuration;
53     }
54
55     public void setConf(String configuration) {
56         this.configuration = configuration;
57     }
58
59     public void setAnswer(String answer) {
60         this.answer = answer;
61     }
62
63     public NetconfConnectionDetails getLastConnectionDetails() {
64         return lastConnectionDetails;
65     }
66
67     @Override
68     public void connect(NetconfConnectionDetails connectionDetails) throws APPCException {
69         this.connection = true;
70         this.lastConnectionDetails = connectionDetails;
71
72     }
73
74     @Override
75     public String exchangeMessage(String message) throws APPCException {
76         if (connection) {
77             this.lastMessage = message;
78             return answer;
79         } else return null;
80     }
81
82     @Override
83     public void configure(String configuration) throws APPCException {
84         if (connection) {
85             this.configuration = configuration;
86         }
87
88     }
89
90     @Override
91     public String getConfiguration() throws APPCException {
92         if (connection) {
93             return configuration;
94         } else return null;
95     }
96
97     @Override
98     public void disconnect() throws APPCException {
99         this.connection = false;
100
101     }
102 }