re base code
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / path / ForwardingPathRenameNodeTest.java
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openecomp.sdc.be.components.path;
18
19 import static org.junit.Assert.assertEquals;
20 import static org.junit.Assert.assertFalse;
21 import static org.junit.Assert.assertTrue;
22
23 import com.google.common.collect.Sets;
24 import java.util.Set;
25 import java.util.UUID;
26 import org.junit.Test;
27 import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
28 import org.openecomp.sdc.be.impl.ForwardingPathUtils;
29
30 public class ForwardingPathRenameNodeTest implements ForwardingPathTestUtils{
31
32     @Test
33     public void renameNodeA(){
34         ForwardingPathUtils forwardingPathUtils = new ForwardingPathUtils();
35         ForwardingPathDataDefinition path = createPath("testPath", "http", "8080", UUID.randomUUID().toString());
36         assertTrue(forwardingPathUtils.shouldRenameCI(path, "nodeA"));
37         assertTrue(forwardingPathUtils.shouldRenameCI(path, "nodeB"));
38         Set<ForwardingPathDataDefinition> updated = forwardingPathUtils.updateComponentInstanceName(Sets.newHashSet(path),"nodeA", "nodeAA");
39         assertEquals(1, updated.size());
40         ForwardingPathDataDefinition updatedPath = updated.iterator().next();
41         assertFalse(forwardingPathUtils.shouldRenameCI(updatedPath, "nodeA"));
42         assertTrue(forwardingPathUtils.shouldRenameCI(updatedPath, "nodeB"));
43     }
44
45     @Test
46     public void cannotRename(){
47         ForwardingPathUtils forwardingPathUtils = new ForwardingPathUtils();
48         ForwardingPathDataDefinition path = createPath("testPath", "http", "8080", UUID.randomUUID().toString());
49         assertTrue(forwardingPathUtils.shouldRenameCI(path, "nodeA"));
50         assertTrue(forwardingPathUtils.shouldRenameCI(path, "nodeB"));
51         Set<ForwardingPathDataDefinition> updated = forwardingPathUtils.updateComponentInstanceName(Sets.newHashSet(path),"nodeAA", "nodeAAA");
52         assertEquals(0, updated.size());
53     }
54 }