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;
23 import static org.mockito.ArgumentMatchers.any;
24 import static org.mockito.ArgumentMatchers.eq;
25 import static org.mockito.Mockito.doThrow;
26 import static org.mockito.Mockito.when;
27 import org.camunda.bpm.engine.delegate.BpmnError;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.mockito.ArgumentMatchers;
31 import org.mockito.InjectMocks;
32 import org.onap.so.bpmn.BaseTaskTest;
33 import org.onap.so.bpmn.common.BuildingBlockExecution;
34 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
35 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
36 import org.onap.so.client.exception.BBObjectNotFoundException;
37 import org.onap.so.db.catalog.beans.OrchestrationStatus;
39 public class AssignNetworkTest extends BaseTaskTest {
42 private AssignNetwork assignNetwork = new AssignNetwork();
44 private L3Network network;
47 public void before() throws BBObjectNotFoundException {
48 network = setL3Network();
49 doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
50 .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
51 when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
55 public void networkNotFoundTest() throws Exception {
56 // network status to PRECREATED - when it was NOT found by name
58 network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
59 } catch (BBObjectNotFoundException e) {
62 network.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
63 boolean networkFound = assignNetwork.networkFoundByName(execution);
64 assertEquals(false, networkFound);
68 public void networkFoundTest() throws Exception {
70 network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
71 } catch (BBObjectNotFoundException e) {
73 boolean networkFound = assignNetwork.networkFoundByName(execution);
74 assertEquals(true, networkFound);