4ccbffd0daa8dfaf2ba27e9a3c6f4536f421be5f
[appc.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2019 Ericsson
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  *
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.appc.adapter.iaas.provider.operation.impl;
23
24 import static org.junit.Assert.assertTrue;
25 import static org.mockito.Mockito.doReturn;
26 import static org.mockito.Mockito.mock;
27 import java.util.ArrayList;
28 import java.util.List;
29 import org.junit.Test;
30 import org.onap.appc.exceptions.APPCException;
31 import com.att.cdp.exceptions.ZoneException;
32 import com.att.cdp.zones.VolumeService;
33 import com.att.cdp.zones.model.ModelObject;
34 import com.att.cdp.zones.model.Server;
35 import com.att.cdp.zones.model.Server.Status;
36 import com.att.cdp.zones.model.Volume;
37
38
39 public class AttachVolumeServerTest {
40
41     @Test
42     public void attachVolumeTest() throws ZoneException, APPCException {
43         MockGenerator mg = new MockGenerator(Status.RUNNING);
44         Server server = mg.getServer();
45         VolumeService volumeService = mock(VolumeService.class);
46         List<Volume> volumeList = new ArrayList<>();
47         doReturn(volumeList).when(volumeService).getVolumes();
48         doReturn(mg.getContext()).when(server).getContext();
49         doReturn(volumeService).when(mg.getContext()).getVolumeService();
50         AttachVolumeServer rbs = new AttachVolumeServer();
51         rbs.setProviderCache(mg.getProviderCacheMap());
52         assertTrue(rbs.executeProviderOperation(mg.getParams(), mg.getSvcLogicContext()) instanceof ModelObject);
53     }
54
55 }