Merge "Corrected hibernate for cfvc customization table"
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / bpmn / infrastructure / audit / AuditTasksTest.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.audit;
21
22 import static com.shazam.shazamcrest.MatcherAssert.assertThat;
23 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
24 import static org.mockito.ArgumentMatchers.any;
25 import static org.mockito.Mockito.when;
26
27 import org.junit.Before;
28 import org.junit.Rule;
29 import org.junit.Test;
30 import org.junit.rules.ExpectedException;
31 import org.mockito.ArgumentMatchers;
32 import org.mockito.InjectMocks;
33 import org.onap.so.audit.beans.AuditInventory;
34 import org.onap.so.bpmn.BaseTaskTest;
35 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
36 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
37 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
38 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
39 import org.onap.so.client.exception.BBObjectNotFoundException;
40
41 public class AuditTasksTest extends BaseTaskTest{
42         
43         @InjectMocks
44         private AuditTasks auditTasks = new AuditTasks();
45         private ServiceInstance serviceInstance;
46         private GenericVnf genericVnf;
47         private VfModule vfModule;
48
49         
50         @Rule
51         public final ExpectedException exception = ExpectedException.none();
52         
53         @Before
54         public void before() throws BBObjectNotFoundException {
55                 serviceInstance = setServiceInstance();         
56                 genericVnf = setGenericVnf();
57                 vfModule = setVfModule();
58                 setCloudRegion();
59                 when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any())).thenReturn(genericVnf);
60                 when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
61                 when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance);
62         }
63         
64         @Test
65         public void setupAuditVariableTest() throws Exception {
66                 AuditInventory expectedAuditInventory = new AuditInventory();
67                 expectedAuditInventory.setCloudOwner("testCloudOwner");
68                 expectedAuditInventory.setCloudRegion("testLcpCloudRegionId");
69                 expectedAuditInventory.setHeatStackName("testVfModuleName1");
70                 expectedAuditInventory.setTenantId("testTenantId");
71                 auditTasks.setupAuditVariable(execution);
72                 assertThat((AuditInventory)execution.getVariable("auditInventory"), sameBeanAs(expectedAuditInventory));
73         }
74 }