2 * Copyright © 2016-2018 European Support Limited
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.openecomp.sdc.be.components.path;
19 import com.google.common.collect.Sets;
20 import org.junit.jupiter.api.Test;
21 import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
22 import org.openecomp.sdc.be.impl.ForwardingPathUtils;
25 import java.util.UUID;
27 import static org.junit.Assert.assertEquals;
28 import static org.junit.Assert.assertFalse;
29 import static org.junit.Assert.assertTrue;
31 public class ForwardingPathRenameNodeTest implements ForwardingPathTestUtils{
34 public void renameNodeA(){
35 ForwardingPathUtils forwardingPathUtils = new ForwardingPathUtils();
36 ForwardingPathDataDefinition path = createPath("testPath", "http", "8080", UUID.randomUUID().toString());
37 assertTrue(forwardingPathUtils.shouldRenameCI(path, "nodeA"));
38 assertTrue(forwardingPathUtils.shouldRenameCI(path, "nodeB"));
39 Set<ForwardingPathDataDefinition> updated = forwardingPathUtils.updateComponentInstanceName(Sets.newHashSet(path),"nodeA", "nodeAA");
40 assertEquals(1, updated.size());
41 ForwardingPathDataDefinition updatedPath = updated.iterator().next();
42 assertFalse(forwardingPathUtils.shouldRenameCI(updatedPath, "nodeA"));
43 assertTrue(forwardingPathUtils.shouldRenameCI(updatedPath, "nodeB"));
47 public void cannotRename(){
48 ForwardingPathUtils forwardingPathUtils = new ForwardingPathUtils();
49 ForwardingPathDataDefinition path = createPath("testPath", "http", "8080", UUID.randomUUID().toString());
50 assertTrue(forwardingPathUtils.shouldRenameCI(path, "nodeA"));
51 assertTrue(forwardingPathUtils.shouldRenameCI(path, "nodeB"));
52 Set<ForwardingPathDataDefinition> updated = forwardingPathUtils.updateComponentInstanceName(Sets.newHashSet(path),"nodeAA", "nodeAAA");
53 assertEquals(0, updated.size());