Migrate TestNG to Junit5
[sdc/sdc-tosca.git] / sdc-tosca / src / test / java / org / onap / sdc / impl / ToscaParserPolicyTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * sdc-tosca
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 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.onap.sdc.impl;
22
23 import static org.junit.jupiter.api.Assertions.assertEquals;
24 import static org.junit.jupiter.api.Assertions.assertNotNull;
25 import static org.junit.jupiter.api.Assertions.assertTrue;
26
27 import java.net.URL;
28 import java.util.List;
29 import org.junit.jupiter.api.BeforeAll;
30 import org.junit.jupiter.api.Test;
31 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
32 import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
33 import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
34 import org.onap.sdc.toscaparser.api.NodeTemplate;
35 import org.onap.sdc.toscaparser.api.Policy;
36
37 public class ToscaParserPolicyTest {
38
39     private static ISdcCsarHelper helper = null;
40
41     @BeforeAll
42     public static void setUpClass() {
43         try {
44             URL resource = GetEntityPortMirroringTest.class.getClassLoader()
45                 .getResource("csars/service-CgnatFwVnfNc-csar.csar");
46             if (resource != null) {
47                 helper = SdcToscaParserFactory.getInstance().getSdcCsarHelper(resource.getFile());
48             }
49
50         } catch (SdcToscaParserException e) {
51             e.printStackTrace();
52         }
53     }
54
55     @Test
56     public void getPolicyOfTargetByNodeTemplate() {
57         List<NodeTemplate> vfList = helper.getServiceVfList();
58         assertEquals(1, vfList.size());
59         List<Policy> policies = helper.getPoliciesOfTarget(vfList.get(0));
60         assertNotNull(policies);
61         assertTrue(policies.isEmpty());
62     }
63
64     @Test
65     public void getPolicyTargetFromOrigin() {
66         List<NodeTemplate> vfList = helper.getServiceVfList();
67         assertEquals(1, vfList.size());
68         List<NodeTemplate> targets = helper.getPolicyTargetsFromOrigin(vfList.get(0), "cgnatfwvnf_nc..External..0");
69         assertNotNull(targets);
70         assertTrue(targets.isEmpty());
71     }
72
73
74 }