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