aeea98a97ded489291f9c3f0c9716ac349b76b3a
[appc.git] / appc-directed-graph / appc-dgraph / provider / src / test / java / org / onap / appc / dg / mock / instance / MockSvcLogicJavaPlugin.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APP-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property.  All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.appc.dg.mock.instance;
22
23 import java.io.FileNotFoundException;
24 import java.io.IOException;
25 import java.util.Map;
26
27 import org.apache.commons.lang.StringUtils;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30
31 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
32 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
33 import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
34
35 public class MockSvcLogicJavaPlugin implements SvcLogicJavaPlugin{
36     private final static Logger logger = LoggerFactory.getLogger(MockSvcLogicJavaPlugin.class);
37     public static String INPUT_PARAM_RESPONSE_PREFIX = "responsePrefix";
38     public static String OUTPUT_STATUS_SUCCESS = "success";
39     public static String OUTPUT_STATUS_FAILURE = "failure";
40     public static String OUTPUT_PARAM_STATUS = "status";
41
42
43     public void mountDevice(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException{
44         logger.info("Executed MountDevice Plugin");
45     }
46
47     public void downloadDeviceConfiguration(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException{
48         ctx.setAttribute("downloadStatus", "success");
49         logger.info("Executed Download Device Configuration Plugin");
50         throw new SvcLogicException("failed in Download..");
51     }
52
53     public void getCommonConfigInfo(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException, FileNotFoundException, IOException {
54         logger.info("Mock getCommonConfigInfo Called....");
55     }
56
57     public void getConfigFileReference(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
58         logger.info("Mock getConfigFileReference Called....");
59     }
60
61     public void getTemplate(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
62         logger.info("Mock getTemplate Called....");
63     }
64
65     public void saveConfigFiles(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
66         logger.info("Mock saveConfigFiles called...");
67     }
68
69     public void updateUploadConfig(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
70         logger.info("Mock updateUploadConfig called...");
71     }
72
73     public void savePrepareRelationship(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
74         logger.info("Mock savePrepareRelationship called...");
75     }
76
77     public void saveConfigBlock(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
78         logger.info("Mock saveConfigBlock called...");
79
80         if (StringUtils.isBlank(ctx.getAttribute("configuration-params"))) {
81             logger.info("No params...");
82             ctx.setAttribute("file-category", "device_configuration");
83             ctx.setAttribute("deviceconfig-file-content", "deviceConfig");
84         } else {
85             logger.info("Config params exist...");
86             ctx.setAttribute("file-category", "device_configuration");
87             ctx.setAttribute("file-category1", "configuration_block");
88             ctx.setAttribute("file-category2", "config_data");
89         }
90     }
91
92     public void saveTemplateConfig(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
93         logger.info("Mock saveTemplateConfig called...");
94
95         if (StringUtils.isBlank(ctx.getAttribute("configuration-params"))) {
96             logger.info("No params...");
97             ctx.setAttribute("file-category", "device_configuration");
98             ctx.setAttribute("deviceconfig-file-content", "deviceConfig");
99
100         } else {
101             logger.info("Config params exist...");
102             ctx.setAttribute("file-category", "device_configuration");
103             ctx.setAttribute("file-category1", "config_data");
104         }
105     }
106 }