diff options
author | Joss Armstrong <joss.armstrong@ericsson.com> | 2019-02-01 12:44:39 +0000 |
---|---|---|
committer | Takamune Cho <takamune.cho@att.com> | 2019-02-01 22:28:58 +0000 |
commit | 61ebd8f1077c653c93fcf647dbb294aff1c01718 (patch) | |
tree | 57284cad72c95e8f6565d7a05386555d2dccf9d0 /appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src | |
parent | 03fe1bbb93175778d2aa42860632259fa90e47fc (diff) |
Add test coverage for AttachVolumeServer
New test file to cover success flow in class
Issue-ID: APPC-1374
Change-Id: I576f523225e5ac427b972e78a8392496a71b6bfa
Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src')
2 files changed, 71 insertions, 14 deletions
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServer.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServer.java index e9b0c9756..ccfcf9dbf 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServer.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServer.java @@ -5,6 +5,8 @@ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs + * ================================================================================ + * Modifications Copyright (C) 2019 Ericsson * ============================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,16 +26,7 @@ package org.onap.appc.adapter.iaas.provider.operation.impl; import static org.onap.appc.adapter.iaas.provider.operation.common.enums.Operation.ATTACHVOLUME_SERVICE; import static org.onap.appc.adapter.utils.Constants.ADAPTER_NAME; -import com.att.cdp.exceptions.ZoneException; -import com.att.cdp.zones.ComputeService; -import com.att.cdp.zones.Context; -import com.att.cdp.zones.VolumeService; -import com.att.cdp.zones.model.ModelObject; -import com.att.cdp.zones.model.Server; -import com.att.cdp.zones.model.Volume; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.att.eelf.i18n.EELFResourceManager; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -43,18 +36,27 @@ import org.onap.appc.adapter.iaas.ProviderAdapter; import org.onap.appc.adapter.iaas.impl.IdentityURL; import org.onap.appc.adapter.iaas.impl.RequestContext; import org.onap.appc.adapter.iaas.impl.RequestFailedException; -import com.att.cdp.exceptions.TimeoutException; import org.onap.appc.adapter.iaas.impl.VMURL; import org.onap.appc.adapter.iaas.provider.operation.common.enums.Operation; import org.onap.appc.adapter.iaas.provider.operation.impl.base.ProviderServerOperation; -import com.woorea.openstack.base.client.OpenStackBaseException; -import com.att.cdp.openstack.util.ExceptionMapper; import org.onap.appc.configuration.Configuration; import org.onap.appc.configuration.ConfigurationFactory; -import java.util.Iterator; import org.onap.appc.exceptions.APPCException; import org.onap.appc.i18n.Msg; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import com.att.cdp.exceptions.TimeoutException; +import com.att.cdp.exceptions.ZoneException; +import com.att.cdp.openstack.util.ExceptionMapper; +import com.att.cdp.zones.ComputeService; +import com.att.cdp.zones.Context; +import com.att.cdp.zones.VolumeService; +import com.att.cdp.zones.model.ModelObject; +import com.att.cdp.zones.model.Server; +import com.att.cdp.zones.model.Volume; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.att.eelf.i18n.EELFResourceManager; +import com.woorea.openstack.base.client.OpenStackBaseException; public class AttachVolumeServer extends ProviderServerOperation { diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServerTest.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServerTest.java new file mode 100644 index 000000000..4ccbffd0d --- /dev/null +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServerTest.java @@ -0,0 +1,55 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2019 Ericsson + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.iaas.provider.operation.impl; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.onap.appc.exceptions.APPCException; +import com.att.cdp.exceptions.ZoneException; +import com.att.cdp.zones.VolumeService; +import com.att.cdp.zones.model.ModelObject; +import com.att.cdp.zones.model.Server; +import com.att.cdp.zones.model.Server.Status; +import com.att.cdp.zones.model.Volume; + + +public class AttachVolumeServerTest { + + @Test + public void attachVolumeTest() throws ZoneException, APPCException { + MockGenerator mg = new MockGenerator(Status.RUNNING); + Server server = mg.getServer(); + VolumeService volumeService = mock(VolumeService.class); + List<Volume> volumeList = new ArrayList<>(); + doReturn(volumeList).when(volumeService).getVolumes(); + doReturn(mg.getContext()).when(server).getContext(); + doReturn(volumeService).when(mg.getContext()).getVolumeService(); + AttachVolumeServer rbs = new AttachVolumeServer(); + rbs.setProviderCache(mg.getProviderCacheMap()); + assertTrue(rbs.executeProviderOperation(mg.getParams(), mg.getSvcLogicContext()) instanceof ModelObject); + } + +} |