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.assertEquals;
16 import static org.junit.Assert.assertFalse;
17 import static org.junit.Assert.assertNotNull;
18 import static org.junit.Assert.assertTrue;
20 public class ForwardingPathDeleteCITest {
22 private Service service;
23 private static final String nodeA = "nodeA";
24 private static final String nodeB = "nodeB";
25 private static final String fpName = "fpName";
28 public void initService() {
29 service = new Service();
30 ForwardingPathDataDefinition forwardingPath = new ForwardingPathDataDefinition(fpName);
31 String protocol = "protocol";
32 forwardingPath.setProtocol(protocol);
33 forwardingPath.setDestinationPortNumber("DestinationPortNumber");
34 ListDataDefinition<ForwardingPathElementDataDefinition> forwardingPathElementListDataDefinition
35 = new ListDataDefinition<>();
37 forwardingPathElementListDataDefinition.add(
38 new ForwardingPathElementDataDefinition(nodeA, nodeB, "nodeAcpType", "nodeBcpType", "nodeDcpName",
40 forwardingPathElementListDataDefinition.add(
41 new ForwardingPathElementDataDefinition(nodeB, "nodeC", "nodeBcpType", "nodeCcpType", "nodeDcpName",
43 forwardingPathElementListDataDefinition.add(
44 new ForwardingPathElementDataDefinition("nodeC", "nodeD", "nodeCcpType", "nodeDcpType", "nodeDcpName",
46 forwardingPath.setPathElements(forwardingPathElementListDataDefinition);
47 Map<String, ForwardingPathDataDefinition> forwardingPaths = new HashMap<>();
48 forwardingPaths.put("NEW", forwardingPath);
49 service.setForwardingPaths(forwardingPaths);
54 public void getListToDelete() {
56 Set<String> forwardingPathNamesToDeleteOnComponenetInstanceDeletion = new ForwardingPathUtils()
57 .findForwardingPathNamesToDeleteOnComponentInstanceDeletion(service, nodeA);
58 assertEquals(1, forwardingPathNamesToDeleteOnComponenetInstanceDeletion.size());
59 assertTrue(forwardingPathNamesToDeleteOnComponenetInstanceDeletion.contains(fpName));
61 Set<String> forwardingPathNamesToDeleteOnCIDelete = new ForwardingPathUtils()
62 .findForwardingPathNamesToDeleteOnComponentInstanceDeletion(service, nodeB);
63 assertNotNull(forwardingPathNamesToDeleteOnCIDelete);
64 assertEquals(1, forwardingPathNamesToDeleteOnCIDelete.size());
65 assertTrue(forwardingPathNamesToDeleteOnComponenetInstanceDeletion.contains(fpName));
67 forwardingPathNamesToDeleteOnCIDelete = new ForwardingPathUtils()
68 .findForwardingPathNamesToDeleteOnComponentInstanceDeletion(service, "Does not exist");
69 assertNotNull(forwardingPathNamesToDeleteOnCIDelete);
70 assertEquals(0, forwardingPathNamesToDeleteOnCIDelete.size());
71 assertFalse(forwardingPathNamesToDeleteOnCIDelete.contains(fpName));