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;
27 import org.onap.sdc.api.notification.IStatusData;
28 import org.onap.sdc.utils.DistributionStatusEnum;
29 import com.fasterxml.jackson.annotation.JsonAnySetter;
30 import com.fasterxml.jackson.annotation.JsonIgnore;
31 import com.fasterxml.jackson.databind.ObjectMapper;
34 public class JsonStatusData implements IStatusData {
37 private static ObjectMapper mapper = new ObjectMapper();
40 private Map<String, Object> attributesMap = new HashMap<>();
42 public JsonStatusData() {
47 public String getErrorReason() {
52 public String getDistributionID() {
53 // return (String)this.attributesMap.get("distributionID");
54 return "35120a87-1f82-4276-9735-f6de5a244d65";
58 public String getConsumerID() {
59 // return (String)this.attributesMap.get("consumerID");
64 public String getComponentName() {
65 // return (String)this.attributesMap.get("componentName");
70 public Long getTimestamp() {
71 // return (String)this.attributesMap.get("timestamp");
76 public String getArtifactURL() {
77 // return (String)this.attributesMap.get("artifactURL");
78 return "/sdc/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml";
82 public DistributionStatusEnum getStatus() {
83 // return (DistributionStatusEnum)this.attributesMap.get(DistributionStatusEnum.DEPLOY_OK);
84 return DistributionStatusEnum.COMPONENT_DONE_OK;
88 * Method instantiate a INotificationData implementation from a JSON file.
90 * @param notifFilePath The file path in String
91 * @return A JsonNotificationData instance
92 * @throws IOException in case of the file is not readable or not accessible
94 public static JsonStatusData instantiateNotifFromJsonFile(String notifFilePath) throws IOException {
96 InputStream is = Thread.currentThread().getContextClassLoader()
97 .getResourceAsStream(notifFilePath + "status-structure.json");
99 // String fileLocation = System.getProperty("mso.config.path") + "notif-structure.json";
101 // String source = fileLocation;
102 // InputStream is = IOUtils.toInputStream(source, "UTF-8");
104 // String myString = IOUtils.toString(is, "UTF-8");
107 // System.out.println(myString);
110 // throw new FileExistsException("Resource Path does not exist: "+notifFilePath);
112 return mapper.readValue(is, JsonStatusData.class);
115 @SuppressWarnings("unused")
117 public final void setAttribute(String attrName, Object attrValue) {
118 if ((null != attrName) && (!attrName.isEmpty()) && (null != attrValue) && (null != attrValue.toString())) {
119 this.attributesMap.put(attrName, attrValue);