2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.sdc.impl;
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;
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;
37 public class ToscaParserPolicyTest {
39 private static ISdcCsarHelper helper = null;
42 public static void setUpClass() {
44 URL resource = GetEntityPortMirroringTest.class.getClassLoader()
45 .getResource("csars/service-CgnatFwVnfNc-csar.csar");
46 if (resource != null) {
47 helper = SdcToscaParserFactory.getInstance().getSdcCsarHelper(resource.getFile());
50 } catch (SdcToscaParserException e) {
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());
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());