re base code
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / path / ForwardingPathDeleteCITest.java
1 package org.openecomp.sdc.be.components.path;
2
3 import org.junit.Before;
4 import org.junit.Test;
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;
10
11 import java.util.HashMap;
12 import java.util.Map;
13 import java.util.Set;
14
15 import static org.junit.Assert.*;
16
17 public class ForwardingPathDeleteCITest {
18
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";
23
24     @Before
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<>();
33
34         forwardingPathElementListDataDefinition.add(
35             new ForwardingPathElementDataDefinition(nodeA, nodeB, "nodeAcpType", "nodeBcpType", "nodeDcpName",
36                 "nodeBcpName"));
37         forwardingPathElementListDataDefinition.add(
38             new ForwardingPathElementDataDefinition(nodeB, "nodeC", "nodeBcpType", "nodeCcpType", "nodeDcpName",
39                 "nodeBcpName"));
40         forwardingPathElementListDataDefinition.add(
41             new ForwardingPathElementDataDefinition("nodeC", "nodeD", "nodeCcpType", "nodeDcpType", "nodeDcpName",
42                 "nodeBcpName"));
43         forwardingPath.setPathElements(forwardingPathElementListDataDefinition);
44         Map<String, ForwardingPathDataDefinition> forwardingPaths = new HashMap<>();
45         forwardingPaths.put("NEW", forwardingPath);
46         service.setForwardingPaths(forwardingPaths);
47     }
48
49
50     @Test
51     public void getListToDelete() {
52
53         Set<String> forwardingPathNamesToDeleteOnComponenetInstanceDeletion = new ForwardingPathUtils()
54             .findForwardingPathNamesToDeleteOnComponentInstanceDeletion(service, nodeA);
55         assertEquals(1, forwardingPathNamesToDeleteOnComponenetInstanceDeletion.size());
56         assertTrue(forwardingPathNamesToDeleteOnComponenetInstanceDeletion.contains(fpName));
57
58         Set<String> forwardingPathNamesToDeleteOnCIDelete = new ForwardingPathUtils()
59             .findForwardingPathNamesToDeleteOnComponentInstanceDeletion(service, nodeB);
60         assertNotNull(forwardingPathNamesToDeleteOnCIDelete);
61         assertEquals(1, forwardingPathNamesToDeleteOnCIDelete.size());
62         assertTrue(forwardingPathNamesToDeleteOnComponenetInstanceDeletion.contains(fpName));
63
64         forwardingPathNamesToDeleteOnCIDelete = new ForwardingPathUtils()
65             .findForwardingPathNamesToDeleteOnComponentInstanceDeletion(service, "Does not exist");
66         assertNotNull(forwardingPathNamesToDeleteOnCIDelete);
67         assertEquals(0, forwardingPathNamesToDeleteOnCIDelete.size());
68         assertFalse(forwardingPathNamesToDeleteOnCIDelete.contains(fpName));
69     }
70
71 }