2 * ============LICENSE_START=======================================================
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
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.
19 * ============LICENSE_END=========================================================
22 package org.onap.appc.adapter.iaas.provider.operation.impl;
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;
39 public class AttachVolumeServerTest {
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);