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.Before;
24 import org.junit.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.*;
37 public class ForwardingPathDeleteCITest {
39 private Service service;
40 private static final String nodeA = "nodeA";
41 private static final String nodeB = "nodeB";
42 private static final String fpName = "fpName";
45 public void initService() {
46 service = new Service();
47 ForwardingPathDataDefinition forwardingPath = new ForwardingPathDataDefinition(fpName);
48 String protocol = "protocol";
49 forwardingPath.setProtocol(protocol);
50 forwardingPath.setDestinationPortNumber("DestinationPortNumber");
51 ListDataDefinition<ForwardingPathElementDataDefinition> forwardingPathElementListDataDefinition
52 = new ListDataDefinition<>();
54 forwardingPathElementListDataDefinition.add(
55 new ForwardingPathElementDataDefinition(nodeA, nodeB, "nodeAcpType", "nodeBcpType", "nodeDcpName",
57 forwardingPathElementListDataDefinition.add(
58 new ForwardingPathElementDataDefinition(nodeB, "nodeC", "nodeBcpType", "nodeCcpType", "nodeDcpName",
60 forwardingPathElementListDataDefinition.add(
61 new ForwardingPathElementDataDefinition("nodeC", "nodeD", "nodeCcpType", "nodeDcpType", "nodeDcpName",
63 forwardingPath.setPathElements(forwardingPathElementListDataDefinition);
64 Map<String, ForwardingPathDataDefinition> forwardingPaths = new HashMap<>();
65 forwardingPaths.put("NEW", forwardingPath);
66 service.setForwardingPaths(forwardingPaths);
71 public void getListToDelete() {
73 Set<String> forwardingPathNamesToDeleteOnComponenetInstanceDeletion = new ForwardingPathUtils()
74 .findForwardingPathNamesToDeleteOnComponentInstanceDeletion(service, nodeA);
75 assertEquals(1, forwardingPathNamesToDeleteOnComponenetInstanceDeletion.size());
76 assertTrue(forwardingPathNamesToDeleteOnComponenetInstanceDeletion.contains(fpName));
78 Set<String> forwardingPathNamesToDeleteOnCIDelete = new ForwardingPathUtils()
79 .findForwardingPathNamesToDeleteOnComponentInstanceDeletion(service, nodeB);
80 assertNotNull(forwardingPathNamesToDeleteOnCIDelete);
81 assertEquals(1, forwardingPathNamesToDeleteOnCIDelete.size());
82 assertTrue(forwardingPathNamesToDeleteOnComponenetInstanceDeletion.contains(fpName));
84 forwardingPathNamesToDeleteOnCIDelete = new ForwardingPathUtils()
85 .findForwardingPathNamesToDeleteOnComponentInstanceDeletion(service, "Does not exist");
86 assertNotNull(forwardingPathNamesToDeleteOnCIDelete);
87 assertEquals(0, forwardingPathNamesToDeleteOnCIDelete.size());
88 assertFalse(forwardingPathNamesToDeleteOnCIDelete.contains(fpName));