2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.be.components.path;
23 import org.javatuples.Pair;
24 import org.junit.jupiter.api.Test;
25 import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
26 import org.openecomp.sdc.be.impl.ForwardingPathUtils;
28 import java.util.HashMap;
32 import static org.junit.Assert.assertEquals;
33 import static org.junit.Assert.assertNotNull;
34 public class ForwardingPathChangeVersionTest extends BaseForwardingPathVersionChangeTest {
38 public void updateForwardingPath() {
39 Pair<Map<String, ForwardingPathDataDefinition>, Map<String, ForwardingPathDataDefinition>> pair = new ForwardingPathUtils()
40 .updateForwardingPathOnVersionChange(service,dataHolder,newNodeAC, newNodeA);
41 Map<String, ForwardingPathDataDefinition> updated = pair.getValue0();
42 assertNotNull(updated);
43 assertEquals(1, updated.size());
44 assertEquals(newNodeA, updated.values().iterator().next().getPathElements().getListToscaDataDefinition().get(0).getFromNode());
45 Map<String, ForwardingPathDataDefinition> deleted = pair.getValue1();
46 assertNotNull(deleted);
47 assertEquals(0, deleted.size());
51 public void deleteForwardingPath(){
52 newNodeAC.setCapabilities(new HashMap<>());
53 Pair<Map<String, ForwardingPathDataDefinition>, Map<String, ForwardingPathDataDefinition>> pair = new ForwardingPathUtils()
54 .updateForwardingPathOnVersionChange(service,dataHolder,newNodeAC, newNodeA);
55 Map<String, ForwardingPathDataDefinition> updated = pair.getValue0();
56 assertNotNull(updated);
57 assertEquals(0, updated.size());
59 Map<String, ForwardingPathDataDefinition> deleted = pair.getValue1();
60 assertNotNull(deleted);
61 assertEquals(1, deleted.size());
62 assertEquals(FPId, deleted.keySet().stream().findAny().get());
66 public void fetchPathsToBeDeletedZeroPaths(){
67 Set<String> data=new ForwardingPathUtils().getForwardingPathsToBeDeletedOnVersionChange(service,
68 dataHolder,newNodeAC);
69 assertEquals(0,data.size());
73 public void fetchPathsToBeDeleted(){
74 Set<String> data=new ForwardingPathUtils().getForwardingPathsToBeDeletedOnVersionChange(service,
75 dataHolder,newNodeWithoutCapability);
76 assertEquals(1,data.size());