6e5bd314d8e2ed6d0f5e19ea69ecc3a39f5bb3f9
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / bpmn / infrastructure / flowspecific / tasks / AssignNetworkTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20 package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
21
22 import static org.junit.Assert.assertEquals;
23
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.entities.ResourceKey;
29 import org.onap.so.client.exception.BBObjectNotFoundException;
30 import org.onap.so.db.catalog.beans.OrchestrationStatus;
31 import org.springframework.beans.factory.annotation.Autowired;
32
33 public class AssignNetworkTest extends BaseTaskTest {
34         
35         @Autowired
36         private AssignNetwork assignNetwork;
37         
38         private L3Network network;
39         
40         @Before
41         public void before() {
42                 network = setL3Network();
43         }
44         
45         @Test
46         public void networkNotFoundTest() throws Exception {
47                 //network status to PRECREATED - when it was NOT found by name
48                 try {
49                         network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID,execution.getLookupMap().get(ResourceKey.NETWORK_ID));
50                 } catch(BBObjectNotFoundException e) {
51                 }
52                 
53                 network.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
54                 boolean networkFound = assignNetwork.networkFoundByName(execution);
55                 assertEquals(false, networkFound);
56         }
57
58         @Test
59         public void networkFoundTest() throws Exception {
60                 try {
61                         network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID,execution.getLookupMap().get(ResourceKey.NETWORK_ID));
62                 } catch(BBObjectNotFoundException e) {
63                 }
64                 boolean networkFound = assignNetwork.networkFoundByName(execution);
65                 assertEquals(true, networkFound);
66         }
67 }