1b7b5ff9a1fa8d0f018c74ceb10002a39d43f542
[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.adapters.tasks.inventory.CreateAAIInventory;
32 import org.onap.so.audit.beans.AuditInventory;
33 import org.onap.aaiclient.client.aai.AAIResourcesClient;
34 import org.onap.so.objects.audit.AAIObjectAuditList;
35 import com.fasterxml.jackson.core.JsonParseException;
36 import com.fasterxml.jackson.databind.JsonMappingException;
37 import com.fasterxml.jackson.databind.ObjectMapper;
38
39 public class CreateAAIInventoryTest extends CreateAAIInventory {
40
41     @InjectMocks
42     private CreateAAIInventory createAAIInventory = new CreateAAIInventory();
43
44     @Mock
45     private ExternalTask mockExternalTask;
46
47     @Mock
48     private AAIResourcesClient mockClient;
49
50     private ObjectMapper objectMapper = new ObjectMapper();
51
52     private AuditInventory auditInventory = new AuditInventory();
53
54     AAIObjectAuditList auditListSuccess;
55
56     AAIObjectAuditList auditListFailure;
57
58     AAIObjectAuditList missingSubInterfaces;
59
60     @Before
61     public void setup() throws JsonParseException, JsonMappingException, IOException {
62         auditInventory.setCloudOwner("cloudOwner");
63         auditInventory.setCloudRegion("cloudRegion");
64         auditInventory.setTenantId("tenantId");
65         auditInventory.setHeatStackName("stackName");
66         MockitoAnnotations.initMocks(this);
67         auditListSuccess = objectMapper.readValue(new File("src/test/resources/ExpectedVServerFound.json"),
68                 AAIObjectAuditList.class);
69         auditListFailure = objectMapper.readValue(new File("src/test/resources/Vserver2_Found_VServer1_Not_Found.json"),
70                 AAIObjectAuditList.class);
71         missingSubInterfaces = objectMapper.readValue(new File("src/test/resources/AuditResultsMissSub.json"),
72                 AAIObjectAuditList.class);
73         doReturn(auditInventory).when(mockExternalTask).getVariable("auditInventory");
74     }
75
76 }