90511033dd82275cce5019a44cfc219159469d0e
[so.git] / packages / arquillian-unit-tests / src / test / java / org / openecomp / mso / global_tests / asdc / notif_emulator / JsonArtifactInfo.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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.openecomp.mso.global_tests.asdc.notif_emulator;
22 import java.util.HashMap;
23 import java.util.LinkedList;
24 import java.util.List;
25 import java.util.Map;
26
27 import org.codehaus.jackson.annotate.JsonAnySetter;
28 import org.codehaus.jackson.annotate.JsonIgnore;
29
30 import org.openecomp.sdc.api.notification.IArtifactInfo;
31
32 public class JsonArtifactInfo implements IArtifactInfo {
33
34         @JsonIgnore
35         private Map<String,IArtifactInfo> artifactsMapByUUID = new HashMap<>();
36         
37         @JsonIgnore
38         private Map<String,Object> attributesMap = new HashMap<>();
39         
40         public JsonArtifactInfo() {
41                 
42         }
43         
44         public synchronized void addArtifactToUUIDMap (List<JsonArtifactInfo> artifactList) {
45                 for (JsonArtifactInfo artifact:artifactList) {
46                         artifactsMapByUUID.put(artifact.getArtifactUUID(), artifact);   
47                 }
48                 
49         }
50         
51         @SuppressWarnings("unused")
52         @JsonAnySetter
53         public final void setAttribute(String attrName, Object attrValue) {
54                 if ((null != attrName) && (!attrName.isEmpty()) && (null != attrValue) && (null != attrValue.toString())) {
55                         this.attributesMap.put(attrName,attrValue);
56                 }
57         }
58         
59         
60         
61         public Map<String, IArtifactInfo> getArtifactsMapByUUID() {
62                 return artifactsMapByUUID;
63         }
64
65         @Override
66         public String getArtifactChecksum() {
67                 return (String)attributesMap.get("artifactCheckSum");
68         }
69
70         @Override
71         public String getArtifactDescription() {
72                 return (String)attributesMap.get("artifactDescription");
73         }
74
75         @Override
76         public String getArtifactName() {
77                 return (String)attributesMap.get("artifactName");
78         }
79
80         @Override
81         public Integer getArtifactTimeout() {
82                 return (Integer)attributesMap.get("artifactTimeout");
83         }
84
85         @Override
86         public String getArtifactType() {
87                 return (String)attributesMap.get("artifactType");
88         }
89
90         @Override
91         public String getArtifactURL() {
92                 return (String)attributesMap.get("artifactURL");
93         }
94
95         @Override
96         public String getArtifactUUID() {
97                 return (String)attributesMap.get("artifactUUID");
98         }
99
100         @Override
101         public String getArtifactVersion() {
102                 return (String)attributesMap.get("artifactVersion");
103         }
104
105         @Override
106         public IArtifactInfo getGeneratedArtifact () {
107                 return artifactsMapByUUID.get(attributesMap.get("generatedArtifact"));
108         }
109
110         @Override
111         public List<IArtifactInfo> getRelatedArtifacts() {
112                 List<IArtifactInfo> listArtifacts = new LinkedList<>();
113                 List<String> uuidList = (List<String>)attributesMap.get("relatedArtifact");
114                 if (uuidList != null) {
115                         for(String uuid:uuidList) {
116                                 listArtifacts.add(artifactsMapByUUID.get(uuid));
117                         }
118                 }
119                 return listArtifacts;
120         }
121
122 }