3abc2e7a623dc73ff18c9f2872038381fbdfab28
[so.git] / asdc-controller / src / test / java / org / onap / so / asdc / util / ASDCNotificationLoggingTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.so.asdc.util;
22
23 import static org.junit.Assert.assertTrue;
24
25 import java.util.ArrayList;
26 import java.util.List;
27
28 import org.junit.Test;
29 import org.onap.sdc.api.notification.IArtifactInfo;
30 import org.onap.sdc.api.notification.INotificationData;
31 import org.onap.sdc.api.notification.IResourceInstance;
32 import org.onap.so.asdc.installer.IVfModuleData;
33 import org.onap.so.asdc.installer.VfModuleMetaData;
34 import org.onap.so.asdc.util.ASDCNotificationLogging;
35
36 public class ASDCNotificationLoggingTest {
37         @Test
38         public void dumpASDCNotificationTestForNull() throws Exception {
39                 INotificationData asdcNotification = iNotificationDataObject();
40
41                 String result = ASDCNotificationLogging.dumpASDCNotification(asdcNotification);
42
43                 assertTrue(!result.equalsIgnoreCase("NULL"));
44         }
45
46         private INotificationData iNotificationDataObject() {
47                 INotificationData iNotification = new INotificationData() {
48
49                         @Override
50                         public String getServiceVersion() {
51                                 return "DistributionID";
52                         }
53
54                         @Override
55                         public String getServiceUUID() {
56                                 return "12343254";
57                         }
58
59                         @Override
60                         public String getServiceName() {
61                                 return "servername";
62                         }
63
64                         @Override
65                         public String getServiceInvariantUUID() {
66                                 return "ServiceInvariantUUID";
67                         }
68
69                         @Override
70                         public String getServiceDescription() {
71                                 return "Description";
72                         }
73
74                         @Override
75                         public List<IArtifactInfo> getServiceArtifacts() {
76                                 return new ArrayList();
77                         }
78
79                         @Override
80                         public List<IResourceInstance> getResources() {
81                                 return new ArrayList();
82                         }
83
84                         @Override
85                         public String getDistributionID() {
86                                 return "23434";
87                         }
88
89                         @Override
90                         public IArtifactInfo getArtifactMetadataByUUID(String arg0) {
91                                 return null;
92                         }
93
94                         @Override
95                         public String getWorkloadContext() {
96                                 // TODO Auto-generated method stub
97                                 return null;
98                         }
99
100                         @Override
101                         public void setWorkloadContext(String arg0) {
102                                 // TODO Auto-generated method stub
103                                 
104                         }
105                 };
106                 return iNotification;
107         }
108
109         @Test
110         public void dumpASDCNotificationTest() throws Exception {
111                 INotificationData asdcNotification = iNotificationDataObject();
112                 String result = ASDCNotificationLogging.dumpASDCNotification(asdcNotification);
113
114                 assertTrue(!result.equalsIgnoreCase("NULL"));
115         }
116
117         @Test
118         public void dumpVfModuleMetaDataListTest() {
119                 INotificationData asdcNotification = iNotificationDataObject();
120                 List<IVfModuleData> list = new ArrayList<>();
121                 list.add(new VfModuleMetaData());
122                 String result = null;
123                 try {
124                         result = ASDCNotificationLogging.dumpVfModuleMetaDataList(list);
125                 } catch (Exception e) {
126                 }
127
128                 assertTrue(result == null);
129
130         }
131
132         public IArtifactInfo getIArtifactInfo() {
133                 return new IArtifactInfo() {
134
135                         @Override
136                         public List<IArtifactInfo> getRelatedArtifacts() {
137                                 return null;
138                         }
139
140                         @Override
141                         public IArtifactInfo getGeneratedArtifact() {
142                                 return null;
143                         }
144
145                         @Override
146                         public String getArtifactVersion() {
147                                 return "version";
148                         }
149
150                         @Override
151                         public String getArtifactUUID() {
152                                 return "123";
153                         }
154
155                         @Override
156                         public String getArtifactURL() {
157                                 return "url";
158                         }
159
160                         @Override
161                         public String getArtifactType() {
162                                 return "type";
163                         }
164
165                         @Override
166                         public Integer getArtifactTimeout() {
167                                 return 12;
168                         }
169
170                         @Override
171                         public String getArtifactName() {
172                                 return "name";
173                         }
174
175                         @Override
176                         public String getArtifactDescription() {
177                                 return "desc";
178                         }
179
180                         @Override
181                         public String getArtifactChecksum() {
182                                 return "true";
183                         }
184                 };
185         }
186 }