2 * ============LICENSE_START=======================================================
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
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.client.orchestration;
23 import static org.junit.Assert.assertEquals;
24 import static org.mockito.Matchers.eq;
25 import static org.mockito.Matchers.isA;
26 import static org.mockito.Mockito.doReturn;
27 import static org.mockito.Mockito.times;
28 import static org.mockito.Mockito.verify;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.mockito.InjectMocks;
34 import org.mockito.Mock;
35 import org.mockito.runners.MockitoJUnitRunner;
36 import org.onap.so.bpmn.common.InjectionHelper;
37 import org.onap.so.bpmn.common.data.TestDataSetup;
38 import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
39 import org.onap.so.client.aai.AAIObjectType;
40 import org.onap.so.client.aai.AAIResourcesClient;
41 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
42 import org.onap.so.client.aai.mapper.AAIObjectMapper;
43 import org.onap.so.db.catalog.beans.OrchestrationStatus;
44 @RunWith(MockitoJUnitRunner.class)
45 public class AAICollectionResourcesTest extends TestDataSetup{
48 private AAICollectionResources aaiCollectionResources = new AAICollectionResources();
51 protected AAIResourcesClient MOCK_aaiResourcesClient;
54 protected AAIObjectMapper MOCK_aaiObjectMapper;
57 protected InjectionHelper MOCK_injectionHelper;
59 private Collection networkCollection;
62 public void before() {
63 networkCollection = buildCollection();
64 doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
68 public void createCollectionTest() throws Exception {
69 networkCollection.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
70 doReturn(new org.onap.aai.domain.yang.Collection()).when(MOCK_aaiObjectMapper).mapCollection(networkCollection);
72 aaiCollectionResources.createCollection(networkCollection);
74 assertEquals(OrchestrationStatus.INVENTORIED, networkCollection.getOrchestrationStatus());
75 verify(MOCK_aaiResourcesClient, times(1)).create(eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())), isA(org.onap.aai.domain.yang.Collection.class));
79 public void updateCollectionTest() throws Exception {
80 doReturn(new org.onap.aai.domain.yang.Collection()).when(MOCK_aaiObjectMapper).mapCollection(networkCollection);
81 aaiCollectionResources.updateCollection(networkCollection);
82 verify(MOCK_aaiResourcesClient, times(1)).update(eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())), isA(org.onap.aai.domain.yang.Collection.class));
86 public void deleteCollectionTest() throws Exception {
87 aaiCollectionResources.deleteCollection(networkCollection);
88 verify(MOCK_aaiResourcesClient, times(1)).delete(eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())));