b857d0cc04fdf976713b618aa693c0a87cd87b58
[sdc.git] /
1 /*
2  * Copyright © 2020 Samsung
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openecomp.core.enrichment.types;
18
19 import static org.hamcrest.CoreMatchers.isA;
20 import static org.hamcrest.CoreMatchers.is;
21 import static org.hamcrest.MatcherAssert.assertThat;
22
23 import java.util.HashMap;
24 import java.util.Map;
25 import mockit.Deencapsulation;
26 import org.junit.Test;
27
28 public class ComponentMonitoringUploadInfoTest {
29
30     @Test
31     public void testGetSnmpTrap() {
32         ComponentMonitoringUploadInfo uploadInfo = new ComponentMonitoringUploadInfo();
33         setInternals(uploadInfo);
34
35         assertThat(uploadInfo.getSnmpTrap(), isA(MonitoringArtifactInfo.class));
36     }
37
38     @Test
39     public void testGetSnmpPoll() {
40         ComponentMonitoringUploadInfo uploadInfo = new ComponentMonitoringUploadInfo();
41         setInternals(uploadInfo);
42
43         assertThat(uploadInfo.getSnmpPoll(), isA(MonitoringArtifactInfo.class));
44     }
45
46     @Test
47     public void testGetVesEvent() {
48         ComponentMonitoringUploadInfo uploadInfo = new ComponentMonitoringUploadInfo();
49         setInternals(uploadInfo);
50
51         assertThat(uploadInfo.getVesEvent(), isA(MonitoringArtifactInfo.class));
52     }
53
54     @Test
55     public void testSetMonitoringArtifactFile() {
56         ComponentMonitoringUploadInfo uploadInfo = new ComponentMonitoringUploadInfo();
57
58         uploadInfo.setMonitoringArtifactFile(MonitoringUploadType.SNMP_POLL, new MonitoringArtifactInfo());
59
60         assertThat(getInternal(uploadInfo).containsKey(MonitoringUploadType.SNMP_POLL), is(true));
61     }
62
63     private Map<MonitoringUploadType, MonitoringArtifactInfo> getInternal(ComponentMonitoringUploadInfo componentMonitoringUploadInfo) {
64         return Deencapsulation.getField(componentMonitoringUploadInfo, "infoByType");
65     }
66
67     private void setInternals(ComponentMonitoringUploadInfo componentMonitoringUploadInfo) {
68         Map<MonitoringUploadType, MonitoringArtifactInfo> infoMap = new HashMap<>();
69         infoMap.put(MonitoringUploadType.SNMP_POLL, new MonitoringArtifactInfo());
70         infoMap.put(MonitoringUploadType.SNMP_TRAP, new MonitoringArtifactInfo());
71         infoMap.put(MonitoringUploadType.VES_EVENTS, new MonitoringArtifactInfo());
72         Deencapsulation.setField(componentMonitoringUploadInfo, "infoByType", infoMap);
73     }
74 }