73bfcefe6da6d564e33cefda60fbcfbca0d324d7
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017-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
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
21 package org.onap.so.adapters.tasks.inventory;
22
23 import static org.mockito.Mockito.doReturn;
24 import java.io.File;
25 import java.io.IOException;
26 import org.camunda.bpm.client.task.ExternalTask;
27 import org.junit.Before;
28 import org.mockito.InjectMocks;
29 import org.mockito.Mock;
30 import org.mockito.MockitoAnnotations;
31 import org.onap.so.audit.beans.AuditInventory;
32 import org.onap.aaiclient.client.aai.AAIResourcesClient;
33 import org.onap.so.objects.audit.AAIObjectAuditList;
34 import com.fasterxml.jackson.databind.ObjectMapper;
35
36 public class CreateAAIInventoryTest extends CreateAAIInventory {
37
38     @InjectMocks
39     private CreateAAIInventory createAAIInventory = new CreateAAIInventory();
40
41     @Mock
42     private ExternalTask mockExternalTask;
43
44     @Mock
45     private AAIResourcesClient mockClient;
46
47     private ObjectMapper objectMapper = new ObjectMapper();
48
49     private AuditInventory auditInventory = new AuditInventory();
50
51     AAIObjectAuditList auditListSuccess;
52
53     AAIObjectAuditList auditListFailure;
54
55     AAIObjectAuditList missingSubInterfaces;
56
57     @Before
58     public void setup() throws IOException {
59         auditInventory.setCloudOwner("cloudOwner");
60         auditInventory.setCloudRegion("cloudRegion");
61         auditInventory.setTenantId("tenantId");
62         auditInventory.setHeatStackName("stackName");
63         MockitoAnnotations.initMocks(this);
64         auditListSuccess = objectMapper.readValue(new File("src/test/resources/ExpectedVServerFound.json"),
65                 AAIObjectAuditList.class);
66         auditListFailure = objectMapper.readValue(new File("src/test/resources/Vserver2_Found_VServer1_Not_Found.json"),
67                 AAIObjectAuditList.class);
68         missingSubInterfaces = objectMapper.readValue(new File("src/test/resources/AuditResultsMissSub.json"),
69                 AAIObjectAuditList.class);
70         doReturn(auditInventory).when(mockExternalTask).getVariable("auditInventory");
71     }
72
73 }