Moving all files to root directory
[appc.git] / appc-dg / appc-dg-shared / appc-dg-netconf / src / test / java / org / openecomp / appc / dg / netconf / impl / DAOServiceMock.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 java.util.HashMap;
25
26 import org.openecomp.appc.adapter.netconf.ConnectionDetails;
27 import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
28 import org.openecomp.appc.adapter.netconf.NetconfDataAccessService;
29 import org.openecomp.appc.adapter.netconf.exception.DataAccessException;
30 import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
31
32 class DAOServiceMock implements NetconfDataAccessService {
33
34     private String configFile;
35     private ConnectionDetails connection;
36     private HashMap<String, String> backupConf;
37
38     @Override
39     public void setSchema(String schema) {
40     }
41
42     @Override
43     public void setDbLibService(DbLibService dbLibService) {
44     }
45
46     void setConfigFile(String configFile) {
47         this.configFile = configFile;
48     }
49
50     public HashMap<String, String> getBackupConf() {
51         return backupConf;
52     }
53
54     public void setConnection(ConnectionDetails connection) {
55         this.connection = connection;
56     }
57
58     @Override
59     public String retrieveConfigFileName(String xmlID) throws DataAccessException {
60         if (!xmlID.equals("wrong")) {
61             return configFile;
62         } else {
63             throw new DataAccessException();
64         }
65     }
66
67     @Override
68     public boolean retrieveConnectionDetails(String vnfType, ConnectionDetails connectionDetails) throws
69                     DataAccessException {
70         return false;
71     }
72
73     @Override
74     public boolean retrieveNetconfConnectionDetails(String vnfType, NetconfConnectionDetails connectionDetails) throws
75                     DataAccessException {
76         if (vnfType.equals("VNF")) {
77             connectionDetails.setHost(connection.getHost());
78             connectionDetails.setPassword(connection.getPassword());
79             connectionDetails.setPort(connection.getPort());
80             connectionDetails.setUsername(connection.getUsername());
81
82             return true;
83         } else {
84             return false;
85         }
86     }
87
88     @Override
89     public boolean logDeviceInteraction(String instanceId, String requestId, String creationDate, String logText) throws
90                     DataAccessException {
91         this.backupConf = new HashMap<>();
92         backupConf.put("creationDate", creationDate);
93         backupConf.put("logText", logText);
94         return true;
95     }
96
97 }