Second part of onap rename
[appc.git] / appc-inbound / appc-artifact-handler / provider / src / test / java / org / onap / appc / artifact / handler / node / MockArtifactHandlerNode.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.onap.appc.artifact.handler.node;
26
27 import org.json.JSONObject;
28 import org.onap.appc.artifact.handler.dbservices.MockDBService;
29 import org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants;
30 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
31
32 public class MockArtifactHandlerNode extends ArtifactHandlerNode {
33
34     @Override
35     public boolean updateStoreArtifacts(JSONObject request_information, JSONObject document_information)
36             throws Exception {
37         if (request_information != null && request_information.get("RequestInfo").equals("testupdateStoreArtifacts")) {
38             super.updateStoreArtifacts(request_information, document_information);
39         }
40         SvcLogicContext context = new SvcLogicContext();
41         MockDBService dbservice = MockDBService.initialise();
42         int intversion = 0;
43         context.setAttribute("artifact_name",
44                 document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME));
45         String internal_version = dbservice.getInternalVersionNumber(context,
46                 document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME), null);
47         if (internal_version != null) {
48             intversion = Integer.parseInt(internal_version);
49             intversion++;
50         }
51
52         return true;
53
54     }
55
56     @Override
57     public boolean storeReferenceData(JSONObject request_information, JSONObject document_information)
58             throws Exception {
59         if (request_information != null && request_information.get("RequestInfo").equals("testStoreReferenceData")) {
60             super.storeReferenceData(request_information, document_information);
61         }
62         return true;
63     }
64
65 }