301eafd6b9d59017f7452cf85117511e0fda8788
[appc.git] / appc-dg / appc-dg-shared / appc-dg-netconf / src / test / java / org / openecomp / appc / dg / netconf / impl / NetconfClientJschMock.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 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  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.openecomp.appc.dg.netconf.impl;
26
27 import org.openecomp.appc.adapter.netconf.NetconfClient;
28 import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
29 import org.openecomp.appc.exceptions.APPCException;
30
31
32 public class NetconfClientJschMock implements NetconfClient {
33
34     private boolean connection;
35     private String lastMessage;
36     private String answer = "answer";
37     private String configuration;
38     private NetconfConnectionDetails lastConnectionDetails;
39
40     public boolean isConnection() {
41         return connection;
42     }
43
44     public String getLastMessage() {
45         return lastMessage;
46     }
47
48     public String getAnswer() {
49         return answer;
50     }
51
52     public String getConf() {
53         return configuration;
54     }
55
56     public void setConf(String configuration) {
57         this.configuration = configuration;
58     }
59
60     public void setAnswer(String answer) {
61         this.answer = answer;
62     }
63
64     public NetconfConnectionDetails getLastConnectionDetails() {
65         return lastConnectionDetails;
66     }
67
68     @Override
69     public void connect(NetconfConnectionDetails connectionDetails) throws APPCException {
70         this.connection = true;
71         this.lastConnectionDetails = connectionDetails;
72
73     }
74
75     @Override
76     public String exchangeMessage(String message) throws APPCException {
77         if (connection) {
78             this.lastMessage = message;
79             return answer;
80         } else return null;
81     }
82
83     @Override
84     public void configure(String configuration) throws APPCException {
85         if (connection) {
86             this.configuration = configuration;
87         }
88
89     }
90
91     @Override
92     public String getConfiguration() throws APPCException {
93         if (connection) {
94             return configuration;
95         } else return null;
96     }
97
98     @Override
99     public void disconnect() throws APPCException {
100         this.connection = false;
101
102     }
103 }