1 package org.openecomp.sdc.be.components.path;
3 import org.junit.Before;
5 import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
6 import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefinition;
7 import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
8 import org.openecomp.sdc.be.impl.ForwardingPathUtils;
9 import org.openecomp.sdc.be.model.Service;
11 import java.util.HashMap;
15 import static org.junit.Assert.*;
17 public class ForwardingPathDeleteCITest {
19 private Service service;
20 private static final String nodeA = "nodeA";
21 private static final String nodeB = "nodeB";
22 private static final String fpName = "fpName";
25 public void initService() {
26 service = new Service();
27 ForwardingPathDataDefinition forwardingPath = new ForwardingPathDataDefinition(fpName);
28 String protocol = "protocol";
29 forwardingPath.setProtocol(protocol);
30 forwardingPath.setDestinationPortNumber("DestinationPortNumber");
31 ListDataDefinition<ForwardingPathElementDataDefinition> forwardingPathElementListDataDefinition
32 = new ListDataDefinition<>();
34 forwardingPathElementListDataDefinition.add(
35 new ForwardingPathElementDataDefinition(nodeA, nodeB, "nodeAcpType", "nodeBcpType", "nodeDcpName",
37 forwardingPathElementListDataDefinition.add(
38 new ForwardingPathElementDataDefinition(nodeB, "nodeC", "nodeBcpType", "nodeCcpType", "nodeDcpName",
40 forwardingPathElementListDataDefinition.add(
41 new ForwardingPathElementDataDefinition("nodeC", "nodeD", "nodeCcpType", "nodeDcpType", "nodeDcpName",
43 forwardingPath.setPathElements(forwardingPathElementListDataDefinition);
44 Map<String, ForwardingPathDataDefinition> forwardingPaths = new HashMap<>();
45 forwardingPaths.put("NEW", forwardingPath);
46 service.setForwardingPaths(forwardingPaths);
51 public void getListToDelete() {
53 Set<String> forwardingPathNamesToDeleteOnComponenetInstanceDeletion = new ForwardingPathUtils()
54 .findForwardingPathNamesToDeleteOnComponentInstanceDeletion(service, nodeA);
55 assertEquals(1, forwardingPathNamesToDeleteOnComponenetInstanceDeletion.size());
56 assertTrue(forwardingPathNamesToDeleteOnComponenetInstanceDeletion.contains(fpName));
58 Set<String> forwardingPathNamesToDeleteOnCIDelete = new ForwardingPathUtils()
59 .findForwardingPathNamesToDeleteOnComponentInstanceDeletion(service, nodeB);
60 assertNotNull(forwardingPathNamesToDeleteOnCIDelete);
61 assertEquals(1, forwardingPathNamesToDeleteOnCIDelete.size());
62 assertTrue(forwardingPathNamesToDeleteOnComponenetInstanceDeletion.contains(fpName));
64 forwardingPathNamesToDeleteOnCIDelete = new ForwardingPathUtils()
65 .findForwardingPathNamesToDeleteOnComponentInstanceDeletion(service, "Does not exist");
66 assertNotNull(forwardingPathNamesToDeleteOnCIDelete);
67 assertEquals(0, forwardingPathNamesToDeleteOnCIDelete.size());
68 assertFalse(forwardingPathNamesToDeleteOnCIDelete.contains(fpName));