2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.asdc.client.test.emulators;
23 import java.io.IOException;
24 import java.io.InputStream;
25 import java.util.HashMap;
28 import org.onap.sdc.api.notification.IStatusData;
29 import org.onap.sdc.utils.DistributionStatusEnum;
31 import com.fasterxml.jackson.annotation.JsonAnySetter;
32 import com.fasterxml.jackson.annotation.JsonIgnore;
33 import com.fasterxml.jackson.databind.ObjectMapper;
36 public class JsonStatusData implements IStatusData {
39 private static ObjectMapper mapper = new ObjectMapper();
42 private Map<String,Object> attributesMap = new HashMap<>();
44 public JsonStatusData() {
49 public String getErrorReason(){
54 public String getDistributionID(){
55 //return (String)this.attributesMap.get("distributionID");
56 return "35120a87-1f82-4276-9735-f6de5a244d65";
60 public String getConsumerID(){
61 //return (String)this.attributesMap.get("consumerID");
66 public String getComponentName(){
67 //return (String)this.attributesMap.get("componentName");
72 public Long getTimestamp(){
73 //return (String)this.attributesMap.get("timestamp");
78 public String getArtifactURL(){
79 //return (String)this.attributesMap.get("artifactURL");
80 return "/sdc/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml";
84 public DistributionStatusEnum getStatus(){
85 //return (DistributionStatusEnum)this.attributesMap.get(DistributionStatusEnum.DEPLOY_OK);
86 return DistributionStatusEnum.COMPONENT_DONE_OK;
90 * Method instantiate a INotificationData implementation from a JSON file.
92 * @param notifFilePath The file path in String
93 * @return A JsonNotificationData instance
94 * @throws IOException in case of the file is not readable or not accessible
96 public static JsonStatusData instantiateNotifFromJsonFile(String notifFilePath) throws IOException {
98 InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(notifFilePath + "status-structure.json");
100 //String fileLocation = System.getProperty("mso.config.path") + "notif-structure.json";
102 //String source = fileLocation;
103 //InputStream is = IOUtils.toInputStream(source, "UTF-8");
105 //String myString = IOUtils.toString(is, "UTF-8");
108 //System.out.println(myString);
111 //throw new FileExistsException("Resource Path does not exist: "+notifFilePath);
113 return mapper.readValue(is, JsonStatusData.class);
116 @SuppressWarnings("unused")
118 public final void setAttribute(String attrName, Object attrValue) {
119 if ((null != attrName) && (!attrName.isEmpty()) && (null != attrValue) && (null != attrValue.toString())) {
120 this.attributesMap.put(attrName,attrValue);