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