Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / bpmn / infrastructure / namingservice / tasks / NamingServiceDeleteTasksTest.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.bpmn.infrastructure.namingservice.tasks;
22
23 import static org.mockito.ArgumentMatchers.any;
24 import static org.mockito.Mockito.doReturn;
25 import static org.mockito.Mockito.doThrow;
26 import static org.mockito.Mockito.times;
27 import static org.mockito.Mockito.verify;
28 import static org.mockito.Mockito.when;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.mockito.ArgumentMatchers;
32 import org.mockito.InjectMocks;
33 import org.onap.so.bpmn.BaseTaskTest;
34 import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
35 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
36 import org.onap.so.client.exception.BBObjectNotFoundException;
37
38 public class NamingServiceDeleteTasksTest extends BaseTaskTest {
39     @InjectMocks
40     private NamingServiceDeleteTasks namingServiceDeleteTasks = new NamingServiceDeleteTasks();
41
42     private InstanceGroup instanceGroup;
43
44     @Before
45     public void before() throws BBObjectNotFoundException {
46         instanceGroup = setInstanceGroup();
47         when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID)))
48                 .thenReturn(instanceGroup);
49     }
50
51     @Test
52     public void deleteInstanceGroupTest() throws Exception {
53
54         doReturn("").when(namingServiceResources).deleteInstanceGroupName(instanceGroup);
55
56         namingServiceDeleteTasks.deleteInstanceGroupName(execution);
57         verify(namingServiceResources, times(1)).deleteInstanceGroupName(instanceGroup);
58     }
59
60     @Test
61     public void deleteInstanceGroupExceptionTest() throws Exception {
62         expectedException.expect(BBObjectNotFoundException.class);
63         lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, "notfound");
64         doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(),
65                 ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID));
66         doReturn("").when(namingServiceResources).deleteInstanceGroupName(instanceGroup);
67         namingServiceDeleteTasks.deleteInstanceGroupName(execution);
68         verify(namingServiceResources, times(1)).deleteInstanceGroupName(instanceGroup);
69     }
70
71 }