Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / client / orchestration / AAICollectionResourcesTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
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.client.orchestration;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.mockito.ArgumentMatchers.eq;
25 import static org.mockito.ArgumentMatchers.isA;
26 import static org.mockito.Mockito.doReturn;
27 import static org.mockito.Mockito.times;
28 import static org.mockito.Mockito.verify;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 import org.mockito.InjectMocks;
33 import org.mockito.Mock;
34 import org.mockito.junit.MockitoJUnitRunner;
35 import org.onap.so.bpmn.BaseTaskTest;
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
45 public class AAICollectionResourcesTest extends BaseTaskTest {
46
47     @InjectMocks
48     private AAICollectionResources aaiCollectionResources = new AAICollectionResources();
49
50
51     private Collection networkCollection;
52
53     @Before
54     public void before() {
55         networkCollection = buildCollection();
56         doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
57     }
58
59     @Test
60     public void createCollectionTest() throws Exception {
61         networkCollection.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
62         doReturn(new org.onap.aai.domain.yang.Collection()).when(MOCK_aaiObjectMapper).mapCollection(networkCollection);
63
64         aaiCollectionResources.createCollection(networkCollection);
65
66         assertEquals(OrchestrationStatus.INVENTORIED, networkCollection.getOrchestrationStatus());
67         verify(MOCK_aaiResourcesClient, times(1)).create(
68                 eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())),
69                 isA(org.onap.aai.domain.yang.Collection.class));
70     }
71
72     @Test
73     public void updateCollectionTest() throws Exception {
74         doReturn(new org.onap.aai.domain.yang.Collection()).when(MOCK_aaiObjectMapper).mapCollection(networkCollection);
75         aaiCollectionResources.updateCollection(networkCollection);
76         verify(MOCK_aaiResourcesClient, times(1)).update(
77                 eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())),
78                 isA(org.onap.aai.domain.yang.Collection.class));
79     }
80
81     @Test
82     public void deleteCollectionTest() throws Exception {
83         aaiCollectionResources.deleteCollection(networkCollection);
84         verify(MOCK_aaiResourcesClient, times(1))
85                 .delete(eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())));
86     }
87
88 }