2 * Copyright © 2020 Samsung
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.openecomp.core.enrichment.types;
19 import static org.hamcrest.CoreMatchers.isA;
20 import static org.hamcrest.CoreMatchers.is;
21 import static org.hamcrest.MatcherAssert.assertThat;
23 import java.util.HashMap;
25 import mockit.Deencapsulation;
26 import org.junit.Test;
28 public class ComponentMonitoringUploadInfoTest {
31 public void testGetSnmpTrap() {
32 ComponentMonitoringUploadInfo uploadInfo = new ComponentMonitoringUploadInfo();
33 setInternals(uploadInfo);
35 assertThat(uploadInfo.getSnmpTrap(), isA(MonitoringArtifactInfo.class));
39 public void testGetSnmpPoll() {
40 ComponentMonitoringUploadInfo uploadInfo = new ComponentMonitoringUploadInfo();
41 setInternals(uploadInfo);
43 assertThat(uploadInfo.getSnmpPoll(), isA(MonitoringArtifactInfo.class));
47 public void testGetVesEvent() {
48 ComponentMonitoringUploadInfo uploadInfo = new ComponentMonitoringUploadInfo();
49 setInternals(uploadInfo);
51 assertThat(uploadInfo.getVesEvent(), isA(MonitoringArtifactInfo.class));
55 public void testSetMonitoringArtifactFile() {
56 ComponentMonitoringUploadInfo uploadInfo = new ComponentMonitoringUploadInfo();
58 uploadInfo.setMonitoringArtifactFile(MonitoringUploadType.SNMP_POLL, new MonitoringArtifactInfo());
60 assertThat(getInternal(uploadInfo).containsKey(MonitoringUploadType.SNMP_POLL), is(true));
63 private Map<MonitoringUploadType, MonitoringArtifactInfo> getInternal(ComponentMonitoringUploadInfo componentMonitoringUploadInfo) {
64 return Deencapsulation.getField(componentMonitoringUploadInfo, "infoByType");
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);