38dde6558ae328b61ec05ddf6d14d2c58d832444
[dcaegen2/analytics/tca.git] / dcae-analytics-model / src / test / java / org / openecomp / dcae / apod / analytics / model / facade / tca / TCAVESResponseTest.java
1 /*
2  * ===============================LICENSE_START======================================
3  *  dcae-analytics
4  * ================================================================================
5  *    Copyright © 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.dcae.apod.analytics.model.facade.tca;
22
23 import org.junit.Test;
24 import org.openecomp.dcae.apod.analytics.model.BaseAnalyticsModelUnitTest;
25
26 import static org.hamcrest.CoreMatchers.is;
27 import static org.junit.Assert.assertThat;
28
29 /**
30  * @author Rajiv Singla . Creation Date: 12/16/2016.
31  */
32 public class TCAVESResponseTest extends BaseAnalyticsModelUnitTest {
33
34     private static final String TCA_VES_CEF_RESPONSE_JSON_FILE_LOCATION = "data/json/facade/tca_ves_cef_response.json";
35
36     @Test
37     public void testTCAPolicyJsonConversions() throws Exception {
38
39         final TCAVESResponse vesCEFMessageResponse =
40             assertJsonConversions(TCA_VES_CEF_RESPONSE_JSON_FILE_LOCATION, TCAVESResponse.class);
41
42         assertThat("VES CEF Message Response AAI generics VNF Id must match",
43                 vesCEFMessageResponse.getAai().getGenericVNFId(), is("vpp-test(?)"));
44
45         assertThat("VES CEF Message target type must be parsed correctly as VNF",
46                 vesCEFMessageResponse.getTargetType(), is("VNF"));
47
48         assertThat("VES closed Loop Name must be CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8",
49                 vesCEFMessageResponse.getClosedLoopControlName(),
50                 is("CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8"));
51
52         assertThat("version must be 1.0.2", vesCEFMessageResponse.getVersion(), is("1.0.2"));
53
54         assertThat("closedLoopAlarmStart must be 1478189220547",
55                 vesCEFMessageResponse.getClosedLoopAlarmStart(), is(1478189220547L));
56         assertThat("closedLoopEventClient must be tca.instance00001",
57                 vesCEFMessageResponse.getClosedLoopEventClient(), is("tca.instance00001"));
58         assertThat("target_type must be VNF", vesCEFMessageResponse.getTargetType(), is("VNF"));
59         assertThat("target must be VNF", vesCEFMessageResponse.getTarget(), is("generic-vnf.vnf-id"));
60         assertThat("aai generic vnf id must be vpp-test(?)", vesCEFMessageResponse.getAai().getGenericVNFId(),
61                 is("vpp-test(?)"));
62         assertThat("from must be DCAE", vesCEFMessageResponse.getFrom(), is("DCAE"));
63         assertThat("policyScope must be resource=vFirewall;type=configuration",
64                 vesCEFMessageResponse.getPolicyScope(), is("resource=vFirewall;type=configuration"));
65
66         assertThat("policyName must be configuration.dcae.microservice.tca.xml",
67                 vesCEFMessageResponse.getPolicyName(), is("configuration.dcae.microservice.tca.xml"));
68
69         assertThat("policyVersion must be v0.0.1",
70                 vesCEFMessageResponse.getPolicyVersion(), is("v0.0.1"));
71
72         assertThat("closedLoopEventStatus is ONSET",
73                 vesCEFMessageResponse.getClosedLoopEventStatus(), is("ONSET"));
74
75     }
76 }