2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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=========================================================
20 package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
22 import static org.junit.Assert.assertEquals;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.onap.so.bpmn.BaseTaskTest;
27 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
28 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
29 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
30 import org.onap.so.client.exception.BBObjectNotFoundException;
31 import org.onap.so.db.catalog.beans.OrchestrationStatus;
32 import org.springframework.beans.factory.annotation.Autowired;
34 public class AssignNetworkTest extends BaseTaskTest {
37 private AssignNetwork assignNetwork;
39 private ServiceInstance serviceInstance;
40 private L3Network network;
43 public void before() {
44 serviceInstance = setServiceInstance();
45 network = setL3Network();
49 public void hasCollectionTest() throws Exception {
51 //collection present by default base test setup
52 boolean hasCollection = assignNetwork.hasCollection(execution);
53 assertEquals(true, hasCollection);
55 boolean skip = assignNetwork.skipNetworkCreationInAAI(execution);
56 assertEquals(false, skip);
60 public void hasNoCollectionTest() throws Exception {
63 serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
64 } catch(BBObjectNotFoundException e) {
65 serviceInstance = setServiceInstance();
67 serviceInstance.setCollection(null);
68 boolean hasCollection = assignNetwork.hasCollection(execution);
69 assertEquals(false, hasCollection);
71 boolean skip = assignNetwork.skipNetworkCreationInAAI(execution);
72 assertEquals(true, skip);
76 public void hasNoCollectionNoNetworkTest() throws Exception {
77 //clear collection and updated network status to PRECREATED - when it was NOT found by name
79 serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
80 network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID,execution.getLookupMap().get(ResourceKey.NETWORK_ID));
81 } catch(BBObjectNotFoundException e) {
82 serviceInstance = setServiceInstance();
84 serviceInstance.setCollection(null);
85 network.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
86 boolean hasCollection = assignNetwork.hasCollection(execution);
87 boolean networkFound = assignNetwork.networkFoundByName(execution);
88 assertEquals(false, hasCollection);
89 assertEquals(false, networkFound);
91 boolean skip = assignNetwork.skipNetworkCreationInAAI(execution);
92 assertEquals(true, skip);
96 public void hasNetworkNoCollectionTest() throws Exception {
97 //clear collection and updated network status to INVENTORIED - when it was found by name
99 serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
100 network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID,execution.getLookupMap().get(ResourceKey.NETWORK_ID));
101 } catch(BBObjectNotFoundException e) {
102 serviceInstance = setServiceInstance();
104 serviceInstance.setCollection(null);
105 network.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
106 boolean hasCollection = assignNetwork.hasCollection(execution);
107 boolean networkFound = assignNetwork.networkFoundByName(execution);
108 assertEquals(false, hasCollection);
109 assertEquals(true, networkFound);
111 boolean skip = assignNetwork.skipNetworkCreationInAAI(execution);
112 assertEquals(true, skip);