summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapters-rest-interface/pom.xml6
-rw-r--r--adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/AdapterRestInterfaceTest.java504
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java111
-rw-r--r--asdc-controller/pom.xml304
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/ToscaResourceInstallerTest.java558
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/VfResourceInstallerTest.java280
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/StubResponseAAITest.java168
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java68
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java38
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java93
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java139
11 files changed, 2117 insertions, 152 deletions
diff --git a/adapters/mso-adapters-rest-interface/pom.xml b/adapters/mso-adapters-rest-interface/pom.xml
index b83d6f82f8..c8f3a8b01a 100644
--- a/adapters/mso-adapters-rest-interface/pom.xml
+++ b/adapters/mso-adapters-rest-interface/pom.xml
@@ -48,5 +48,11 @@
<artifactId>mso-adapter-utils</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.10.19</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/AdapterRestInterfaceTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/AdapterRestInterfaceTest.java
new file mode 100644
index 0000000000..e15d828bf5
--- /dev/null
+++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/AdapterRestInterfaceTest.java
@@ -0,0 +1,504 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.openecomp.mso.adapters;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.map.DeserializationContext;
+import org.codehaus.jackson.map.SerializerProvider;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.mso.adapters.json.MapDeserializer;
+import org.openecomp.mso.adapters.json.MapSerializer;
+import org.openecomp.mso.adapters.nwrest.ContrailNetwork;
+import org.openecomp.mso.adapters.nwrest.CreateNetworkError;
+import org.openecomp.mso.adapters.nwrest.CreateNetworkRequest;
+import org.openecomp.mso.adapters.nwrest.CreateNetworkResponse;
+import org.openecomp.mso.adapters.nwrest.DeleteNetworkError;
+import org.openecomp.mso.adapters.nwrest.DeleteNetworkRequest;
+import org.openecomp.mso.adapters.nwrest.DeleteNetworkResponse;
+import org.openecomp.mso.adapters.nwrest.NetworkExceptionResponse;
+import org.openecomp.mso.adapters.nwrest.NetworkRequestCommon;
+import org.openecomp.mso.adapters.nwrest.ProviderVlanNetwork;
+import org.openecomp.mso.adapters.nwrest.QueryNetworkError;
+import org.openecomp.mso.adapters.nwrest.QueryNetworkResponse;
+import org.openecomp.mso.adapters.nwrest.RollbackNetworkError;
+import org.openecomp.mso.adapters.nwrest.RollbackNetworkRequest;
+import org.openecomp.mso.adapters.nwrest.RollbackNetworkResponse;
+import org.openecomp.mso.adapters.nwrest.UpdateNetworkError;
+import org.openecomp.mso.adapters.nwrest.UpdateNetworkRequest;
+import org.openecomp.mso.adapters.nwrest.UpdateNetworkResponse;
+import org.openecomp.mso.adapters.vnfrest.CreateVfModuleRequest;
+import org.openecomp.mso.adapters.vnfrest.CreateVolumeGroupRequest;
+import org.openecomp.mso.adapters.vnfrest.UpdateVfModuleRequest;
+import org.openecomp.mso.adapters.vnfrest.VfModuleRollback;
+import org.openecomp.mso.adapters.vnfrest.VolumeGroupRollback;
+import org.openecomp.mso.entity.MsoRequest;
+import org.openecomp.mso.openstack.beans.NetworkRollback;
+import org.openecomp.mso.openstack.beans.NetworkStatus;
+import org.openecomp.mso.openstack.beans.Subnet;
+import org.openecomp.mso.openstack.beans.VnfRollback;
+
+public class AdapterRestInterfaceTest {
+ @Test(expected = Exception.class)
+ public final void mapDeserializerTest() {
+ MapDeserializer mapDeserializer = new MapDeserializer();
+ JsonParser jsonParser = Mockito.mock(JsonParser.class);
+ DeserializationContext deserializationContext = Mockito.mock(DeserializationContext.class);
+ try {
+ mapDeserializer.deserialize(jsonParser, deserializationContext);
+ } catch (IOException e) {
+ }
+ }
+
+ @Test
+ public final void mapSerializerTest() {
+ MapSerializer mapSerializer = new MapSerializer();
+ mapSerializer.isUnwrappingSerializer();
+ mapSerializer.toString();
+ mapSerializer.unwrappingSerializer();
+ JsonGenerator jsonGenerator = Mockito.mock(JsonGenerator.class);
+ SerializerProvider serializerProvider = Mockito.mock(SerializerProvider.class);
+ try {
+ mapSerializer.serialize(new HashMap<String, String>(), jsonGenerator, serializerProvider);
+ } catch (IOException e) {
+ }
+ }
+
+ /**
+ * Test case for coverage
+ */
+ @Test
+ public final void contrailNetworkPOJOTest() {
+ try {
+ ContrailNetwork contrailNetwork = new ContrailNetwork();
+ ContrailNetwork contrailNetwork2 = new ContrailNetwork("", "", new ArrayList<String>(),
+ new ArrayList<String>(), new ArrayList<String>());
+ contrailNetwork.getExternal();
+ contrailNetwork.setExternal("external");
+ contrailNetwork.setPolicyFqdns(new ArrayList<String>());
+ contrailNetwork.setRouteTableFqdns(new ArrayList<String>());
+ contrailNetwork.setRouteTargets(new ArrayList<String>());
+ contrailNetwork.setShared("shared");
+ contrailNetwork.getShared();
+ contrailNetwork.getPolicyFqdns();
+ contrailNetwork.getRouteTableFqdns();
+ contrailNetwork.getRouteTargets();
+
+ UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
+ updateNetworkRequest.setBackout(false);
+ updateNetworkRequest.setCloudSiteId("cloudSiteId");
+ updateNetworkRequest.setContrailNetwork(new ContrailNetwork());
+ updateNetworkRequest.setMessageId("messageId");
+ updateNetworkRequest.setModelCustomizationUuid("modelCustomizationUuid");
+ updateNetworkRequest.setMsoRequest(new MsoRequest());
+ updateNetworkRequest.setNetworkId("networkId");
+ updateNetworkRequest.setNetworkName("networkName");
+ updateNetworkRequest.setNetworkParams(new HashMap<String, String>());
+ updateNetworkRequest.setNetworkStackId("networkStackId");
+ updateNetworkRequest.setNetworkTechnology("networkTechnology");
+ updateNetworkRequest.setNetworkType("networkType");
+ updateNetworkRequest.setNetworkTypeVersion("networkTypeVersion");
+ updateNetworkRequest.setNotificationUrl("notificationUrl");
+ updateNetworkRequest.setProviderVlanNetwork(new ProviderVlanNetwork());
+ updateNetworkRequest.setSkipAAI(true);
+ updateNetworkRequest.setSubnets(new ArrayList<Subnet>());
+ updateNetworkRequest.setTenantId("tenantId");
+ updateNetworkRequest.isContrailRequest();
+ updateNetworkRequest.getCloudSiteId();
+ updateNetworkRequest.getContrailNetwork();
+ updateNetworkRequest.getMessageId();
+ updateNetworkRequest.getNetworkId();
+ updateNetworkRequest.getModelCustomizationUuid();
+ updateNetworkRequest.getMsoRequest();
+ updateNetworkRequest.getNetworkName();
+ updateNetworkRequest.getNetworkParams();
+ updateNetworkRequest.getNetworkStackId();
+ updateNetworkRequest.getNetworkTechnology();
+ updateNetworkRequest.getNetworkType();
+ updateNetworkRequest.getNetworkTypeVersion();
+ updateNetworkRequest.getNotificationUrl();
+ updateNetworkRequest.getProviderVlanNetwork();
+ updateNetworkRequest.getSkipAAI();
+ updateNetworkRequest.getSubnets();
+ updateNetworkRequest.getTenantId();
+ updateNetworkRequest.getBackout();
+
+ CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
+ createNetworkRequest.setBackout(false);
+ createNetworkRequest.setCloudSiteId("cloudSiteId");
+ createNetworkRequest.setContrailNetwork(new ContrailNetwork());
+ createNetworkRequest.setFailIfExists(false);
+ createNetworkRequest.setMessageId("messageId");
+ createNetworkRequest.setModelCustomizationUuid("modelCustomizationUuid");
+ createNetworkRequest.setMsoRequest(new MsoRequest());
+ createNetworkRequest.setNetworkId("networkId");
+ createNetworkRequest.setNetworkName("networkName");
+ createNetworkRequest.setNetworkType("networkType");
+ createNetworkRequest.setNetworkTypeVersion("networkTypeVersion");
+ createNetworkRequest.setNotificationUrl("notificationUrl");
+ createNetworkRequest.setProviderVlanNetwork(new ProviderVlanNetwork());
+ createNetworkRequest.setSkipAAI(true);
+ createNetworkRequest.setSubnets(new ArrayList<Subnet>());
+ createNetworkRequest.setTenantId("tenantId");
+ createNetworkRequest.setNetworkParams(new HashMap<String, String>());
+ createNetworkRequest.setNetworkTechnology("VMWARE");
+ createNetworkRequest.getBackout();
+ createNetworkRequest.getCloudSiteId();
+ createNetworkRequest.getContrailNetwork();
+ createNetworkRequest.getFailIfExists();
+ createNetworkRequest.getMessageId();
+ createNetworkRequest.getModelCustomizationUuid();
+ createNetworkRequest.getMsoRequest();
+ createNetworkRequest.getNetworkId();
+ createNetworkRequest.getNetworkName();
+ createNetworkRequest.getNetworkParams();
+ createNetworkRequest.getNetworkTechnology();
+ createNetworkRequest.getNetworkType();
+ createNetworkRequest.getNetworkTypeVersion();
+ createNetworkRequest.getNotificationUrl();
+ createNetworkRequest.getProviderVlanNetwork();
+ createNetworkRequest.getSkipAAI();
+ createNetworkRequest.getSubnets();
+ createNetworkRequest.getTenantId();
+ createNetworkRequest.isContrailRequest();
+
+ QueryNetworkResponse queryNetworkResponse = new QueryNetworkResponse();
+ QueryNetworkResponse queryNetworkResponse2 = new QueryNetworkResponse("", "", "", NetworkStatus.ACTIVE,
+ new HashMap<String, String>());
+ queryNetworkResponse.setNetworkExists(true);
+ queryNetworkResponse.setNetworkId("networkId");
+ queryNetworkResponse.setNetworkOutputs(new HashMap<String, String>());
+ queryNetworkResponse.setNetworkStackId("networkStackId");
+ queryNetworkResponse.setNetworkStatus(NetworkStatus.ACTIVE);
+ queryNetworkResponse.setNeutronNetworkId("neutronNetworkId");
+ queryNetworkResponse.setRouteTargets(new ArrayList<String>());
+ queryNetworkResponse.setSubnetIdMap(new HashMap<String, String>());
+ queryNetworkResponse.setVlans(new ArrayList<Integer>());
+ queryNetworkResponse.getNetworkExists();
+ queryNetworkResponse.getNetworkId();
+ queryNetworkResponse.getNetworkOutputs();
+ queryNetworkResponse.getNetworkStackId();
+ queryNetworkResponse.getNetworkStatus();
+ queryNetworkResponse.getNeutronNetworkId();
+ queryNetworkResponse.getRouteTargets();
+ queryNetworkResponse.getSubnetIdMap();
+ queryNetworkResponse.getVlans();
+ queryNetworkResponse.toJsonString();
+
+ CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
+ CreateNetworkResponse createNetworkResponse2 = new CreateNetworkResponse("", "", "", "", true,
+ new HashMap<String, String>(), new NetworkRollback(), "");
+ createNetworkResponse.setMessageId("messageId");
+ createNetworkResponse.setNetworkCreated(true);
+ createNetworkResponse.setNetworkFqdn("networkFqdn");
+ createNetworkResponse.setNetworkId("networkId");
+ createNetworkResponse.setNetworkStackId("networkStackId");
+ createNetworkResponse.setNeutronNetworkId("neutronNetworkId");
+ createNetworkResponse.setRollback(new NetworkRollback());
+ createNetworkResponse.setSubnetMap(new HashMap<String, String>());
+ createNetworkResponse.toJsonString();
+ createNetworkResponse.toXmlString();
+ createNetworkResponse.getMessageId();
+ createNetworkResponse.getNetworkCreated();
+ createNetworkResponse.getNetworkFqdn();
+ createNetworkResponse.getNetworkId();
+ createNetworkResponse.getNetworkStackId();
+ createNetworkResponse.getNeutronNetworkId();
+ createNetworkResponse.getRollback();
+ createNetworkResponse.getSubnetMap();
+
+ NetworkRequestCommon networkRequestCommon = new CreateNetworkRequest();
+ networkRequestCommon.getMessageId();
+ networkRequestCommon.getNotificationUrl();
+ networkRequestCommon.getSkipAAI();
+ networkRequestCommon.setMessageId("messageId");
+ networkRequestCommon.setNotificationUrl("notificationUrl");
+ networkRequestCommon.setSkipAAI(false);
+ networkRequestCommon.isSynchronous();
+ networkRequestCommon.toXmlString();
+ networkRequestCommon.toJsonString();
+
+ DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
+ deleteNetworkRequest.setCloudSiteId("cloudSiteId");
+ deleteNetworkRequest.setMessageId("messageId");
+ deleteNetworkRequest.setModelCustomizationUuid("modelCustomizationUuid");
+ deleteNetworkRequest.setMsoRequest(new MsoRequest());
+ deleteNetworkRequest.setNetworkId("networkId");
+ deleteNetworkRequest.setNetworkStackId("networkStackId");
+ deleteNetworkRequest.setNetworkType("networkType");
+ deleteNetworkRequest.setNotificationUrl("notificationUrl");
+ deleteNetworkRequest.setSkipAAI(true);
+ deleteNetworkRequest.setTenantId("tenantId");
+ deleteNetworkRequest.getCloudSiteId();
+ deleteNetworkRequest.getMessageId();
+ deleteNetworkRequest.getModelCustomizationUuid();
+ deleteNetworkRequest.getMsoRequest();
+ deleteNetworkRequest.getNetworkId();
+ deleteNetworkRequest.getNetworkStackId();
+ deleteNetworkRequest.getNetworkType();
+ deleteNetworkRequest.getNotificationUrl();
+ deleteNetworkRequest.getSkipAAI();
+ deleteNetworkRequest.getTenantId();
+
+ NetworkExceptionResponse networkExceptionResponse = new NetworkExceptionResponse();
+ NetworkExceptionResponse networkExceptionResponse2 = new NetworkExceptionResponse("", null, false, "");
+ NetworkExceptionResponse networkExceptionResponse3 = new NetworkExceptionResponse("");
+ networkExceptionResponse.setCategory(null);
+ networkExceptionResponse.setMessage("message");
+ networkExceptionResponse.setMessageId("messageId");
+ networkExceptionResponse.setRolledBack(true);
+ networkExceptionResponse.getCategory();
+ networkExceptionResponse.getMessage();
+ networkExceptionResponse.getMessageId();
+ networkExceptionResponse.getRolledBack();
+
+ UpdateNetworkResponse updateNetworkResponse = new UpdateNetworkResponse();
+ UpdateNetworkResponse updateNetworkResponse2 = new UpdateNetworkResponse("", "", null, "");
+ updateNetworkResponse.setMessageId("messageId");
+ updateNetworkResponse.setNetworkId("networkId");
+ updateNetworkResponse.setNeutronNetworkId("");
+ updateNetworkResponse.setSubnetMap(null);
+ updateNetworkResponse.getNetworkId();
+ updateNetworkResponse.getMessageId();
+ updateNetworkResponse.getNeutronNetworkId();
+ updateNetworkResponse.getSubnetMap();
+
+ DeleteNetworkResponse deleteNetworkResponse = new DeleteNetworkResponse();
+ DeleteNetworkResponse deleteNetworkResponse2 = new DeleteNetworkResponse("", false, "");
+ deleteNetworkResponse.setNetworkDeleted(false);
+ deleteNetworkResponse.setNetworkId("networkId");
+ deleteNetworkResponse.getNetworkDeleted();
+ deleteNetworkResponse.getNetworkId();
+
+ ProviderVlanNetwork providerVlanNetwork = new ProviderVlanNetwork();
+ ProviderVlanNetwork providerVlanNetwork2 = new ProviderVlanNetwork("", null);
+ providerVlanNetwork.setPhysicalNetworkName("");
+ providerVlanNetwork.setVlans(null);
+ providerVlanNetwork.getPhysicalNetworkName();
+ providerVlanNetwork.getVlans();
+
+ RollbackNetworkResponse rollbackNetworkResponse = new RollbackNetworkResponse();
+ RollbackNetworkResponse rollbackNetworkResponse2 = new RollbackNetworkResponse(false, "");
+ rollbackNetworkResponse.setNetworkRolledBack(false);
+ rollbackNetworkResponse.getNetworkRolledBack();
+
+ CreateNetworkError createNetworkError = new CreateNetworkError();
+ CreateNetworkError createNetworkError2 = new CreateNetworkError("");
+ CreateNetworkError createNetworkError3 = new CreateNetworkError("", null, false, "");
+
+ DeleteNetworkError deleteNetworkError = new DeleteNetworkError();
+ DeleteNetworkError deleteNetworkError2 = new DeleteNetworkError("");
+ DeleteNetworkError deleteNetworkError3 = new DeleteNetworkError("", null, false, "");
+
+ RollbackNetworkError rollbackNetworkError = new RollbackNetworkError();
+ RollbackNetworkError rollbackNetworkError2 = new RollbackNetworkError("");
+ RollbackNetworkError rollbackNetworkError3 = new RollbackNetworkError("", null, false, "");
+
+ UpdateNetworkError updateNetworkError = new UpdateNetworkError();
+ UpdateNetworkError updateNetworkError2 = new UpdateNetworkError("");
+ UpdateNetworkError updateNetworkError3 = new UpdateNetworkError("", null, false, "");
+
+ RollbackNetworkRequest rollbackNetworkRequest = new RollbackNetworkRequest();
+ rollbackNetworkRequest.setNetworkRollback(null);
+ rollbackNetworkRequest.getNetworkRollback();
+
+ QueryNetworkError queryNetworkError = new QueryNetworkError();
+
+ UpdateVfModuleRequest updateVfModuleRequest = new UpdateVfModuleRequest();
+ updateVfModuleRequest.setBackout(false);
+ updateVfModuleRequest.setBaseVfModuleId("");
+ updateVfModuleRequest.setBaseVfModuleStackId("");
+ updateVfModuleRequest.setCloudSiteId("");
+ updateVfModuleRequest.setFailIfExists(false);
+ updateVfModuleRequest.setMessageId("");
+ updateVfModuleRequest.setModelCustomizationUuid("");
+ updateVfModuleRequest.setMsoRequest(null);
+ updateVfModuleRequest.setNotificationUrl("");
+ updateVfModuleRequest.setRequestType("");
+ updateVfModuleRequest.setSkipAAI(false);
+ updateVfModuleRequest.setTenantId("");
+ updateVfModuleRequest.setVfModuleId("");
+ updateVfModuleRequest.setVfModuleName("");
+ updateVfModuleRequest.setVfModuleParams(null);
+ updateVfModuleRequest.setVfModuleStackId("");
+ updateVfModuleRequest.setVfModuleType("");
+ updateVfModuleRequest.setVnfId("");
+ updateVfModuleRequest.setVnfType("");
+ updateVfModuleRequest.setVnfVersion("");
+ updateVfModuleRequest.setVolumeGroupId("");
+ updateVfModuleRequest.setVolumeGroupStackId("");
+ updateVfModuleRequest.getBackout();
+ updateVfModuleRequest.getBaseVfModuleId();
+ updateVfModuleRequest.getBaseVfModuleStackId();
+ updateVfModuleRequest.getCloudSiteId();
+ updateVfModuleRequest.getFailIfExists();
+ updateVfModuleRequest.getMessageId();
+ updateVfModuleRequest.getModelCustomizationUuid();
+ updateVfModuleRequest.getMsoRequest();
+ updateVfModuleRequest.getNotificationUrl();
+ updateVfModuleRequest.getRequestType();
+ updateVfModuleRequest.getSkipAAI();
+ updateVfModuleRequest.getTenantId();
+ updateVfModuleRequest.getVfModuleId();
+ updateVfModuleRequest.getVfModuleName();
+ updateVfModuleRequest.getVfModuleParams();
+ updateVfModuleRequest.getVfModuleStackId();
+ updateVfModuleRequest.getVfModuleType();
+ updateVfModuleRequest.getVnfId();
+ updateVfModuleRequest.getVnfType();
+ updateVfModuleRequest.getVnfVersion();
+ updateVfModuleRequest.getVolumeGroupId();
+ updateVfModuleRequest.getVolumeGroupStackId();
+
+ CreateVfModuleRequest createVfModuleRequest = new CreateVfModuleRequest();
+ createVfModuleRequest.setBackout(false);
+ createVfModuleRequest.setBaseVfModuleId("");
+ createVfModuleRequest.setBaseVfModuleStackId("");
+ createVfModuleRequest.setCloudSiteId("");
+ createVfModuleRequest.setFailIfExists(false);
+ createVfModuleRequest.setModelCustomizationUuid("");
+ createVfModuleRequest.setMsoRequest(null);
+ createVfModuleRequest.setNotificationUrl("");
+ createVfModuleRequest.setRequestType("");
+ createVfModuleRequest.setSkipAAI(false);
+ createVfModuleRequest.setTenantId("");
+ createVfModuleRequest.setVfModuleId("");
+ createVfModuleRequest.setVfModuleName("");
+ createVfModuleRequest.setVfModuleParams(null);
+ createVfModuleRequest.setVfModuleType("");
+ createVfModuleRequest.setVnfId("");
+ createVfModuleRequest.setVnfType("");
+ createVfModuleRequest.setVnfVersion("");
+ createVfModuleRequest.setVolumeGroupId("volumeGroupId");
+ createVfModuleRequest.setVolumeGroupStackId("volumeGroupStackId");
+ createVfModuleRequest.getBackout();
+ createVfModuleRequest.getBaseVfModuleId();
+ createVfModuleRequest.getBaseVfModuleStackId();
+ createVfModuleRequest.getCloudSiteId();
+ createVfModuleRequest.getFailIfExists();
+ createVfModuleRequest.getModelCustomizationUuid();
+ createVfModuleRequest.getMsoRequest();
+ createVfModuleRequest.getNotificationUrl();
+ createVfModuleRequest.getRequestType();
+ createVfModuleRequest.getSkipAAI();
+ createVfModuleRequest.getTenantId();
+ createVfModuleRequest.getVfModuleId();
+ createVfModuleRequest.getVfModuleName();
+ createVfModuleRequest.getVfModuleParams();
+ createVfModuleRequest.getVfModuleType();
+ createVfModuleRequest.getVnfId();
+ createVfModuleRequest.getVnfType();
+ createVfModuleRequest.getVnfVersion();
+ createVfModuleRequest.getVolumeGroupId();
+ createVfModuleRequest.getVolumeGroupStackId();
+
+ VnfRollback vnfRollback = new VnfRollback();
+ vnfRollback.setBaseGroupHeatStackId("");
+ vnfRollback.setCloudSiteId("");
+ vnfRollback.setIsBase(false);
+ vnfRollback.setModelCustomizationUuid("");
+ vnfRollback.setMsoRequest(null);
+ vnfRollback.setRequestType("");
+ vnfRollback.setTenantCreated(false);
+ vnfRollback.setTenantId("");
+ vnfRollback.setVfModuleStackId("");
+ vnfRollback.setVnfCreated(false);
+ vnfRollback.setVnfId("");
+ vnfRollback.setVolumeGroupHeatStackId("");
+ vnfRollback.setVolumeGroupId("");
+ vnfRollback.setVolumeGroupName("");
+
+ VfModuleRollback vfModuleRollback = new VfModuleRollback();
+ VfModuleRollback vfModuleRollback2 = new VfModuleRollback(vnfRollback, "", "", "");
+ VfModuleRollback vfModuleRollback3 = new VfModuleRollback("", "", "", false, "", "", null, "");
+ vfModuleRollback.setCloudSiteId("");
+ vfModuleRollback.setMsoRequest(null);
+ vfModuleRollback.setTenantId("");
+ vfModuleRollback.setVfModuleCreated(false);
+ vfModuleRollback.setVfModuleId("");
+ vfModuleRollback.setVfModuleStackId("");
+ vfModuleRollback.setVnfId("");
+ vfModuleRollback.getCloudSiteId();
+ vfModuleRollback.getMsoRequest();
+ vfModuleRollback.getTenantId();
+ vfModuleRollback.getVfModuleId();
+ vfModuleRollback.getVfModuleStackId();
+ vfModuleRollback.getVnfId();
+
+ VolumeGroupRollback volumeGroupRollback = new VolumeGroupRollback();
+ volumeGroupRollback.setCloudSiteId("cloudSiteId");
+ volumeGroupRollback.setMsoRequest(null);
+ volumeGroupRollback.setTenantId("");
+ volumeGroupRollback.setVolumeGroupCreated(false);
+ volumeGroupRollback.setVolumeGroupId("");
+ volumeGroupRollback.setVolumeGroupStackId("");
+ volumeGroupRollback.setMessageId("messageId");
+ volumeGroupRollback.getMessageId();
+ volumeGroupRollback.getCloudSiteId();
+ volumeGroupRollback.getMsoRequest();
+ volumeGroupRollback.getTenantId();
+ volumeGroupRollback.getVolumeGroupId();
+ volumeGroupRollback.getVolumeGroupStackId();
+ VolumeGroupRollback volumeGroupRollback2 = new VolumeGroupRollback(volumeGroupRollback, "", "");
+ VolumeGroupRollback volumeGroupRollback3 = new VolumeGroupRollback("", "", false, "", "", null, "");
+
+ CreateVolumeGroupRequest createVolumeGroupRequest = new CreateVolumeGroupRequest();
+ createVolumeGroupRequest.setCloudSiteId("");
+ createVolumeGroupRequest.setFailIfExists(false);
+ createVolumeGroupRequest.setMessageId("messageId");
+ createVolumeGroupRequest.setModelCustomizationUuid("modelCustomizationUuid");
+ createVolumeGroupRequest.setMsoRequest(null);
+ createVolumeGroupRequest.setNotificationUrl("");
+ createVolumeGroupRequest.setSkipAAI(false);
+ createVolumeGroupRequest.setSuppressBackout(false);
+ createVolumeGroupRequest.setTenantId("");
+ createVolumeGroupRequest.setVfModuleType("");
+ createVolumeGroupRequest.setVnfType("");
+ createVolumeGroupRequest.setVnfVersion("");
+ createVolumeGroupRequest.setVolumeGroupId("");
+ createVolumeGroupRequest.setVolumeGroupName("");
+ createVolumeGroupRequest.setVolumeGroupParams(null);
+ createVolumeGroupRequest.getCloudSiteId();
+ createVolumeGroupRequest.getFailIfExists();
+ createVolumeGroupRequest.getMessageId();
+ createVolumeGroupRequest.getModelCustomizationUuid();
+ createVolumeGroupRequest.getMsoRequest();
+ createVolumeGroupRequest.getNotificationUrl();
+ createVolumeGroupRequest.getSkipAAI();
+ createVolumeGroupRequest.getSuppressBackout();
+ createVolumeGroupRequest.getTenantId();
+ createVolumeGroupRequest.getVfModuleType();
+ createVolumeGroupRequest.getVnfType();
+ createVolumeGroupRequest.getVnfVersion();
+ createVolumeGroupRequest.getVolumeGroupId();
+ createVolumeGroupRequest.getVolumeGroupName();
+ createVolumeGroupRequest.getVolumeGroupParams();
+ } catch (Exception e) {
+ assert (false);
+
+ }
+ }
+}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java
new file mode 100644
index 0000000000..e96e416d65
--- /dev/null
+++ b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.openecomp.mso.adapters.network;
+
+import java.util.ArrayList;
+
+import org.junit.Test;
+import org.openecomp.mso.openstack.beans.Pool;
+import org.openecomp.mso.openstack.beans.Subnet;
+
+public class NetworkBeansTest {
+
+ /**
+ * Test case for coverage
+ */
+ @Test()
+ public final void bpelRestClientPOJOTest() {
+ try {
+ BpelRestClient bpelRestClient = new BpelRestClient();
+ bpelRestClient.setConnectTimeout(180);
+ bpelRestClient.setCredentials("credentials");
+ bpelRestClient.setRetryCount(-1);
+ bpelRestClient.setRetryInterval(2);
+ bpelRestClient.setSocketTimeout(10);
+ bpelRestClient.equals(bpelRestClient);
+ bpelRestClient.bpelPost("toBpelStr", "bpelUrl", true);
+ bpelRestClient.getConnectTimeout();
+ bpelRestClient.getCredentials();
+ bpelRestClient.getLastResponse();
+ bpelRestClient.getLastResponseCode();
+ bpelRestClient.getRetryCount();
+ bpelRestClient.getRetryInterval();
+ bpelRestClient.getRetryList();
+ bpelRestClient.getSocketTimeout();
+ bpelRestClient.hashCode();
+ bpelRestClient.toString();
+
+ ContrailPolicyRef contrailPolicyRef = new ContrailPolicyRef();
+ contrailPolicyRef.populate("major", "minor");
+ contrailPolicyRef.toJsonNode();
+ contrailPolicyRef.toJsonString();
+ contrailPolicyRef.toString();
+
+ ContrailPolicyRefSeq contrailPolicyRefSeq = new ContrailPolicyRefSeq();
+ ContrailPolicyRefSeq contrailPolicyRefSeq2 = new ContrailPolicyRefSeq("", "");
+ contrailPolicyRefSeq.setMajor("major");
+ contrailPolicyRefSeq.setMinor("minor");
+ contrailPolicyRefSeq.getMajor();
+ contrailPolicyRefSeq.getMinor();
+ contrailPolicyRefSeq.toString();
+
+ ContrailSubnet contrailSubnet = new ContrailSubnet();
+ contrailSubnet.setAddrFromStart(true);
+ contrailSubnet.setDefaultGateway("defaultGateway");
+ contrailSubnet.setEnableDhcp(true);
+ contrailSubnet.setPools(new ArrayList<ContrailSubnetPool>());
+ contrailSubnet.setSubnet(new ContrailSubnetIp());
+ contrailSubnet.setSubnetName("subnetName");
+ contrailSubnet.getAllocationPools();
+ contrailSubnet.getDefaultGateway();
+ contrailSubnet.getSubnet();
+ contrailSubnet.getSubnetName();
+ contrailSubnet.isAddrFromStart();
+ contrailSubnet.isEnableDhcp();
+ contrailSubnet.populateWith(new Subnet());
+ contrailSubnet.toJsonNode();
+ contrailSubnet.toJsonString();
+ contrailSubnet.toString();
+
+ ContrailSubnetIp contrailSubnetIp = new ContrailSubnetIp();
+ contrailSubnetIp.setIpPrefix("ipPrefix");
+ contrailSubnetIp.setIpPrefixLen("ipPrefixLen");
+ contrailSubnetIp.getIpPrefix();
+ contrailSubnetIp.getIpPrefixLen();
+ contrailSubnetIp.toString();
+
+ ContrailSubnetPool contrailSubnetPool = new ContrailSubnetPool();
+ contrailSubnetPool.setEnd("end");
+ contrailSubnetPool.setStart("start");
+ contrailSubnetPool.getEnd();
+ contrailSubnetPool.getStart();
+ contrailSubnetPool.populateWith(new Pool());
+ contrailSubnetPool.toString();
+
+ // HealthCheckHandler healthCheckHandler = new HealthCheckHandler();
+ // healthCheckHandler.healthcheck("60c3e96e-0970-4871-b6e0-3b6de7561519");
+ // healthCheckHandler.healthcheck("requestId");
+ } catch (Exception e) {
+ assert (false);
+
+ }
+ }
+}
diff --git a/asdc-controller/pom.xml b/asdc-controller/pom.xml
index fa4538c19c..e8dfe9f107 100644
--- a/asdc-controller/pom.xml
+++ b/asdc-controller/pom.xml
@@ -1,149 +1,155 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.openecomp.so</groupId>
- <artifactId>so</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.openecomp.so</groupId>
- <artifactId>asdc-controller</artifactId>
- <name>asdc-controller</name>
- <description>ASDC CLient and Controller</description>
- <packaging>war</packaging>
-
- <build>
- <finalName>${project.artifactId}-${project.version}</finalName>
- <plugins>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <version>2.4</version>
- <configuration>
- <warSourceDirectory>WebContent</warSourceDirectory>
- <failOnMissingWebXml>false</failOnMissingWebXml>
- <attachClasses>true</attachClasses>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
- <version>1.9.13</version>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.10.19</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.openecomp.so</groupId>
- <artifactId>mso-catalog-db</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.spec.javax.ejb</groupId>
- <artifactId>jboss-ejb-api_3.2_spec</artifactId>
- <version>1.0.0.Final</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.ejb3</groupId>
- <artifactId>jboss-ejb3-ext-api</artifactId>
- <version>2.2.0.Final</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>3.1.0</version>
- <scope>test</scope>
- </dependency>
-
- <!-- <dependency>
- <groupId>org.openecomp.sdc.sdc-distribution-client</groupId>
- <artifactId>sdc-distribution-client</artifactId>
- <version>1.1.16</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- </exclusions>
- </dependency> -->
-
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>4.4.1</version>
- <scope>compile</scope>
- <exclusions>
- <exclusion>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.openecomp.sdc.sdc-distribution-client</groupId>
- <artifactId>sdc-distribution-client</artifactId>
- <version>1.1.32-SNAPSHOT</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
-
- <dependency>
- <groupId>org.openecomp.sdc.sdc-tosca</groupId>
- <artifactId>sdc-tosca</artifactId>
- <version>1.1.32-SNAPSHOT</version>
- </dependency>
-
-
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpmime</artifactId>
- <version>4.5</version>
- </dependency>
-
- <dependency>
- <groupId>org.openecomp.so</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.yaml</groupId>
- <artifactId>snakeyaml</artifactId>
- <version>1.15</version>
- </dependency>
-
- <dependency>
- <groupId>javax</groupId>
- <artifactId>javaee-web-api</artifactId>
- <version>6.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.openecomp.so</groupId>
- <artifactId>status-control</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- </dependencies>
-
-</project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>so</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>asdc-controller</artifactId>
+ <name>asdc-controller</name>
+ <description>ASDC CLient and Controller</description>
+ <packaging>war</packaging>
+
+ <build>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <warSourceDirectory>WebContent</warSourceDirectory>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ <attachClasses>true</attachClasses>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>1.9.13</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.10.19</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jmockit</groupId>
+ <artifactId>jmockit</artifactId>
+ <version>1.8</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>mso-catalog-db</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.2_spec</artifactId>
+ <version>1.0.0.Final</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-ext-api</artifactId>
+ <version>2.2.0.Final</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.1.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- <dependency>
+ <groupId>org.openecomp.sdc.sdc-distribution-client</groupId>
+ <artifactId>sdc-distribution-client</artifactId>
+ <version>1.1.16</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency> -->
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.4.1</version>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdc.sdc-distribution-client</groupId>
+ <artifactId>sdc-distribution-client</artifactId>
+ <version>1.1.32-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.openecomp.sdc.sdc-tosca</groupId>
+ <artifactId>sdc-tosca</artifactId>
+ <version>1.1.32-SNAPSHOT</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpmime</artifactId>
+ <version>4.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ <version>1.15</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-web-api</artifactId>
+ <version>6.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>status-control</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/ToscaResourceInstallerTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/ToscaResourceInstallerTest.java
new file mode 100644
index 0000000000..a4563c66ac
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/ToscaResourceInstallerTest.java
@@ -0,0 +1,558 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.openecomp.mso.asdc.installer.heat.tests;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang3.tuple.Pair;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.mso.asdc.client.ASDCConfiguration;
+import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;
+import org.openecomp.mso.asdc.client.tests.ASDCControllerTest;
+import org.openecomp.mso.asdc.installer.ToscaResourceStructure;
+import org.openecomp.mso.asdc.installer.VfResourceStructure;
+import org.openecomp.mso.asdc.installer.heat.ToscaResourceInstaller;
+import org.openecomp.mso.db.catalog.CatalogDatabase;
+import org.openecomp.mso.db.catalog.beans.AllottedResource;
+import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.NetworkResource;
+import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.Service;
+import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources;
+import org.openecomp.mso.db.catalog.beans.ServiceToNetworks;
+import org.openecomp.mso.db.catalog.beans.ServiceToResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.TempNetworkHeatTemplateLookup;
+import org.openecomp.mso.db.catalog.beans.ToscaCsar;
+import org.openecomp.mso.db.catalog.beans.VfModule;
+import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
+import org.openecomp.mso.db.catalog.beans.VfModuleToHeatFiles;
+import org.openecomp.mso.db.catalog.beans.VnfResCustomToVfModuleCustom;
+import org.openecomp.mso.db.catalog.beans.VnfResource;
+import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
+import org.openecomp.mso.properties.MsoJavaProperties;
+import org.openecomp.mso.properties.MsoPropertiesException;
+import org.openecomp.mso.properties.MsoPropertiesFactory;
+import org.openecomp.sdc.api.IDistributionClient;
+import org.openecomp.sdc.api.notification.IArtifactInfo;
+import org.openecomp.sdc.api.notification.INotificationData;
+import org.openecomp.sdc.api.notification.IResourceInstance;
+import org.openecomp.sdc.api.results.IDistributionClientDownloadResult;
+import org.openecomp.sdc.api.results.IDistributionClientResult;
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.impl.FilterType;
+import org.openecomp.sdc.tosca.parser.impl.SdcTypes;
+import org.openecomp.sdc.toscaparser.api.Group;
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.openecomp.sdc.toscaparser.api.elements.Metadata;
+import org.openecomp.sdc.toscaparser.api.parameters.Input;
+import org.openecomp.sdc.utils.DistributionActionResultEnum;
+
+import mockit.Mock;
+import mockit.MockUp;
+
+public class ToscaResourceInstallerTest {
+
+ private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
+
+ private static String heatExample;
+ private static String heatExampleMD5HashBase64;
+
+ private static INotificationData iNotif;
+
+ private static IDistributionClientDownloadResult downloadResult;
+ private static IDistributionClientDownloadResult downloadCorruptedResult;
+
+ private static IDistributionClientResult successfulClientInitResult;
+ private static IDistributionClientResult unsuccessfulClientInitResult;
+
+ private static IDistributionClient distributionClient;
+
+ private static IArtifactInfo artifactInfo1;
+
+ private static IResourceInstance resource1;
+
+ private static VfResourceStructure vrs;
+
+ public static final String ASDC_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.json").toString()
+ .substring(5);
+ public static final String ASDC_PROP2 = MsoJavaProperties.class.getClassLoader().getResource("mso2.json").toString()
+ .substring(5);
+ public static final String ASDC_PROP3 = MsoJavaProperties.class.getClassLoader().getResource("mso3.json").toString()
+ .substring(5);
+ public static final String ASDC_PROP_BAD = MsoJavaProperties.class.getClassLoader().getResource("mso-bad.json")
+ .toString().substring(5);
+ public static final String ASDC_PROP_WITH_NULL = MsoJavaProperties.class.getClassLoader()
+ .getResource("mso-with-NULL.json").toString().substring(5);
+
+ @BeforeClass
+ public static final void prepareMockNotification() throws MsoPropertiesException, IOException, URISyntaxException,
+ NoSuchAlgorithmException, ArtifactInstallerException {
+
+ heatExample = new String(Files.readAllBytes(Paths.get(
+ ASDCControllerTest.class.getClassLoader().getResource("resource-examples/autoscaling.yaml").toURI())));
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ byte[] md5Hash = md.digest(heatExample.getBytes());
+ heatExampleMD5HashBase64 = Base64.encodeBase64String(md5Hash);
+
+ iNotif = Mockito.mock(INotificationData.class);
+
+ // Create fake ArtifactInfo
+ artifactInfo1 = Mockito.mock(IArtifactInfo.class);
+ Mockito.when(artifactInfo1.getArtifactChecksum())
+ .thenReturn(ToscaResourceInstallerTest.heatExampleMD5HashBase64);
+
+ Mockito.when(artifactInfo1.getArtifactName()).thenReturn("artifact1");
+ Mockito.when(artifactInfo1.getArtifactType()).thenReturn(ASDCConfiguration.HEAT);
+ Mockito.when(artifactInfo1.getArtifactURL())
+ .thenReturn("https://localhost:8080/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml");
+ Mockito.when(artifactInfo1.getArtifactUUID()).thenReturn("UUID1");
+ Mockito.when(artifactInfo1.getArtifactDescription()).thenReturn("testos artifact1");
+
+ distributionClient = Mockito.mock(IDistributionClient.class);
+
+ // Now provision the NotificationData mock
+ List<IArtifactInfo> listArtifact = new ArrayList<IArtifactInfo>();
+ listArtifact.add(artifactInfo1);
+
+ // Create fake resource Instance
+ resource1 = Mockito.mock(IResourceInstance.class);
+ // Mockito.when(resource1.getResourceType()).thenReturn("VF");
+ Mockito.when(resource1.getResourceName()).thenReturn("resourceName");
+ Mockito.when(resource1.getArtifacts()).thenReturn(listArtifact);
+
+ List<IResourceInstance> resources = new ArrayList<>();
+ resources.add(resource1);
+
+ Mockito.when(iNotif.getResources()).thenReturn(resources);
+ Mockito.when(iNotif.getDistributionID()).thenReturn("distributionID1");
+ Mockito.when(iNotif.getServiceName()).thenReturn("serviceName1");
+ Mockito.when(iNotif.getServiceUUID()).thenReturn("serviceNameUUID1");
+ Mockito.when(iNotif.getServiceVersion()).thenReturn("1.0");
+
+ downloadResult = Mockito.mock(IDistributionClientDownloadResult.class);
+ Mockito.when(downloadResult.getArtifactPayload()).thenReturn(heatExample.getBytes());
+ Mockito.when(downloadResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS);
+ Mockito.when(downloadResult.getDistributionMessageResult()).thenReturn("Success");
+
+ downloadCorruptedResult = Mockito.mock(IDistributionClientDownloadResult.class);
+ Mockito.when(downloadCorruptedResult.getArtifactPayload()).thenReturn((heatExample + "badone").getBytes());
+ Mockito.when(downloadCorruptedResult.getDistributionActionResult())
+ .thenReturn(DistributionActionResultEnum.SUCCESS);
+ Mockito.when(downloadCorruptedResult.getDistributionMessageResult()).thenReturn("Success");
+
+ vrs = new VfResourceStructure(iNotif, resource1);
+ try {
+ vrs.addArtifactToStructure(distributionClient, artifactInfo1, downloadResult);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ try {
+ vrs.createVfModuleStructures();
+ } catch (ArtifactInstallerException e) {
+ e.printStackTrace();
+ }
+ vrs.getNotification();
+ vrs.getArtifactsMapByUUID();
+ vrs.getCatalogNetworkResourceCustomization();
+ vrs.getCatalogResourceCustomization();
+ vrs.getCatalogService();
+ vrs.getCatalogServiceToAllottedResources();
+ vrs.getCatalogServiceToNetworks();
+ vrs.getCatalogVnfResource();
+ vrs.getResourceInstance();
+ vrs.getVfModulesStructureList();
+ vrs.getVfModuleStructure();
+ vrs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());
+ vrs.setCatalogResourceCustomization(new AllottedResourceCustomization());
+ vrs.setCatalogService(new Service());
+ vrs.setCatalogServiceToAllottedResources(new ServiceToAllottedResources());
+ vrs.setCatalogServiceToNetworks(new ServiceToNetworks());
+ vrs.setCatalogVnfResource(new VnfResource());
+ vrs.setSuccessfulDeployment();
+
+ AllottedResourceCustomization arc = new AllottedResourceCustomization();
+ arc.setModelCustomizationUuid("modelCustomizationUuid");
+ List<AllottedResourceCustomization> allottedResources = new ArrayList<>();
+ allottedResources.add(arc);
+
+ NetworkResourceCustomization nrc = new NetworkResourceCustomization();
+ nrc.setModelCustomizationUuid("modelCustomizationUuid");
+ List<NetworkResourceCustomization> networkResources = new ArrayList<>();
+ networkResources.add(nrc);
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelUuid(
+ String serviceModelUuid) {
+ return allottedResources;
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public List<NetworkResourceCustomization> getAllNetworksByServiceModelUuid(String serviceModelUuid) {
+ return networkResources;
+ }
+ };
+
+ // Mock now the ASDC distribution client behavior
+ successfulClientInitResult = Mockito.mock(IDistributionClientResult.class);
+ Mockito.when(successfulClientInitResult.getDistributionActionResult())
+ .thenReturn(DistributionActionResultEnum.SUCCESS);
+
+ unsuccessfulClientInitResult = Mockito.mock(IDistributionClientResult.class);
+ Mockito.when(unsuccessfulClientInitResult.getDistributionActionResult())
+ .thenReturn(DistributionActionResultEnum.GENERAL_ERROR);
+
+ }
+
+ @Before
+ public final void initBeforeEachTest() throws MsoPropertiesException {
+ // load the config
+ msoPropertiesFactory.removeAllMsoProperties();
+ msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP);
+ }
+
+ @AfterClass
+ public static final void kill() throws MsoPropertiesException {
+
+ msoPropertiesFactory.removeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC);
+
+ }
+
+ @Test
+ public void isResourceAlreadyDeployedAllotedResourceTest() {
+ Mockito.when(resource1.getResourceType()).thenReturn("VF");
+ Mockito.when(resource1.getCategory()).thenReturn("Allotted Resource");
+ ToscaResourceInstaller tri = new ToscaResourceInstaller();
+
+ try {
+ tri.isResourceAlreadyDeployed(vrs);
+ } catch (ArtifactInstallerException e) {
+ }
+ }
+
+ @Test(expected=Exception.class)
+ public void installTheResourceTest() {
+
+ ToscaResourceStructure trs = new ToscaResourceStructure();
+ trs.getAllottedResource();
+ trs.getAllottedList();
+ trs.getCatalogAllottedResourceCustomization();
+ trs.getCatalogAllottedServiceToResourceCustomization();
+ trs.getCatalogNetworkResource();
+ trs.getCatalogNetworkResourceCustomization();
+ trs.getCatalogResourceCustomization();
+ trs.getCatalogService();
+ trs.getCatalogTempNetworkHeatTemplateLookup();
+ trs.getCatalogToscaCsar();
+ trs.getCatalogVfModule();
+ trs.getCatalogVfModuleCustomization();
+ trs.getCatalogVfModuleToHeatFiles();
+ trs.getCatalogVfServiceToResourceCustomization();
+ trs.getCatalogVlServiceToResourceCustomization();
+ trs.getCatalogVnfResCustomToVfModuleCustom();
+ trs.getCatalogVnfResource();
+ trs.getCatalogVnfResourceCustomization();
+ trs.getEnvHeatTemplateUUID();
+ trs.getHeatFilesUUID();
+ trs.getHeatTemplateUUID();
+ trs.getNetworkTypes();
+ trs.getSdcCsarHelper();
+ trs.getServiceMetadata();
+ trs.getServiceToResourceCustomization();
+ trs.getServiceVersion();
+ trs.getToscaArtifact();
+ trs.getVfTypes();
+ trs.getVolHeatEnvTemplateUUID();
+ trs.getVolHeatTemplateUUID();
+
+ NodeTemplate nodeTemplate = Mockito.mock(NodeTemplate.class);
+ List<NodeTemplate> alnt = new ArrayList<>();
+ trs.setAllottedList(alnt);
+ trs.setAllottedResource(new AllottedResource());
+ trs.setCatalogAllottedResourceCustomization(new AllottedResourceCustomization());
+ trs.setCatalogAllottedServiceToResourceCustomization(new ServiceToResourceCustomization());
+ trs.setCatalogNetworkResource(new NetworkResource());
+ trs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());
+ trs.setCatalogResourceCustomization(new AllottedResourceCustomization());
+ trs.setCatalogService(new Service());
+ trs.setCatalogTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());
+ trs.setCatalogToscaCsar(new ToscaCsar());
+ trs.setCatalogVfModule(new VfModule());
+ trs.setCatalogVfModuleCustomization(new VfModuleCustomization());
+ trs.setCatalogVfModuleToHeatFiles(new VfModuleToHeatFiles());
+ trs.setCatalogVfServiceToResourceCustomization(new ServiceToResourceCustomization());
+ trs.setCatalogVlServiceToResourceCustomization(new ServiceToResourceCustomization());
+ trs.setCatalogVnfResCustomToVfModuleCustom(new VnfResCustomToVfModuleCustom());
+ trs.setCatalogVnfResource(new VnfResource());
+ trs.setCatalogVnfResourceCustomization(new VnfResourceCustomization());
+ trs.setEnvHeatTemplateUUID("envHeatTemplateUUID");
+ trs.setHeatFilesUUID("heatFilesUUID");
+ trs.setHeatTemplateUUID("heatTemplateUUID");
+ trs.setNetworkTypes(alnt);
+ trs.setVolHeatTemplateUUID("volHeatTemplateUUID");
+ trs.setSdcCsarHelper(new ISdcCsarHelper() {
+
+ @Override
+ public boolean hasTopology(NodeTemplate arg0) {
+ return false;
+ }
+
+ @Override
+ public NodeTemplate getVnfConfig(String arg0) {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getVfcListByVf(String arg0) {
+ return null;
+ }
+
+ @Override
+ public List<Group> getVfModulesByVf(String arg0) {
+ return null;
+ }
+
+ @Override
+ public String getTypeOfNodeTemplate(NodeTemplate arg0) {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getServiceVlList() {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getServiceVfList() {
+ return null;
+ }
+
+ @Override
+ public String getServiceSubstitutionMappingsTypeName() {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getServiceNodeTemplatesByType(String arg0) {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getServiceNodeTemplates() {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getServiceNodeTemplateBySdcType(SdcTypes arg0) {
+ return null;
+ }
+
+ @Override
+ public Map<String, Object> getServiceMetadataProperties() {
+ return null;
+ }
+
+ @Override
+ public Metadata getServiceMetadata() {
+ return null;
+ }
+
+ @Override
+ public List<Input> getServiceInputs() {
+ return null;
+ }
+
+ @Override
+ public Object getServiceInputLeafValueOfDefaultAsObject(String arg0) {
+ return null;
+ }
+
+ @Override
+ public String getServiceInputLeafValueOfDefault(String arg0) {
+ return null;
+ }
+
+ @Override
+ public String getNodeTemplatePropertyLeafValue(NodeTemplate arg0, String arg1) {
+ return null;
+ }
+
+ @Override
+ public Object getNodeTemplatePropertyAsObject(NodeTemplate arg0, String arg1) {
+ return null;
+ }
+
+ @Override
+ public List<Pair<NodeTemplate, NodeTemplate>> getNodeTemplatePairsByReqName(List<NodeTemplate> arg0,
+ List<NodeTemplate> arg1, String arg2) {
+ return null;
+ }
+
+ @Override
+ public String getNodeTemplateCustomizationUuid(NodeTemplate arg0) {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getNodeTemplateChildren(NodeTemplate arg0) {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate arg0, SdcTypes arg1) {
+ return null;
+ }
+
+ @Override
+ public String getMetadataPropertyValue(Metadata arg0, String arg1) {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getMembersOfVfModule(NodeTemplate arg0, Group arg1) {
+ return null;
+ }
+
+ @Override
+ public String getGroupPropertyLeafValue(Group arg0, String arg1) {
+ return null;
+ }
+
+ @Override
+ public Object getGroupPropertyAsObject(Group arg0, String arg1) {
+ return null;
+ }
+
+ @Override
+ public Map<String, Map<String, Object>> getCpPropertiesFromVfcAsObject(NodeTemplate arg0) {
+ return null;
+ }
+
+ @Override
+ public Map<String, Map<String, Object>> getCpPropertiesFromVfc(NodeTemplate arg0) {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getCpListByVf(String arg0) {
+ return null;
+ }
+
+ @Override
+ public String getConformanceLevel() {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getAllottedResources() {
+ return null;
+ }
+
+ @Override
+ public Map<String, String> filterNodeTemplatePropertiesByValue(NodeTemplate arg0, FilterType arg1,
+ String arg2) {
+ return null;
+ }
+ });
+ // trs.setServiceMetadata(new Metadata(new HashMap<>()));
+ trs.setServiceToResourceCustomization(new ServiceToResourceCustomization());
+ trs.setServiceVersion("1.0");
+ trs.setToscaArtifact(new IArtifactInfo() {
+
+ @Override
+ public List<IArtifactInfo> getRelatedArtifacts() {
+ return null;
+ }
+
+ @Override
+ public IArtifactInfo getGeneratedArtifact() {
+ return null;
+ }
+
+ @Override
+ public String getArtifactVersion() {
+ return null;
+ }
+
+ @Override
+ public String getArtifactUUID() {
+ return null;
+ }
+
+ @Override
+ public String getArtifactURL() {
+ return null;
+ }
+
+ @Override
+ public String getArtifactType() {
+ return null;
+ }
+
+ @Override
+ public Integer getArtifactTimeout() {
+ return null;
+ }
+
+ @Override
+ public String getArtifactName() {
+ return null;
+ }
+
+ @Override
+ public String getArtifactDescription() {
+ return null;
+ }
+
+ @Override
+ public String getArtifactChecksum() {
+ return null;
+ }
+ });
+ trs.setVfTypes(alnt);
+ trs.setVnfAlreadyInstalled(true);
+ trs.setVolHeatEnvTemplateUUID("volHeatEnvTemplateUUID");
+ trs.isVnfAlreadyInstalled();
+
+ trs.updateResourceStructure(artifactInfo1);
+ ToscaResourceInstaller tri = new ToscaResourceInstaller();
+
+ try {
+ tri.installTheResource(trs, vrs);
+ } catch (ArtifactInstallerException e) {
+ }
+ }
+}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/VfResourceInstallerTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/VfResourceInstallerTest.java
new file mode 100644
index 0000000000..c4ada7437e
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/VfResourceInstallerTest.java
@@ -0,0 +1,280 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.openecomp.mso.asdc.installer.heat.tests;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.codec.binary.Base64;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.mso.asdc.client.ASDCConfiguration;
+import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;
+import org.openecomp.mso.asdc.client.tests.ASDCControllerTest;
+import org.openecomp.mso.asdc.installer.VfResourceStructure;
+import org.openecomp.mso.asdc.installer.heat.VfResourceInstaller;
+import org.openecomp.mso.db.catalog.CatalogDatabase;
+import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.Service;
+import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources;
+import org.openecomp.mso.db.catalog.beans.ServiceToNetworks;
+import org.openecomp.mso.db.catalog.beans.VnfResource;
+import org.openecomp.mso.properties.MsoJavaProperties;
+import org.openecomp.mso.properties.MsoPropertiesException;
+import org.openecomp.mso.properties.MsoPropertiesFactory;
+import org.openecomp.sdc.api.IDistributionClient;
+import org.openecomp.sdc.api.notification.IArtifactInfo;
+import org.openecomp.sdc.api.notification.INotificationData;
+import org.openecomp.sdc.api.notification.IResourceInstance;
+import org.openecomp.sdc.api.results.IDistributionClientDownloadResult;
+import org.openecomp.sdc.api.results.IDistributionClientResult;
+import org.openecomp.sdc.utils.DistributionActionResultEnum;
+
+import mockit.Mock;
+import mockit.MockUp;
+
+public class VfResourceInstallerTest {
+ private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
+
+ private static String heatExample;
+ private static String heatExampleMD5HashBase64;
+
+ private static INotificationData iNotif;
+
+ private static IDistributionClientDownloadResult downloadResult;
+ private static IDistributionClientDownloadResult downloadCorruptedResult;
+
+ private static IDistributionClientResult successfulClientInitResult;
+ private static IDistributionClientResult unsuccessfulClientInitResult;
+
+ private static IDistributionClient distributionClient;
+
+ private static IArtifactInfo artifactInfo1;
+
+ private static IResourceInstance resource1;
+
+ private static VfResourceStructure vrs;
+
+ public static final String ASDC_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.json").toString()
+ .substring(5);
+ public static final String ASDC_PROP2 = MsoJavaProperties.class.getClassLoader().getResource("mso2.json").toString()
+ .substring(5);
+ public static final String ASDC_PROP3 = MsoJavaProperties.class.getClassLoader().getResource("mso3.json").toString()
+ .substring(5);
+ public static final String ASDC_PROP_BAD = MsoJavaProperties.class.getClassLoader().getResource("mso-bad.json")
+ .toString().substring(5);
+ public static final String ASDC_PROP_WITH_NULL = MsoJavaProperties.class.getClassLoader()
+ .getResource("mso-with-NULL.json").toString().substring(5);
+
+ @BeforeClass
+ public static final void prepareMockNotification() throws MsoPropertiesException, IOException, URISyntaxException,
+ NoSuchAlgorithmException, ArtifactInstallerException {
+
+ heatExample = new String(Files.readAllBytes(Paths.get(
+ ASDCControllerTest.class.getClassLoader().getResource("resource-examples/autoscaling.yaml").toURI())));
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ byte[] md5Hash = md.digest(heatExample.getBytes());
+ heatExampleMD5HashBase64 = Base64.encodeBase64String(md5Hash);
+
+ iNotif = Mockito.mock(INotificationData.class);
+
+ // Create fake ArtifactInfo
+ artifactInfo1 = Mockito.mock(IArtifactInfo.class);
+ Mockito.when(artifactInfo1.getArtifactChecksum()).thenReturn(VfResourceInstallerTest.heatExampleMD5HashBase64);
+
+ Mockito.when(artifactInfo1.getArtifactName()).thenReturn("artifact1");
+ Mockito.when(artifactInfo1.getArtifactType()).thenReturn(ASDCConfiguration.HEAT);
+ Mockito.when(artifactInfo1.getArtifactURL())
+ .thenReturn("https://localhost:8080/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml");
+ Mockito.when(artifactInfo1.getArtifactUUID()).thenReturn("UUID1");
+ Mockito.when(artifactInfo1.getArtifactDescription()).thenReturn("testos artifact1");
+
+ distributionClient = Mockito.mock(IDistributionClient.class);
+
+ // Now provision the NotificationData mock
+ List<IArtifactInfo> listArtifact = new ArrayList<IArtifactInfo>();
+ listArtifact.add(artifactInfo1);
+
+ // Create fake resource Instance
+ resource1 = Mockito.mock(IResourceInstance.class);
+// Mockito.when(resource1.getResourceType()).thenReturn("VF");
+ Mockito.when(resource1.getResourceName()).thenReturn("resourceName");
+ Mockito.when(resource1.getArtifacts()).thenReturn(listArtifact);
+
+ List<IResourceInstance> resources = new ArrayList<>();
+ resources.add(resource1);
+
+ Mockito.when(iNotif.getResources()).thenReturn(resources);
+ Mockito.when(iNotif.getDistributionID()).thenReturn("distributionID1");
+ Mockito.when(iNotif.getServiceName()).thenReturn("serviceName1");
+ Mockito.when(iNotif.getServiceUUID()).thenReturn("serviceNameUUID1");
+ Mockito.when(iNotif.getServiceVersion()).thenReturn("1.0");
+
+ downloadResult = Mockito.mock(IDistributionClientDownloadResult.class);
+ Mockito.when(downloadResult.getArtifactPayload()).thenReturn(heatExample.getBytes());
+ Mockito.when(downloadResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS);
+ Mockito.when(downloadResult.getDistributionMessageResult()).thenReturn("Success");
+
+ downloadCorruptedResult = Mockito.mock(IDistributionClientDownloadResult.class);
+ Mockito.when(downloadCorruptedResult.getArtifactPayload()).thenReturn((heatExample + "badone").getBytes());
+ Mockito.when(downloadCorruptedResult.getDistributionActionResult())
+ .thenReturn(DistributionActionResultEnum.SUCCESS);
+ Mockito.when(downloadCorruptedResult.getDistributionMessageResult()).thenReturn("Success");
+
+ vrs = new VfResourceStructure(iNotif, resource1);
+ try {
+ vrs.addArtifactToStructure(distributionClient, artifactInfo1, downloadResult);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ try {
+ vrs.createVfModuleStructures();
+ } catch (ArtifactInstallerException e) {
+ e.printStackTrace();
+ }
+ vrs.getNotification();
+ vrs.getArtifactsMapByUUID();
+ vrs.getCatalogNetworkResourceCustomization();
+ vrs.getCatalogResourceCustomization();
+ vrs.getCatalogService();
+ vrs.getCatalogServiceToAllottedResources();
+ vrs.getCatalogServiceToNetworks();
+ vrs.getCatalogVnfResource();
+ vrs.getResourceInstance();
+ vrs.getVfModulesStructureList();
+ vrs.getVfModuleStructure();
+ vrs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());
+ vrs.setCatalogResourceCustomization(new AllottedResourceCustomization());
+ vrs.setCatalogService(new Service());
+ vrs.setCatalogServiceToAllottedResources(new ServiceToAllottedResources());
+ vrs.setCatalogServiceToNetworks(new ServiceToNetworks());
+ vrs.setCatalogVnfResource(new VnfResource());
+ vrs.setSuccessfulDeployment();
+
+ AllottedResourceCustomization arc= new AllottedResourceCustomization();
+ arc.setModelCustomizationUuid("modelCustomizationUuid");
+ List<AllottedResourceCustomization> allottedResources = new ArrayList<>();
+ allottedResources.add(arc);
+
+ NetworkResourceCustomization nrc = new NetworkResourceCustomization();
+ nrc.setModelCustomizationUuid("modelCustomizationUuid");
+ List<NetworkResourceCustomization> networkResources = new ArrayList<>();
+ networkResources.add(nrc);
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelUuid(String serviceModelUuid) {
+ return allottedResources;
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public List<NetworkResourceCustomization> getAllNetworksByServiceModelUuid(String serviceModelUuid) {
+ return networkResources;
+ }
+ };
+
+ // Mock now the ASDC distribution client behavior
+ successfulClientInitResult = Mockito.mock(IDistributionClientResult.class);
+ Mockito.when(successfulClientInitResult.getDistributionActionResult())
+ .thenReturn(DistributionActionResultEnum.SUCCESS);
+
+ unsuccessfulClientInitResult = Mockito.mock(IDistributionClientResult.class);
+ Mockito.when(unsuccessfulClientInitResult.getDistributionActionResult())
+ .thenReturn(DistributionActionResultEnum.GENERAL_ERROR);
+
+ }
+
+ @Before
+ public final void initBeforeEachTest() throws MsoPropertiesException {
+ // load the config
+ msoPropertiesFactory.removeAllMsoProperties();
+ msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP);
+ }
+
+ @AfterClass
+ public static final void kill() throws MsoPropertiesException {
+
+ msoPropertiesFactory.removeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC);
+
+ }
+
+ @Test
+ public void isResourceAlreadyDeployedAllotedResourceTest() {
+
+ Mockito.when(resource1.getResourceType()).thenReturn("VF");
+ Mockito.when(resource1.getCategory()).thenReturn("Allotted Resource");
+ VfResourceInstaller vfri = new VfResourceInstaller();
+
+ try {
+ vfri.isResourceAlreadyDeployed(vrs);
+ } catch (ArtifactInstallerException e) {
+ }
+
+ }
+
+ @Test
+ public void isResourceAlreadyDeployedTest() {
+
+ Mockito.when(resource1.getResourceType()).thenReturn("VF");
+ Mockito.when(resource1.getCategory()).thenReturn("Not Allotted Resource");
+ VfResourceInstaller vfri = new VfResourceInstaller();
+
+ try {
+ vfri.isResourceAlreadyDeployed(vrs);
+ } catch (ArtifactInstallerException e) {
+ }
+
+ }
+ @Test
+ public void isResourceAlreadyDeployedDuplicateNtwrkTest() {
+
+ Mockito.when(resource1.getResourceType()).thenReturn("VL");
+ Mockito.when(resource1.getCategory()).thenReturn("Not Allotted Resource");
+ VfResourceInstaller vfri = new VfResourceInstaller();
+
+ try {
+ vfri.isResourceAlreadyDeployed(vrs);
+ } catch (ArtifactInstallerException e) {
+ }
+
+ }
+
+ @Test(expected=Exception.class)
+ public void installTheResourceTest() {
+ VfResourceInstaller vfri = new VfResourceInstaller();
+ try {
+ vfri.installTheResource(vrs);
+ } catch (ArtifactInstallerException e) {
+ }
+ }
+}
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/StubResponseAAITest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/StubResponseAAITest.java
new file mode 100644
index 0000000000..8f16ed3b1e
--- /dev/null
+++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/StubResponseAAITest.java
@@ -0,0 +1,168 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.openecomp.mso.bpmn.infrastructure;
+
+import org.junit.Test;
+import org.openecomp.mso.bpmn.common.WorkflowTest;
+import org.openecomp.mso.bpmn.mock.StubResponseAAI;
+
+public class StubResponseAAITest extends WorkflowTest{
+
+ @Test
+ public void testStubResponseAAIforNullAndDefaultInputs()
+ {
+ try{
+ StubResponseAAI.MockPutTunnelXConnect(null, null, null, null, null);
+ StubResponseAAI.MockGetAllottedResource(null, null, null, null, null);
+ StubResponseAAI.MockPutAllottedResource(null, null, null, null);
+ StubResponseAAI.MockPutAllottedResource_500(null, null, null, null);
+ StubResponseAAI.MockDeleteAllottedResource(null, null, null, null, null);
+ StubResponseAAI.MockPatchAllottedResource(null, null, null, null);
+ StubResponseAAI.MockQueryAllottedResourceById(null, null);
+ StubResponseAAI.MockGetServiceInstance(null, null, null, null);
+ StubResponseAAI.MockGetServiceInstance_404(null, null, null);
+ StubResponseAAI.MockGetServiceInstance_500(null, null, null);
+ StubResponseAAI.MockGetServiceInstance_500(null, null, null, null);
+ StubResponseAAI.MockNodeQueryServiceInstanceByName(null, null);
+ StubResponseAAI.MockNodeQueryServiceInstanceByName_404(null);
+ StubResponseAAI.MockNodeQueryServiceInstanceByName_500(null);
+ StubResponseAAI.MockNodeQueryServiceInstanceById(null, null);
+ StubResponseAAI.MockNodeQueryServiceInstanceById_404(null);
+ StubResponseAAI.MockNodeQueryServiceInstanceById_500(null);
+ StubResponseAAI.MockDeleteServiceInstance(null, null, null, null);
+ StubResponseAAI.MockGetServiceInstance(null, null, null, null, 0);
+ StubResponseAAI.MockGetServiceInstance(null, null, null, 0);
+ StubResponseAAI.MockDeleteServiceInstance(null, null, null, null, 0);
+ StubResponseAAI.MockDeleteServiceInstance(null, null, null, 0);
+ StubResponseAAI.MockDeleteServiceInstance_404(null, null, null, null);
+ StubResponseAAI.MockDeleteServiceInstance_500(null, null, null, null);
+ StubResponseAAI.MockPutServiceInstance(null, null, null, null);
+ StubResponseAAI.MockPutServiceInstance_500(null, null, null);
+ StubResponseAAI.MockGetServiceSubscription(null, null, null);
+ StubResponseAAI.MockDeleteServiceSubscription(null, null, 0);
+ StubResponseAAI.MockDeleteServiceInstanceId(null, null, null);
+ StubResponseAAI.MockPutServiceSubscription(null, null);
+ StubResponseAAI.MockGetServiceSubscription(null, null, 0);
+ StubResponseAAI.MockGetCustomer(null, null);
+ StubResponseAAI.MockDeleteCustomer(null);
+ StubResponseAAI.MockPutCustomer(null);
+ StubResponseAAI.MockPutCustomer_500(null);
+ StubResponseAAI.MockGetGenericVnfById(null, null);
+ StubResponseAAI.MockGetGenericVnfById(null, null, 0);
+ StubResponseAAI.MockGetGenericVnfByIdWithPriority(null, 0, null);
+ StubResponseAAI.MockGetGenericVnfByIdWithPriority(null, null, 0, null, 0);
+ StubResponseAAI.MockGetGenericVnfByIdWithDepth(null, 0, null);
+ StubResponseAAI.MockGetGenericVnfById_404(null);
+ StubResponseAAI.MockGetGenericVnfById_500(null);
+ StubResponseAAI.MockGetGenericVnfByName(null, null);
+ StubResponseAAI.MockGetGenericVnfByNameWithDepth(null, 0, null);
+ StubResponseAAI.MockGetGenericVnfByName_404(null);
+ StubResponseAAI.MockDeleteGenericVnf(null, null);
+ StubResponseAAI.MockDeleteGenericVnf(null, null, 0);
+ StubResponseAAI.MockDeleteGenericVnf_500(null, null);
+ StubResponseAAI.MockPutGenericVnf(null);
+ StubResponseAAI.MockPutGenericVnf(null, null, 0);
+ StubResponseAAI.MockPutGenericVnf(null, 0);
+ StubResponseAAI.MockPutGenericVnf_Bad(null, 0);
+ StubResponseAAI.MockPatchGenericVnf(null);
+ StubResponseAAI.MockGetVceById(null, null);
+ StubResponseAAI.MockGetVceByName(null, null);
+ StubResponseAAI.MockDeleteVce(null, null, 0);
+ StubResponseAAI.MockPutVce(null);
+ StubResponseAAI.MockGetGenericVceByNameWithDepth(null, 0, null);
+ StubResponseAAI.MockGetVceGenericQuery(null, 0, 0, null);
+ StubResponseAAI.MockGetTenantGenericQuery(null, null, null);
+ StubResponseAAI.MockGetTenant(null, null);
+ StubResponseAAI.MockGetNetwork(null, null, 0);
+ StubResponseAAI.MockGetNetworkByIdWithDepth(null, null, null);
+ StubResponseAAI.MockGetNetworkCloudRegion(null, null);
+ StubResponseAAI.MockGetNetworkByName(null, null);
+ StubResponseAAI.MockGetNetworkByName_404(null, null);
+ StubResponseAAI.MockGetNetworkCloudRegion_404(null);
+ StubResponseAAI.MockPutNetwork(null, 0, null);
+ StubResponseAAI.MockPutNetwork(null, null, 0);
+ StubResponseAAI.MockGetNetworkName(null, null, 0);
+ StubResponseAAI.MockGetNetworkVpnBinding(null, null);
+ StubResponseAAI.MockGetNetworkPolicy(null, null);
+ StubResponseAAI.MockGetNetworkVpnBinding(null, null, 0);
+ StubResponseAAI.MockGetNetworkPolicy(null, null, 0);
+ StubResponseAAI.MockGetNetworkTableReference(null, null);
+ StubResponseAAI.MockPutNetworkIdWithDepth(null, null, null);
+ StubResponseAAI.MockGetNetworkPolicyfqdn(null, null, 0);
+ StubResponseAAI.MockGetNetworkRouteTable(null, null, 0);
+ StubResponseAAI.MockPatchVfModuleId(null, null);
+ StubResponseAAI.MockVNFAdapterRestVfModule();
+ StubResponseAAI.MockDBUpdateVfModule();
+ StubResponseAAI.MockSDNCAdapterVfModule();
+ StubResponseAAI.MockAAIVfModule();
+ StubResponseAAI.MockGetCloudRegion(null, 0, null);
+ StubResponseAAI.MockGetVolumeGroupById(null, null, null);
+ StubResponseAAI.MockPutVolumeGroupById(null, null, null, 0);
+ StubResponseAAI.MockGetVolumeGroupByName(null, null, null, 0);
+ StubResponseAAI.MockDeleteVolumeGroupById(null, null, null, 0);
+ StubResponseAAI.MockGetVolumeGroupByName_404(null, null);
+ StubResponseAAI.MockDeleteVolumeGroup(null, null, null);
+ StubResponseAAI.MockGetVfModuleId(null, null, null, 0);
+ StubResponseAAI.MockGetVfModuleByNameWithDepth(null, null, 0, null, 0);
+ StubResponseAAI.MockGetVfModuleIdNoResponse(null, null, null);
+ StubResponseAAI.MockPutVfModuleIdNoResponse(null, null, null);
+ StubResponseAAI.MockPutVfModuleId(null, null);
+ StubResponseAAI.MockPutVfModuleId(null, null, 0);
+ StubResponseAAI.MockDeleteVfModuleId(null, null, null, 0);
+ StubResponseAAI.MockAAIVfModuleBadPatch(null, 0);
+ StubResponseAAI.MockGetPserverByVnfId(null, null, 0);
+ StubResponseAAI.MockGetGenericVnfsByVnfId(null, null, 0);
+ StubResponseAAI.MockSetInMaintFlagByVnfId(null, 0);
+ StubResponseAAI.MockGetVceById();
+ StubResponseAAI.MockGetVceByName();
+ StubResponseAAI.MockPutVce();
+ StubResponseAAI.MockDeleteVce();
+ StubResponseAAI.MockDeleteVce_404();
+ StubResponseAAI.MockDeleteServiceSubscription();
+ StubResponseAAI.MockGetServiceSubscription();
+ StubResponseAAI.MockGetServiceSubscription_200Empty();
+ StubResponseAAI.MockGetServiceSubscription_404();
+ StubResponseAAI.MockGENPSIPutServiceInstance();
+ StubResponseAAI.MockGENPSIPutServiceSubscription();
+ StubResponseAAI.MockGENPSIPutServiceInstance_get500();
+ StubResponseAAI.MockGetGenericVnfById();
+ StubResponseAAI.MockGetGenericVnfById_404();
+ StubResponseAAI.MockGetGenericVnfByName();
+ StubResponseAAI.MockGetGenericVnfByName_hasRelationships();
+ StubResponseAAI.MockGetGenericVnfById_hasRelationships();
+ StubResponseAAI.MockGetGenericVnfById_500();
+ StubResponseAAI.MockGetGenericVnfByName_404();
+ StubResponseAAI.MockPutGenericVnf();
+ StubResponseAAI.MockPutGenericVnf_400();
+ StubResponseAAI.MockDeleteGenericVnf();
+ StubResponseAAI.MockDeleteGenericVnf_404();
+ StubResponseAAI.MockDeleteGenericVnf_500();
+ StubResponseAAI.MockDeleteGenericVnf_412();
+ }
+ catch(Exception ex)
+ {
+
+ System.err.println(ex);
+ }
+
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java
index 3feb168f51..3c5c89fc92 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java
@@ -24,6 +24,9 @@ import static org.junit.Assert.assertTrue;
import java.lang.reflect.Field;
import java.net.URI;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@@ -35,7 +38,9 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequest;
+import org.openecomp.mso.requestsdb.InfraActiveRequests;
import org.openecomp.mso.requestsdb.InfraRequests;
+import org.openecomp.mso.requestsdb.RequestsDatabase;
public class NetworkRequestHandlerTest {
@@ -61,6 +66,23 @@ UriInfo uriInfo = null;
Response resp = handler.manageNetworkRequest("<name>Test</name>", "v2");
assertTrue(null != resp);
}
+ @Test
+ public void manageVnfRequestTestV1(){
+ Response resp = handler.manageNetworkRequest("<name>Test</name>", "v1");
+ assertTrue(null != resp);
+ }
+
+ @Test
+ public void manageVnfRequestTestV3(){
+ Response resp = handler.manageNetworkRequest("<name>Test</name>", "v3");
+ assertTrue(null != resp);
+ }
+
+ @Test
+ public void manageVnfRequestTestInvalidVersion(){
+ Response resp = handler.manageNetworkRequest("<name>Test</name>", "v249");
+ assertTrue(null != resp);
+ }
@Test
public void manageVnfRequest2Test(){
@@ -150,4 +172,50 @@ UriInfo uriInfo = null;
assertTrue(param.equals("test"));
}
+ @Test
+ public void queryFiltersTest(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public List <InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName,
+ String queryValue,
+ String requestType) {
+ List <InfraActiveRequests> list = new ArrayList<InfraActiveRequests>();
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setAaiServiceId("299392");
+ req.setAction("CREATE");
+ req.setRequestStatus("COMPLETE");
+ req.setProgress(10001l);
+ req.setSource("test");
+ req.setStartTime(new Timestamp(10020100));
+ req.setEndTime(new Timestamp(20020100));
+ req.setStatusMessage("message");
+ list.add(req);
+ return list;
+ }
+ };
+ Response resp = handler.queryFilters("networkType", "serviceType", "aicNodeClli", "tenantId", "v1");
+ assertTrue(resp.getEntity().toString() != null);
+ }
+
+ @Test
+ public void getRequestTest(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) {
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setAaiServiceId("299392");
+ req.setAction("CREATE");
+ req.setRequestStatus("COMPLETE");
+ req.setProgress(10001l);
+ req.setSource("test");
+ req.setStartTime(new Timestamp(10020100));
+ req.setEndTime(new Timestamp(20020100));
+ req.setStatusMessage("message");
+ return req;
+ }
+ };
+ Response resp = handler.getRequest("388293", "v1");
+ assertTrue(resp.getEntity().toString() != null);
+ }
+
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java
new file mode 100644
index 0000000000..c8ab6b5612
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.openecomp.mso.apihandlerinfra;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.openecomp.mso.apihandler.common.ValidationException;
+import org.openecomp.mso.properties.MsoJavaProperties;
+
+public class VnfMsoInfraRequestTest {
+ VnfMsoInfraRequest request = new VnfMsoInfraRequest("29919020");
+
+ @Test(expected=Exception.class)
+ public void parseTest() throws ValidationException {
+ String reqXML = "<vnf-request><request-info> <request-id>29993</request-id><request-status>COMPLETE</request-status></request-info></vnf-request>";
+ request.parse(reqXML, "v1", new MsoJavaProperties());
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java
index 8d06b40074..2d3a2a47a5 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java
@@ -24,6 +24,9 @@ import static org.junit.Assert.assertTrue;
import java.lang.reflect.Field;
import java.net.URI;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
import mockit.Mock;
import mockit.MockUp;
@@ -32,7 +35,9 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequest;
+import org.openecomp.mso.requestsdb.InfraActiveRequests;
import org.openecomp.mso.requestsdb.InfraRequests;
+import org.openecomp.mso.requestsdb.RequestsDatabase;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@@ -55,10 +60,25 @@ public class VnfRequestHandlerTest {
}
@Test
- public void manageVnfRequestTest(){
+ public void manageVnfRequestTestV2(){
Response resp = handler.manageVnfRequest("<name>Test</name>", "v2");
assertTrue(null != resp);
}
+ @Test
+ public void manageVnfRequestTestv1(){
+ Response resp = handler.manageVnfRequest("<name>Test</name>", "v1");
+ assertTrue(null != resp);
+ }
+ @Test
+ public void manageVnfRequestTestv3(){
+ Response resp = handler.manageVnfRequest("<name>Test</name>", "v3");
+ assertTrue(null != resp);
+ }
+ @Test
+ public void manageVnfRequestTestInvalidVersion(){
+ Response resp = handler.manageVnfRequest("<name>Test</name>", "v30");
+ assertTrue(null != resp);
+ }
@Test
public void manageVnfRequest2Test(){
@@ -149,5 +169,76 @@ public class VnfRequestHandlerTest {
String param = (String)qr.getVnfParams();
assertTrue(param.equals("test"));
}
+
+ @Test
+ public void queryFiltersTest(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public List <InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName,
+ String queryValue,
+ String requestType) {
+ List <InfraActiveRequests> list = new ArrayList<InfraActiveRequests>();
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setAaiServiceId("299392");
+ req.setAction("CREATE");
+ req.setRequestStatus("COMPLETE");
+ req.setProgress(10001l);
+ req.setSource("test");
+ req.setStartTime(new Timestamp(10020100));
+ req.setEndTime(new Timestamp(20020100));
+ req.setStatusMessage("message");
+ list.add(req);
+ return list;
+ }
+ };
+ Response resp = handler.queryFilters("vnfType", "serviceType", "aicNodeClli", "tenantId", "volumeGroupId", "volumeGroupName", "vnfName", "v1");
+ assertTrue(resp.getEntity().toString() != null);
+ }
+
+ @Test
+ public void queryFiltersTestNullVnfType(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public List <InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName,
+ String queryValue,
+ String requestType) {
+ List <InfraActiveRequests> list = new ArrayList<InfraActiveRequests>();
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setAaiServiceId("299392");
+ req.setAction("CREATE");
+ req.setRequestStatus("COMPLETE");
+ req.setProgress(10001l);
+ req.setSource("test");
+ req.setStartTime(new Timestamp(10020100));
+ req.setEndTime(new Timestamp(20020100));
+ req.setStatusMessage("message");
+ list.add(req);
+ return list;
+ }
+ };
+ Response resp = handler.queryFilters(null, null, null, null, null, null, null, "v1");
+ assertTrue(resp.getEntity().toString() != null);
+ }
+
+ @Test
+ public void getRequestTest(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) {
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setAaiServiceId("299392");
+ req.setAction("CREATE");
+ req.setRequestStatus("COMPLETE");
+ req.setProgress(10001l);
+ req.setSource("test");
+ req.setStartTime(new Timestamp(10020100));
+ req.setEndTime(new Timestamp(20020100));
+ req.setStatusMessage("message");
+ return req;
+ }
+ };
+ Response resp = handler.getRequest("388293", "v1");
+ assertTrue(resp.getEntity().toString() != null);
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java
index be41944b31..bf4d7c4d98 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java
@@ -24,6 +24,9 @@ import static org.junit.Assert.assertTrue;
import java.lang.reflect.Field;
import java.net.URI;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@@ -34,6 +37,10 @@ import mockit.MockUp;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
+import org.openecomp.mso.apihandler.common.ValidationException;
+import org.openecomp.mso.properties.MsoJavaProperties;
+import org.openecomp.mso.requestsdb.InfraActiveRequests;
+import org.openecomp.mso.requestsdb.RequestsDatabase;
public class VolumeRequestHandlerTest {
VolumeRequestHandler handler = null;
@@ -60,7 +67,7 @@ public class VolumeRequestHandlerTest {
}
@Test
- public void manageVnfRequest2Test(){
+ public void manageVnfRequest2TestV1InvalidRequestData(){
Mockito.when(uriInfo.getRequestUri())
.thenReturn(URI.create("http://localhost:8080/test"));
@@ -70,7 +77,135 @@ public class VolumeRequestHandlerTest {
return false;
}
};
- Response resp = handler.manageVolumeRequest("<name>Test</name>", "v2");
+ String request = "{\"result\":\"success\"}";
+ Response resp = handler.manageVolumeRequest(request, "v1");
+ assertTrue(null != resp);
+ }
+
+ @Test
+ public void manageVnfRequest2TestV1(){
+ Mockito.when(uriInfo.getRequestUri())
+ .thenReturn(URI.create("http://localhost:8080/test"));
+
+ new MockUp<MsoPropertiesUtils>() {
+ @Mock
+ public synchronized final boolean getNoPropertiesState() {
+ return false;
+ }
+ };
+ String request = "<volume-request xmlns=\"http://org.openecomp/mso/infra/volume-request/v1\"><request-info><action>CREATE</action><request-status>COMPLETE</request-status><status-message>message</status-message><progress>10001</progress><start-time>1970-01-01 02:47:00.1</start-time><end-time>1970-01-01 05:33:40.1</end-time><source>test</source></request-info><volume-inputs><service-id>299392</service-id></volume-inputs></volume-request>";
+ Response resp = handler.manageVolumeRequest(request, "v1");
+ assertTrue(null != resp);
+ }
+
+ @Test
+ public void manageVnfRequest2TestV2(){
+ Mockito.when(uriInfo.getRequestUri())
+ .thenReturn(URI.create("http://localhost:8080/test"));
+
+ new MockUp<MsoPropertiesUtils>() {
+ @Mock
+ public synchronized final boolean getNoPropertiesState() {
+ return false;
+ }
+ };
+ String request = "<volume-request xmlns=\"http://org.openecomp/mso/infra/volume-request/v2\"><request-info><action>CREATE</action><request-status>COMPLETE</request-status><status-message>message</status-message><progress>10001</progress><start-time>1970-01-01 02:47:00.1</start-time><end-time>1970-01-01 05:33:40.1</end-time><source>test</source></request-info><volume-inputs><service-id>299392</service-id></volume-inputs></volume-request>";
+ Response resp = handler.manageVolumeRequest(request, "v2");
assertTrue(null != resp);
}
+ @Test
+ public void manageVnfRequest2TestV3(){
+ Mockito.when(uriInfo.getRequestUri())
+ .thenReturn(URI.create("http://localhost:8080/test"));
+
+ new MockUp<MsoPropertiesUtils>() {
+ @Mock
+ public synchronized final boolean getNoPropertiesState() {
+ return false;
+ }
+ };
+ String request = "<volume-request xmlns=\"http://org.openecomp/mso/infra/volume-request/v3\"><request-info><action>CREATE</action><request-status>COMPLETE</request-status><status-message>message</status-message><progress>10001</progress><start-time>1970-01-01 02:47:00.1</start-time><end-time>1970-01-01 05:33:40.1</end-time><source>test</source></request-info><volume-inputs><service-id>299392</service-id></volume-inputs></volume-request>";
+ Response resp = handler.manageVolumeRequest(request, "v3");
+ assertTrue(null != resp);
+ }
+ @Test
+ public void manageVnfRequest2TestInvalidVersion(){
+ Mockito.when(uriInfo.getRequestUri())
+ .thenReturn(URI.create("http://localhost:8080/test"));
+
+ new MockUp<MsoPropertiesUtils>() {
+ @Mock
+ public synchronized final boolean getNoPropertiesState() {
+ return false;
+ }
+ };
+ String request = "<volume-request xmlns=\"http://org.openecomp/mso/infra/volume-request/v1\"><request-info><action>CREATE</action><request-status>COMPLETE</request-status><status-message>message</status-message><progress>10001</progress><start-time>1970-01-01 02:47:00.1</start-time><end-time>1970-01-01 05:33:40.1</end-time><source>test</source></request-info><volume-inputs><service-id>299392</service-id></volume-inputs></volume-request>";
+ Response resp = handler.manageVolumeRequest(request, "v33");
+ assertTrue(null != resp);
+ }
+
+ @Test
+ public void queryFiltersTest(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public List <InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName,
+ String queryValue,
+ String requestType) {
+ List <InfraActiveRequests> list = new ArrayList<InfraActiveRequests>();
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setAaiServiceId("299392");
+ req.setAction("CREATE");
+ req.setRequestStatus("COMPLETE");
+ req.setProgress(10001l);
+ req.setSource("test");
+ req.setStartTime(new Timestamp(10020100));
+ req.setEndTime(new Timestamp(20020100));
+ req.setStatusMessage("message");
+ list.add(req);
+ return list;
+ }
+ };
+ Response resp = handler.queryFilters("vnfType", "serviceType", "aic", "19929293", "288393923", "test", "v1");
+ assertTrue(resp.getEntity().toString() != null);
+ }
+ @Test
+ public void getRequestTestV3(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) {
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setAaiServiceId("299392");
+ req.setAction("CREATE");
+ req.setRequestStatus("COMPLETE");
+ req.setProgress(10001l);
+ req.setSource("test");
+ req.setStartTime(new Timestamp(10020100));
+ req.setEndTime(new Timestamp(20020100));
+ req.setStatusMessage("message");
+ return req;
+ }
+ };
+ Response resp = handler.getRequest("399293", "v3");
+ assertTrue(resp.getEntity().toString() != null);
+ }
+ @Test
+ public void getRequestTestV2(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) {
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setAaiServiceId("299392");
+ req.setAction("CREATE");
+ req.setRequestStatus("COMPLETE");
+ req.setProgress(10001l);
+ req.setSource("test");
+ req.setStartTime(new Timestamp(10020100));
+ req.setEndTime(new Timestamp(20020100));
+ req.setStatusMessage("message");
+ return req;
+ }
+ };
+ Response resp = handler.getRequest("399293", "v2");
+ assertTrue(resp.getEntity().toString() != null);
+ }
}