2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 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.openecomp.sdc.be.components.path;
23 import org.junit.jupiter.api.BeforeEach;
24 import org.junit.jupiter.api.Test;
25 import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
26 import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefinition;
27 import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
28 import org.openecomp.sdc.be.impl.ForwardingPathUtils;
29 import org.openecomp.sdc.be.model.Service;
31 import java.util.HashMap;
35 import static org.junit.Assert.assertEquals;
36 import static org.junit.Assert.assertFalse;
37 import static org.junit.Assert.assertNotNull;
38 import static org.junit.Assert.assertTrue;
40 public class ForwardingPathDeleteCITest {
42 private Service service;
43 private static final String nodeA = "nodeA";
44 private static final String nodeB = "nodeB";
45 private static final String fpName = "fpName";
48 public void initService() {
49 service = new Service();
50 ForwardingPathDataDefinition forwardingPath = new ForwardingPathDataDefinition(fpName);
51 String protocol = "protocol";
52 forwardingPath.setProtocol(protocol);
53 forwardingPath.setDestinationPortNumber("DestinationPortNumber");
54 ListDataDefinition<ForwardingPathElementDataDefinition> forwardingPathElementListDataDefinition
55 = new ListDataDefinition<>();
57 forwardingPathElementListDataDefinition.add(
58 new ForwardingPathElementDataDefinition(nodeA, nodeB, "nodeAcpType", "nodeBcpType", "nodeDcpName",
60 forwardingPathElementListDataDefinition.add(
61 new ForwardingPathElementDataDefinition(nodeB, "nodeC", "nodeBcpType", "nodeCcpType", "nodeDcpName",
63 forwardingPathElementListDataDefinition.add(
64 new ForwardingPathElementDataDefinition("nodeC", "nodeD", "nodeCcpType", "nodeDcpType", "nodeDcpName",
66 forwardingPath.setPathElements(forwardingPathElementListDataDefinition);
67 Map<String, ForwardingPathDataDefinition> forwardingPaths = new HashMap<>();
68 forwardingPaths.put("NEW", forwardingPath);
69 service.setForwardingPaths(forwardingPaths);
74 public void getListToDelete() {
76 Set<String> forwardingPathNamesToDeleteOnComponenetInstanceDeletion = new ForwardingPathUtils()
77 .findForwardingPathNamesToDeleteOnComponentInstanceDeletion(service, nodeA);
78 assertEquals(1, forwardingPathNamesToDeleteOnComponenetInstanceDeletion.size());
79 assertTrue(forwardingPathNamesToDeleteOnComponenetInstanceDeletion.contains(fpName));
81 Set<String> forwardingPathNamesToDeleteOnCIDelete = new ForwardingPathUtils()
82 .findForwardingPathNamesToDeleteOnComponentInstanceDeletion(service, nodeB);
83 assertNotNull(forwardingPathNamesToDeleteOnCIDelete);
84 assertEquals(1, forwardingPathNamesToDeleteOnCIDelete.size());
85 assertTrue(forwardingPathNamesToDeleteOnComponenetInstanceDeletion.contains(fpName));
87 forwardingPathNamesToDeleteOnCIDelete = new ForwardingPathUtils()
88 .findForwardingPathNamesToDeleteOnComponentInstanceDeletion(service, "Does not exist");
89 assertNotNull(forwardingPathNamesToDeleteOnCIDelete);
90 assertEquals(0, forwardingPathNamesToDeleteOnCIDelete.size());
91 assertFalse(forwardingPathNamesToDeleteOnCIDelete.contains(fpName));