2 * ============LICENSE_START=======================================================
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
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=========================================================
21 package org.onap.so.adapters.tasks.inventory;
23 import static org.mockito.Mockito.doReturn;
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;
39 public class CreateAAIInventoryTest extends CreateAAIInventory {
42 private CreateAAIInventory createAAIInventory = new CreateAAIInventory();
45 private ExternalTask mockExternalTask;
48 private AAIResourcesClient mockClient;
50 private ObjectMapper objectMapper = new ObjectMapper();
52 private AuditInventory auditInventory = new AuditInventory();
54 AAIObjectAuditList auditListSuccess;
56 AAIObjectAuditList auditListFailure;
58 AAIObjectAuditList missingSubInterfaces;
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");