Initial TCA commit into DCAEGEN2
[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     final String tcaVESCEFResponseJsonFileLocation = "data/json/facade/tca_ves_cef_response.json";
35
36
37     @Test
38     public void testTCAPolicyJsonConversions() throws Exception {
39
40         final TCAVESResponse vesCEFMessageResponse =
41                 assertJsonConversions(tcaVESCEFResponseJsonFileLocation, TCAVESResponse.class);
42
43         assertThat("VES CEF Message Response AAI generics VNF Id must match",
44                 vesCEFMessageResponse.getAai().getGenericVNFId(), is("vpp-test(?)"));
45
46         assertThat("VES CEF Message target type must be parsed correctly as VNF",
47                 vesCEFMessageResponse.getTargetType(), is("VNF"));
48
49         assertThat("VES closed Loop Name must be CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8",
50                 vesCEFMessageResponse.getClosedLoopControlName(),
51                 is("CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8"));
52
53         assertThat("version must be 1.0.2", vesCEFMessageResponse.getVersion(), is("1.0.2"));
54
55         assertThat("closedLoopAlarmStart must be 1478189220547",
56                 vesCEFMessageResponse.getClosedLoopAlarmStart(), is(1478189220547L));
57         assertThat("closedLoopEventClient must be tca.instance00001",
58                 vesCEFMessageResponse.getClosedLoopEventClient(), is("tca.instance00001"));
59         assertThat("target_type must be VNF", vesCEFMessageResponse.getTargetType(), is("VNF"));
60         assertThat("target must be VNF", vesCEFMessageResponse.getTarget(), is("generic-vnf.vnf-id"));
61         assertThat("aai generic vnf id must be vpp-test(?)", vesCEFMessageResponse.getAai().getGenericVNFId(),
62                 is("vpp-test(?)"));
63         assertThat("from must be DCAE", vesCEFMessageResponse.getFrom(), is("DCAE"));
64         assertThat("policyScope must be resource=vFirewall;type=configuration",
65                 vesCEFMessageResponse.getPolicyScope(), is("resource=vFirewall;type=configuration"));
66
67         assertThat("policyName must be configuration.dcae.microservice.tca.xml",
68                 vesCEFMessageResponse.getPolicyName(), is("configuration.dcae.microservice.tca.xml"));
69
70         assertThat("policyVersion must be v0.0.1",
71                 vesCEFMessageResponse.getPolicyVersion(), is("v0.0.1"));
72
73         assertThat("closedLoopEventStatus is ONSET",
74                 vesCEFMessageResponse.getClosedLoopEventStatus(), is("ONSET"));
75
76     }
77
78 }