summaryrefslogtreecommitdiffstats
path: root/vid-automation/src/test/java/org/onap
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-03-11 09:34:34 +0200
committerIttay Stern <ittay.stern@att.com>2019-03-17 17:02:43 +0200
commit66af8b9b391879be78660d6ccb0a1f1f9340b423 (patch)
treefc0d510f7ea28a437bcb1e3b950d1281ac88a4e4 /vid-automation/src/test/java/org/onap
parent37ad0cc1d36ec6ff68ec39fcaaf2617eef7d08fe (diff)
Merge automation from ECOMP's repository
Reference commit in ECOMP: 8e92a8c6 Issue-ID: VID-378 Change-Id: Ia32f4813378ef95097f788246aa5b1172e20ca48 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-automation/src/test/java/org/onap')
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java270
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/AsyncInfraApiTest.java177
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationALaCarteApiTest.java532
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationALaCarteApiTest2.java211
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationALaCarteApiTest3.java645
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationApiTest.java431
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/BaseApiAaiTest.java2
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/BaseApiTest.java203
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/BaseMsoApiTest.java78
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/CategoryParametersApiTest.java1
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/ChangeManagementApiTest.java135
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/OperationalEnvironmentControllerApiTest.java2
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/ProbeApiTest.java209
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/SampleApiTest.java3
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/SdcApiTest.java88
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/ServiceInstanceMsoApiTest.java51
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/ServicePermissionsApiTest.java63
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/ServiceTreeApiTest.java370
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/TestUtils.java81
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/VersionControllerApiTest.java26
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/VidConfigurationApiTest.java1
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/pProbeAaiApiTest.java21
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/pProbeMsoApiTest.java42
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/asyncInstantiation/JobAuditStatus.java121
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/asyncInstantiation/ServiceInfo.java75
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/mso/ChangeManagementRequest.java4
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/mso/MsoResponseWrapper2.java60
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/mso/MsoResponseWrapperInterface.java15
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/mso/OperationalEnvironment.java11
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/mso/OperationalEnvironmentList.java5
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/mso/RelatedToProperty.java4
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/mso/Relationship.java6
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/mso/RelationshipData.java8
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/mso/RelationshipList.java5
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/mso/RequestInfo.java2
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/mso/RequestParameters.java2
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/mso/RestObject.java123
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/mso/SubscriberInfo.java2
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/mso/UserParam.java2
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/probe/ExternalComponentStatus.java2
-rw-r--r--vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java28
-rw-r--r--vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java44
-rw-r--r--vid-automation/src/test/java/org/onap/vid/more/SimulatorLoaderTest.java24
43 files changed, 2687 insertions, 1498 deletions
diff --git a/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java
index 7d558940d..952aa522d 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java
@@ -1,12 +1,33 @@
package org.onap.vid.api;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet.ofL3Network;
+import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet.ofServiceInstance;
+import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet.ofVlanTag;
+import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet.ofVnf;
+import static org.onap.simulator.presetGenerator.presets.ecompportal_att.EcompPortalPresetsUtils.getEcompPortalPresets;
+import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND;
+import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET;
+import static vid.automation.test.utils.TestHelper.GET_SERVICE_MODELS_BY_DISTRIBUTION_STATUS;
+
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMultimap;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.URISyntaxException;
+import java.util.UUID;
import net.javacrumbs.jsonunit.JsonAssert;
+import net.javacrumbs.jsonunit.core.Configuration;
+import net.javacrumbs.jsonunit.core.Option;
import org.apache.commons.text.StringEscapeUtils;
-import org.codehaus.jackson.map.ObjectMapper;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIBadBodyForGetServicesGet;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAICloudRegionAndSourceFromConfigurationPut;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetHomingForVfModule;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetInstanceGroupsByCloudRegion;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetInstanceGroupsByCloudRegionRequiredMissing;
@@ -17,6 +38,9 @@ import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetPortMirroringS
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetPortMirroringSourcePortsError;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetRelatedInstanceGroupsByVnfId;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet;
+import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceMetadataGet;
+import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGet;
import org.onap.vid.model.aai.AaiResponse;
import org.onap.vid.model.mso.OperationalEnvironmentList;
import org.onap.vid.more.LoggerFormatTest;
@@ -29,31 +53,23 @@ import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.util.UriComponentsBuilder;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import vid.automation.test.infra.FeatureTogglingTest;
+import vid.automation.test.infra.Features;
import vid.automation.test.services.SimulatorApi;
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.net.URISyntaxException;
-
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.*;
-import static org.onap.simulator.presetGenerator.presets.ecompportal_att.EcompPortalPresetsUtils.getEcompPortalPresets;
-import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND;
-import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET;
+import vid.automation.test.utils.TestHelper;
public class AaiApiTest extends BaseApiAaiTest {
-
+ private static final String AAI_HOMING_DATA_RESPONSE = "viewEdit/aaiHomingDataResponse.json";
public static final String GET_OPERATIONAL_ENVIRONMENTS_JSON = "get_operational_environments_aai.json";
public static final String GET_OPERATIONAL_ENVIRONMENTS_JSON_ERROR = "get_operational_environments_aai_error.json";
- public static final String[] AAI_GET_SERVICES_ERROR_SIMULATOR_RESPONSES = {"getServicesAaiErrorResp.json", "aai_get_full_subscribers.json"};
- public static final String[] AAI_GET_SERVICES_FINE_SIMULATOR_RESPONSES = {"getServicesAaiFineResp.json", "aai_get_full_subscribers.json"};
-
+ public static final String[] AAI_GET_SERVICES_ERROR_SIMULATOR_RESPONSES = {"getServicesAaiErrorResp.json", "create_new_instance/aai_get_full_subscribers.json"};
+ public static final String[] AAI_GET_SERVICES_FINE_SIMULATOR_RESPONSES = {"getServicesAaiFineResp.json", "create_new_instance/aai_get_full_subscribers.json"};
+ public static final String AAI_VNFS_FOR_CHANGE_MANAGEMENT_JSON = "changeManagement/get_vnf_data_by_globalid_and_service_type.json";
public static final String OPERATIONAL_ENVIRONMENT_TYPE = "VNF";
public static final String OPERATIONAL_ENVIRONMENT_STATUS = "Activate";
- public static final String BASE_GET_SERVICES_AAI_REQUEST_BODY = "{\"start\" : \"service-design-and-creation/models\", \"query\" : \"query/serviceModels-byDistributionStatus?distributionStatus=DISTRIBUTION_COMPLETE_OK\";}";
public static final String GET_INSTANCE_GROUPS_BY_CLOUDREGION_EXPECTED_RESPONSE = "{\"results\":[{\"instance-group\":{\"id\":\"AAI-12002-test3-vm230w\",\"description\":\"a9DEa0kpY\",\"instance-group-role\":\"JZmha7QSS4tJ\",\"model-invariant-id\":\"model-id3\",\"model-version-id\":\"a0efd5fc-f7be-4502-936a-a6c6392b958f\",\"instance-group-type\":\"type\",\"resource-version\":\"1520888659539\",\"instance-group-name\":\"wKmBXiO1xm8bK\",\"instance-group-function\":\"testfunction2\",\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"AAI-12002-vm230w\"},{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"AAI-region-vm230w\"}],\"relatedToPropertyList\":[{\"property-key\":\"cloud-region.owner-defined-type\",\"property-value\":null}],\"related-to\":\"cloud-region\",\"related-link\":\"/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/AAI-12002-vm230w/AAI-region-vm230w\",\"relationship-label\":\"org.onap.relationships.inventory.Uses\",\"relationship-data\":[{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"AAI-12002-vm230w\"},{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"AAI-region-vm230w\"}],\"related-to-property\":[{\"property-key\":\"cloud-region.owner-defined-type\",\"property-value\":null}]}]}}},{\"instance-group\":{\"id\":\"AAI-12002-test1-vm230w\",\"description\":\"a9DEa0kpY\",\"instance-group-role\":\"JZmha7QSS4tJ\",\"model-invariant-id\":\"model-id1\",\"model-version-id\":\"a0efd5fc-f7be-4502-936a-a6c6392b958f\",\"instance-group-type\":\"type\",\"resource-version\":\"1520886467989\",\"instance-group-name\":\"wKmBXiO1xm8bK\",\"instance-group-function\":\"testfunction2\",\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"AAI-12002-vm230w\"},{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"AAI-region-vm230w\"}],\"relatedToPropertyList\":[{\"property-key\":\"cloud-region.owner-defined-type\",\"property-value\":null}],\"related-to\":\"cloud-region\",\"related-link\":\"/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/AAI-12002-vm230w/AAI-region-vm230w\",\"relationship-label\":\"org.onap.relationships.inventory.Uses\",\"relationship-data\":[{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"AAI-12002-vm230w\"},{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"AAI-region-vm230w\"}],\"related-to-property\":[{\"property-key\":\"cloud-region.owner-defined-type\",\"property-value\":null}]}]}}},{\"instance-group\":{\"id\":\"AAI-12002-test2-vm230w\",\"description\":\"a9DEa0kpY\",\"instance-group-role\":\"JZmha7QSS4tJ\",\"model-invariant-id\":\"model-id2\",\"model-version-id\":\"version2\",\"instance-group-type\":\"type\",\"resource-version\":\"1520888629970\",\"instance-group-name\":\"wKmBXiO1xm8bK\",\"instance-group-function\":\"testfunction2\",\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"AAI-12002-vm230w\"},{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"AAI-region-vm230w\"}],\"relatedToPropertyList\":[{\"property-key\":\"cloud-region.owner-defined-type\",\"property-value\":null}],\"related-to\":\"cloud-region\",\"related-link\":\"/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/AAI-12002-vm230w/AAI-region-vm230w\",\"relationship-label\":\"org.onap.relationships.inventory.Uses\",\"relationship-data\":[{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"AAI-12002-vm230w\"},{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"AAI-region-vm230w\"}],\"related-to-property\":[{\"property-key\":\"cloud-region.owner-defined-type\",\"property-value\":null}]}]}}}]}\n";
- public static final String GET_NETWORK_COLLECTION_EXPECTED_RESPONSE = "{\"results\":{\"collection\":{\"collection-id\":\"collection-1-2018-rs804s\",\"model-invariant-id\":\"5761e0a7-defj777\",\"model-version-id\":\"5761e0a7-defj232\",\"collection-name\":\"collection-name\",\"collection-type\":\"L3-NETWORK\",\"collection-role\":\"SUB-INTERFACE\",\"collection-function\":\"collection-function\",\"collection-customization-id\":\"custom-unique-data-id\",\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"customer.global-customer-id\",\"relationship-value\":\"customer-1-2017-rs804s\"},{\"relationship-key\":\"service-subscription.service-type\",\"relationship-value\":\"service-value7-rs804s\"},{\"relationship-key\":\"service-instance.service-instance-id\",\"relationship-value\":\"2UJZZ01777-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"service-instance.service-instance-name\",\"property-value\":null}],\"related-to\":\"service-instance\",\"related-link\":\"/aai/v13/business/customers/customer/customer-1-2017-rs804s/service-subscriptions/service-subscription/service-value7-rs804s/service-instances/service-instance/2UJZZ01777-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"customer.global-customer-id\",\"relationship-value\":\"customer-1-2017-rs804s\"},{\"relationship-key\":\"service-subscription.service-type\",\"relationship-value\":\"service-value7-rs804s\"},{\"relationship-key\":\"service-instance.service-instance-id\",\"relationship-value\":\"2UJZZ01777-rs804s\"}],\"related-to-property\":[{\"property-key\":\"service-instance.service-instance-name\",\"property-value\":null}]},{\"relationDataList\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}],\"related-to\":\"instance-group\",\"related-link\":\"/aai/v13/network/instance-groups/instance-group/instanceGroup-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"related-to-property\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}]}]},\"resource-version\":\"1521662811309\"},\"networks\":[{\"network-id\":\"l3network-id-rs804s\",\"network-name\":\"oam-net\",\"network-type\":\"Tenant_Layer_3\",\"network-role\":\"HngwProtectedOam.OAM\",\"network-technology\":\"Contrail\",\"is-bound-to-vpn\":false,\"resource-version\":\"1521662814627\",\"is-provider-network\":false,\"is-shared-network\":false,\"is-external-network\":false,\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}],\"related-to\":\"instance-group\",\"related-link\":\"/aai/v13/network/instance-groups/instance-group/instanceGroup-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"related-to-property\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}]}]}},{\"network-id\":\"l3network-id-3-rs804s\",\"network-name\":\"oam-net\",\"network-type\":\"Tenant_Layer_3\",\"network-role\":\"HngwProtectedOam.OAM\",\"network-technology\":\"Contrail\",\"is-bound-to-vpn\":false,\"resource-version\":\"1521662816043\",\"is-provider-network\":false,\"is-shared-network\":false,\"is-external-network\":false,\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}],\"related-to\":\"instance-group\",\"related-link\":\"/aai/v13/network/instance-groups/instance-group/instanceGroup-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"related-to-property\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}]}]}},{\"network-id\":\"l3network-id-2-rs804s\",\"network-name\":\"oam-net\",\"network-type\":\"Tenant_Layer_3\",\"network-role\":\"HngwProtectedOam.OAM\",\"network-technology\":\"Contrail\",\"is-bound-to-vpn\":false,\"resource-version\":\"1521662815304\",\"is-provider-network\":false,\"is-shared-network\":false,\"is-external-network\":false,\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}],\"related-to\":\"instance-group\",\"related-link\":\"/aai/v13/network/instance-groups/instance-group/instanceGroup-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"related-to-property\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}]}]}}],\"service-instance\":{\"service-instance-id\":\"2UJZZ01777-rs804s\",\"resource-version\":\"1521662813382\",\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"collection.collection-id\",\"relationship-value\":\"collection-1-2018-rs804s\"}],\"relatedToPropertyList\":null,\"related-to\":\"collection\",\"related-link\":\"/aai/v13/network/collections/collection/collection-1-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"collection.collection-id\",\"relationship-value\":\"collection-1-2018-rs804s\"}],\"related-to-property\":null}]}},\"instance-group\":{\"id\":\"instanceGroup-2018-rs804s\",\"description\":\"zr6h\",\"instance-group-role\":\"JZmha7QSS4tJ\",\"model-invariant-id\":\"5761e0a7-defj777\",\"model-version-id\":\"5761e0a7-defj22\",\"instance-group-type\":\"7DDjOdNL\",\"resource-version\":\"1521662814023\",\"instance-group-name\":\"wKmBXiO1xm8bK\",\"instance-group-function\":\"testfunction2\",\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}],\"related-to\":\"l3-network\",\"related-link\":\"/aai/v13/network/l3-networks/l3-network/l3network-id-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-rs804s\"}],\"related-to-property\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}]},{\"relationDataList\":[{\"relationship-key\":\"collection.collection-id\",\"relationship-value\":\"collection-1-2018-rs804s\"}],\"relatedToPropertyList\":null,\"related-to\":\"collection\",\"related-link\":\"/aai/v13/network/collections/collection/collection-1-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"collection.collection-id\",\"relationship-value\":\"collection-1-2018-rs804s\"}],\"related-to-property\":null},{\"relationDataList\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-3-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}],\"related-to\":\"l3-network\",\"related-link\":\"/aai/v13/network/l3-networks/l3-network/l3network-id-3-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-3-rs804s\"}],\"related-to-property\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}]},{\"relationDataList\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-2-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}],\"related-to\":\"l3-network\",\"related-link\":\"/aai/v13/network/l3-networks/l3-network/l3network-id-2-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-2-rs804s\"}],\"related-to-property\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}]}]}}}}\n";
+ public static final String GET_NETWORK_COLLECTION_EXPECTED_RESPONSE = "{\"results\":{\"collection\":{\"collection-id\":\"collection-1-2018-rs804s\",\"model-invariant-id\":\"5761e0a7-defj777\",\"model-version-id\":\"5761e0a7-defj232\",\"collection-name\":\"collection-name\",\"collection-type\":\"L3-NETWORK\",\"collection-role\":\"SUB-INTERFACE\",\"collection-function\":\"collection-function\",\"collection-customization-id\":\"custom-unique-data-id\",\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"customer.global-customer-id\",\"relationship-value\":\"customer-1-2017-rs804s\"},{\"relationship-key\":\"service-subscription.service-type\",\"relationship-value\":\"service-value7-rs804s\"},{\"relationship-key\":\"service-instance.service-instance-id\",\"relationship-value\":\"2UJZZ01777-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"service-instance.service-instance-name\",\"property-value\":null}],\"related-to\":\"service-instance\",\"related-link\":\"/aai/v13/business/customers/customer/customer-1-2017-rs804s/service-subscriptions/service-subscription/service-value7-rs804s/service-instances/service-instance/2UJZZ01777-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"customer.global-customer-id\",\"relationship-value\":\"customer-1-2017-rs804s\"},{\"relationship-key\":\"service-subscription.service-type\",\"relationship-value\":\"service-value7-rs804s\"},{\"relationship-key\":\"service-instance.service-instance-id\",\"relationship-value\":\"2UJZZ01777-rs804s\"}],\"related-to-property\":[{\"property-key\":\"service-instance.service-instance-name\",\"property-value\":null}]},{\"relationDataList\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}],\"related-to\":\"instance-group\",\"related-link\":\"/aai/v13/network/instance-groups/instance-group/instanceGroup-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"related-to-property\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}]}]},\"resource-version\":\"1521662811309\"},\"networks\":[{\"network-id\":\"l3network-id-rs804s\",\"network-name\":\"oam-net\",\"network-type\":\"Tenant_Layer_3\",\"network-role\":\"RosemaProtectedOam.OAM\",\"network-technology\":\"Contrail\",\"is-bound-to-vpn\":false,\"resource-version\":\"1521662814627\",\"orchestration-status\":\"Created\",\"is-provider-network\":false,\"is-shared-network\":false,\"is-external-network\":false,\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}],\"related-to\":\"instance-group\",\"related-link\":\"/aai/v13/network/instance-groups/instance-group/instanceGroup-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"related-to-property\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}]}]}},{\"network-id\":\"l3network-id-3-rs804s\",\"network-name\":\"oam-net\",\"network-type\":\"Tenant_Layer_3\",\"network-role\":\"RosemaProtectedOam.OAM\",\"network-technology\":\"Contrail\",\"is-bound-to-vpn\":false,\"resource-version\":\"1521662816043\",\"orchestration-status\":\"Created\",\"is-provider-network\":false,\"is-shared-network\":false,\"is-external-network\":false,\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}],\"related-to\":\"instance-group\",\"related-link\":\"/aai/v13/network/instance-groups/instance-group/instanceGroup-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"related-to-property\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}]}]}},{\"network-id\":\"l3network-id-2-rs804s\",\"network-name\":\"oam-net\",\"network-type\":\"Tenant_Layer_3\",\"network-role\":\"RosemaProtectedOam.OAM\",\"network-technology\":\"Contrail\",\"is-bound-to-vpn\":false,\"resource-version\":\"1521662815304\",\"orchestration-status\":\"Created\",\"is-provider-network\":false,\"is-shared-network\":false,\"is-external-network\":false,\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}],\"related-to\":\"instance-group\",\"related-link\":\"/aai/v13/network/instance-groups/instance-group/instanceGroup-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"related-to-property\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}]}]}}],\"service-instance\":{\"service-instance-id\":\"2UJZZ01777-rs804s\",\"resource-version\":\"1521662813382\",\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"collection.collection-id\",\"relationship-value\":\"collection-1-2018-rs804s\"}],\"relatedToPropertyList\":null,\"related-to\":\"collection\",\"related-link\":\"/aai/v13/network/collections/collection/collection-1-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"collection.collection-id\",\"relationship-value\":\"collection-1-2018-rs804s\"}],\"related-to-property\":null}]}},\"instance-group\":{\"id\":\"instanceGroup-2018-rs804s\",\"description\":\"zr6h\",\"instance-group-role\":\"JZmha7QSS4tJ\",\"model-invariant-id\":\"5761e0a7-defj777\",\"model-version-id\":\"5761e0a7-defj22\",\"instance-group-type\":\"7DDjOdNL\",\"resource-version\":\"1521662814023\",\"instance-group-name\":\"wKmBXiO1xm8bK\",\"instance-group-function\":\"testfunction2\",\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}],\"related-to\":\"l3-network\",\"related-link\":\"/aai/v13/network/l3-networks/l3-network/l3network-id-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-rs804s\"}],\"related-to-property\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}]},{\"relationDataList\":[{\"relationship-key\":\"collection.collection-id\",\"relationship-value\":\"collection-1-2018-rs804s\"}],\"relatedToPropertyList\":null,\"related-to\":\"collection\",\"related-link\":\"/aai/v13/network/collections/collection/collection-1-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"collection.collection-id\",\"relationship-value\":\"collection-1-2018-rs804s\"}],\"related-to-property\":null},{\"relationDataList\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-3-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}],\"related-to\":\"l3-network\",\"related-link\":\"/aai/v13/network/l3-networks/l3-network/l3network-id-3-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-3-rs804s\"}],\"related-to-property\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}]},{\"relationDataList\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-2-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}],\"related-to\":\"l3-network\",\"related-link\":\"/aai/v13/network/l3-networks/l3-network/l3network-id-2-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-2-rs804s\"}],\"related-to-property\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}]}]}}}}\n";
public static final String GET_AAI_SERVIES_EXPECTED_RESULT = "{\n" +
" \"services\": [{\n" +
" \"uuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\n" +
@@ -202,8 +218,6 @@ public class AaiApiTest extends BaseApiAaiTest {
" \"readOnly\": false\n" +
"}";
- static final ObjectMapper om = new ObjectMapper();
-
private String getGetOperationEnvironmentsUri() {
return uri.toASCIIString() + "/get_operational_environments";
}
@@ -262,18 +276,9 @@ public class AaiApiTest extends BaseApiAaiTest {
assertEquals(1, list.getOperationalEnvironment().get(0).getRelationshipList().getRelationship().size());
}
-
- @Test
- public void testVoid(){
- SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET,
- "add_subinterface/aai_get_tenants.json"
- , "add_subinterface/aai_get_services.json"
- );
- }
-
-
@Test(dataProvider = "errorCodes")
public void getServicesWitErrorResponse(int errorCode) throws IOException, URISyntaxException {
+ TestHelper.resetAaiCache(GET_SERVICE_MODELS_BY_DISTRIBUTION_STATUS, restTemplate, uri);
final String expectedResult = "{\"services\":[],\"readOnly\":false}";
callAaiWithSimulatedErrorResponse(AAI_GET_SERVICES_ERROR_SIMULATOR_RESPONSES,
@@ -284,11 +289,25 @@ public class AaiApiTest extends BaseApiAaiTest {
@Test
public void getServicesFineRequest() throws IOException, URISyntaxException {
-
+ TestHelper.resetAaiCache(GET_SERVICE_MODELS_BY_DISTRIBUTION_STATUS, restTemplate, uri);
callAaiWithSimulatedErrorResponse(AAI_GET_SERVICES_FINE_SIMULATOR_RESPONSES,
ImmutableMap.of(),
getAaiServicesUri(), "", 200, GET_AAI_SERVIES_EXPECTED_RESULT, HttpMethod.GET);
+ }
+ @Test
+ public void whenGetServicesErrorResponse_badResponseIsNotCached() throws IOException, URISyntaxException {
+ TestHelper.resetAaiCache(GET_SERVICE_MODELS_BY_DISTRIBUTION_STATUS, restTemplate, uri);
+
+
+ final String expectedErrorResult = "{\"services\":[],\"readOnly\":false}";
+ //call AAI with bad response by clear exceptions from simulator, bad response shall not be cached
+ callAaiWithSimulatedErrorResponse(new String[]{}, ImmutableMap.of(), getAaiServicesUri(), "", 200, expectedErrorResult, HttpMethod.GET);
+
+ //call AAI with fine response
+ callAaiWithSimulatedErrorResponse(AAI_GET_SERVICES_FINE_SIMULATOR_RESPONSES,
+ ImmutableMap.of(),
+ getAaiServicesUri(), "", 200, GET_AAI_SERVIES_EXPECTED_RESULT, HttpMethod.GET);
}
@DataProvider
@@ -305,7 +324,7 @@ public class AaiApiTest extends BaseApiAaiTest {
SimulatorApi.registerExpectationFromPresets(getEcompPortalPresets(), APPEND);
SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), APPEND);
- restTemplateErrorAgnostic.getForEntity(uri + "/aai_get_services",String.class);
+ restTemplateErrorAgnostic.getForEntity(uri + "/aai_get_services", String.class);
String logLines = LoggerFormatTest.getLogLines("error", 15, 0, restTemplate, uri);
assertThat("not found in error log", logLines, containsString("Failed to parse aai response"));
@@ -425,12 +444,13 @@ public class AaiApiTest extends BaseApiAaiTest {
assertResponse(GET_NETWORK_COLLECTION_EXPECTED_RESPONSE, response);
}
+
@Test
public void getNetworkCollectionDetailsByServiceInstanceId_given404ErrorAaiResponse_yield200OkWithErrorMsg() {
SimulatorApi.clearAll();
try {
restTemplate.getForObject(uri + "/aai_get_network_collection_details/" + "SOME-RANDOM-UUID", String.class);
- }catch (HttpClientErrorException e){
+ } catch (HttpClientErrorException e) {
assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
}
}
@@ -442,7 +462,7 @@ public class AaiApiTest extends BaseApiAaiTest {
SimulatorApi.registerExpectationFromPreset(presetAAIGetNetworkCollectionDetails, CLEAR_THEN_SET);
try {
restTemplate.getForObject(uri + "/aai_get_network_collection_details/" + "SOME-RANDOM-UUID", String.class);
- }catch (HttpServerErrorException e){
+ } catch (HttpServerErrorException e) {
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, e.getStatusCode());
}
}
@@ -450,9 +470,9 @@ public class AaiApiTest extends BaseApiAaiTest {
@Test
public void getGetInstanceGroupsByCloudRegion_yieldValidResponse() {
SimulatorApi.clearAll();
- final PresetAAIGetInstanceGroupsByCloudRegion presetAAIGetInstanceGroupsByCloudRegion = new PresetAAIGetInstanceGroupsByCloudRegion("CLOUD-OWNER", "CLOUD-REGION-ID", "NETWORK-FUNCTION");
+ final PresetAAIGetInstanceGroupsByCloudRegion presetAAIGetInstanceGroupsByCloudRegion = new PresetAAIGetInstanceGroupsByCloudRegion("CLOUD%20OWNER", "CLOUD-REGION-ID", "NETWORK%20FUNCTION");
SimulatorApi.registerExpectationFromPreset(presetAAIGetInstanceGroupsByCloudRegion, CLEAR_THEN_SET);
- final String response = restTemplate.getForObject(uri + "/aai_get_instance_groups_by_cloudregion/" + "CLOUD-OWNER" + "/" + "CLOUD-REGION-ID" + "/" +"NETWORK-FUNCTION", String.class);
+ final String response = restTemplate.getForObject(uri + "/aai_get_instance_groups_by_cloudregion/" + "CLOUD OWNER" + "/" + "CLOUD-REGION-ID" + "/" + "NETWORK FUNCTION", String.class);
assertResponse(GET_INSTANCE_GROUPS_BY_CLOUDREGION_EXPECTED_RESPONSE, response);
}
@@ -462,16 +482,17 @@ public class AaiApiTest extends BaseApiAaiTest {
SimulatorApi.clearAll();
final PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest presetAAIGetInstanceGroupsByCloudRegion = new PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest("CLOUD-OWNER", "CLOUD-REGION-ID", "NETWORK-FUNCTION");
SimulatorApi.registerExpectationFromPreset(presetAAIGetInstanceGroupsByCloudRegion, CLEAR_THEN_SET);
- final String response = restTemplate.getForObject(uri + "/aai_get_instance_groups_by_cloudregion/" + "CLOUD-OWNER" + "/" + "CLOUD-REGION-ID" + "/" +"NETWORK-FUNCTION", String.class);
+ final String response = restTemplate.getForObject(uri + "/aai_get_instance_groups_by_cloudregion/" + "CLOUD-OWNER" + "/" + "CLOUD-REGION-ID" + "/" + "NETWORK-FUNCTION", String.class);
assertResponse(GET_INSTANCE_GROUPS_BY_CLOUDREGION_EXPECTED_RESPONSE, response);
}
+
@Test
public void getGetInstanceGroupsByCloudRegion_given404ErrorAaiResponse_yield200OkWithErrorMsg() {
SimulatorApi.clearAll();
try {
- restTemplate.getForObject(uri + "/aai_get_instance_groups_by_cloudregion/" + "CLOUD-OWNER" + "/" + "CLOUD-REGION-ID" + "/" +"NETWORK-FUNCTION", String.class);
- }catch (HttpClientErrorException e){
+ restTemplate.getForObject(uri + "/aai_get_instance_groups_by_cloudregion/" + "CLOUD-OWNER" + "/" + "CLOUD-REGION-ID" + "/" + "NETWORK-FUNCTION", String.class);
+ } catch (HttpClientErrorException e) {
assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
}
}
@@ -482,8 +503,8 @@ public class AaiApiTest extends BaseApiAaiTest {
final PresetAAIGetInstanceGroupsByCloudRegionRequiredMissing presetAAIGetInstanceGroupsByCloudRegion = new PresetAAIGetInstanceGroupsByCloudRegionRequiredMissing("CLOUD-OWNER", "CLOUD-REGION-ID", "NETWORK-FUNCTION");
SimulatorApi.registerExpectationFromPreset(presetAAIGetInstanceGroupsByCloudRegion, CLEAR_THEN_SET);
try {
- restTemplate.getForObject(uri + "/aai_get_instance_groups_by_cloudregion/" + "CLOUD-OWNER" + "/" + "CLOUD-REGION-ID" + "/" +"NETWORK-FUNCTION", String.class);
- }catch (HttpServerErrorException e){
+ restTemplate.getForObject(uri + "/aai_get_instance_groups_by_cloudregion/" + "CLOUD-OWNER" + "/" + "CLOUD-REGION-ID" + "/" + "NETWORK-FUNCTION", String.class);
+ } catch (HttpServerErrorException e) {
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, e.getStatusCode());
}
}
@@ -510,18 +531,28 @@ public class AaiApiTest extends BaseApiAaiTest {
final PresetAAIGetRelatedInstanceGroupsByVnfId getRelatedInstanceGroupsByVnfId = new PresetAAIGetRelatedInstanceGroupsByVnfId(vnfId);
SimulatorApi.registerExpectationFromPreset(getRelatedInstanceGroupsByVnfId, CLEAR_THEN_SET);
- final String response = restTemplate.getForObject(uri + "/aai_get_instance_groups_by_vnf_instance_id/" + vnfId, String.class);
+ final String response = restTemplate.getForObject(uri + "/aai_get_instance_groups_by_vnf_instance_id/" + vnfId,
+ String.class);
assertResponse("[{\"type\":\"instance-group\",\"name\":\"instance group name\"},{\"type\":\"instance-group\",\"name\":\"instance group name\"}]", response);
}
@Test
+ public void getHomingDataForVfModule(){
+ String vnfId= "0846287b-65bf-45a6-88f6-6a1af4149fac", vfModuleId= "a9b70ac0-5917-4203-a308-0e6920e6d09b";
+ SimulatorApi.registerExpectationFromPreset(new PresetAAIGetHomingForVfModule(vnfId,vfModuleId), CLEAR_THEN_SET);
+ final String response = restTemplate.getForObject(uri + "/aai_get_homing_by_vfmodule/"+ vnfId +"/"+vfModuleId, String.class);
+ String exectedResponse = TestUtils.convertRequest(objectMapper, AAI_HOMING_DATA_RESPONSE);
+ assertResponse(exectedResponse,response);
+ }
+
+ @Test
public void getGetRelatedInstanceGroupsByVnfId__yield404NotFound() {
final PresetAAIGetRelatedInstanceGroupsByVnfId getRelatedInstanceGroupsByVnfId = new PresetAAIGetRelatedInstanceGroupsByVnfId("abcd");
SimulatorApi.registerExpectationFromPreset(getRelatedInstanceGroupsByVnfId, CLEAR_THEN_SET);
try {
restTemplate.getForObject(uri + "/aai_get_instance_groups_by_vnf_instance_id/" + "dcba", String.class);
- } catch (HttpClientErrorException e){
+ } catch (HttpClientErrorException e) {
assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
}
@@ -547,9 +578,162 @@ public class AaiApiTest extends BaseApiAaiTest {
assertResponse(expected, response);
}
+ @Test
+ @FeatureTogglingTest(Features.FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS)
+ public void networksToVlans_simpleRequest_responseIsCorrect() {
+ // Prepare randomized values
+ // Some of these random values are persisted to match with the
+ // cypress preset "aaiGetNetworksToVlansByServiceInstance.json".
+ String globalCustomerId = UUID.randomUUID().toString();
+ String sdcModelUuid = "5a3ad576-c01d-4bed-8194-0e72b4a3d020";
+ String serviceType = "vMOG";
+ int vlanIdOuter = 34612;
+ int vlanIdOuter2 = 8568012;
+ int vlanIdOuter3 = 4;
+
+ // build hierarchical presets:
+ //
+ // service instance
+ // ║
+ // ╠═ network 1
+ // ║ ╠═ vlan 1
+ // ║ ╚═ vlan 2
+ // ║
+ // ╠═ network 2
+ // ║ ╚═ vlan 3
+ // ║
+ PresetAAIStandardQueryGet vlanTagPreset1 = ofVlanTag(vlanIdOuter);
+ PresetAAIStandardQueryGet vlanTagPreset2 = ofVlanTag(vlanIdOuter2);
+ PresetAAIStandardQueryGet vlanTagPreset3 = ofVlanTag(vlanIdOuter3);
+
+ PresetAAIStandardQueryGet l3NetworkPreset1 = ofL3Network("7989a6d2-ba10-4a5d-8f15-4520bc833090", "DDDEEEFFF", "Provider Network",
+ ImmutableMultimap.of("vlan-tag", vlanTagPreset1.getReqPath(), "vlan-tag", vlanTagPreset2.getReqPath()), "Failed");
+ PresetAAIStandardQueryGet l3NetworkPreset2 = ofL3Network("e8e2332e-1f84-4237-bc97-3b5b842f52e4","GGGHHHIII", "Network",
+ ImmutableMultimap.of("vlan-tag", vlanTagPreset3.getReqPath()), "Assigned");
+
+ PresetAAIStandardQueryGet serviceInstance = ofServiceInstance("9cdd1b2a-43a7-47bc-a88e-759ba2399f0b",
+ "7a6ee536-f052-46fa-aa7e-2fca9d674c44", "6e59c5de-f052-46fa-aa7e-2fca9d674c44", globalCustomerId, serviceType,
+ ImmutableMultimap.of("l3-network", l3NetworkPreset1.getReqPath(), "l3-network", l3NetworkPreset2.getReqPath()));
+
+ SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
+ serviceInstance, l3NetworkPreset1, l3NetworkPreset2, vlanTagPreset1, vlanTagPreset2, vlanTagPreset3,
+ new PresetSDCGetServiceMetadataGet(sdcModelUuid, UUID.randomUUID().toString(), "service-vl-with-5g-network-provider-alacarte.zip"),
+ new PresetSDCGetServiceToscaModelGet(sdcModelUuid, "service-vl-with-5g-network-provider-alacarte.zip")
+ ), CLEAR_THEN_SET);
+
+ // THE TEST
+ final String response = restTemplate.getForObject(uri + "/aai/standardQuery/vlansByNetworks"
+ + "?serviceInstanceId=" + serviceInstance.getInstanceId()
+ + "&serviceType=" + serviceType
+ + "&globalCustomerId=" + globalCustomerId
+ + "&sdcModelUuid=" + sdcModelUuid
+ , String.class);
+
+ assertResponse(JsonAssert.when(Option.IGNORING_ARRAY_ORDER),
+ getResourceAsString("serviceWithNetwork/aaiGetNetworksToVlansByServiceInstance.json"),
+ response);
+ }
+
+ @Test
+ @FeatureTogglingTest(Features.FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS)
+ public void networksWithVlansToVnf_simpleRequest_responseIsCorrect() {
+ // Prepare randomized values
+ // Some of these random values are persisted to match with the
+ // cypress preset "aaiGetNetworksWithVlansToVnfByServiceInstance.json".
+ String globalCustomerId = UUID.randomUUID().toString();
+ String sdcModelUuid = "5a3ad576-c01d-4bed-8194-0e72b4a3d020";
+ String serviceType = "vMOG";
+ int vlanIdOuter = 34123;
+ int vlanIdOuter2 = 65540;
+ int vlanIdOuter3 = 12345;
+ int vlanIdOuter4 = 67890;
+ int vlanIdOuter5 = 417695;
+ int vlanIdOuter6 = 783243;
+
+ // build hierarchical presets:
+ //
+ // service instance
+ // ║
+ // ╠═ vnf 1
+ // ║ ╚═ network 1
+ // ║ ╠═ vlan 1
+ // ║ ╚═ vlan 2
+ // ║ ╚═ network 2
+ // ║ ╠═ vlan 3
+ // ║ ╚═ vlan 4
+ // ║
+ // ╠═ vnf 2
+ // ║ ╚═ network 3
+ // ║ ╠═ vlan 5
+ // ║ ╚═ vlan 6
+ // ║
+ PresetAAIStandardQueryGet vlanTagPreset1 = ofVlanTag(vlanIdOuter);
+ PresetAAIStandardQueryGet vlanTagPreset2 = ofVlanTag(vlanIdOuter2);
+ PresetAAIStandardQueryGet vlanTagPreset3 = ofVlanTag(vlanIdOuter3);
+ PresetAAIStandardQueryGet vlanTagPreset4 = ofVlanTag(vlanIdOuter4);
+ PresetAAIStandardQueryGet vlanTagPreset5 = ofVlanTag(vlanIdOuter5);
+ PresetAAIStandardQueryGet vlanTagPreset6 = ofVlanTag(vlanIdOuter6);
+
+ PresetAAIStandardQueryGet l3NetworkPreset1 = ofL3Network("36517f3d-2bc2-48f5-aaf8-418520c54330","AAAAABBBBCCCC", "Provider Network",
+ ImmutableMultimap.of("vlan-tag", vlanTagPreset1.getReqPath(), "vlan-tag", vlanTagPreset2.getReqPath()), "Assigned");
+
+ PresetAAIStandardQueryGet l3NetworkPreset2 = ofL3Network("12347f3d-2bc2-48f5-aaf8-418520c54330","DDDEEEE", "Provider Network",
+ ImmutableMultimap.of("vlan-tag", vlanTagPreset3.getReqPath(), "vlan-tag", vlanTagPreset4.getReqPath()), "Created");
+
+ PresetAAIStandardQueryGet vnfPreset1 = ofVnf("c015cc0f-0f37-4488-aabf-53795fd93cd3",
+ ImmutableMultimap.of("l3-network", l3NetworkPreset1.getReqPath() , "l3-network", l3NetworkPreset2.getReqPath()));
+
+ PresetAAIStandardQueryGet l3NetworkPreset3 = ofL3Network("12aa7f3d-2bc2-48f5-aaf8-418520c54330","XXXYYYZZZ", "Network",
+ ImmutableMultimap.of("vlan-tag", vlanTagPreset5.getReqPath(), "vlan-tag", vlanTagPreset6.getReqPath()), "Created");
+
+ PresetAAIStandardQueryGet vnfPreset2 = ofVnf("c55da606-cf38-42c7-bc3c-be8e23b19299", ImmutableMultimap.of("l3-network", l3NetworkPreset3.getReqPath()));
+
+ PresetAAIStandardQueryGet serviceInstance = ofServiceInstance("9cdd1b2a-43a7-47bc-a88e-759ba2399f0b",
+ "7a6ee536-f052-46fa-aa7e-2fca9d674c44", "6e59c5de-f052-46fa-aa7e-2fca9d674c44", globalCustomerId, serviceType,
+ ImmutableMultimap.of("generic-vnf", vnfPreset1.getReqPath(), "generic-vnf", vnfPreset2.getReqPath()));
+
+ SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
+ serviceInstance, vnfPreset1, vnfPreset2, l3NetworkPreset1, l3NetworkPreset2, l3NetworkPreset3, vlanTagPreset1, vlanTagPreset2, vlanTagPreset3, vlanTagPreset4, vlanTagPreset5, vlanTagPreset6,
+ new PresetSDCGetServiceMetadataGet(sdcModelUuid, UUID.randomUUID().toString(), "service-vl-with-5g-network-provider-alacarte.zip"),
+ new PresetSDCGetServiceToscaModelGet(sdcModelUuid, "service-vl-with-5g-network-provider-alacarte.zip")
+ ), CLEAR_THEN_SET);
+
+ // THE TEST
+ final String response = restTemplate.getForObject(uri + "/aai/standardQuery/vlansByNetworks"
+ + "?serviceInstanceId=" + serviceInstance.getInstanceId()
+ + "&serviceType=" + serviceType
+ + "&globalCustomerId=" + globalCustomerId
+ + "&sdcModelUuid=" + sdcModelUuid
+ , String.class);
+
+ assertResponse(JsonAssert.when(Option.IGNORING_ARRAY_ORDER),
+ getResourceAsString("serviceWithNetwork/aaiGetNetworksWithVlansToVnfByServiceInstance.json"),
+ response);
+ }
+
+ @Test
+ public void getVnfDataByGlobalIdAndServiceType() {
+
+ SimulatorApi.registerExpectation(AAI_VNFS_FOR_CHANGE_MANAGEMENT_JSON, APPEND);
+
+ String url = uri + "/get_vnf_data_by_globalid_and_service_type/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/vFlowLogic";
+
+ ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
+//reduced_vnf_data_by_globalid_and_service_type.json
+ assertTrue(false == response.getBody().contains("generic-vfmodule"));
+ assertResponse(JsonAssert.when(Option.IGNORING_ARRAY_ORDER),
+ getResourceAsString("changeManagement/reduced_vnf_data_by_globalid_and_service_type.json"),
+ response.getBody());
+
+ }
+
private void assertResponse(Object expected, String response) {
+ assertResponse(Configuration.empty(), expected, response);
+ }
+
+ private void assertResponse(Configuration configuration, Object expected, String response) {
try {
- JsonAssert.assertJsonEquals(expected, response);
+ JsonAssert.assertJsonEquals(expected, response, configuration);
} catch (Exception | AssertionError e) {
System.err.println("response was: " + response);
throw e;
diff --git a/vid-automation/src/test/java/org/onap/vid/api/AsyncInfraApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/AsyncInfraApiTest.java
index 5f83f36dc..058cb2f5b 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/AsyncInfraApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/AsyncInfraApiTest.java
@@ -1,205 +1,30 @@
package org.onap.vid.api;
import com.google.common.collect.ImmutableList;
-import com.google.gson.JsonObject;
-import net.codestory.http.WebServer;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet;
import org.onap.vid.more.LoggerFormatTest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.testng.Assert;
import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import vid.automation.test.infra.Features;
-import vid.automation.test.infra.Wait;
-import vid.automation.test.model.JobBulk;
-import vid.automation.test.model.JobModel;
import vid.automation.test.services.SimulatorApi;
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.List;
import java.util.UUID;
-import java.util.concurrent.ConcurrentSkipListSet;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsString;
import static org.testng.AssertJUnit.assertEquals;
public class AsyncInfraApiTest extends BaseApiTest {
- private static final String PENDING = "PENDING";
public static final String API_URL = "asyncForTests";
- private boolean asyncJobsIsOn() {
- return Features.FLAG_ASYNC_JOBS.isActive()
- && Features.FLAG_ASYNC_INSTANTIATION.isActive();
- }
-
@BeforeClass
public void login() {
super.login();
}
- @BeforeMethod
- protected void deleteAllPendingJobs() {
- System.out.println("Connecting database...");
-
- try (Connection connection = DriverManager.getConnection(DB_CONFIG.url, DB_CONFIG.username, DB_CONFIG.password)) {
- System.out.println("Database connected!");
- try (Statement stmt = connection.createStatement()) {
- stmt.addBatch("DELETE from `vid_service_info`");
- stmt.addBatch("DELETE FROM `vid_job`");
-
- int[] executeBatch = stmt.executeBatch();
- }
-
- } catch (SQLException e) {
- throw new IllegalStateException("Cannot connect the database!", e);
- }
- }
-
-
- @Test
- public void createBulkOfJobsViaApi_thenGetEachOneOfThem() {
- int jobCount = 10;
- final String url = "http://localhost:1234/testMe";
- ResponseEntity<JobBulk> result = postJobBulk(jobCount, url, "NoOp");
- assertEquals(HttpStatus.OK, result.getStatusCode());
- Assert.assertNotNull(result.getBody());
- assertEquals(jobCount, getJobChildren(result).size());
-
-
- result.getBody().getJobs().forEach(job -> {
- assertThat(job.getUuid(), not(isEmptyOrNullString()));
- assertEquals(PENDING, job.getStatus());
- });
-
- result.getBody().getJobs().forEach(job -> {
- ResponseEntity<JobModel> jobResult = restTemplate.getForEntity(buildUri(API_URL+"/job/{uuid}"), JobModel.class, job.getUuid());
- assertEquals(job.getUuid(), jobResult.getBody().getUuid());
- //assertEquals(PENDING, jobResult.getBody().getStatus());
- });
- }
-
- private List<JobModel> getJobChildren(ResponseEntity<JobBulk> result) {
- return result.getBody().getJobs().stream().filter(job -> job.getTemplateId() != null).collect(Collectors.toList());
- }
-
- private ResponseEntity<JobBulk> postJobBulk(int jobCount, String url, String type) {
- JsonObject jsonObject = new JsonObject();
- jsonObject.addProperty("name", "service-"+random.nextInt());
- jsonObject.addProperty("count", jobCount);
- jsonObject.addProperty("url", url);
- jsonObject.addProperty("type", type);
- ResponseEntity<JobBulk> result = restTemplate.postForEntity(buildUri(API_URL), jsonObject.toString(), JobBulk.class);
- return result;
- }
-
- @Test
- public void addFewJobs_verifyCallbacksAreAllAndNoDuplicates() throws InterruptedException {
- final Collection<String> expected = new ConcurrentSkipListSet<>();
- final Collection<String> results = new ConcurrentSkipListSet<>();
- final Collection<String> duplicates = new ConcurrentSkipListSet<>();
- final String targetPath = "/my-mso";
-
- // https://github.com/CodeStory/fluent-http
- final WebServer server = new WebServer().configure(routes -> routes
- .post(targetPath, (context) -> {
- final String body = context.extract(String.class);
- if (!results.add(body)) {
- duplicates.add(body);
- }
- return body;
- })
- ).startOnRandomPort();
-
- final int jobCount = 10;
- final int childCount = 2;
-
- InetAddress inetAddress = getExternalInetAddress();
-
- final String returnUrl = "http://" + inetAddress.getHostAddress() + ":" + server.port() + targetPath;
- System.out.println(returnUrl);
-
- // POST jobs
- IntStream.range(0, jobCount).parallel().forEach(i -> {
- ResponseEntity<JobBulk> result = postJobBulk(childCount, returnUrl, "HttpCall");
- getJobChildren(result).forEach(child -> {
- expected.add(child.getUuid());
- });
- });
- Wait.waitFor((actual -> actual.size() == expected.size()), results, 75, 200, TimeUnit.MILLISECONDS);
- // wait some another time give change for duplications
- TimeUnit.SECONDS.sleep(5);
-
- if (asyncJobsIsOn()) {
- assertThat("async jobs is on: should callback for all jobs - no more, no less", results, equalTo(expected));
- assertThat("async jobs is on: should callback for exactly number of jobs", results, hasSize(jobCount * childCount));
- assertThat("async jobs is on: should have no duplicate jobs callback", duplicates, empty());
- } else {
- assertThat("async jobs is off: should not callback for any job", results, empty());
- assertThat("async jobs is off: should have no duplicate jobs callback", duplicates, empty());
- }
-
- server.stop();
-
- }
-
- private InetAddress getExternalInetAddress() {
- // https://stackoverflow.com/questions/9481865/getting-the-ip-address-of-the-current-machine-using-java
- InetAddress candidateAddress = null;
- try {
- for (Enumeration ifaces = NetworkInterface.getNetworkInterfaces(); ifaces.hasMoreElements(); ) {
- NetworkInterface iface = (NetworkInterface) ifaces.nextElement();
-
- if (iface.getName().contains("docker")) {
- // ignore local docker virtual gateway IPs
- continue;
- }
-
- // Iterate all IP addresses assigned to each card...
- for (Enumeration inetAddrs = iface.getInetAddresses(); inetAddrs.hasMoreElements(); ) {
- InetAddress inetAddr = (InetAddress) inetAddrs.nextElement();
-
- // take only non-loopback, ipv4 addresses
- if (!inetAddr.isLoopbackAddress() && inetAddr instanceof Inet4Address) {
-
- System.out.println("inetAddr (" + iface.getName() + "): " + inetAddr);
- if (inetAddr.isSiteLocalAddress()) {
- // Found non-loopback site-local address. Return it immediately...
- System.out.println("inetAddr, site-local (" + iface.getName() + "): " + inetAddr);
- candidateAddress = inetAddr;
- }
- else if (candidateAddress == null) {
- // Found non-loopback address, but not necessarily site-local.
- // Store it as a candidate to be returned if site-local address is not subsequently found...
- candidateAddress = inetAddr;
- // Note that we don't repeatedly assign non-loopback non-site-local addresses as candidates,
- // only the first. For subsequent iterations, candidate will be non-null.
- }
- }
- }
-
- }
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- return candidateAddress;
- }
-
@Test
public void testGetStatusBadRequest() {
ResponseEntity<String> jobResult = getJob("1234");
diff --git a/vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationALaCarteApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationALaCarteApiTest.java
new file mode 100644
index 000000000..539e857c9
--- /dev/null
+++ b/vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationALaCarteApiTest.java
@@ -0,0 +1,532 @@
+package org.onap.vid.api;
+
+import static java.util.Collections.emptyMap;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
+import static org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset.DEFAULT_INSTANCE_ID;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateInstancePost.DEFAULT_REQUEST_ID;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet.COMPLETE;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.SERVICE_NAME;
+import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset;
+import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOAddOrRemoveOneInstanceGroupMember;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOAddOrRemoveOneInstanceGroupMember.InstanceGroupMemberAction;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateInstancePost;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseDelete;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateNetworkALaCarteCypress;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2WithNamesAlacarteService;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2WithNamesAlacarteServiceCypress;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVfModuleALaCarteCypress;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVfModuleWithVolumeGroupALaCarteCypress;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVnfALaCarteCypress2;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVnfGroup;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteALaCarteService;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteInstanceGroup;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames;
+import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceMetadataGet;
+import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGet;
+import org.onap.vid.model.asyncInstantiation.JobAuditStatus;
+import org.onap.vid.model.asyncInstantiation.JobAuditStatus.SourceStatus;
+import org.onap.vid.model.asyncInstantiation.ServiceInfo;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import vid.automation.test.Constants;
+import vid.automation.test.infra.FeatureTogglingTest;
+import vid.automation.test.infra.Features;
+import vid.automation.test.model.JobStatus;
+import vid.automation.test.model.ServiceAction;
+import vid.automation.test.services.AsyncJobsService;
+import vid.automation.test.services.SimulatorApi;
+import vid.automation.test.services.SimulatorApi.RegistrationStrategy;
+
+@FeatureTogglingTest({Features.FLAG_ASYNC_JOBS, Features.FLAG_ASYNC_INSTANTIATION, Features.FLAG_ASYNC_ALACARTE_VNF})
+public class AsyncInstantiationALaCarteApiTest extends AsyncInstantiationBase {
+
+ private static final String CREATE_BULK_OF_ALACARTE_REQUEST = "asyncInstantiation/vidRequestCreateALaCarte.json";
+ private static final String CREATE_BULK_OF_ALACARTE_REQUEST_CYPRESS = "a-la-carte/redux-a-la-carte.json";
+ private static final String CREATE_BULK_OF_ALACARTE_NO_TESTAPI_REQUEST_CYPRESS = "a-la-carte/redux-a-la-carte-no-testapi.json";
+ private static final String DELETE_BULK_OF_ALACARTE_REQUEST = "VnfGroup/ServiceWithVnfGroupsDeleteRequest.json";
+ private static final String VIEW_EDIT_VNF_GROUPS_REQUEST = "VnfGroup/VnfGroupCreate1Delete1None1Request.json";
+ private static final String DELETE_TWO_VNF_GROUPS_MEMBER_AND_ADD_ONE_REQUEST = "VnfGroup/vnfGroupCreate1VnfGroupAndDelete2VnfGroupsRequest.json";
+ private static final String DELETE_SERVICE_WITH_TWO_VNF_GROUPS_REQUEST_WITH_GROUPMEMBERS = "VnfGroup/deleteServiceWith2VnfGroupsRequest_AndThreeGroupMembers.json";
+
+
+ private static final String SERVICE_INSTANCE_ID = BaseMSOPreset.DEFAULT_INSTANCE_ID;
+ private static final String MSO_COMPLETE_STATUS = "COMPLETE";
+ private static final String MSO_FAILED_STATUS = "FAILED";
+
+
+ @DataProvider
+ public static Object[][] scenarios() {
+ return new Object[][]{
+ {Scenario.PARALLEL},
+ {Scenario.COMPLETED},
+// {Scenario.NAME_TAKEN}, Not relevant because the name uniqueness is supported only for bulk in Macro
+// {Scenario.DUPLICATE_NAME}, Not relevant because name duplication is not handled in A La Carte
+ {Scenario.IN_PROGRESS},
+ {Scenario.MSO_FAIL}
+ };
+ }
+
+ @AfterMethod
+ protected void dropAllFromNameCounter() {
+ AsyncJobsService asyncJobsService = new AsyncJobsService();
+ asyncJobsService.dropAllFromNameCounter();
+ }
+
+ @Test
+ public void deploy1Service0VnfWithStrictSimulatorCompare__verifyStatusAndAudit() {
+ /*
+ Legit Preset || deploy 1 Service, no VNF inside
+ -> JobStatus is Eventually success, audit
+ is adequate; strict simulator compare
+ */
+
+ final ImmutableMap<PresetMSOServiceInstanceGen2WithNames.Keys, String> names = ImmutableMap.of(SERVICE_NAME, "calazixide85");
+ List<PresetMSOBaseCreateInstancePost> createPresets = ImmutableList.of(new PresetMSOCreateServiceInstanceGen2WithNamesAlacarteService(names, 0, DEFAULT_REQUEST_ID));
+ List<PresetMSOOrchestrationRequestGet> inProgressPresets = ImmutableList.of(new PresetMSOOrchestrationRequestGet());
+ List<BasePreset> presets = getPresets(createPresets, inProgressPresets);
+
+ registerExpectationFromPresets(presets, RegistrationStrategy.CLEAR_THEN_SET);
+ final List<String> uuids = createBulkOfInstances(false, 1, names, CREATE_BULK_OF_ALACARTE_REQUEST);
+
+ assertThat(uuids, hasSize(1));
+ final String jobId = uuids.get(0);
+
+ assertServiceInfoSpecific1(jobId, JobStatus.COMPLETED, names.get(SERVICE_NAME));
+ assertAuditStatuses(jobId, vidAuditStatusesCompleted(jobId), msoAuditStatusesCompleted(jobId));
+ }
+
+ @Test
+ public void deleteServiceWithTwoVnfGroups_andRetry() {
+ String parentServiceInstanceId = "service-instance-id";
+ String firstVnfGroupToDeleteInstanceId = "VNF_GROUP1_INSTANCE_ID";
+ String secondVnfGroupToDeleteInstanceId = "VNF_GROUP2_INSTANCE_ID";
+ String firstVnfGroupToDeleteRequestId = UUID.randomUUID().toString();
+ String secondVnfGroupToDeleteRequestId = UUID.randomUUID().toString();
+ String parentServiceRequestId = UUID.randomUUID().toString();
+ List<String> vnfGroupMemberRemoveRequestsIds = ImmutableList.of(UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString());
+
+ //failed to delete vnf group, and then also service is not deleted
+ List<PresetMSOBaseCreateInstancePost> createPresets = ImmutableList.of(
+ new PresetMSOAddOrRemoveOneInstanceGroupMember(firstVnfGroupToDeleteInstanceId, "RELATED_VNF1_INSTANCE_ID", getUserCredentials().getUserId(), vnfGroupMemberRemoveRequestsIds.get(0), InstanceGroupMemberAction.Remove),
+ new PresetMSOAddOrRemoveOneInstanceGroupMember(firstVnfGroupToDeleteInstanceId, "RELATED_VNF2_INSTANCE_ID", getUserCredentials().getUserId(), vnfGroupMemberRemoveRequestsIds.get(1), InstanceGroupMemberAction.Remove),
+ new PresetMSOAddOrRemoveOneInstanceGroupMember(firstVnfGroupToDeleteInstanceId, "RELATED_VNF3_INSTANCE_ID", getUserCredentials().getUserId(), vnfGroupMemberRemoveRequestsIds.get(2), InstanceGroupMemberAction.Remove));
+
+ List<PresetMSOBaseDelete> deletePresets = ImmutableList.of(
+ new PresetMSODeleteInstanceGroup(firstVnfGroupToDeleteRequestId, firstVnfGroupToDeleteInstanceId, getUserCredentials().getUserId()),
+ new PresetMSODeleteInstanceGroup(secondVnfGroupToDeleteRequestId, secondVnfGroupToDeleteInstanceId, getUserCredentials().getUserId())
+ );
+
+ List<PresetMSOOrchestrationRequestGet> inProgressPresets = new ArrayList<>();
+ inProgressPresets.add(new PresetMSOOrchestrationRequestGet( MSO_COMPLETE_STATUS, firstVnfGroupToDeleteRequestId));
+ inProgressPresets.add(new PresetMSOOrchestrationRequestGet( MSO_FAILED_STATUS, secondVnfGroupToDeleteRequestId));
+ inProgressPresets.add(new PresetMSOOrchestrationRequestGet( MSO_COMPLETE_STATUS, vnfGroupMemberRemoveRequestsIds.get(0)));
+ inProgressPresets.add(new PresetMSOOrchestrationRequestGet( MSO_COMPLETE_STATUS, vnfGroupMemberRemoveRequestsIds.get(1)));
+ inProgressPresets.add(new PresetMSOOrchestrationRequestGet( MSO_COMPLETE_STATUS, vnfGroupMemberRemoveRequestsIds.get(2)));
+
+ List<BasePreset> presets = getPresets(deletePresets, createPresets, inProgressPresets);
+ registerExpectationFromPresets(presets, RegistrationStrategy.CLEAR_THEN_SET);
+ final List<String> uuids = createBulkOfInstances(false, 1, ImmutableMap.of(), DELETE_SERVICE_WITH_TWO_VNF_GROUPS_REQUEST_WITH_GROUPMEMBERS);
+
+ assertThat(uuids, hasSize(1));
+ final String jobId = uuids.get(0);
+ assertServiceInfoSpecificDeletion(jobId, JobStatus.COMPLETED_WITH_ERRORS, "SERVICE_INSTANCE_NAME", "service-instance-type");
+ assertThat(SimulatorApi.retrieveRecordedRequestsPathCounter(), allOf(
+ TestUtils.hasOrLacksOfEntry(deletePresets.get(0).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(deletePresets.get(1).getReqPath(), 1L),
+
+ TestUtils.hasOrLacksOfEntry(inProgressPresets.get(0).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(inProgressPresets.get(1).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(createPresets.get(0).getReqPath(), 3L)
+
+ ));
+
+ //retry to delete vnf-group and then delete service
+ List<BasePreset> retryPresets = ImmutableList.of(
+ new PresetMSODeleteInstanceGroup(secondVnfGroupToDeleteRequestId, secondVnfGroupToDeleteInstanceId, getUserCredentials().getUserId()),
+ new PresetMSODeleteALaCarteService(parentServiceRequestId,parentServiceInstanceId ),
+ new PresetMSOOrchestrationRequestGet( MSO_COMPLETE_STATUS, secondVnfGroupToDeleteRequestId),
+ new PresetMSOOrchestrationRequestGet( MSO_COMPLETE_STATUS, parentServiceRequestId));
+ registerExpectationFromPresets(retryPresets, RegistrationStrategy.CLEAR_THEN_SET);
+
+ List<String> retryUuids = retryJob(jobId);
+ assertThat(retryUuids, hasSize(1));
+ final String retryJobId = retryUuids.get(0);
+ assertServiceInfoSpecificDeletion(retryJobId, JobStatus.COMPLETED, "SERVICE_INSTANCE_NAME", "service-instance-type");
+
+ assertThat(SimulatorApi.retrieveRecordedRequestsPathCounter(), allOf(
+ TestUtils.hasOrLacksOfEntry(retryPresets.get(0).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(retryPresets.get(1).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(retryPresets.get(2).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(retryPresets.get(3).getReqPath(), 1L)
+ ));
+ }
+
+ @DataProvider
+ public static Object[][] msoRequestStatusDataProvider() {
+ return new Object[][]{
+ {MSO_COMPLETE_STATUS, JobStatus.COMPLETED},
+ {MSO_FAILED_STATUS, JobStatus.FAILED}
+ };
+ }
+
+ @Test(dataProvider = "msoRequestStatusDataProvider")
+ public void deleteServiceWithStrictSimulatorCompare__verifyStatusAndAudit(String msoStatus, JobStatus expectedStatus) {
+ List<PresetMSOBaseDelete> deletePresets = ImmutableList.of(new PresetMSODeleteALaCarteService( DEFAULT_REQUEST_ID, SERVICE_INSTANCE_ID));
+ List<PresetMSOOrchestrationRequestGet> inProgressPresets = ImmutableList.of (new PresetMSOOrchestrationRequestGet(msoStatus),
+ new PresetMSOOrchestrationRequestGet(msoStatus));
+ List<BasePreset> presets = getDeletePresets(deletePresets, inProgressPresets);
+
+ registerExpectationFromPresets(presets, RegistrationStrategy.CLEAR_THEN_SET);
+ final List<String> uuids = createBulkOfInstances(false, 1, ImmutableMap.of(), DELETE_BULK_OF_ALACARTE_REQUEST);
+
+ assertThat(uuids, hasSize(1));
+ final String jobId = uuids.get(0);
+
+ assertServiceInfoSpecificDeletion(jobId, expectedStatus, "wowServiceWithVnfGroping", "TYLER SILVIA");
+ switch (expectedStatus) {
+ case COMPLETED:
+ assertAuditStatuses(jobId, vidAuditStatusesCompleted(jobId), msoAuditStatusesCompleted(jobId));
+ break;
+
+ case FAILED:
+ assertAuditStatuses(jobId, vidAuditStatusesFailed(jobId), null);
+ break;
+ }
+
+ assertThat(SimulatorApi.retrieveRecordedRequestsPathCounter(), allOf(
+ TestUtils.hasOrLacksOfEntry(deletePresets.get(0).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(inProgressPresets.get(0).getReqPath(), 1L)
+ ));
+ }
+
+ @Test(dataProvider = "msoRequestStatusDataProvider")
+ public void deleteTwoGroupsAddOneGroup(String msoStatus, JobStatus expectedStatus) {
+ String parentServiceInstanceId = "service-instance-id";
+ String firstVnfGroupToDeleteInstanceId = "VNF_GROUP1_INSTANCE_ID";
+ String secondVnfGroupToDeleteInstanceId = "VNF_GROUP2_INSTANCE_ID";
+ String firstVnfGroupToDeleteRequestId = UUID.randomUUID().toString();
+ String secondVnfGroupToDeleteRequestId = UUID.randomUUID().toString();
+ String vnfGroupToCreateRequestId = UUID.randomUUID().toString();
+
+ List<PresetMSOBaseDelete> deletePresets = ImmutableList.of(
+ new PresetMSODeleteInstanceGroup(firstVnfGroupToDeleteRequestId, firstVnfGroupToDeleteInstanceId, getUserCredentials().getUserId()),
+ new PresetMSODeleteInstanceGroup(secondVnfGroupToDeleteRequestId, secondVnfGroupToDeleteInstanceId, getUserCredentials().getUserId()));
+
+ List<PresetMSOBaseCreateInstancePost> createPresets = ImmutableList.of(
+ new PresetMSOCreateVnfGroup("VNF_GROUP3_INSTANCE_NAME", vnfGroupToCreateRequestId,
+ PresetMSOCreateVnfGroup.MODEL_INFO_0, parentServiceInstanceId, false));
+ List<PresetMSOOrchestrationRequestGet> inProgressPresets = ImmutableList.of(
+ new PresetMSOOrchestrationRequestGet(msoStatus, firstVnfGroupToDeleteRequestId),
+ new PresetMSOOrchestrationRequestGet(msoStatus, secondVnfGroupToDeleteRequestId),
+ new PresetMSOOrchestrationRequestGet(msoStatus, vnfGroupToCreateRequestId, "Instance group was created successfully.")
+ );
+ List<BasePreset> presets = getPresets(deletePresets, createPresets, inProgressPresets);
+ registerExpectationFromPresets(presets, RegistrationStrategy.CLEAR_THEN_SET);
+ final List<String> uuids = createBulkOfInstances(false, 1, ImmutableMap.of(), DELETE_TWO_VNF_GROUPS_MEMBER_AND_ADD_ONE_REQUEST);
+
+ assertThat(uuids, hasSize(1));
+ final String jobId = uuids.get(0);
+
+ assertServiceInfoSpecificUpdate(jobId, expectedStatus, "SERVICE_INSTANCE_NAME");
+ assertExpectedStatus(expectedStatus, jobId);
+ assertThat(SimulatorApi.retrieveRecordedRequestsPathCounter(), allOf(
+ TestUtils.hasOrLacksOfEntry(deletePresets.get(0).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(inProgressPresets.get(0).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(deletePresets.get(1).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(inProgressPresets.get(1).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(createPresets.get(0).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(inProgressPresets.get(2).getReqPath(), 1L)
+ ));
+
+ }
+
+ @Test
+ public void viewEditVnfGroup__verifyStatusAndAudit() {
+ String parentServiceInstanceId = "service-instance-id";
+ String vnfGroupToDeleteInstanceId = "VNF_GROUP1_INSTANCE_ID";
+
+ //failed to create vnf group, failed to remove 1 member (and then also vnf group isn't deleted)
+ viewEditVnfGroup_registerPresets(parentServiceInstanceId, vnfGroupToDeleteInstanceId, MSO_FAILED_STATUS);
+
+ final List<String> uuids = createBulkOfInstances(false, 1, ImmutableMap.of(), VIEW_EDIT_VNF_GROUPS_REQUEST);
+
+ assertThat(uuids, hasSize(1));
+ final String jobId = uuids.get(0);
+
+ assertServiceInfoSpecificUpdate(jobId, JobStatus.COMPLETED_WITH_ERRORS, "SERVICE_INSTANCE_NAME");
+ assertExpectedStatus(JobStatus.COMPLETED_WITH_ERRORS, jobId);
+ Map<String, Long> recordedRequest = SimulatorApi.retrieveRecordedRequestsPathCounter();
+ assertThat(recordedRequest, allOf(
+ TestUtils.hasOrLacksOfEntry("/mso/serviceInstantiation/v./instanceGroups/" + vnfGroupToDeleteInstanceId, 0L), //delete vnf group
+ TestUtils.hasOrLacksOfEntry("/mso/serviceInstantiation/v./instanceGroups", 1L), //create vnf group
+ TestUtils.hasOrLacksOfEntry("/mso/serviceInstantiation/v./instanceGroups/" + vnfGroupToDeleteInstanceId + "/removeMembers", 3L) //remove vnf group members
+ ));
+
+ //retry - vnf group create, 1 member remove, vnf group delete
+ viewEditVnfGroup_registerPresets(parentServiceInstanceId, vnfGroupToDeleteInstanceId, MSO_COMPLETE_STATUS);
+ final List<String> retryUuids = retryJob(jobId);
+ assertThat(retryUuids, hasSize(1));
+ final String retryJobId = retryUuids.get(0);
+
+ assertServiceInfoSpecificUpdate(retryJobId, JobStatus.COMPLETED, "SERVICE_INSTANCE_NAME");
+ assertExpectedStatus(JobStatus.COMPLETED, retryJobId);
+ assertThat(SimulatorApi.retrieveRecordedRequestsPathCounter(), allOf(
+ TestUtils.hasOrLacksOfEntry("/mso/serviceInstantiation/v./instanceGroups/" + vnfGroupToDeleteInstanceId, 1L), //delete vnf group
+ TestUtils.hasOrLacksOfEntry("/mso/serviceInstantiation/v./instanceGroups", 1L), //create vnf group
+ TestUtils.hasOrLacksOfEntry("/mso/serviceInstantiation/v./instanceGroups/" + vnfGroupToDeleteInstanceId + "/removeMembers", 1L) //remove vnf group members
+ ));
+ }
+
+ private void viewEditVnfGroup_registerPresets(String parentServiceInstanceId, String vnfGroupToDeleteInstanceId, String msoStatus) {
+ String vnfGroupToDeleteRequestId = UUID.randomUUID().toString();
+ String vnfGroupToCreateRequestId = UUID.randomUUID().toString();
+ List<String> vnfGroupMemberRemoveRequestsIds = ImmutableList.of(UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString());
+
+ List<PresetMSOBaseDelete> deletePresets = ImmutableList.of(
+ new PresetMSODeleteInstanceGroup(vnfGroupToDeleteRequestId, vnfGroupToDeleteInstanceId, getUserCredentials().getUserId()));
+ List<PresetMSOBaseCreateInstancePost> createPresets = ImmutableList.of(
+ new PresetMSOCreateVnfGroup("VNF_GROUP3_INSTANCE_NAME", vnfGroupToCreateRequestId,
+ PresetMSOCreateVnfGroup.MODEL_INFO_0, parentServiceInstanceId, false),
+ new PresetMSOAddOrRemoveOneInstanceGroupMember(vnfGroupToDeleteInstanceId, "RELATED_VNF1_INSTANCE_ID", getUserCredentials().getUserId(), vnfGroupMemberRemoveRequestsIds.get(0), InstanceGroupMemberAction.Remove),
+ new PresetMSOAddOrRemoveOneInstanceGroupMember(vnfGroupToDeleteInstanceId, "RELATED_VNF2_INSTANCE_ID", getUserCredentials().getUserId(), vnfGroupMemberRemoveRequestsIds.get(1), InstanceGroupMemberAction.Remove),
+ new PresetMSOAddOrRemoveOneInstanceGroupMember(vnfGroupToDeleteInstanceId, "RELATED_VNF3_INSTANCE_ID", getUserCredentials().getUserId(), vnfGroupMemberRemoveRequestsIds.get(2), InstanceGroupMemberAction.Remove));
+ List<PresetMSOOrchestrationRequestGet> inProgressPresets = ImmutableList.of(
+ new PresetMSOOrchestrationRequestGet(MSO_COMPLETE_STATUS, vnfGroupToDeleteRequestId), // delete instance group
+ new PresetMSOOrchestrationRequestGet(msoStatus, vnfGroupToCreateRequestId, "Instance group was created successfully."), // create instance group
+ new PresetMSOOrchestrationRequestGet(MSO_COMPLETE_STATUS, vnfGroupMemberRemoveRequestsIds.get(0)), // remove instance group member
+ new PresetMSOOrchestrationRequestGet(msoStatus, vnfGroupMemberRemoveRequestsIds.get(1)), // remove instance group member
+ new PresetMSOOrchestrationRequestGet(MSO_COMPLETE_STATUS, vnfGroupMemberRemoveRequestsIds.get(2))); // remove instance group member
+
+ List<BasePreset> presets = getPresets(deletePresets, createPresets, inProgressPresets);
+ registerExpectationFromPresets(presets, RegistrationStrategy.CLEAR_THEN_SET);
+ }
+
+ private void assertExpectedStatus(JobStatus expectedStatus, String jobId) {
+ switch (expectedStatus) {
+ case COMPLETED:
+ assertAuditStatuses(jobId, vidAuditStatusesCompleted(jobId), null);
+ break;
+
+ case FAILED:
+ assertAuditStatuses(jobId, vidAuditStatusesFailed(jobId), null);
+ break;
+ }
+ }
+
+ @Test
+ public void deploy1Service1FailedVnf__verifyStatus_andRetry() {
+ //CreateServiceWithFailedVnf is common for API test and UI test,
+ //so if you change it, make sure both test are compatible with your changes
+ CreateServiceWithFailedVnf createServiceWithFailedVnf = new CreateServiceWithFailedVnf(this);
+ createServiceWithFailedVnf.deployService1FailedVnf();
+ createServiceWithFailedVnf.secondRegistration();
+ createServiceWithFailedVnf.retryJob();
+ createServiceWithFailedVnf.retryAssertion();
+ createServiceWithFailedVnf.simulatorCallsAssertion();
+ }
+
+ @DataProvider
+ Object[][] data_deploy1ServiceFromCypress__verifyStatusAndMsoCalls() {
+ return Features.FLAG_ASYNC_ALACARTE_VFMODULE.isActive() ? new Object[][]{
+ {"none", emptyMap(), emptyMap(), true},
+ {"none", emptyMap(), emptyMap(), false},
+ {"instance", ImmutableMap.of("vnfs", 0L, "networks", 0L, "vfModules", 0L, "volumeGroups", 0L),
+ ImmutableMap.of("serviceInstances", 1L, "vnfs", 1L, "networks", 1L, "vfModules", 3L, "volumeGroups", 1L),true},
+ {"network", emptyMap(),
+ ImmutableMap.of("networks", 1L), true},
+ {"vnf0", ImmutableMap.of("vfModules", 0L, "volumeGroups", 0L),
+ ImmutableMap.of("vnfs", 1L, "vfModules", 3L, "volumeGroups", 1L), true},
+ {"vfModule0", ImmutableMap.of("vfModules", 1L, "volumeGroups", 0L),
+ ImmutableMap.of("vfModules", 3L, "volumeGroups", 1L), true},
+ {"volumeGroup", ImmutableMap.of("vfModules", 2L),
+ ImmutableMap.of("vfModules", 1L, "volumeGroups", 1L), true},
+ {"vfModule1", emptyMap(),
+ ImmutableMap.of("vfModules", 1L, "volumeGroups", 1L), true},
+ {"vfModule2", emptyMap(),
+ ImmutableMap.of("vfModules", 1L), true}
+ } : new Object[][]{
+ {"none", ImmutableMap.of("vfModules", 0L, "volumeGroups", 0L), emptyMap(), true}
+ };
+ }
+
+ @Test(dataProvider = "data_deploy1ServiceFromCypress__verifyStatusAndMsoCalls")
+ public void deploy1ServiceFromCypress__verifyStatusAndMsoCalls_andRetry(String whatToFail, Map<String, Long> pathCounterOverride, Map<String, Long> retryPathCounterOverride, boolean withTestApi) {
+ final ImmutableMap<PresetMSOServiceInstanceGen2WithNames.Keys, String> names = ImmutableMap.of(SERVICE_NAME, "serviceInstanceName");
+ String vnfRequestId = UUID.randomUUID().toString();
+ registerPresetsForRetryTest(whatToFail, names, vnfRequestId, withTestApi);
+
+ final List<String> uuids = createBulkOfInstances(false, 1, names, withTestApi? CREATE_BULK_OF_ALACARTE_REQUEST_CYPRESS: CREATE_BULK_OF_ALACARTE_NO_TESTAPI_REQUEST_CYPRESS);
+
+ assertThat(uuids, hasSize(1));
+ final String jobId = uuids.get(0);
+
+ JobStatus finalJobStatus;
+ switch (whatToFail) {
+ case "none": finalJobStatus = JobStatus.COMPLETED; break;
+ case "instance": finalJobStatus = JobStatus.FAILED; break;
+ default: finalJobStatus = JobStatus.COMPLETED_WITH_ERRORS; break;
+ }
+ assertServiceInfoSpecific2(jobId, finalJobStatus, names.get(SERVICE_NAME));
+ assertRecordedRequests(pathCounterOverride, 1L, vnfRequestId);
+
+ if (!"none".equals(whatToFail)) {
+ registerPresetsForRetryTest("none", names, vnfRequestId, withTestApi);
+
+ List<String> retryUuids = retryJob(jobId);
+ assertThat(retryUuids, hasSize(1));
+ final String retryJobId = retryUuids.get(0);
+
+ ServiceAction serviceAction = "instance".equals(whatToFail) ? ServiceAction.INSTANTIATE : ServiceAction.UPDATE;
+ assertServiceInfoSpecific2(retryJobId, JobStatus.COMPLETED, names.get(SERVICE_NAME), serviceAction);
+
+ assertRecordedRequests(retryPathCounterOverride, 0L, vnfRequestId);
+ }
+ }
+
+ private void registerPresetsForRetryTest(String whatToFail, ImmutableMap<PresetMSOServiceInstanceGen2WithNames.Keys, String> names, String vnfRequestId, boolean withTestApi ) {
+ String networkRequestId = UUID.randomUUID().toString();
+ String vfModule0RequestId = UUID.randomUUID().toString();
+ String vfModule1RequestId = UUID.randomUUID().toString();
+ String vfModule2RequestId = UUID.randomUUID().toString();
+ String volumeGroupRequestId = UUID.randomUUID().toString();
+ List<PresetMSOBaseCreateInstancePost> createPresets = ImmutableList.of(
+ new PresetMSOCreateServiceInstanceGen2WithNamesAlacarteServiceCypress(names, 0, DEFAULT_REQUEST_ID, Constants.GR_API, withTestApi),
+ new PresetMSOCreateVnfALaCarteCypress2(vnfRequestId, DEFAULT_INSTANCE_ID, vnfRequestId, "2017-488_PASQUALE-vPE", Constants.GR_API, withTestApi),
+ new PresetMSOCreateNetworkALaCarteCypress(networkRequestId, DEFAULT_INSTANCE_ID, networkRequestId, "ExtVL", Constants.GR_API, withTestApi)
+ );
+ List<PresetMSOOrchestrationRequestGet> inProgressPresets = ImmutableList.of(
+ new PresetMSOOrchestrationRequestGet("instance".equals(whatToFail) ? MSO_FAILED_STATUS : COMPLETE),
+ new PresetMSOOrchestrationRequestGet("vnf0".equals(whatToFail) ? MSO_FAILED_STATUS : COMPLETE, vnfRequestId),
+ new PresetMSOOrchestrationRequestGet("vfModule0".equals(whatToFail) ? MSO_FAILED_STATUS : COMPLETE, vfModule0RequestId),
+ new PresetMSOOrchestrationRequestGet("vfModule1".equals(whatToFail) ? MSO_FAILED_STATUS : COMPLETE, vfModule1RequestId),
+ new PresetMSOOrchestrationRequestGet("vfModule2".equals(whatToFail) ? MSO_FAILED_STATUS : COMPLETE, vfModule2RequestId),
+ new PresetMSOOrchestrationRequestGet("volumeGroup".equals(whatToFail) ? MSO_FAILED_STATUS : COMPLETE, volumeGroupRequestId),
+ new PresetMSOOrchestrationRequestGet("network".equals(whatToFail) ? MSO_FAILED_STATUS : COMPLETE, networkRequestId)
+ );
+ List<BasePreset> presetsWithoutVfModule = getPresets(createPresets, inProgressPresets);
+
+ ImmutableList<BasePreset> presets = new ImmutableList.Builder<BasePreset>()
+ .addAll(presetsWithoutVfModule)
+ .add(new PresetSDCGetServiceToscaModelGet("2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd", "csar-noDynamicFields-ecompNamingFalse-fullModelDetails.zip"))
+ .add(new PresetSDCGetServiceMetadataGet("2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd", "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", "csar-noDynamicFields-ecompNamingFalse-fullModelDetails.zip"))
+ .add(new PresetMSOCreateVfModuleALaCarteCypress(vfModule0RequestId, DEFAULT_INSTANCE_ID, vnfRequestId, PresetMSOCreateVfModuleALaCarteCypress.module0Names, Constants.GR_API, withTestApi))
+ .add(PresetMSOCreateVfModuleWithVolumeGroupALaCarteCypress.forVolumeGroup(volumeGroupRequestId, DEFAULT_INSTANCE_ID, vnfRequestId, Constants.GR_API, withTestApi))
+ .add(PresetMSOCreateVfModuleWithVolumeGroupALaCarteCypress.forVfModule(vfModule1RequestId, DEFAULT_INSTANCE_ID, vnfRequestId, volumeGroupRequestId, Constants.GR_API, withTestApi))
+ .add(PresetAAIGetCloudOwnersByCloudRegionId.PRESET_JUST_ANOTHER_REGION_TO_ATT_AIC)
+ .add(PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MTN6_TO_ATT_AIC)
+ .add(PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MY_REGION_TO_ATT_AIC)
+ .add(PresetAAIGetCloudOwnersByCloudRegionId.PRESET_LCP_REGION_TEXT_TO_ATT_AIC)
+ .add(new PresetMSOCreateVfModuleALaCarteCypress(vfModule2RequestId, DEFAULT_INSTANCE_ID, vnfRequestId, PresetMSOCreateVfModuleALaCarteCypress.module2Names, Constants.GR_API, withTestApi))
+ .build();
+
+ registerExpectationFromPresets(
+ Features.FLAG_ASYNC_ALACARTE_VFMODULE.isActive() ? presets : presetsWithoutVfModule,
+ RegistrationStrategy.CLEAR_THEN_SET);
+ }
+
+ private void assertRecordedRequests(Map<String, Long> pathCounterOverride, Long defaultValue, String vnfRequestId) {
+ Long vfModulesDefaultValue = defaultValue == 1L ? 3L : 0L;
+
+ //noinspection unchecked
+ assertThat(SimulatorApi.retrieveRecordedRequestsPathCounter(), allOf(
+ TestUtils.hasOrLacksOfEntry("/mso/serviceInstantiation/v./serviceInstances",
+ pathCounterOverride.getOrDefault("serviceInstances", defaultValue)),
+
+ TestUtils.hasOrLacksOfEntry("/mso/serviceInstantiation/v./serviceInstances/" + DEFAULT_INSTANCE_ID + "/networks",
+ pathCounterOverride.getOrDefault("networks", defaultValue)),
+
+ TestUtils.hasOrLacksOfEntry("/mso/serviceInstantiation/v./serviceInstances/" + DEFAULT_INSTANCE_ID + "/vnfs",
+ pathCounterOverride.getOrDefault("vnfs", defaultValue)),
+
+ TestUtils.hasOrLacksOfEntry("/mso/serviceInstances/v./" + DEFAULT_INSTANCE_ID + "/vnfs/" + vnfRequestId + "/volumeGroups",
+ pathCounterOverride.getOrDefault("volumeGroups", defaultValue)),
+
+ TestUtils.hasOrLacksOfEntry("/mso/serviceInstantiation/v./serviceInstances/" + DEFAULT_INSTANCE_ID + "/vnfs/" + vnfRequestId + "/vfModules",
+ pathCounterOverride.getOrDefault("vfModules", vfModulesDefaultValue))
+ ));
+ }
+
+ private ImmutableList<JobAuditStatus> vidAuditStatusesCompleted(String jobId) {
+ return ImmutableList.of(
+ vidAuditStatus(jobId, "PENDING", false),
+ vidAuditStatus(jobId, "IN_PROGRESS", false),
+ vidAuditStatus(jobId, "COMPLETED", true)
+ );
+ }
+
+ private ImmutableList<JobAuditStatus> msoAuditStatusesCompleted(String jobId ) {
+ return ImmutableList.of(
+ msoAuditStatus(jobId, "REQUESTED", null, UUID.fromString(DEFAULT_REQUEST_ID)),
+ msoAuditStatus(jobId, MSO_COMPLETE_STATUS, "Service Instance was created successfully.", UUID.fromString(DEFAULT_REQUEST_ID))
+ );
+ }
+
+ private JobAuditStatus msoAuditStatus(String jobId, String jobStatus, String additionalInfo, UUID requestId) {
+ return new JobAuditStatus(UUID.fromString(jobId), jobStatus, SourceStatus.MSO, requestId, additionalInfo, false);
+ }
+
+ private void assertServiceInfoSpecific2(String jobId, JobStatus jobStatus, String serviceInstanceName) {
+ assertServiceInfoSpecific2(jobId, jobStatus, serviceInstanceName, ServiceAction.INSTANTIATE);
+ }
+
+ private void assertServiceInfoSpecific2(String jobId, JobStatus jobStatus, String serviceInstanceName, ServiceAction serviceAction) {
+ assertExpectedStatusAndServiceInfo(jobStatus, jobId, true, new ServiceInfo(
+ "us16807000", jobStatus, false,
+ "d61e6f2d-12fa-4cc2-91df-7c244011d6fc", "WayneHolland", "WATKINS",
+ "JAG1", null,
+ "092eb9e8e4b7412e8787dd091bc58e86", null,
+ "JANET25", null,
+ "TYLER SILVIA", null,
+ null, serviceInstanceName,
+ "2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd", "action-data", "1.0",
+ jobId, null, serviceAction, false)
+ );
+ }
+
+ private void assertServiceInfoSpecificDeletion(String jobId, JobStatus jobStatus, String serviceInstanceName, String serviceType) {
+ assertExpectedStatusAndServiceInfo(jobStatus, jobId, true, new ServiceInfo(
+ "us16807000", jobStatus, false,
+ null, null, null,
+ null, null,
+ null, null,
+ null, null,
+ serviceType, null,
+ null, serviceInstanceName,
+ "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc", "Grouping Service for Test", "1.0",
+ jobId, null, ServiceAction.DELETE, false)
+ );
+ }
+
+ private void assertServiceInfoSpecificUpdate(String jobId, JobStatus jobStatus, String serviceInstanceName) {
+ assertExpectedStatusAndServiceInfo(jobStatus, jobId, true, new ServiceInfo(
+ "us16807000", jobStatus, false,
+ null, null, null,
+ null, null,
+ null, null,
+ null, null,
+ "service-instance-type", null,
+ "service-instance-id", serviceInstanceName,
+ "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc", "Grouping Service for Test", "1.0",
+ jobId, null, ServiceAction.UPDATE, false)
+ );
+ }
+
+ enum Scenario {
+ PARALLEL, COMPLETED, NAME_TAKEN, DUPLICATE_NAME, IN_PROGRESS, MSO_FAIL
+ }
+
+}
diff --git a/vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationALaCarteApiTest2.java b/vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationALaCarteApiTest2.java
new file mode 100644
index 000000000..54f2cc66f
--- /dev/null
+++ b/vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationALaCarteApiTest2.java
@@ -0,0 +1,211 @@
+package org.onap.vid.api;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateInstancePost.DEFAULT_REQUEST_ID;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.SERVICE_NAME;
+import static vid.automation.test.services.SimulatorApi.registerExpectationFromPreset;
+import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset;
+import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
+import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseDelete;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2ErrorResponse;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteALaCarteService;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGetErrorResponse;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestsGetByRequestId;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestsGetByServiceInstanceId;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames;
+import org.onap.vid.model.asyncInstantiation.JobAuditStatus;
+import org.onap.vid.model.asyncInstantiation.JobAuditStatus.SourceStatus;
+import org.onap.vid.model.asyncInstantiation.ServiceInfo;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import vid.automation.test.infra.FeatureTogglingTest;
+import vid.automation.test.infra.Features;
+import vid.automation.test.model.JobStatus;
+import vid.automation.test.model.ServiceAction;
+import vid.automation.test.services.AsyncJobsService;
+import vid.automation.test.services.SimulatorApi;
+import vid.automation.test.services.SimulatorApi.RegistrationStrategy;
+
+@FeatureTogglingTest({Features.FLAG_ASYNC_JOBS, Features.FLAG_ASYNC_INSTANTIATION, Features.FLAG_ASYNC_ALACARTE_VNF})
+public class AsyncInstantiationALaCarteApiTest2 extends AsyncInstantiationBase {
+
+ private static final String CREATE_BULK_OF_ALACARTE_MULTIPLE_VNF_NETWORK_REQUEST_CYPRESS = "a-la-carte/redux-multiple-vnf-network.json";
+ private static final String DELETE_BULK_OF_ALACARTE_REQUEST = "VnfGroup/ServiceWithVnfGroupsDeleteRequest.json";
+ private static final String SERVICE_INSTANCE_ID = BaseMSOPreset.DEFAULT_INSTANCE_ID;
+
+
+ @DataProvider
+ public static Object[][] scenarios() {
+ return new Object[][]{
+ {Scenario.PARALLEL},
+ {Scenario.COMPLETED},
+// {Scenario.NAME_TAKEN}, Not relevant because the name uniqueness is supported only for bulk in Macro
+// {Scenario.DUPLICATE_NAME}, Not relevant because name duplication is not handled in A La Carte
+ {Scenario.IN_PROGRESS},
+ {Scenario.MSO_FAIL}
+ };
+ }
+
+ @AfterMethod
+ protected void dropAllFromNameCounter() {
+ AsyncJobsService asyncJobsService = new AsyncJobsService();
+ asyncJobsService.dropAllFromNameCounter();
+ }
+
+ @Test
+ public void deleteService_withBadResponseFromMso_verifyStatus() {
+ List<PresetMSOBaseDelete> deletePresets = ImmutableList.of(new PresetMSODeleteALaCarteService( DEFAULT_REQUEST_ID, SERVICE_INSTANCE_ID, 500));
+ List<PresetMSOOrchestrationRequestGet> inProgressPresets = ImmutableList.of(new PresetMSOOrchestrationRequestGet());
+ List<BasePreset> presets = getDeletePresets(deletePresets, inProgressPresets);
+
+ registerExpectationFromPresets(presets, RegistrationStrategy.CLEAR_THEN_SET);
+ final List<String> uuids = createBulkOfInstances(false, 1, ImmutableMap.of(), DELETE_BULK_OF_ALACARTE_REQUEST);
+
+ assertThat(uuids, hasSize(1));
+ final String jobId = uuids.get(0);
+
+ assertServiceInfoSpecificDeletion(jobId, JobStatus.FAILED, "wowServiceWithVnfGroping", "TYLER SILVIA");
+ assertThat(SimulatorApi.retrieveRecordedRequestsPathCounter(), allOf(
+ TestUtils.hasOrLacksOfEntry(deletePresets.get(0).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(inProgressPresets.get(0).getReqPath(), 0L)
+ ));
+ }
+
+
+ @Test
+ public void instantiationFailedForService(){
+ CreateInstanceWithFailedService createInstanceWithFailedService = new CreateInstanceWithFailedService(this);
+ createInstanceWithFailedService.deployServiceFailedInstance();
+ }
+
+ @Test
+ void getBulkForRetry_notFoundException(){
+ CreateServiceWithFailedVnf createServiceWithFailedVnf = new CreateServiceWithFailedVnf(this);
+ createServiceWithFailedVnf.getBulkForRetryNotFound();
+ }
+
+
+ @Test
+ public void deploy1Service1FailedVnf_EditJobSendingSameDataAndRetry_verifyNewJobWithSameData() {
+ CreateServiceWithFailedVnf createServiceWithFailedVnf = new CreateServiceWithFailedVnf(this);
+ String bulkRetryPayload = createServiceWithFailedVnf.deployService1FailedVnf();
+ createServiceWithFailedVnf.assertResourceAuditStatus(bulkRetryPayload);
+ createServiceWithFailedVnf.secondRegistration();
+ createServiceWithFailedVnf.retryJobWithOtherDataAndAssert(bulkRetryPayload);
+ }
+
+ @Test
+ public void deploy1Service1FailedVnf_EditSomeDetailsAndRetry_verifyNewJobWithEditedData() {
+ CreateServiceWithFailedVnf createServiceWithFailedVnf = new CreateServiceWithFailedVnf(this);
+ String originalBulkForRetry = createServiceWithFailedVnf.deployService1FailedVnf();
+ createServiceWithFailedVnf.assertResourceAuditStatus(originalBulkForRetry);
+ String changedData = createServiceWithFailedVnf.changeSomeDataAndRegisterToSimulator(originalBulkForRetry);
+ createServiceWithFailedVnf.retryJobWithOtherDataAndAssert(changedData);
+ }
+
+ private List<JobAuditStatus> getExpectedAuditFromFile(String fileName) throws IOException {
+ String content = TestUtils.convertRequest(objectMapper, fileName);
+ List<JobAuditStatus> auditStatusList = ImmutableList.copyOf(objectMapper.readValue(content, JobAuditStatus[].class));
+ return auditStatusList;
+
+
+ }
+
+ @Test
+ public void getAuditInfoForALaCarteByServiceInstanceId() throws IOException {
+ final String expectedMsoAuditInfo = "a-la-carte/auditInfoMSOALaCarte.json";
+ registerExpectationFromPreset(
+ new PresetMSOOrchestrationRequestsGetByServiceInstanceId(),
+ RegistrationStrategy.CLEAR_THEN_SET);
+ List<JobAuditStatus> actualMsoAudits = getJobMsoAuditStatusForAlaCarte(UUID.randomUUID().toString(), "aa1234d1-5a33-55df-13ab-12abad84e333", "bc305d54-75b4-431b-adb2-eb6b9e546014");
+ List<JobAuditStatus> expectedMsoAudits = getExpectedAuditFromFile(expectedMsoAuditInfo);
+ assertThat(actualMsoAudits, is(expectedMsoAudits));
+
+ }
+
+ @Test
+ public void getAuditInfoForALaCarteByRequestId() {
+ registerExpectationFromPreset(
+ new PresetMSOOrchestrationRequestsGetByRequestId(),
+ RegistrationStrategy.CLEAR_THEN_SET);
+ final ImmutableMap<PresetMSOServiceInstanceGen2WithNames.Keys, String> names = ImmutableMap.of(SERVICE_NAME, "serviceInstanceName");
+ String uuid = createBulkOfInstances(false, 1, names, CREATE_BULK_OF_ALACARTE_MULTIPLE_VNF_NETWORK_REQUEST_CYPRESS).get(0);
+ List<JobAuditStatus> actualMsoAudits = getJobMsoAuditStatusForAlaCarte( uuid, "405652f4-ceb3-4a75-9474-8aea71480a77", null);
+ List<JobAuditStatus> expectedMsoAudits = ImmutableList.of(
+ new JobAuditStatus("serviceInstanceName", "FAILED", UUID.fromString("405652f4-ceb3-4a75-9474-8aea71480a77"),"Service Instance was failed.",false, "service"));
+ assertThat(actualMsoAudits, is(expectedMsoAudits));
+
+ }
+
+ @Test
+ public void getAuditInfoForALaCarteByJobId() throws IOException {
+ SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
+ new PresetMSOCreateServiceInstanceGen2ErrorResponse(),
+ new PresetGetSessionSlotCheckIntervalGet(),
+ new PresetAAIGetSubscribersGet()
+ ),
+ RegistrationStrategy.CLEAR_THEN_SET);
+ final ImmutableMap<PresetMSOServiceInstanceGen2WithNames.Keys, String> names = ImmutableMap.of(SERVICE_NAME, "serviceInstanceName");
+ String uuid = createBulkOfInstances(false, 1, names, CREATE_BULK_OF_ALACARTE_MULTIPLE_VNF_NETWORK_REQUEST_CYPRESS).get(0);
+
+ assertAndRetryIfNeeded(() -> {
+ final List<JobAuditStatus> actualMsoAudits = getJobMsoAuditStatusForAlaCarte( uuid, null, null);
+ List<JobAuditStatus> expectedMsoAudits = ImmutableList.of(
+ new JobAuditStatus(UUID.fromString(uuid), "FAILED", SourceStatus.MSO, null,
+ "Http Code:500, \"messageId\":\"SVC0002\",\"text\":\"JSON Object Mapping Request\"", false, "serviceInstanceName"));
+ assertThat(actualMsoAudits, is(expectedMsoAudits));
+ }, 15);
+
+ //assert error audit status
+ Map<String, Object> bulkForRetry = objectMapper.readValue(getRetryBulk(uuid).getBody(), new TypeReference<Map<String, Object>>(){});
+ String serviceTrackById = bulkForRetry.get("trackById").toString();
+ Map<String, Object> resourceAuditInfo = (Map) getResourceAuditInfo(serviceTrackById);
+ assertThat(resourceAuditInfo.get("jobStatus"), equalTo("FAILED"));
+ assertThat(resourceAuditInfo.get("additionalInfo"), equalTo("Http Code:500, \"messageId\":\"SVC0002\",\"text\":\"JSON Object Mapping Request\""));
+ }
+
+ @Test(expectedExceptions = RuntimeException.class)
+ public void getAuditInfoForALaCarte_badResponseFromMso_throwsException() {
+ registerExpectationFromPreset(
+ new PresetMSOOrchestrationRequestGetErrorResponse(500),
+ RegistrationStrategy.CLEAR_THEN_SET);
+ getJobMsoAuditStatusForAlaCarte( UUID.randomUUID().toString(), "405652f4-ceb3-4a75-9474-8aea71480a77", null);
+ }
+
+ private void assertServiceInfoSpecificDeletion(String jobId, JobStatus jobStatus, String serviceInstanceName, String serviceType) {
+ assertExpectedStatusAndServiceInfo(jobStatus, jobId, true, new ServiceInfo(
+ "us16807000", jobStatus, false,
+ null, null, null,
+ null, null,
+ null, null,
+ null, null,
+ serviceType, null,
+ null, serviceInstanceName,
+ "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc", "Grouping Service for Test", "1.0",
+ jobId, null, ServiceAction.DELETE, false)
+ );
+ }
+
+
+ enum Scenario {
+ PARALLEL, COMPLETED, NAME_TAKEN, DUPLICATE_NAME, IN_PROGRESS, MSO_FAIL
+ }
+
+}
diff --git a/vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationALaCarteApiTest3.java b/vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationALaCarteApiTest3.java
new file mode 100644
index 000000000..eed6ee90b
--- /dev/null
+++ b/vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationALaCarteApiTest3.java
@@ -0,0 +1,645 @@
+package org.onap.vid.api;
+
+import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateInstancePost.DEFAULT_REQUEST_ID;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet.COMPLETE;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.RELATED_VNF1_ACTION;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.RELATED_VNF2_ACTION;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.SERVICE_NAME;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.VNF_GROUP1_ACTION;
+import static vid.automation.test.services.SimulatorApi.registerExpectationFromPreset;
+import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.Function;
+import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset;
+import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAISearchNodeQueryNonEmptyResult;
+import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOAddOrRemoveOneInstanceGroupMember;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOAddOrRemoveOneInstanceGroupMember.InstanceGroupMemberAction;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateInstancePost;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateNetworkALaCarteServiceCypress2;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2WithNamesAlacarteGroupingService;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2WithNamesAlacarteService;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceMultipleVnfsServiceCypress;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVnfALaCarteServiceCypress;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVnfALaCarteServiceCypress2;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVnfGroup;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteBaseVfModuleCypress;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteNetworkAlaCarteCypress;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteService;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteVfModuleCypress;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteVnfAlaCarteCypress;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames;
+import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceMetadataGet;
+import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGet;
+import org.onap.vid.model.asyncInstantiation.JobAuditStatus;
+import org.onap.vid.model.asyncInstantiation.JobAuditStatus.SourceStatus;
+import org.onap.vid.model.asyncInstantiation.ServiceInfo;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import vid.automation.test.infra.FeatureTogglingTest;
+import vid.automation.test.infra.Features;
+import vid.automation.test.model.JobStatus;
+import vid.automation.test.model.ServiceAction;
+import vid.automation.test.services.AsyncJobsService;
+import vid.automation.test.services.SimulatorApi;
+import vid.automation.test.services.SimulatorApi.RegistrationStrategy;
+
+@FeatureTogglingTest({Features.FLAG_ASYNC_JOBS, Features.FLAG_ASYNC_INSTANTIATION, Features.FLAG_ASYNC_ALACARTE_VNF})
+public class AsyncInstantiationALaCarteApiTest3 extends AsyncInstantiationBase {
+
+ private static final String CREATE_BULK_OF_ALACARTE_REQUEST = "asyncInstantiation/vidRequestCreateALaCarte.json";
+ private static final String CREATE_BULK_OF_ALACARTE_MULTIPLE_VNF_NETWORK_REQUEST_CYPRESS = "a-la-carte/redux-multiple-vnf-network.json";
+ private static final String CREATE_BULK_OF_ALACARTE_REQUEST_WITH_VNF_GROUP = "VnfGroup/serviceWithVnfGroupCreateRequest.json";
+ private static final String PAYLOAD_TEMPLATE_1_VNF_GROUP_WITH_3_MEMBERS_REQUEST = "VnfGroup/payloadTemplate1VnfGroupWith3MembersRequest.json";
+ private static final String DELETE_AND_CREATE_NETWORK_FROM_SERVICE = "asyncInstantiation/vidRequestDelete1Create1Network.json";
+ private static final String DELETE_SERVICE_WITH_NETWORK = "asyncInstantiation/vidRequestDeleteServiceWithNetwork.json";
+ private static final String DELETE_AND_CREATE_VNF_FROM_SERVICE = "asyncInstantiation/vidRequestDelete1Create1Vnf.json";
+ private static final String DELETE_SERVICE_WITH_VNF = "asyncInstantiation/vidRequestDeleteServiceWithVnf.json";
+
+
+ private static final String FIRST_REQUEST_ID = "d1011670-0e1a-4b74-945d-8bf5aede1d9c";
+ private static final String SECOND_REQUEST_ID = "e2011670-0e1a-4b74-945d-8bf5aede1d9c";
+ private static final String THIRD_REQUEST_ID = "f3011670-0e1a-4b74-945d-8bf5aede1d9c";
+ private static final String SERVICE_INSTANCE_ID = BaseMSOPreset.DEFAULT_INSTANCE_ID;
+ private static final String MSO_COMPLETE_STATUS = "COMPLETE";
+ private static final String MSO_FAILED_STATUS = "FAILED";
+
+
+ @DataProvider
+ public static Object[][] scenarios() {
+ return new Object[][]{
+ {Scenario.PARALLEL},
+ {Scenario.COMPLETED},
+// {Scenario.NAME_TAKEN}, Not relevant because the name uniqueness is supported only for bulk in Macro
+// {Scenario.DUPLICATE_NAME}, Not relevant because name duplication is not handled in A La Carte
+ {Scenario.IN_PROGRESS},
+ {Scenario.MSO_FAIL}
+ };
+ }
+
+ @AfterMethod
+ protected void dropAllFromNameCounter() {
+ AsyncJobsService asyncJobsService = new AsyncJobsService();
+ asyncJobsService.dropAllFromNameCounter();
+ }
+
+ @Test(dataProvider = "multipleVnfDataProvider")
+ public void deployServiceFromCypress__multipleVnfsAndNetwork(String expectedStatus, JobStatus expectedJobStatus) {
+ dropAllFromNameCounter();// needed because each data provider info not going to after method
+ final ImmutableMap<PresetMSOServiceInstanceGen2WithNames.Keys, String> names = ImmutableMap.of(SERVICE_NAME, "serviceInstanceName");
+
+ List<PresetMSOBaseCreateInstancePost> createPresets = ImmutableList.of(
+ new PresetMSOCreateServiceInstanceMultipleVnfsServiceCypress(names, 0, DEFAULT_REQUEST_ID),
+ new PresetMSOCreateVnfALaCarteServiceCypress(FIRST_REQUEST_ID, SERVICE_INSTANCE_ID,"VFvGeraldine00001", "zzz1"),
+ new PresetMSOCreateVnfALaCarteServiceCypress(SECOND_REQUEST_ID, SERVICE_INSTANCE_ID,"VFvGeraldine00001_001", "ONAP"),
+ new PresetMSOCreateNetworkALaCarteServiceCypress2(THIRD_REQUEST_ID, SERVICE_INSTANCE_ID, "ExtVL")
+ );
+ List<PresetMSOOrchestrationRequestGet> inProgressPresets = ImmutableList.of(
+ new PresetMSOOrchestrationRequestGet(expectedStatus.equals("SERVICE_FAILED") ? MSO_FAILED_STATUS : MSO_COMPLETE_STATUS, DEFAULT_REQUEST_ID),
+ new PresetMSOOrchestrationRequestGet( MSO_COMPLETE_STATUS, FIRST_REQUEST_ID, "First VNF instance was created successfully." ),
+ new PresetMSOOrchestrationRequestGet(expectedStatus, SECOND_REQUEST_ID, expectedStatus.equals(MSO_COMPLETE_STATUS)?"Second VNF instance was created successfully.": MSO_BASE_ERROR),
+ new PresetMSOOrchestrationRequestGet(MSO_COMPLETE_STATUS, THIRD_REQUEST_ID,"Network was created successfully.")
+ );
+ List<BasePreset> presets = getPresets( createPresets, inProgressPresets);
+
+ registerExpectationFromPresets(presets, RegistrationStrategy.CLEAR_THEN_SET);
+ registerExpectationFromPreset(PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MTN6_TO_ATT_AIC, RegistrationStrategy.APPEND);
+
+ final List<String> uuids = createBulkOfInstances(false, 1, names, CREATE_BULK_OF_ALACARTE_MULTIPLE_VNF_NETWORK_REQUEST_CYPRESS);
+
+ assertThat(uuids, hasSize(1));
+ final String jobId = uuids.get(0);
+
+ //expected vid statuses
+ ImmutableList<JobAuditStatus> vidAuditStatuses;
+
+ if (expectedStatus.equals(MSO_COMPLETE_STATUS)){
+ vidAuditStatuses = vidAuditStatusesCompleted(jobId);
+ } else if (expectedStatus.equals("SERVICE_FAILED")){
+ vidAuditStatuses = vidAuditStatusesFailed(jobId);
+ } else {
+ vidAuditStatuses = vidAuditStatusesCompletedWithErrors(jobId);
+ }
+
+ assertServiceInfoSpecific3(jobId, expectedJobStatus , names.get(SERVICE_NAME));
+ assertAuditStatuses(jobId, vidAuditStatuses, null);
+ }
+
+
+ @DataProvider
+ Object[][] multipleVnfDataProvider() {
+ return new Object[][]{{MSO_FAILED_STATUS, JobStatus.COMPLETED_WITH_ERRORS},{MSO_COMPLETE_STATUS, JobStatus.COMPLETED}, {"SERVICE_FAILED", JobStatus.FAILED}};
+ }
+
+ @Test
+ @FeatureTogglingTest(Features.FLAG_1902_VNF_GROUPING)
+ public void deploy1ServiceWith1VnfGroup() {
+ final ImmutableMap<PresetMSOServiceInstanceGen2WithNames.Keys, String> names = ImmutableMap.of(SERVICE_NAME, "Grouping_Service_Instance");
+ String serviceReqId = "3cf5ea96-6b34-4945-b5b1-4a7798b1caf2";
+ String serviceInstanceId = BaseMSOPreset.DEFAULT_INSTANCE_ID;
+ String instanceGroupReqId = "715a5106-cdcc-44ee-8923-83d68a896908";
+
+ List<PresetMSOBaseCreateInstancePost> createPresets = ImmutableList.of(
+ new PresetMSOCreateServiceInstanceGen2WithNamesAlacarteGroupingService(names, 0, serviceReqId),
+ new PresetMSOCreateVnfGroup("ABC", instanceGroupReqId, PresetMSOCreateVnfGroup.MODEL_INFO_1, serviceInstanceId, false));
+ List<PresetMSOOrchestrationRequestGet> inProgressPresets = ImmutableList.of(
+ new PresetMSOOrchestrationRequestGet("COMPLETE", serviceReqId),
+ new PresetMSOOrchestrationRequestGet("COMPLETE", instanceGroupReqId, "Instance group was created successfully."));
+ List<BasePreset> presets = getPresets(createPresets, inProgressPresets);
+
+ registerExpectationFromPresets(presets, RegistrationStrategy.CLEAR_THEN_SET);
+
+ final List<String> uuids = createBulkOfInstances(false, 1, names, CREATE_BULK_OF_ALACARTE_REQUEST_WITH_VNF_GROUP);
+
+ assertThat(uuids, hasSize(1));
+ final String jobId = uuids.get(0);
+
+ assertExpectedStatusAndServiceInfo(JobStatus.COMPLETED, jobId, new ServiceInfo(
+ "us16807000", JobStatus.COMPLETED, false,
+ "d61e6f2d-12fa-4cc2-91df-7c244011d6fc", "WayneHolland", "WATKINS",
+ null, null,
+ null, null,
+ null, null,
+ "TYLER SILVIA", "SILVIA ROBBINS",
+ null, names.get(SERVICE_NAME),
+ "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc", "Grouping Service for Test", "1.0",
+ jobId, null, ServiceAction.INSTANTIATE, false));
+
+
+ assertAuditStatuses(jobId, vidAuditStatusesCompleted(jobId),null);
+
+ assertThat(SimulatorApi.retrieveRecordedRequestsPathCounter(), allOf(
+ TestUtils.hasOrLacksOfEntry(createPresets.get(0).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(createPresets.get(1).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(inProgressPresets.get(0).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(inProgressPresets.get(1).getReqPath(), 1L)));
+ }
+
+ @DataProvider
+ public static Object[][] addAndDeleteMembersMsoStatus() {
+ return new Object[][]{
+ {MSO_COMPLETE_STATUS, MSO_COMPLETE_STATUS, JobStatus.COMPLETED},
+ {MSO_FAILED_STATUS, MSO_FAILED_STATUS, JobStatus.FAILED},
+ {MSO_COMPLETE_STATUS, MSO_FAILED_STATUS, JobStatus.COMPLETED_WITH_ERRORS}
+ };
+ }
+
+ @Test(dataProvider = "addAndDeleteMembersMsoStatus")
+ @FeatureTogglingTest(Features.FLAG_1902_VNF_GROUPING)
+ public void add1delete1GroupMembers_withGoodResponseFromMso_verifyStatusAndRequests(String firstMemberStatus, String secondMemberStatus, JobStatus expectedJobStatus) {
+
+ String firstMemberRequestId = UUID.randomUUID().toString();
+ String secondMemberRequestId = UUID.randomUUID().toString();
+
+ List<PresetMSOAddOrRemoveOneInstanceGroupMember> instanceGroupMemberPreset = ImmutableList.of(
+ new PresetMSOAddOrRemoveOneInstanceGroupMember("VNF_GROUP1_INSTANCE_ID", "RELATED_VNF1_INSTANCE_ID", getUserCredentials().getUserId(), firstMemberRequestId, InstanceGroupMemberAction.Add),
+ new PresetMSOAddOrRemoveOneInstanceGroupMember("VNF_GROUP1_INSTANCE_ID", "RELATED_VNF2_INSTANCE_ID", getUserCredentials().getUserId(), secondMemberRequestId, InstanceGroupMemberAction.Remove)
+ );
+ List<PresetMSOOrchestrationRequestGet> inProgressPresets = ImmutableList.of(
+ new PresetMSOOrchestrationRequestGet(firstMemberStatus, firstMemberRequestId),
+ new PresetMSOOrchestrationRequestGet(secondMemberStatus, secondMemberRequestId)
+ );
+
+ List<BasePreset> presets = getGroupMembersPresets(instanceGroupMemberPreset,inProgressPresets);
+ registerExpectationFromPresets(presets, RegistrationStrategy.CLEAR_THEN_SET);
+ final List<String> uuids = createBulkOfInstances(false, 1, ImmutableMap.of(
+ VNF_GROUP1_ACTION, "None",
+ RELATED_VNF1_ACTION, "Create",
+ RELATED_VNF2_ACTION, "None_Delete"
+ ), PAYLOAD_TEMPLATE_1_VNF_GROUP_WITH_3_MEMBERS_REQUEST);
+
+ assertThat(uuids, hasSize(1));
+ final String jobId = uuids.get(0);
+
+ assertAuditStatuses(jobId, vidAuditStatuses(jobId, expectedJobStatus), null, 60);
+ assertThat(SimulatorApi.retrieveRecordedRequestsPathCounter(), allOf(
+ TestUtils.hasOrLacksOfEntry(instanceGroupMemberPreset.get(0).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(instanceGroupMemberPreset.get(1).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(inProgressPresets.get(0).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(inProgressPresets.get(1).getReqPath(), 1L)
+ ));
+ }
+
+ @Test
+ @FeatureTogglingTest(Features.FLAG_1902_VNF_GROUPING)
+ public void addVnfGroupWith2GroupMembers_withGoodResponseFromMso_verifyStatusAndRequests() {
+
+ String vnfGroupRequestId = UUID.randomUUID().toString();
+ String firstMemberRequestId = UUID.randomUUID().toString();
+ String secondMemberRequestId = UUID.randomUUID().toString();
+
+ List <PresetMSOCreateVnfGroup> vnfGroupPreset = ImmutableList.of(
+ new PresetMSOCreateVnfGroup("VNF_GROUP1_INSTANCE_NAME",vnfGroupRequestId,PresetMSOCreateVnfGroup.MODEL_INFO_0,"service-instance-id", true));
+ List<PresetMSOAddOrRemoveOneInstanceGroupMember> instanceGroupMemberPreset = ImmutableList.of(
+ new PresetMSOAddOrRemoveOneInstanceGroupMember("VNF_GROUP1_INSTANCE_ID", "RELATED_VNF1_INSTANCE_ID", getUserCredentials().getUserId(), firstMemberRequestId, InstanceGroupMemberAction.Add),
+ new PresetMSOAddOrRemoveOneInstanceGroupMember("VNF_GROUP1_INSTANCE_ID", "RELATED_VNF2_INSTANCE_ID", getUserCredentials().getUserId(), secondMemberRequestId, InstanceGroupMemberAction.Add)
+ );
+ List<PresetMSOOrchestrationRequestGet> inProgressPresets = ImmutableList.of(
+ new PresetMSOOrchestrationRequestGet(MSO_COMPLETE_STATUS, vnfGroupRequestId),
+ new PresetMSOOrchestrationRequestGet(MSO_COMPLETE_STATUS, firstMemberRequestId),
+ new PresetMSOOrchestrationRequestGet(MSO_COMPLETE_STATUS, secondMemberRequestId)
+ );
+
+ final ImmutableList.Builder<BasePreset> basePresetBuilder = new ImmutableList.Builder<>();
+ basePresetBuilder
+ .add(new PresetGetSessionSlotCheckIntervalGet())
+ .add(new PresetAAIGetSubscribersGet())
+ .addAll(instanceGroupMemberPreset)
+ .addAll(inProgressPresets)
+ .addAll(vnfGroupPreset);
+ List<BasePreset> presets = basePresetBuilder.build();
+
+ registerExpectationFromPresets(presets, RegistrationStrategy.CLEAR_THEN_SET);
+ final List<String> uuids = createBulkOfInstances(false, 1, ImmutableMap.of(
+ VNF_GROUP1_ACTION, "Create",
+ RELATED_VNF1_ACTION, "Create",
+ RELATED_VNF2_ACTION, "Create"
+ ), PAYLOAD_TEMPLATE_1_VNF_GROUP_WITH_3_MEMBERS_REQUEST);
+
+ assertThat(uuids, hasSize(1));
+ final String jobId = uuids.get(0);
+
+ assertAuditStatuses(jobId, vidAuditStatusesCompleted(jobId), null, 60);
+ assertThat(SimulatorApi.retrieveRecordedRequestsPathCounter(), allOf(
+ TestUtils.hasOrLacksOfEntry(vnfGroupPreset.get(0).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(instanceGroupMemberPreset.get(0).getReqPath(), 2L),
+ TestUtils.hasOrLacksOfEntry(inProgressPresets.get(0).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(inProgressPresets.get(1).getReqPath(), 1L),
+ TestUtils.hasOrLacksOfEntry(inProgressPresets.get(2).getReqPath(), 1L)
+ ));
+ }
+
+ @Test(dataProvider = "scenarios")
+ public void aLaCarteServiceScenarioRunner(Scenario scenario) {
+ /*
+ This tests creates one or more a-la-carte requests, following one of the these scenarios:
+
+ MSO_FAIL: Submits to MSO, but while getting Orchestration status -> MSO
+ reports failure
+ COMPLETED: Clean legit flow.
+ NAME_TAKEN: Sends request for instance, where AAI reports the name is
+ already taken. Therefore, MSO expects added postfix _001.
+ IN_PROGRESS: Submits to MSO, but while getting Orchestration status -> MSO
+ reports IN_PROGRESS endlessly
+ DUPLICATE_NAME: Sends two requests for instances with the same name.
+ PARALLEL: Submits 3 requests, that must not interfere with each other.
+ */
+
+ registerExpectationFromPresets(ImmutableList.of(
+ new PresetGetSessionSlotCheckIntervalGet(),
+ new PresetAAIGetSubscribersGet()
+ ), RegistrationStrategy.CLEAR_THEN_SET);
+
+
+ final String name0 = randomAlphabetic(18);
+
+ OneServiceActor inProgressCase = new OneServiceActor(
+ scenario == Scenario.PARALLEL || scenario == Scenario.IN_PROGRESS || scenario == Scenario.DUPLICATE_NAME,
+ "IN_PROGRESS", "status #1",
+ ImmutableMap.of(SERVICE_NAME, name0), 0,
+ JobStatus.IN_PROGRESS, this::vidAuditStatusesInProgress
+ );
+
+ OneServiceActor completedCase = new OneServiceActor(
+ scenario == Scenario.PARALLEL || scenario == Scenario.COMPLETED,
+ MSO_COMPLETE_STATUS, "status #2",
+ ImmutableMap.of(SERVICE_NAME, randomAlphabetic(5)), 0,
+ JobStatus.COMPLETED, this::vidAuditStatusesCompleted
+ );
+
+ final String name1 = randomAlphabetic(5);
+ OneServiceActor occupiedNameCase = new OneServiceActor(
+ scenario == Scenario.NAME_TAKEN,
+ MSO_COMPLETE_STATUS, "status #6",
+ ImmutableMap.of(SERVICE_NAME, name1), 1,
+ JobStatus.COMPLETED, this::vidAuditStatusesCompleted,
+ ImmutableList.of(new PresetAAISearchNodeQueryNonEmptyResult("service-instance", name1))
+ );
+
+ OneServiceActor failedCase = new OneServiceActor(
+ scenario == Scenario.PARALLEL || scenario == Scenario.MSO_FAIL,
+ "FAILED", "status #3",
+ ImmutableMap.of(SERVICE_NAME, randomAlphabetic(10)), 0,
+ JobStatus.FAILED, this::vidAuditStatusesFailed
+ );
+
+ OneServiceActor duplicateNameCase = new OneServiceActor(
+ scenario == Scenario.DUPLICATE_NAME,
+ MSO_COMPLETE_STATUS, "status #4",
+ ImmutableMap.of(SERVICE_NAME, name0), 1,
+ JobStatus.COMPLETED, this::vidAuditStatusesCompleted
+ );
+
+ OneServiceActor inProgressTooLongCase = new OneServiceActor(
+ scenario == Scenario.IN_PROGRESS,
+ "IN_PROGRESS", "status #5",
+ ImmutableMap.of(SERVICE_NAME, randomAlphabetic(10)), 0,
+ JobStatus.FAILED, this::vidAuditStatusesFailed, 24
+ );
+
+ final List<OneServiceActor> servicesActors =
+ ImmutableList.of(inProgressCase, completedCase, occupiedNameCase, failedCase, duplicateNameCase, inProgressTooLongCase);
+
+ servicesActors.forEach(actor -> registerExpectationFromPresets(actor.getPresets(),
+ RegistrationStrategy.APPEND));
+
+ servicesActors.forEach(OneServiceActor::createInstances);
+
+ servicesActors.forEach(OneServiceActor::assertServiceInfo);
+ servicesActors.forEach(OneServiceActor::assertAuditStatuses2);
+ }
+
+ @Test
+ public void delete1Create1NetworkFromService() {
+ String deleteRequestId = UUID.randomUUID().toString();
+ String createRequestId = UUID.randomUUID().toString();
+ String serviceInstanceId = BaseMSOPreset.DEFAULT_INSTANCE_ID;
+ String networkInstanceId = "NETWORK_INSTANCE_ID";
+
+ registerExpectationFromPresets(ImmutableList.of(
+ new PresetMSODeleteNetworkAlaCarteCypress(deleteRequestId, serviceInstanceId, networkInstanceId, "us16807000"),
+ new PresetMSOOrchestrationRequestGet(COMPLETE, deleteRequestId),
+ new PresetMSOCreateNetworkALaCarteServiceCypress2(createRequestId, serviceInstanceId, "ExtVL", "action-data", "6b528779-44a3-4472-bdff-9cd15ec93450"),
+ new PresetMSOOrchestrationRequestGet(COMPLETE, createRequestId),
+ PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MTN6_TO_ATT_AIC
+ ), RegistrationStrategy.CLEAR_THEN_SET);
+
+ List<String> uuids = createBulkOfInstances(false, 1, ImmutableMap.of(), DELETE_AND_CREATE_NETWORK_FROM_SERVICE);
+ assertThat(uuids, hasSize(1));
+ String jobId = uuids.get(0);
+
+ assertExpectedStatusAndServiceInfo(JobStatus.COMPLETED, jobId, true, new ServiceInfo(
+ "us16807000", JobStatus.COMPLETED, false,
+ "d61e6f2d-12fa-4cc2-91df-7c244011d6fc", "WayneHolland", "WATKINS",
+ "JAG1", "YUDFJULP-JAG1",
+ "092eb9e8e4b7412e8787dd091bc58e86", "USP-SIP-IC-24335-T-01",
+ "JANET25", null,
+ "TYLER SILVIA", null,
+ null, "InstanceName",
+ "6b528779-44a3-4472-bdff-9cd15ec93450", "action-data", "1.0",
+ jobId, null, ServiceAction.UPDATE, false)
+ );
+ }
+
+ @Test
+ public void deleteServiceWithNetwork() {
+ String deleteNetworkRequestId = UUID.randomUUID().toString();
+ String deleteServiceRequestId = UUID.randomUUID().toString();
+ String serviceInstanceId = BaseMSOPreset.DEFAULT_INSTANCE_ID;
+ String networkInstanceId = "NETWORK_INSTANCE_ID";
+
+ registerExpectationFromPresets(ImmutableList.of(
+ new PresetMSODeleteNetworkAlaCarteCypress(deleteNetworkRequestId, serviceInstanceId, networkInstanceId, "us16807000"),
+ new PresetMSOOrchestrationRequestGet(COMPLETE, deleteNetworkRequestId),
+ new PresetMSODeleteService(deleteServiceRequestId, serviceInstanceId),
+ new PresetMSOOrchestrationRequestGet(COMPLETE, deleteServiceRequestId),
+ PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MTN6_TO_ATT_AIC
+ ), RegistrationStrategy.CLEAR_THEN_SET);
+
+ List<String> uuids = createBulkOfInstances(false, 1, ImmutableMap.of(), DELETE_SERVICE_WITH_NETWORK);
+ assertThat(uuids, hasSize(1));
+ String jobId = uuids.get(0);
+
+ assertExpectedStatusAndServiceInfo(JobStatus.COMPLETED, jobId, true, new ServiceInfo(
+ "us16807000", JobStatus.COMPLETED, false,
+ "d61e6f2d-12fa-4cc2-91df-7c244011d6fc", "WayneHolland", "WATKINS",
+ "JAG1", "YUDFJULP-JAG1",
+ "092eb9e8e4b7412e8787dd091bc58e86", "USP-SIP-IC-24335-T-01",
+ "JANET25", null,
+ "TYLER SILVIA", null,
+ null, "InstanceName",
+ "6b528779-44a3-4472-bdff-9cd15ec93450", "action-data", "1.0",
+ jobId, null, ServiceAction.DELETE, false)
+ );
+ }
+
+ @Test
+ public void delete1VnfWithVfModulesAndCreate1VnfFromService() {
+ String deleteVnfRequestId = UUID.randomUUID().toString();
+ String createVnfRequestId = UUID.randomUUID().toString();
+ String deleteVfModuleRequestId = UUID.randomUUID().toString();
+ String deleteBaseVfModuleRequestId = UUID.randomUUID().toString();
+ String serviceInstanceId = BaseMSOPreset.DEFAULT_INSTANCE_ID;
+ String vnfInstanceId = "VNF_INSTANCE_ID";
+
+ registerExpectationFromPresets(ImmutableList.of(
+ new PresetAAIGetSubscribersGet(),
+ new PresetMSODeleteVnfAlaCarteCypress(deleteVnfRequestId, serviceInstanceId, vnfInstanceId, "us16807000"),
+ new PresetMSOOrchestrationRequestGet(COMPLETE, deleteVnfRequestId),
+ new PresetSDCGetServiceToscaModelGet("6b528779-44a3-4472-bdff-9cd15ec93450", "csar-withDynamicFields-ecompNamingFalse-partialModelDetails-vnfEcompNamingFalse.zip"),
+ new PresetSDCGetServiceMetadataGet("6b528779-44a3-4472-bdff-9cd15ec93450", "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0" , "csar-withDynamicFields-ecompNamingFalse-partialModelDetails-vnfEcompNamingFalse.zip"),
+ new PresetMSODeleteVfModuleCypress(deleteVfModuleRequestId, serviceInstanceId, vnfInstanceId, "VF_MODULE_INSTANCE_ID"),
+ new PresetMSOOrchestrationRequestGet(COMPLETE, deleteVfModuleRequestId),
+ new PresetMSODeleteBaseVfModuleCypress(deleteBaseVfModuleRequestId, serviceInstanceId, vnfInstanceId, "VF_MODULE_BASE_INSTANCE_ID"),
+ new PresetMSOOrchestrationRequestGet(COMPLETE, deleteBaseVfModuleRequestId),
+ new PresetMSOCreateVnfALaCarteServiceCypress2(createVnfRequestId, serviceInstanceId, "2017388_PASQUALEvPEmCaNkinstanceName", "zzz1"),
+ new PresetMSOOrchestrationRequestGet(COMPLETE, createVnfRequestId),
+ PresetAAIGetCloudOwnersByCloudRegionId.PRESET_SOME_LEGACY_REGION_TO_ATT_AIC,
+ PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MTN6_TO_ATT_AIC,
+ PresetAAIGetCloudOwnersByCloudRegionId.PRESET_AAIAIC25_TO_ATT_AIC
+ ), RegistrationStrategy.CLEAR_THEN_SET);
+
+ List<String> uuids = createBulkOfInstances(false, 1, ImmutableMap.of(), DELETE_AND_CREATE_VNF_FROM_SERVICE);
+ assertThat(uuids, hasSize(1));
+ String jobId = uuids.get(0);
+
+ assertExpectedStatusAndServiceInfo(JobStatus.COMPLETED, jobId, true, new ServiceInfo(
+ "us16807000", JobStatus.COMPLETED, false,
+ "d61e6f2d-12fa-4cc2-91df-7c244011d6fc", "WayneHolland", "WATKINS",
+ "NFT1", "NFTJSSSS-NFT1",
+ "bae71557c5bb4d5aac6743a4e5f1d054", "AIN Web Tool-15-D-testalexandria",
+ "hvf6", null,
+ "TYLER SILVIA", null,
+ "f8791436-8d55-4fde-b4d5-72dd2cf13cfb", "mCaNkinstancename",
+ "6b528779-44a3-4472-bdff-9cd15ec93450", "action-data", "1.0",
+ jobId, null, ServiceAction.UPDATE, false)
+ );
+ }
+
+ @Test
+ public void deleteServiceWithVnf() {
+ String deleteVnfRequestId = UUID.randomUUID().toString();
+ String deleteServiceRequestId = UUID.randomUUID().toString();
+ String serviceInstanceId = BaseMSOPreset.DEFAULT_INSTANCE_ID;
+ String vnfInstanceId = "VNF_INSTANCE_ID";
+
+ registerExpectationFromPresets(ImmutableList.of(
+ new PresetMSODeleteVnfAlaCarteCypress(deleteVnfRequestId, serviceInstanceId, vnfInstanceId, "us16807000"),
+ new PresetMSOOrchestrationRequestGet(COMPLETE, deleteVnfRequestId),
+ new PresetMSODeleteService(deleteServiceRequestId, serviceInstanceId),
+ new PresetMSOOrchestrationRequestGet(COMPLETE, deleteServiceRequestId),
+ PresetAAIGetCloudOwnersByCloudRegionId.PRESET_SOME_LEGACY_REGION_TO_ATT_AIC
+ ), RegistrationStrategy.CLEAR_THEN_SET);
+
+ List<String> uuids = createBulkOfInstances(false, 1, ImmutableMap.of(), DELETE_SERVICE_WITH_VNF);
+ assertThat(uuids, hasSize(1));
+ String jobId = uuids.get(0);
+
+ assertExpectedStatusAndServiceInfo(JobStatus.COMPLETED, jobId, true, new ServiceInfo(
+ "us16807000", JobStatus.COMPLETED, false,
+ "d61e6f2d-12fa-4cc2-91df-7c244011d6fc", "WayneHolland", "WATKINS",
+ "NFT1", "NFTJSSSS-NFT1",
+ "bae71557c5bb4d5aac6743a4e5f1d054", "AIN Web Tool-15-D-testalexandria",
+ "hvf6", null,
+ "TYLER SILVIA", null,
+ "f8791436-8d55-4fde-b4d5-72dd2cf13cfb", "mCaNkinstancename",
+ "6b528779-44a3-4472-bdff-9cd15ec93450", "action-data", "1.0",
+ jobId, null, ServiceAction.DELETE, false)
+ );
+ }
+
+ private ImmutableList<JobAuditStatus> vidAuditStatusesInProgress(String jobId) {
+ return ImmutableList.of(
+ vidAuditStatus(jobId, "PENDING", false),
+ vidAuditStatus(jobId, "IN_PROGRESS", false)
+ );
+ }
+
+ private ImmutableList<JobAuditStatus> vidAuditStatusesCompleted(String jobId) {
+ return ImmutableList.of(
+ vidAuditStatus(jobId, "PENDING", false),
+ vidAuditStatus(jobId, "IN_PROGRESS", false),
+ vidAuditStatus(jobId, "COMPLETED", true)
+ );
+ }
+
+ private ImmutableList<JobAuditStatus> vidAuditStatuses(String jobId, JobStatus jobStatus) {
+ switch(jobStatus) {
+ case COMPLETED:
+ return vidAuditStatusesCompleted(jobId);
+ case COMPLETED_WITH_ERRORS:
+ return vidAuditStatusesCompletedWithErrors(jobId);
+ case FAILED:
+ return vidAuditStatusesFailed(jobId);
+ case IN_PROGRESS:
+ return vidAuditStatusesInProgress(jobId);
+ }
+
+ return null;
+ }
+
+ private ImmutableList<JobAuditStatus> msoAuditStatuses(String jobId , String lastStatus, String lastAdditionalInfo) {
+ final List<JobAuditStatus> auditMsoStatuses = getAuditStatuses(jobId, SourceStatus.MSO.name());
+ final UUID actualRequestId = auditMsoStatuses.get(0).getRequestId();
+ return ImmutableList.of(
+ msoAuditStatus(jobId, "REQUESTED", null, actualRequestId),
+ msoAuditStatus(jobId, lastStatus, lastAdditionalInfo, actualRequestId)
+ );
+ }
+
+ private JobAuditStatus msoAuditStatus(String jobId, String jobStatus, String additionalInfo, UUID requestId) {
+ return new JobAuditStatus(UUID.fromString(jobId), jobStatus, SourceStatus.MSO, requestId, additionalInfo, false);
+ }
+
+ private void assertServiceInfoSpecific3(String jobId, JobStatus jobStatus, String serviceInstanceName) {
+ assertExpectedStatusAndServiceInfo(jobStatus, jobId, true, new ServiceInfo(
+ "us16807000", jobStatus, false,
+ "aaa1", "aaa1", "yyy1",
+ "YYY1", "UUUAIAAI-YYY1",
+ "1178612d2b394be4834ad77f567c0af2", "AIN Web Tool-15-D-SSPtestcustome",
+ "hvf6", null,
+ "TYLER SILVIA", null,
+ null, serviceInstanceName,
+ "6e59c5de-f052-46fa-aa7e-2fca9d674c44", "ComplexService", "1.0",
+ jobId, null, ServiceAction.INSTANTIATE, false)
+ );
+ }
+
+ private List<BasePreset> getGroupMembersPresets(List<PresetMSOAddOrRemoveOneInstanceGroupMember> deleteMembersPreset, List<PresetMSOOrchestrationRequestGet> inProgressPresets) {
+ final ImmutableList.Builder<BasePreset> basePresetBuilder = new ImmutableList.Builder<>();
+ basePresetBuilder
+ .add(new PresetGetSessionSlotCheckIntervalGet())
+ .add(new PresetAAIGetSubscribersGet())
+ .addAll(deleteMembersPreset)
+ .addAll(inProgressPresets);
+ return basePresetBuilder.build();
+ }
+
+
+ enum Scenario {
+ PARALLEL, COMPLETED, NAME_TAKEN, DUPLICATE_NAME, IN_PROGRESS, MSO_FAIL
+ }
+
+ class OneServiceActor {
+ private final boolean isRelevant;
+ private final String requestId;
+ private final String msoInfo;
+ private final Map<PresetMSOServiceInstanceGen2WithNames.Keys, String> serviceNames;
+ private final int suffix;
+ private final String expectedMsoLastStatus;
+ private final JobStatus jobStatus;
+ private final Function<String, List<JobAuditStatus>> jobAuditStatusesProvider;
+ private String jobId;
+ private int startedHoursAgo = 1;
+ private List<BasePreset> morePresets = ImmutableList.of();
+
+ private OneServiceActor(boolean isRelevant, String msoLastStatus, String msoInfo, Map<PresetMSOServiceInstanceGen2WithNames.Keys, String> serviceNames, int suffix, JobStatus jobStatus, Function<String, List<JobAuditStatus>> jobAuditStatusesProvider) {
+ this.isRelevant = isRelevant;
+ this.requestId = UUID.randomUUID().toString();
+ this.msoInfo = msoInfo;
+ this.serviceNames = serviceNames;
+ this.suffix = suffix;
+ this.expectedMsoLastStatus = msoLastStatus;
+ this.jobStatus = jobStatus;
+ this.jobAuditStatusesProvider = jobAuditStatusesProvider;
+ }
+
+ private OneServiceActor(boolean isRelevant, String msoLastStatus, String msoInfo, Map<PresetMSOServiceInstanceGen2WithNames.Keys, String> serviceNames, int suffix, JobStatus jobStatus, Function<String, List<JobAuditStatus>> jobAuditStatusesProvider, int startedHoursAgo) {
+ this(isRelevant, msoLastStatus, msoInfo, serviceNames, suffix, jobStatus, jobAuditStatusesProvider);
+ this.startedHoursAgo = startedHoursAgo;
+ }
+
+ private OneServiceActor(boolean isRelevant, String msoLastStatus, String msoInfo, Map<PresetMSOServiceInstanceGen2WithNames.Keys, String> serviceNames, int suffix, JobStatus jobStatus, Function<String, List<JobAuditStatus>> jobAuditStatusesProvider, List<BasePreset> morePresets) {
+ this(isRelevant, msoLastStatus, msoInfo, serviceNames, suffix, jobStatus, jobAuditStatusesProvider);
+ this.morePresets = morePresets;
+ }
+
+ public List<BasePreset> getPresets() {
+ // if not relevant -> return empty list
+ return isRelevant ?
+ ImmutableList.<BasePreset>builder().add(
+ new PresetMSOCreateServiceInstanceGen2WithNamesAlacarteService(serviceNames, suffix, requestId),
+ new PresetMSOOrchestrationRequestGet(expectedMsoLastStatus, requestId, msoInfo, startedHoursAgo)
+ ).addAll(morePresets).build()
+ : ImmutableList.of();
+ }
+
+ private void createInstances() {
+ // call VID with 1 request, keep the job id
+ if (!isRelevant) return;
+ final List<String> jobIds = createBulkOfInstances(false, 1, serviceNames, CREATE_BULK_OF_ALACARTE_REQUEST);
+ assertThat(jobIds, hasSize(1));
+ jobId = jobIds.get(0);
+ }
+
+ private void assertServiceInfo() {
+ if (!isRelevant) return;
+ assertThat(jobId, is(not(nullValue())));
+ assertServiceInfoSpecific1(jobId, jobStatus, serviceNames.get(SERVICE_NAME));
+ }
+
+ private void assertAuditStatuses2() {
+ if (!isRelevant) return;
+ assertThat(jobId, is(not(nullValue())));
+ assertAuditStatuses(jobId, jobAuditStatusesProvider.apply(jobId), msoAuditStatuses(jobId, expectedMsoLastStatus, msoInfo));
+ }
+ }
+
+}
diff --git a/vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationApiTest.java
index a5b72c261..5c4d8a876 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationApiTest.java
@@ -1,27 +1,22 @@
package org.onap.vid.api;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
import net.bytebuddy.utility.RandomString;
import net.javacrumbs.jsonunit.JsonAssert;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.Description;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
-import org.onap.simulator.presetGenerator.presets.aai.PresetAAISearchNodeQueryEmptyResult;
import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet;
import org.onap.simulator.presetGenerator.presets.mso.*;
import org.onap.vid.model.asyncInstantiation.JobAuditStatus;
import org.onap.vid.model.asyncInstantiation.ServiceInfo;
-import org.onap.vid.model.mso.MsoResponseWrapper2;
-import org.springframework.core.ParameterizedTypeReference;
+import org.onap.sdc.ci.tests.datatypes.UserCredentials;
import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
import org.springframework.web.client.HttpClientErrorException;
-import org.springframework.web.client.RestTemplate;
+import org.springframework.web.client.HttpServerErrorException;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -32,76 +27,33 @@ import vid.automation.test.model.JobStatus;
import vid.automation.test.services.SimulatorApi;
import java.util.*;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.IntStream;
import java.util.stream.Stream;
-import static java.lang.Boolean.FALSE;
-import static java.lang.Boolean.TRUE;
import static java.util.stream.Collectors.*;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasProperty;
import static org.hamcrest.Matchers.hasSize;
import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys;
-import static org.testng.Assert.assertNotNull;
+import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
+import static vid.automation.test.infra.Features.FLAG_1906_INSTANTIATION_API_USER_VALIDATION;
+import static vid.automation.test.utils.ExtendedHamcrestMatcher.hasItemsFromCollection;
@FeatureTogglingTest({Features.FLAG_ASYNC_JOBS, Features.FLAG_ASYNC_INSTANTIATION})
-public class AsyncInstantiationApiTest extends BaseMsoApiTest {
+public class AsyncInstantiationApiTest extends AsyncInstantiationBase {
+ private static final Logger logger = LogManager.getLogger(AsyncInstantiationApiTest.class);
- private static final String CREATE_BULK_OF_MACRO_REQUEST = "asyncInstantiation/vidRequestCreateBulkOfMacro.json";
-
- @DataProvider
- public static Object[][] trueAndFalse() {
- return new Object[][]{{TRUE},{FALSE}};
- }
-
- private String getCreateBulkUri() {
- return uri.toASCIIString() + "/asyncInstantiation/bulk";
- }
-
- private String getHideServiceUri(String jobId) {
- return uri.toASCIIString() + "/asyncInstantiation/hide/"+jobId;
- }
-
- private String getServiceInfoUrl() {
- return uri.toASCIIString() + "/asyncInstantiation";
- }
-
- private String getJobAuditUrl() {
- return uri.toASCIIString() + "/asyncInstantiation/auditStatus/{JOB_ID}?source={SOURCE}";
- }
-
- private String getDeleteServiceUrl(String uuid) {
- return uri.toASCIIString() + "/asyncInstantiation/job/" + uuid;
- }
-
- public static class JobIdAndStatusMatcher extends BaseMatcher<ServiceInfo> {
- private String expectedJobId;
-
- public JobIdAndStatusMatcher(String expectedJobId) {
- this.expectedJobId = expectedJobId;
- }
-
- @Override
- public boolean matches(Object item) {
- if (!(item instanceof ServiceInfo)) {
- return false;
- }
- ServiceInfo serviceInfo = (ServiceInfo) item;
- return expectedJobId.equals(serviceInfo.jobId);
- }
-
- @Override
- public void describeTo(Description description) {
- description.appendText("failed to find job with uuid ")
- .appendValue(expectedJobId);
- }
- }
+ private static final String MSO_BASE_ERROR =
+ "Received error from SDN-C: java.lang.IllegalArgumentException: All keys must be specified for class org."+
+ "opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.assignments.vf."+
+ "module.assignments.vms.VmKey. Missing key is getVmType. Supplied key is VmKey [].";
+ private static final String MSO_ERROR = MSO_BASE_ERROR + StringUtils.repeat(" and a lot of sentences for long message", 60);
+ private static final String INSTANCE_GROUP_ID_LABEL = "instanceGroupId";
+ private static final String INSTANCE_GROUP_LABEL = "instanceGroup";
@Test
public void createBulkOfCreateInstances(){
@@ -111,40 +63,6 @@ public class AsyncInstantiationApiTest extends BaseMsoApiTest {
createBulkOfInstancesAndAssert(presets, false, bulkSize, JobStatus.COMPLETED, names);
}
- private Map<Keys,String> generateNames() {
- return Stream.of(Keys.values()).collect(
- Collectors.toMap(x->x, x -> UUID.randomUUID().toString().replace("-","")));
- }
-
- private ImmutableList<BasePreset> addPresetsForCreateBulkOfCreateInstances(int bulkSize, Map<Keys, String> names){
- ImmutableList<BasePreset> msoBulkPresets = IntStream.rangeClosed(1,bulkSize).
- mapToObj(i-> new PresetMSOCreateServiceInstanceGen2WithNames(names, i))
- .collect(ImmutableList.toImmutableList());
- ImmutableList<BasePreset> presets = new ImmutableList.Builder<BasePreset>()
- .add(new PresetGetSessionSlotCheckIntervalGet())
- .add(new PresetAAIGetSubscribersGet())
- .add(new PresetAAISearchNodeQueryEmptyResult())
- .addAll(msoBulkPresets)
- .add(new PresetMSOOrchestrationRequestGet())
- .build();
- return presets;
-
- }
-
- private ResponseEntity<List<JobAuditStatus>> auditStatusCall(String url) {
- return restTemplate.exchange(
- url,
- org.springframework.http.HttpMethod.GET,
- null,
- new ParameterizedTypeReference<List<JobAuditStatus>>() {});
- }
-
- @DataProvider
- public static Object[][] auditSources() {
- return new Object[][]{{JobAuditStatus.SourceStatus.VID},{JobAuditStatus.SourceStatus.MSO}};
- }
-
-
@Test(dataProvider = "auditSources")
public void getAuditStatus_nonExistingJobId_returnsEmptyList(JobAuditStatus.SourceStatus source){
List<JobAuditStatus> audits = getAuditStatuses(UUID.randomUUID().toString(), source.name());
@@ -170,13 +88,8 @@ public class AsyncInstantiationApiTest extends BaseMsoApiTest {
for(String jobId: jobIds) {
List<JobAuditStatus> actualVidAudits = getAuditStatuses(jobId, JobAuditStatus.SourceStatus.VID.name());
List<JobAuditStatus> expectedVidAudits = Stream.of(JobStatus.PENDING, JobStatus.IN_PROGRESS, JobStatus.COMPLETED)
- .map(status->new JobAuditStatus(UUID.fromString(jobId),
- status.name(),
- JobAuditStatus.SourceStatus.VID,
- null,
- null,
- status.equals(JobStatus.COMPLETED))).collect(toList());
- assertThat(actualVidAudits, is(expectedVidAudits));
+ .map(status-> vidAuditStatus(jobId, status.name(), status.equals(JobStatus.COMPLETED))).collect(toList());
+ assertThat(actualVidAudits, hasItemsFromCollection(expectedVidAudits));
List<JobAuditStatus> actualMsoAudits = getAuditStatuses(jobId, JobAuditStatus.SourceStatus.MSO.name());
List<JobAuditStatus> expectedMsoAudits = Stream.of("REQUESTED", "COMPLETE")
@@ -190,29 +103,6 @@ public class AsyncInstantiationApiTest extends BaseMsoApiTest {
}
}
- protected List<String> createBulkAndWaitForBeCompleted(int bulkSize){
- Map<Keys, String> names = generateNames();
- ImmutableList<BasePreset> presets = addPresetsForCreateBulkOfCreateInstances(bulkSize, names);
- final List<String> jobIds = createBulkOfInstances(presets, false, bulkSize, names);
- Assert.assertEquals(jobIds.size(),bulkSize);
-
- assertTrue(String.format("Not all services with ids: %s are in state completed after 30 sec",
- jobIds.stream().collect(joining(","))),
-
- Wait.waitFor(y-> serviceListCall().getBody().stream()
- .filter(si -> jobIds.contains(si.jobId))
- .filter(si -> si.jobStatus==JobStatus.COMPLETED)
- .count() == bulkSize,
- null, 30, 1 ));
- return jobIds;
- }
-
- private List<JobAuditStatus> getAuditStatuses(String jobUUID, String source){
- String url = getJobAuditUrl().replace("{JOB_ID}",jobUUID).replace("{SOURCE}", source);
- ResponseEntity<List<JobAuditStatus>> statusesResponse = auditStatusCall(url);
- assertThat(statusesResponse.getStatusCode(), CoreMatchers.equalTo(HttpStatus.OK));
- return statusesResponse.getBody();
- }
@Test(expectedExceptions = HttpClientErrorException.class)
public void addBulkAndDeleteInProgress_deletionIsRejected(){
@@ -245,52 +135,6 @@ public class AsyncInstantiationApiTest extends BaseMsoApiTest {
assertThat("deleted job shall not be present in StatusInfo response", statusesNow, is(statusesBefore));
}
- private Map<String, JobStatus> addBulkAllPendingButOneInProgress(){
- return addBulkAllPendingButOneInProgress(3);
- }
-
- private Map<String, JobStatus> addBulkAllPendingButOneInProgress(int bulkSize){
- Map<Keys, String> names = generateNames();
- ImmutableList<BasePreset> msoBulkPresets = IntStream.rangeClosed(1,bulkSize)
- .mapToObj(i-> new PresetMSOCreateServiceInstanceGen2WithNames(names, i))
- .collect(ImmutableList.toImmutableList());
- ImmutableList<BasePreset> presets = new ImmutableList.Builder<BasePreset>()
- .add(new PresetGetSessionSlotCheckIntervalGet())
- .add(new PresetAAISearchNodeQueryEmptyResult())
- .add(new PresetAAIGetSubscribersGet())
- .addAll(msoBulkPresets)
- .add(new PresetMSOOrchestrationRequestGet("IN_PROGRESS"))
- .build();
- final List<String> jobIds = createBulkOfInstances(presets, false, bulkSize, names);
-
- // wait for single IN_PROGRESS, so statuses will stop from changing
- Wait.waitFor(foo -> serviceListCall().getBody().stream()
- .filter(si -> jobIds.contains(si.jobId))
- .anyMatch(si -> si.jobStatus.equals(JobStatus.IN_PROGRESS)),
- null, 20, 1);
-
- final Map<String, JobStatus> statusMapBefore = serviceListCall().getBody().stream()
- .filter(si -> jobIds.contains(si.jobId))
- .collect(toMap(si -> si.jobId, si -> si.jobStatus));
-
- assertThat(jobIds, hasSize(bulkSize));
-
-
- return statusMapBefore;
- }
-
- private String deleteOneJobHavingTheStatus(Map<String, JobStatus> jobIdToStatus, JobStatus jobStatus) {
- final String jobToDelete = jobIdToStatus.entrySet().stream()
- .filter(entry -> entry.getValue().equals(jobStatus))
- .map(Map.Entry::getKey)
- .findFirst().orElseThrow(() -> new AssertionError("no job in " + jobStatus + " state: " + jobIdToStatus));
-
-
- restTemplate.delete(getDeleteServiceUrl(jobToDelete));
-
- return jobToDelete;
- }
-
@Test(invocationCount = 3)
public void createBulkOfCreateInstancesWithSinglePreset_firstOneInProgressOtherArePending(){
final int bulkSize = 3;
@@ -306,7 +150,6 @@ public class AsyncInstantiationApiTest extends BaseMsoApiTest {
// PENDING: The other two jobs - named with _002 and _003 - are the still pending
assertThat(jobIds, hasSize(bulkSize));
assertThat(statuses.get(JobStatus.IN_PROGRESS), hasSize(1));
- assertThat(statuses.get(JobStatus.IN_PROGRESS), everyItem(hasProperty("serviceInstanceName", endsWith("_001"))));
assertThat(statuses.get(JobStatus.PENDING), hasSize(bulkSize - 1));
}
@@ -320,18 +163,16 @@ public class AsyncInstantiationApiTest extends BaseMsoApiTest {
//if there is a preset for create, service shall failed during in_progress (upon get status)
//it there is no preset for create, service shall failed during pending (upon create request)
List<BasePreset> msoBulkPresets = isPresetForCreate ?
- IntStream.rangeClosed(1,bulkSize)
- .mapToObj(i-> new PresetMSOCreateServiceInstanceGen2WithNames(names, i))
- .collect(ImmutableList.toImmutableList()) :
+ generateMsoCreateBulkPresets(bulkSize, names) :
new LinkedList<>();
ImmutableList<BasePreset> presets = new ImmutableList.Builder<BasePreset>()
.add(new PresetGetSessionSlotCheckIntervalGet())
.add(new PresetAAIGetSubscribersGet())
- .add(new PresetAAISearchNodeQueryEmptyResult())
+ .add(PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MTN3_TO_ATT_SABABA)
.addAll(msoBulkPresets)
.add(new PresetMSOOrchestrationRequestGet("FAILED"))
.build();
- List<String> jobIds = createBulkOfInstances(presets, false, bulkSize, names);
+ List<String> jobIds = createBulkOfMacroInstances(presets, false, bulkSize, names);
Assert.assertEquals(jobIds.size(),bulkSize);
boolean result = Wait.waitFor(x->{
List<ServiceInfo> serviceInfoList = serviceListCall().getBody();
@@ -346,13 +187,13 @@ public class AsyncInstantiationApiTest extends BaseMsoApiTest {
public void createBulkOfAssignInstances(){
Map<Keys, String> names = generateNames();
final int bulkSize = 2;
- ImmutableList<BasePreset> msoBulkPresets = IntStream.rangeClosed(1,bulkSize)
+ ImmutableList<BasePreset> msoBulkPresets = IntStream.rangeClosed(0, bulkSize-1)
.mapToObj(i-> new PresetMSOAssignServiceInstanceGen2WithNames(names, i))
.collect(ImmutableList.toImmutableList());
ImmutableList<BasePreset> presets = new ImmutableList.Builder<BasePreset>()
.add(new PresetGetSessionSlotCheckIntervalGet())
.add(new PresetAAIGetSubscribersGet())
- .add(new PresetAAISearchNodeQueryEmptyResult())
+ .add(PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MTN3_TO_ATT_SABABA)
.addAll(msoBulkPresets)
.add(new PresetMSOOrchestrationRequestGet())
.build();
@@ -364,13 +205,12 @@ public class AsyncInstantiationApiTest extends BaseMsoApiTest {
ImmutableList<BasePreset> presets = ImmutableList.of(
new PresetGetSessionSlotCheckIntervalGet(),
new PresetAAIGetSubscribersGet(),
- new PresetAAISearchNodeQueryEmptyResult(),
new PresetMSOServiceInstanceGen2ErrorResponse(406));
List<String> jobIds = createBulkOfInstancesAndAssert(presets, true,1, JobStatus.FAILED, generateNames());
String jobId = jobIds.get(0);
List<JobAuditStatus> actualMsoAudits = getAuditStatuses(jobId, JobAuditStatus.SourceStatus.MSO.name());
- JobAuditStatus expectedMsoAudit = new JobAuditStatus(UUID.fromString(jobId),"FAILED",JobAuditStatus.SourceStatus.MSO,
+ JobAuditStatus expectedMsoAudit = new JobAuditStatus(UUID.fromString(jobId), "FAILED", JobAuditStatus.SourceStatus.MSO,
null,
"Http Code:406, \"messageId\":\"SVC0002\",\"text\":\"JSON Object Mapping Request\"" ,
false);
@@ -378,6 +218,24 @@ public class AsyncInstantiationApiTest extends BaseMsoApiTest {
}
@Test
+ public void whenGetLongErrorMessageFromMso_ThenAuditFirst2000Chars() {
+ Map<Keys, String> names = generateNames();
+ ImmutableList<BasePreset> presets = ImmutableList.of(
+ new PresetGetSessionSlotCheckIntervalGet(),
+ new PresetAAIGetSubscribersGet(),
+ new PresetMSOCreateServiceInstanceGen2WithNames(names, 0),
+ new PresetMSOOrchestrationRequestGet("FAILED", PresetMSOOrchestrationRequestGet.DEFAULT_REQUEST_ID, MSO_ERROR));
+
+ List<String> jobIds = createBulkOfInstancesAndAssert(presets, false, 1, JobStatus.FAILED, names);
+ String jobId = jobIds.get(0);
+ List<JobAuditStatus> actualMsoAudits = getAuditStatuses(jobId, JobAuditStatus.SourceStatus.MSO.name());
+ Optional<JobAuditStatus> jobAuditStatus = actualMsoAudits.stream().filter(x -> x.getJobStatus().equals("FAILED")).findFirst();
+ assertTrue(jobAuditStatus.isPresent());
+ assertThat(jobAuditStatus.get().getAdditionalInfo(), startsWith(MSO_BASE_ERROR));
+ assertThat(jobAuditStatus.get().getAdditionalInfo().length(), is(2000));
+ }
+
+ @Test
public void whenHideCompletedService_thenServiceNotReturnInServiceList(){
List<String> services = createBulkAndWaitForBeCompleted(2);
hideService(services.get(0));
@@ -386,116 +244,14 @@ public class AsyncInstantiationApiTest extends BaseMsoApiTest {
assertThat(serviceInfoList, not(hasItem(services.get(0))));
}
- private MsoResponseWrapper2 hideService(String jobId) {
- MsoResponseWrapper2 responseWrapper2 = callMsoForResponseWrapper(org.springframework.http.HttpMethod.POST, getHideServiceUri(jobId), "");
- return responseWrapper2;
- }
-
- private List<String> createBulkOfInstancesAndAssert(ImmutableList<BasePreset> presets, boolean isPause, int bulkSize, JobStatus finalState, Map<Keys, String> names){
- List<String> jobIds = createBulkOfInstances(presets, isPause, bulkSize, names);
- Assert.assertEquals(jobIds.size(),bulkSize);
- for(String jobId: jobIds) {
- ServiceInfo expectedServiceInfo = new ServiceInfo("vid1", JobStatus.IN_PROGRESS, isPause, "someID",
- "someName", "myProject", "NFT1", "NFTJSSSS-NFT1", "greatTenant", "greatTenant", "mtn3", null,
- "mySubType", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", null, names.get(Keys.SERVICE_NAME),
- "300adb1e-9b0c-4d52-bfb5-fa5393c4eabb", "AIM_TRANSPORT_00004", "1.0", jobId, null);
- JobInfoChecker jobInfoChecker = new JobInfoChecker(
- restTemplate, ImmutableSet.of(JobStatus.PENDING, JobStatus.IN_PROGRESS, finalState), jobId, expectedServiceInfo);
- boolean result = jobInfoChecker.test(null);
- assertTrue("service info of jobId: " + jobId + " was in status: " + jobInfoChecker.lastStatus, result);
-
- jobInfoChecker.setExpectedJobStatus(ImmutableSet.of(finalState));
- if (ImmutableList.of(JobStatus.COMPLETED, JobStatus.PAUSE).contains(finalState)) {
- expectedServiceInfo.serviceInstanceId = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
- }
- result = Wait.waitFor(jobInfoChecker, null, 20, 1);
- assertTrue("service info of jobId: " + jobId + " was in status: " + jobInfoChecker.lastStatus, result);
- }
-
- return jobIds;
- }
-
- private List<String> createBulkOfInstances(ImmutableList<BasePreset> presets, boolean isPause, int bulkSize, Map<Keys, String> names){
-
- SimulatorApi.registerExpectationFromPresets(presets, SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET);
-
- String requestBody = TestUtils.convertRequest(objectMapper, CREATE_BULK_OF_MACRO_REQUEST);
- requestBody = requestBody.replace("\"IS_PAUSE_VALUE\"", String.valueOf(isPause)).replace("\"BULK_SIZE\"", String.valueOf(bulkSize));
- for (Map.Entry<Keys, String> e : names.entrySet()) {
- requestBody = requestBody.replace(e.getKey().name(), e.getValue());
- }
- MsoResponseWrapper2 responseWrapper2 = callMsoForResponseWrapper(org.springframework.http.HttpMethod.POST, getCreateBulkUri(), requestBody);
- assertNotNull(responseWrapper2);
- return (List<String>)responseWrapper2.getEntity();
- }
-
- public class JobInfoChecker<Integer> implements Predicate<Integer> {
-
- private final RestTemplate restTemplate;
- private Set<JobStatus> expectedJobStatus;
- private ServiceInfo expectedServiceInfo;
- private final String jobId;
- private JobStatus lastStatus;
-
- public JobInfoChecker(RestTemplate restTemplate, Set<JobStatus> expectedJobStatus, String jobId, ServiceInfo expectedServiceInfo) {
- this.restTemplate = restTemplate;
- this.expectedJobStatus = expectedJobStatus;
- this.jobId = jobId;
- this.expectedServiceInfo = expectedServiceInfo;
- }
-
- public void setExpectedJobStatus(Set<JobStatus> expectedJobStatus) {
- this.expectedJobStatus = expectedJobStatus;
- }
-
- @Override
- public boolean test(Integer integer) {
- ResponseEntity<List<ServiceInfo>> serviceListResponse = serviceListCall();
- assertThat(serviceListResponse.getStatusCode(), CoreMatchers.equalTo(HttpStatus.OK));
- assertThat(serviceListResponse.getBody(), hasItem(new JobIdAndStatusMatcher(jobId)));
- ServiceInfo serviceInfoFromDB = serviceListResponse.getBody().stream()
- .filter(serviceInfo -> serviceInfo.jobId.equals(jobId))
- .findFirst().orElse(null);
- Assert.assertNotNull(serviceInfoFromDB);
- Assert.assertEquals(serviceInfoDataReflected(serviceInfoFromDB), serviceInfoDataReflected(expectedServiceInfo));
- assertTrue("actual service instance doesn't contain template service name:" + expectedServiceInfo.serviceInstanceName,
- serviceInfoFromDB.serviceInstanceName.contains(expectedServiceInfo.serviceInstanceName));
- if (serviceInfoFromDB.jobStatus==JobStatus.IN_PROGRESS || serviceInfoFromDB.jobStatus==JobStatus.COMPLETED) {
- assertTrue("actual service instance doesn't contain template service name and trailing numbers:" + expectedServiceInfo.serviceInstanceName,
- serviceInfoFromDB.serviceInstanceName.contains(expectedServiceInfo.serviceInstanceName+"_00"));
- }
-
- if (expectedServiceInfo.serviceInstanceId != null) {
- assertThat(serviceInfoFromDB.serviceInstanceId, is(expectedServiceInfo.serviceInstanceId));
- }
- lastStatus = serviceInfoFromDB.jobStatus;
- return expectedJobStatus.contains(serviceInfoFromDB.jobStatus);
- }
- }
-
- private ResponseEntity<List<ServiceInfo>> serviceListCall() {
- return restTemplate.exchange(
- getServiceInfoUrl(),
- org.springframework.http.HttpMethod.GET,
- null,
- new ParameterizedTypeReference<List<ServiceInfo>>() {});
- }
-
- //serialize fields except of fields we cannot know ahead of time
- private static String serviceInfoDataReflected(ServiceInfo service1) {
- return new ReflectionToStringBuilder(service1, ToStringStyle.SHORT_PREFIX_STYLE)
- .setExcludeFieldNames("jobStatus", "templateId", "statusModifiedDate", "createdBulkDate", "serviceInstanceId", "serviceInstanceName")
- .toString();
- }
-
@Test
public void errorResponseInGetStatusFromMso_getAuditStatusFromMso_errorMsgExistInAdditionalInfo(){
Map<Keys, String> names = generateNames();
ImmutableList<BasePreset> presets = new ImmutableList.Builder<BasePreset>()
.add(new PresetGetSessionSlotCheckIntervalGet())
.add(new PresetAAIGetSubscribersGet())
- .add(new PresetAAISearchNodeQueryEmptyResult())
- .add(new PresetMSOAssignServiceInstanceGen2WithNames(names, 1))
+ .add(PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MTN3_TO_ATT_SABABA)
+ .add(new PresetMSOAssignServiceInstanceGen2WithNames(names, 0))
.add(new PresetMSOOrchestrationRequestGetErrorResponse(406))
.build();
@@ -516,4 +272,97 @@ public class AsyncInstantiationApiTest extends BaseMsoApiTest {
}
+ @Test
+ public void inProgressJobMoreThan24HoursIsFailedInVidAudit(){
+ addBulkPendingWithCustomList(Collections.singletonList(new PresetMSOOrchestrationRequestGet("IN_PROGRESS",24)));
+
+ AtomicReference<ServiceInfo> inProgressJob = new AtomicReference<>();
+ boolean isJobFound = Wait.waitFor(x->{
+ List<ServiceInfo> serviceInfoList = serviceListCall().getBody();
+ inProgressJob.set(serviceInfoList.stream().
+ filter(serviceInfo -> serviceInfo.serviceInstanceId.equals(PresetMSOOrchestrationRequestGet.DEFAULT_SERVICE_INSTANCE_ID) && serviceInfo.jobStatus.equals(JobStatus.FAILED))
+ .findFirst()
+ .orElse(null));
+ return inProgressJob.get() != null;
+ }, null, 15, 1);
+
+ org.junit.Assert.assertTrue("Job with DEFAULT_SERVICE_INSTANCE_ID and status FAILED should present", isJobFound);
+
+ verifyAuditStatuses(inProgressJob.get().jobId, Arrays.asList(JobStatus.PENDING.name(), JobStatus.IN_PROGRESS.name(),JobStatus.FAILED.name()), JobAuditStatus.SourceStatus.VID);
+ verifyAuditStatuses(inProgressJob.get().jobId, Arrays.asList("REQUESTED", "IN_PROGRESS"), JobAuditStatus.SourceStatus.MSO);
+ }
+
+ @Test
+ public void inProgressJobLessThan24HoursIsStillInProgressInVidAudit(){
+ addBulkPendingWithCustomList(Collections.singletonList(new PresetMSOOrchestrationRequestGet("IN_PROGRESS",23)));
+
+ AtomicReference<ServiceInfo> inProgressJob = new AtomicReference<>();
+ boolean isJobFound = Wait.waitFor(x->{
+ List<ServiceInfo> serviceInfoList = serviceListCall().getBody();
+ inProgressJob.set(serviceInfoList.stream().filter(serviceInfo -> serviceInfo.serviceInstanceId.equals(PresetMSOOrchestrationRequestGet.DEFAULT_SERVICE_INSTANCE_ID))
+ .findFirst()
+ .orElse(null));
+ return inProgressJob.get() != null;
+ }, null, 15, 1);
+
+ org.junit.Assert.assertTrue("Job with DEFAULT_SERVICE_INSTANCE_ID should present", isJobFound);
+ org.junit.Assert.assertEquals("Tested job status is not as expected", JobStatus.IN_PROGRESS, inProgressJob.get().getJobStatus());
+
+ verifyAuditStatuses(inProgressJob.get().jobId, Arrays.asList(JobStatus.PENDING.name(), JobStatus.IN_PROGRESS.name()), JobAuditStatus.SourceStatus.VID);
+ verifyAuditStatuses(inProgressJob.get().jobId, Arrays.asList("REQUESTED", "IN_PROGRESS"), JobAuditStatus.SourceStatus.MSO);
+ }
+
+ @Test
+ public void verifyAuditStatusOfInstanceGroupId(){
+ SimulatorApi.registerExpectationFromPreset(new PresetMSOOrchestrationRequestsManyInstanceStatusesGet(INSTANCE_GROUP_ID_LABEL, INSTANCE_GROUP_LABEL), SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET);
+ final List<JobAuditStatus> expectedAuditStatusList = getAuditStatusesForInstance("VNFGROUP", "df305d54-75b4-431b-adb2-eb6b9e5460df");
+ verifyInstanceAuditStatuses(Arrays.asList(
+ new JobAuditStatus("groupTestName", "IN_PROGRESS", UUID.fromString("28502bd2-3aff-4a03-9f2b-5a0d1cb1ca24") , INSTANCE_GROUP_LABEL+" instance creation", null, INSTANCE_GROUP_LABEL),
+ new JobAuditStatus("groupTestName", "COMPLETE",UUID.fromString("28502bd2-3aff-4a03-9f2b-5a0d1cb1ca24") , INSTANCE_GROUP_LABEL+" instance creation", null, INSTANCE_GROUP_LABEL),
+ new JobAuditStatus("groupTestName", "IN_PROGRESS", UUID.fromString("f711f0ff-24b6-4d7f-9314-4b4eae15f48c") , INSTANCE_GROUP_LABEL+" instance deletion", null, INSTANCE_GROUP_LABEL),
+ new JobAuditStatus("groupTestName", "COMPLETE",UUID.fromString("f711f0ff-24b6-4d7f-9314-4b4eae15f48c") , INSTANCE_GROUP_LABEL+" instance deletion", null, INSTANCE_GROUP_LABEL)),
+ expectedAuditStatusList);
+ }
+
+ @Test(expectedExceptions = HttpClientErrorException.class)
+ public void verifyAuditStatusOfInstanceGroupId_notExistingVidType(){
+ try {
+ getAuditStatusesForInstance("KUKU", "df305d54-75b4-431b-adb2-eb6b9e5460df");
+ } catch (HttpClientErrorException e){ //to verify the properiatary statusCode field
+ assertThat("Code is not as expected", HttpStatus.BAD_REQUEST.equals(e.getStatusCode()));
+ throw e;
+ }
+ }
+
+ @Test(expectedExceptions = HttpServerErrorException.class)
+ public void verifyAuditStatusOfInstanceGroupId_notExistingMsoInstanceId(){
+ try {
+ getAuditStatusesForInstance("VNFGROUP", "df305d54-75b4-431b-adb2-eb6b9e5460aa");
+ } catch (HttpServerErrorException e){ //to verify the properiatary statusCode field
+ assertThat("Code is not as expected", HttpStatus.INTERNAL_SERVER_ERROR.equals(e.getStatusCode()));
+ throw e;
+ }
+ }
+
+ @DataProvider
+ public static Object[][] macroAndALaCarteBulk(){
+ return new Object[][]{{CREATE_BULK_OF_MACRO_REQUEST}, {CREATE_BULK_OF_ALACARTE_REQUEST_WITH_VNF}};
+ }
+
+ @Test(dataProvider = "macroAndALaCarteBulk", expectedExceptions = HttpClientErrorException.class)
+ @FeatureTogglingTest(FLAG_1906_INSTANTIATION_API_USER_VALIDATION)
+ public void verifyCreateBulkOfInstancesUserPermissionValidation(String requestDetailsFileName) {
+ login(new UserCredentials("mo57174000", "mo57174000", null, null, null));
+ try {
+ createBulkOfInstances(false, 1, Collections.EMPTY_MAP, requestDetailsFileName);
+ } catch (HttpClientErrorException e){
+ assertEquals("Code is not as expected", HttpStatus.FORBIDDEN.value(), e.getStatusCode().value());
+ throw e;
+ }
+ finally {
+ login();
+ }
+
+ }
+
}
diff --git a/vid-automation/src/test/java/org/onap/vid/api/BaseApiAaiTest.java b/vid-automation/src/test/java/org/onap/vid/api/BaseApiAaiTest.java
index 69a6f66cc..4ac38a0e7 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/BaseApiAaiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/BaseApiAaiTest.java
@@ -15,9 +15,9 @@ import java.net.URI;
import java.net.URISyntaxException;
import static net.javacrumbs.jsonunit.JsonMatchers.jsonStringEquals;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.either;
import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
import static vid.automation.test.services.SimulatorApi.registerExpectation;
/**
diff --git a/vid-automation/src/test/java/org/onap/vid/api/BaseApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/BaseApiTest.java
deleted file mode 100644
index e7c6045a4..000000000
--- a/vid-automation/src/test/java/org/onap/vid/api/BaseApiTest.java
+++ /dev/null
@@ -1,203 +0,0 @@
-package org.onap.vid.api;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.google.common.primitives.Ints;
-import org.apache.commons.io.IOUtils;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.SerializationConfig;
-import org.glassfish.jersey.client.ClientProperties;
-import org.glassfish.jersey.uri.internal.JerseyUriBuilder;
-import org.openecomp.sdc.ci.tests.datatypes.UserCredentials;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.MediaType;
-import org.springframework.http.client.ClientHttpRequestInterceptor;
-import org.springframework.http.client.ClientHttpResponse;
-import org.springframework.web.client.DefaultResponseErrorHandler;
-import org.springframework.web.client.RestTemplate;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import vid.automation.test.infra.FeaturesTogglingConfiguration;
-import vid.automation.test.services.UsersService;
-import vid.automation.test.utils.CookieAndJsonHttpHeadersInterceptor;
-
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URL;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.List;
-import java.util.Properties;
-import java.util.Random;
-
-import static java.util.Collections.singletonList;
-import static org.apache.commons.text.StringEscapeUtils.unescapeJson;
-import static org.hamcrest.CoreMatchers.everyItem;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.greaterThan;
-
-public class BaseApiTest {
- protected static final Logger LOGGER = LogManager.getLogger(BaseApiTest.class);
-
- @SuppressWarnings("WeakerAccess")
- protected URI uri;
- @SuppressWarnings("WeakerAccess")
- protected ObjectMapper objectMapper = new ObjectMapper();
- @SuppressWarnings("WeakerAccess")
- protected Client client;
- protected Random random;
- protected final RestTemplate restTemplate = new RestTemplate();
-
- protected final UsersService usersService = new UsersService();
- protected final RestTemplate restTemplateErrorAgnostic = new RestTemplate();
-
- @BeforeClass
- public void init() {
- uri = getUri();
- objectMapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
- client = ClientBuilder.newClient();
- client.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
- random = new Random(System.currentTimeMillis());
- FeaturesTogglingConfiguration.initializeFeatureManager();
- }
-
- private URI getUri() {
- String host = System.getProperty("VID_HOST", "127.0.0.1");
- Integer port = Integer.valueOf(System.getProperty("VID_PORT", "8080"));
- return new JerseyUriBuilder().host(host).port(port).scheme("http").path("vid").build();
- }
-
- public void login() {
- UserCredentials userCredentials = getUserCredentials();
- final List<ClientHttpRequestInterceptor> interceptors = singletonList(new CookieAndJsonHttpHeadersInterceptor(getUri(), userCredentials));
- restTemplate.setInterceptors(interceptors);
-
- restTemplateErrorAgnostic.setInterceptors(interceptors);
- restTemplateErrorAgnostic.setErrorHandler(new DefaultResponseErrorHandler() {
- @Override
- public boolean hasError(ClientHttpResponse response) {
- return false;
- }
- });
- }
-
-
- static class DB_CONFIG {
- static String url = String.format("jdbc:mariadb://%s:%d/vid_portal",
- System.getProperty("DB_HOST", System.getProperty("VID_HOST", "127.0.0.1")),
- Integer.valueOf(System.getProperty("DB_PORT", "3306"))
- );
- static String username = "euser";
- static String password = "euser";
-
- static final int userId = 2222;
- static final String loginId = "vid1";
- static final int roleId = 2222221;
- static final int logRoleId = 2222222;
- }
-
-
- @BeforeClass
- protected void createNewTestUser() {
-
- deleteNewTestUser();
-
- LOGGER.debug("Connecting database...");
-
- try (Connection connection = DriverManager.getConnection(DB_CONFIG.url, DB_CONFIG.username, DB_CONFIG.password)) {
-
- LOGGER.debug("Database connected!");
- //create new user with specific role
- Statement stmt = connection.createStatement();
- stmt.addBatch("INSERT INTO `fn_user` (`USER_ID`, `ORG_USER_ID`, `LOGIN_ID`, `LOGIN_PWD`) VALUES (" + DB_CONFIG.userId + ", 'Porfirio Gerhardt', '" + DB_CONFIG.loginId + "', '" + DB_CONFIG.loginId + "')");
- stmt.addBatch("INSERT INTO `fn_role` (`ROLE_ID`, `ROLE_NAME`, `ACTIVE_YN`, `PRIORITY`) VALUES (" + DB_CONFIG.roleId + ", 'PACKET CORE___vFlowLogic', 'Y', 5)");
- stmt.addBatch("INSERT INTO `fn_role` (`ROLE_ID`, `ROLE_NAME`, `ACTIVE_YN`, `PRIORITY`) VALUES (" + DB_CONFIG.logRoleId + ", 'READ___LOGS___PERMITTED', 'Y', 5)");
- stmt.addBatch("INSERT INTO `fn_user_role` (`USER_ID`, `ROLE_ID`, `PRIORITY`, `APP_ID`) VALUES (" + DB_CONFIG.userId + ", " + DB_CONFIG.roleId + ", NULL, 1)");
- stmt.addBatch("INSERT INTO `fn_user_role` (`USER_ID`, `ROLE_ID`, `PRIORITY`, `APP_ID`) VALUES (" + DB_CONFIG.userId + ", " + DB_CONFIG.logRoleId + ", NULL, 1)");
-
-
- int[] executeBatch = stmt.executeBatch();
- assertThat(Ints.asList(executeBatch), everyItem(greaterThan(0)));
-
- } catch (SQLException e) {
- throw new IllegalStateException("Cannot connect the database!", e);
- }
-
- }
-
- @AfterClass
- protected void deleteNewTestUser() {
- LOGGER.debug("Connecting database...");
-
- try (Connection connection = DriverManager.getConnection(DB_CONFIG.url, DB_CONFIG.username, DB_CONFIG.password)) {
- LOGGER.debug("Database connected!");
- Statement stmt = connection.createStatement();
- stmt.addBatch("DELETE FROM `fn_user_role` WHERE `USER_ID` = " + DB_CONFIG.userId);
- stmt.addBatch("DELETE FROM `fn_user` WHERE `USER_ID` = " + DB_CONFIG.userId);
- stmt.addBatch("DELETE FROM `fn_role` WHERE `ROLE_ID` = " + DB_CONFIG.roleId);
- stmt.addBatch("DELETE FROM `fn_role` WHERE `ROLE_ID` = " + DB_CONFIG.logRoleId);
-
-
- int[] executeBatch = stmt.executeBatch();
-
- } catch (SQLException e) {
- throw new IllegalStateException("Cannot connect the database!", e);
- }
- }
-
- protected UserCredentials getUserCredentials() {
- final Properties configProp = new Properties();
- try {
- InputStream input = ClassLoader.getSystemResourceAsStream("test_config.properties");
- configProp.load(input);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
- HttpHeaders loginRequestHeaders = new HttpHeaders();
- loginRequestHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
- String loginId = configProp.getProperty("test.loginId", "i'm illegal");
- String loginPassword = configProp.getProperty("test.loginPassword", "i'm illegal");
- return new UserCredentials(loginId, loginPassword, null, null, null);
- }
-
-
-
-
- protected String getCleanJsonString(String jsonString) {
- // remove leading/trailing double-quotes and unescape
- String res = unescapeJson(jsonString.replaceAll("^\"|\"$", ""));
- LOGGER.debug("getCleanJsonString: " + jsonString + " ==> " + res);
- return res;
- }
-
- protected String getCleanJsonString(Object object) throws JsonProcessingException {
- if (object instanceof String) {
- return getCleanJsonString((String) object);
- } else {
- return new com.fasterxml.jackson.databind.ObjectMapper().writeValueAsString(object);
- }
- }
-
- protected String buildUri(String path) {
- return uri + "/" + path;
- }
-
- public static String getResourceAsString(String resourcePath) {
- // load expected result
- final URL resource = BaseApiTest.class.getClassLoader().getResource(resourcePath);
- if (resource == null) throw new RuntimeException("resource file not found: " + resourcePath);
- try {
- return IOUtils.toString(resource, "UTF-8");
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
-}
diff --git a/vid-automation/src/test/java/org/onap/vid/api/BaseMsoApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/BaseMsoApiTest.java
deleted file mode 100644
index 1495f1852..000000000
--- a/vid-automation/src/test/java/org/onap/vid/api/BaseMsoApiTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package org.onap.vid.api;
-
-import com.google.common.collect.ImmutableMap;
-import org.json.JSONException;
-import org.onap.vid.model.mso.MsoResponseWrapper2;
-import org.skyscreamer.jsonassert.JSONAssert;
-import org.skyscreamer.jsonassert.JSONCompareMode;
-import org.springframework.http.HttpMethod;
-import org.springframework.web.client.HttpClientErrorException;
-import org.springframework.web.client.HttpServerErrorException;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import vid.automation.test.services.SimulatorApi;
-import vid.automation.test.services.SimulatorApi.RegistrationStrategy;
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-
-public class BaseMsoApiTest extends BaseApiTest {
-
- @BeforeClass
- public void login() {
- super.login();
- }
-
- protected void callMsoWithSimulatedErrorResponse(String expectationJsonFileName, ImmutableMap<String, Object> replacementsForJson, String targetUri, String basicRequestBody, int expectedErrorCode, String expectedResult, HttpMethod method) throws IOException {
- SimulatorApi.registerExpectation(expectationJsonFileName, replacementsForJson, RegistrationStrategy.CLEAR_THEN_SET);
- try {
- MsoResponseWrapper2 responseWrapper = callMsoForResponseWrapper(method, targetUri, basicRequestBody);
-
- assertThat("Wrong propagated status from MSO", responseWrapper.getStatus(), is(expectedErrorCode));
- assertThat("Wrong propagated body from MSO", getCleanJsonString(responseWrapper.getEntity()), is(expectedResult));
- }catch(HttpClientErrorException | HttpServerErrorException e) {
- assertThat("Wrong propagated status from MSO", e.getStatusCode().value(), is(expectedErrorCode));
- }
- }
-
-
- protected void callMsoWithFineRequest(String expectationJsonFileName, ImmutableMap<String, Object> replacementsForJson, String targetUri, String requestBody, int expectedStatusCode, String expectedResult, HttpMethod method) throws IOException {
- SimulatorApi.registerExpectation(expectationJsonFileName, replacementsForJson, RegistrationStrategy.CLEAR_THEN_SET);
-
- MsoResponseWrapper2 responseWrapper = callMsoForResponseWrapper(method, targetUri, requestBody);
-
- assertThat("Wrong propagated status from MSO", responseWrapper.getStatus(), is(expectedStatusCode));
- try {
- JSONAssert.assertEquals("Wrong propagated body from MSO", expectedResult, getCleanJsonString(responseWrapper.getEntity()), JSONCompareMode.NON_EXTENSIBLE);
- } catch (JSONException e) {
- throw new RuntimeException(e);
- }
- }
-
- protected MsoResponseWrapper2 callMsoForResponseWrapper(HttpMethod method, String uri, String body) {
- MsoResponseWrapper2 responseWrapper;
- switch (method) {
- case POST:
- responseWrapper = restTemplate.postForObject(uri, body, MsoResponseWrapper2.class);
- break;
- case GET:
- default:
- responseWrapper = restTemplate.getForObject(uri, MsoResponseWrapper2.class);
- break;
- }
-
- System.out.println("response: " + responseWrapper);
-
- return responseWrapper;
- }
-
- @DataProvider
- public static Object[][] errorCodes(Method test) {
- return new Object[][]{
- {500},{505}, {400}, {401}, {404}, {405}
- };
- }
-}
diff --git a/vid-automation/src/test/java/org/onap/vid/api/CategoryParametersApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/CategoryParametersApiTest.java
index 54df0e83e..c04d2ff0d 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/CategoryParametersApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/CategoryParametersApiTest.java
@@ -17,6 +17,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.List;
+import java.util.Random;
import java.util.UUID;
import java.util.stream.Collectors;
diff --git a/vid-automation/src/test/java/org/onap/vid/api/ChangeManagementApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/ChangeManagementApiTest.java
index 2ad68d75d..999b66cee 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/ChangeManagementApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/ChangeManagementApiTest.java
@@ -3,35 +3,27 @@ package org.onap.vid.api;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
-import org.onap.vid.model.mso.ChangeManagementRequest;
-import org.onap.vid.model.mso.ChangeManagementRequestDetails;
-import org.onap.vid.model.mso.CloudConfiguration;
-import org.onap.vid.model.mso.MsoExceptionResponse;
-import org.onap.vid.model.mso.MsoResponseWrapper2;
-import org.onap.vid.model.mso.RelatedInstance;
-import org.onap.vid.model.mso.RelatedInstanceList;
-import org.onap.vid.model.mso.RequestInfo;
-import org.onap.vid.model.mso.RequestParameters;
-import org.onap.vid.model.workflow.GetVnfWorkflowRelationRequest;
-import org.onap.vid.model.workflow.GetWorkflowsResponse;
-import org.onap.vid.model.workflow.VnfDetails;
-import org.onap.vid.model.workflow.VnfDetailsWithWorkflows;
-import org.onap.vid.model.workflow.VnfWorkflowRelationAllResponse;
-import org.onap.vid.model.workflow.VnfWorkflowRelationRequest;
-import org.onap.vid.model.workflow.VnfWorkflowRelationResponse;
-import org.onap.vid.model.workflow.WorkflowsDetail;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId;
+import org.onap.simulator.presetGenerator.presets.mso.changeManagement.PresetMsoChangeManagementBase;
+import org.onap.simulator.presetGenerator.presets.mso.changeManagement.PresetMsoVnfInPlaceSoftwareUpdate;
+import org.onap.simulator.presetGenerator.presets.mso.changeManagement.PresetMsoVnfReplace;
+import org.onap.simulator.presetGenerator.presets.mso.changeManagement.PresetMsoVnfUpdate;
+import org.onap.simulator.presetGenerator.presets.aaf.*;
import org.onap.vid.model.mso.*;
import org.onap.vid.model.workflow.*;
import org.springframework.http.HttpStatus;
import org.springframework.util.StopWatch;
import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import vid.automation.test.services.SimulatorApi;
import vid.automation.test.services.SimulatorApi.RegistrationStrategy;
+import vid.automation.test.utils.ReadFile;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MediaType;
@@ -51,6 +43,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.onap.vid.api.TestUtils.getNestedPropertyInMap;
+import static org.testng.AssertJUnit.assertEquals;
//This is integration test that require running tomcat
@@ -139,6 +132,30 @@ public class ChangeManagementApiTest extends BaseApiTest {
};
}
+ @DataProvider
+ public static Object[][] credentialsFilterTestData(Method test) {
+ return new Object[][]{
+ {AAFGetBasicAuthPreset.VALID_AUTH_VALUE, 200},
+// {null, 401}, // No auth header TODO: Uncomment when the bug in epsdk will be fixed. Currently If there is no auth header then no credentials validation.
+ {"xyz", 401}, //undecodable value
+ {"YUBiLmM6ZGVm", 401} //decodable value but not that expected by cadi filter (simulator)
+
+ };
+ }
+
+ @BeforeClass
+ public static void commonSimulatorRegistration() {
+ SimulatorApi.registerExpectationFromPreset(
+ PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MDT1_TO_ATT_NC,
+ RegistrationStrategy.CLEAR_THEN_SET);
+ SimulatorApi.registerExpectationFromPreset(
+ new AAFGetUrlServicePreset(),
+ RegistrationStrategy.APPEND);
+ SimulatorApi.registerExpectationFromPreset(
+ new AAFGetBasicAuthPreset(),
+ RegistrationStrategy.APPEND);
+ }
+
// IN_PLACE_SOFTWARE_UPDATE
@Test
public void testInPlaceSoftwareUpdateHappyPath() throws IOException {
@@ -199,6 +216,12 @@ public class ChangeManagementApiTest extends BaseApiTest {
"mso_in_place_software_update_ok.json",
ImmutableMap.of("SERVICE_INSTANCE_ID", vnfIds.serviceInstanceId, "VNF_INSTANCE_ID", vnfIds.vnfInstanceId),
RegistrationStrategy.APPEND);
+ SimulatorApi.registerExpectationFromPreset(
+ new AAFGetUrlServicePreset(),
+ RegistrationStrategy.APPEND);
+ SimulatorApi.registerExpectationFromPreset(
+ new AAFGetBasicAuthPreset(),
+ RegistrationStrategy.APPEND);
return null;
}))
.collect(Collectors.toList());
@@ -216,9 +239,8 @@ public class ChangeManagementApiTest extends BaseApiTest {
stopWatch.start("init requests");
List<ChangeManagementRequest> requestsList = vnfList.stream().map(vnfIds -> this.createChangeManagementRequest(vnfIds, ChangeManagementRequest.VNF_IN_PLACE_SOFTWARE_UPDATE)).collect(Collectors.toList());
- WebTarget webTarget = client.target(uri).
- path(CHANGE_MANAGEMENT+WORKFLOW).resolveTemplate("vnfname","VidVnf");
- List<Callable<Response>> callables = requestsList.stream().map(request->((Callable<Response>) () -> webTarget.request(MediaType.APPLICATION_JSON_TYPE).header("Authorization", "Basic 123==").post(Entity.json(request)))).collect(Collectors.toList());
+ WebTarget webTarget = buildWebTarget("VidVnf");
+ List<Callable<Response>> callables = requestsList.stream().map(request->((Callable<Response>) () -> webTarget.request(MediaType.APPLICATION_JSON_TYPE).header("Authorization", "Basic " + AAFGetBasicAuthPreset.VALID_AUTH_VALUE).post(Entity.json(request)))).collect(Collectors.toList());
stopWatch.stop();
stopWatch.start("invoke calling to vid");
@@ -286,16 +308,54 @@ public class ChangeManagementApiTest extends BaseApiTest {
testChangeManagementGoodPayload(payload, "mso_config_update_ok.json", ChangeManagementRequest.CONFIG_UPDATE);
}
- @Test
- public void testClientCredentialsFilter_expect401()
+ @Test(dataProvider = "credentialsFilterTestData")
+ public void testCadiCredentialsFilter(String authValue, int expectedStatusCode)
{
VnfIds vnfIds = new VnfIds();
ChangeManagementRequest changeManagementRequest = createBasicChangeManagementRequest(vnfIds);
changeManagementRequest.setRequestType(ChangeManagementRequest.REPLACE);
- WebTarget webTarget = client.target(uri).
- path(CHANGE_MANAGEMENT + WORKFLOW).resolveTemplate("vnfname", vnfIds.vnfName);
+ WebTarget webTarget = buildWebTarget(vnfIds.vnfName);
Entity entity = Entity.json(changeManagementRequest);
- Assert.assertEquals(401, webTarget.request(MediaType.APPLICATION_JSON_TYPE).post(entity).getStatus());
+ Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON_TYPE);
+ if (authValue != null) {
+ invocationBuilder.header("Authorization", "Basic " + authValue);
+ }
+ Response response = invocationBuilder.post(entity);
+ String body = response.readEntity(String.class);
+ Assert.assertEquals(response.getStatus(), expectedStatusCode, "Full response: " + body);
+ }
+
+ @DataProvider
+ public static Object[][] requestFromSchedulerDataProvider(Method test) {
+ return new Object[][]{
+ {
+ "e9181708-f105-4dfd-9a36-0e089faa72ba",
+ new PresetMsoVnfReplace("254583ad-b38c-498b-bdbd-b8de5e07541b", "e9181708-f105-4dfd-9a36-0e089faa72ba"),
+ "changeManagement/vnfReplaceRequest.json"
+ },
+ {
+ "c929b7ec-cc9d-11e8-a8d5-f2801f1b9fd1",
+ new PresetMsoVnfUpdate("d0c59d4a-cc9d-11e8-a8d5-f2801f1b9fd1","c929b7ec-cc9d-11e8-a8d5-f2801f1b9fd1"),
+ "changeManagement/vnfUpdateRequest.json"
+ },
+ {
+ "e5403738-da34-4090-8864-ba9cf1bcdd88",
+ new PresetMsoVnfInPlaceSoftwareUpdate("12709275-787c-4be7-8c9c-fce64ab7ca8c","e5403738-da34-4090-8864-ba9cf1bcdd88"),
+ "changeManagement/vnfInPlaceSoftwareUpdate.json"
+ }
+ };
+ }
+
+ @Test(dataProvider = "requestFromSchedulerDataProvider")
+ public void whenGetFromSchedulerRequest_sendAsExpectedToMso(String vnfInstanceId, PresetMsoChangeManagementBase preset, String requestPath) {
+ SimulatorApi.registerExpectationFromPreset(
+ preset,
+ RegistrationStrategy.APPEND);
+ String schedulerRequest = ReadFile.loadResourceAsString(requestPath);
+ Response response = callChangeManagement("VidVnf", Entity.json(schedulerRequest));
+ MsoResponseWrapper2 body = response.readEntity(MsoResponseWrapper2.class);
+ assertEquals(202, body.getStatus());
+ assertEquals(vnfInstanceId, getNestedPropertyInMap(body.getEntity(), "requestReferences/instanceId"));
}
@@ -308,7 +368,7 @@ public class ChangeManagementApiTest extends BaseApiTest {
private void assertForHappyPath(VnfIds vnfIds, MsoResponseWrapper2 body, String requestType) {
Assert.assertEquals(body.getStatus(), 202, requestType + " failed with wrong http status");
Assert.assertEquals(
- TestUtils.getNestedPropertyInMap(body.getEntity(), "requestReferences/instanceId"),
+ getNestedPropertyInMap(body.getEntity(), "requestReferences/instanceId"),
vnfIds.serviceInstanceId,
String.format("Failed to find instanceId: %s in " + requestType + " response. Actual body:%s",
vnfIds.serviceInstanceId, body.getEntity()));
@@ -317,18 +377,25 @@ public class ChangeManagementApiTest extends BaseApiTest {
private <T> T callChangeManagementUpdate(VnfIds vnfIds, String expectationPath, Class<T> responseClass, String requestType) {
SimulatorApi.registerExpectation(
expectationPath,
- ImmutableMap.of("SERVICE_INSTANCE_ID", vnfIds.serviceInstanceId, "VNF_INSTANCE_ID", vnfIds.vnfInstanceId), RegistrationStrategy.CLEAR_THEN_SET);
+ ImmutableMap.of("SERVICE_INSTANCE_ID", vnfIds.serviceInstanceId, "VNF_INSTANCE_ID", vnfIds.vnfInstanceId), RegistrationStrategy.APPEND);
ChangeManagementRequest changeManagementRequest = createChangeManagementRequest(vnfIds, requestType);
Response response = callChangeManagementUpdate(vnfIds, changeManagementRequest);
return response.readEntity(responseClass);
}
private Response callChangeManagementUpdate(VnfIds vnfIds, ChangeManagementRequest changeManagementRequest) {
- WebTarget webTarget = client.target(uri).
- path(CHANGE_MANAGEMENT + WORKFLOW).resolveTemplate("vnfname", vnfIds.vnfName);
Entity entity = Entity.json(changeManagementRequest);
- Response response = webTarget.request(MediaType.APPLICATION_JSON_TYPE).header("Authorization", "Basic 123==").post(entity);
- return response;
+ return callChangeManagement(vnfIds.vnfName, entity);
+ }
+
+ private Response callChangeManagement(String vnfName, Entity entity) {
+ WebTarget webTarget = buildWebTarget(vnfName);
+ return webTarget.request(MediaType.APPLICATION_JSON_TYPE).header("Authorization", "Basic " + AAFGetBasicAuthPreset.VALID_AUTH_VALUE).post(entity);
+ }
+
+ private WebTarget buildWebTarget(String vnfName) {
+ return client.target(uri).
+ path(CHANGE_MANAGEMENT + WORKFLOW).resolveTemplate("vnfname", vnfName);
}
private void testChangeManagement409Error(String expectationPath, String requestType) throws IOException {
@@ -336,13 +403,13 @@ public class ChangeManagementApiTest extends BaseApiTest {
MsoResponseWrapper2 body = callChangeManagementUpdate(vnfIds, expectationPath, MsoResponseWrapper2.class, requestType);
Assert.assertEquals(body.getStatus(), 409, requestType + " failed with wrong http status");
Assert.assertEquals(
- TestUtils.getNestedPropertyInMap(body.getEntity(), "serviceException/messageId"),
+ getNestedPropertyInMap(body.getEntity(), "serviceException/messageId"),
"SVC2000",
String.format("Failed to find messageId: %s in " + requestType + " response. Actual body:%s",
"SVC2000", body.getEntity()));
- assertThat(TestUtils.getNestedPropertyInMap(body.getEntity(), "serviceException/text"), containsString(vnfIds.vnfInstanceId));
+ assertThat(getNestedPropertyInMap(body.getEntity(), "serviceException/text"), containsString(vnfIds.vnfInstanceId));
}
private void testChangeManagement404Error(String expectationPath, String requestType) throws IOException {
@@ -398,7 +465,7 @@ public class ChangeManagementApiTest extends BaseApiTest {
VnfIds vnfIds = new VnfIds();
SimulatorApi.registerExpectation(
expectationFileName,
- ImmutableMap.of("SERVICE_INSTANCE_ID", vnfIds.serviceInstanceId, "VNF_INSTANCE_ID", vnfIds.vnfInstanceId), RegistrationStrategy.CLEAR_THEN_SET);
+ ImmutableMap.of("SERVICE_INSTANCE_ID", vnfIds.serviceInstanceId, "VNF_INSTANCE_ID", vnfIds.vnfInstanceId), RegistrationStrategy.APPEND);
ChangeManagementRequest changeManagementRequest = createChangeManagementRequest(vnfIds, requestType);
changeManagementRequest.getRequestDetails().get(0).getRequestParameters().getAdditionalProperties().put("payload",payload);
Response response = callChangeManagementUpdate(vnfIds, changeManagementRequest);
diff --git a/vid-automation/src/test/java/org/onap/vid/api/OperationalEnvironmentControllerApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/OperationalEnvironmentControllerApiTest.java
index e5df2d3b9..222b0f5fb 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/OperationalEnvironmentControllerApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/OperationalEnvironmentControllerApiTest.java
@@ -22,8 +22,8 @@ import java.util.LinkedList;
import java.util.stream.Collectors;
import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.METHOD_NOT_ALLOWED;
diff --git a/vid-automation/src/test/java/org/onap/vid/api/ProbeApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/ProbeApiTest.java
index 931f0004a..e38617b39 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/ProbeApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/ProbeApiTest.java
@@ -1,12 +1,31 @@
package org.onap.vid.api;
+import static org.hamcrest.CoreMatchers.anyOf;
+import static org.hamcrest.CoreMatchers.both;
+import static org.hamcrest.CoreMatchers.endsWith;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.startsWith;
+import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET;
+
+import com.google.common.collect.ImmutableList;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
-import org.hamcrest.MatcherAssert;
import org.junit.Assert;
import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGetInvalidResponse;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestsManyStatusesGet;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestsManyStatusesInvalidResponseGet;
+import org.onap.simulator.presetGenerator.presets.scheduler.PresetGetSchedulerChangeManagementInvalidResponse;
+import org.onap.simulator.presetGenerator.presets.scheduler.PresetGetSchedulerChangeManagements;
+import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGet;
+import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGetEmptyResult;
+import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGetInvalidResponse;
import org.onap.vid.model.probe.ExternalComponentStatus;
import org.onap.vid.model.probe.HttpRequestMetadata;
import org.springframework.core.ParameterizedTypeReference;
@@ -17,14 +36,13 @@ import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import vid.automation.test.services.SimulatorApi;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Optional;
+public class ProbeApiTest extends BaseApiTest {
-import static org.hamcrest.CoreMatchers.*;
-import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET;
+ private static final String MSO_QUERY_PARAMS = "filter=requestExecutionDate:EQUALS:01-01-2100";
+ private static final String AAI_QUERY_PARMAS = "business/customers?subscriber-type=INFRA&depth=0";
+ private static final String SDC_PATH_PARAMS = "46401eec-35bd-4e96-ad0d-0356ff6b8c8d/toscaModel";
+ private static final String SCHEDULER_PATH = "http://localhost:1080/scheduler/v1/ChangeManagement/schedules/scheduleDetails/";
-public class ProbeApiTest extends BaseApiTest {
@BeforeClass
public void login() {
@@ -35,70 +53,183 @@ public class ProbeApiTest extends BaseApiTest {
public static Object[][] probePresetAndResponse(Method test) {
return new Object[][]{
{
- new PresetAAIGetSubscribersGet(),
- new ExternalComponentStatus(ExternalComponentStatus.Component.AAI,
- true,
- new HttpRequestMetadata(HttpMethod.GET,
- 200,
- "business/customers?subscriber-type=INFRA&depth=0",
- "{\"customer\":[{\"global-customer-id\":\"MSO_1610_ST\",\"subscriber-name\":\"MSO_1610_ST\",\"subscriber-type\":\"INFRA\",\"resource-version\":\"1494001902987\"},{\"global-customer-id\":\"21014aa2-526b-11e6-beb8-9e71128cae77\",\"subscriber-name\":\"PACKET CORE\",\"subscriber-type\":\"INFRA\",\"resource-version\":\"1494001776295\"},{\"global-customer-id\":\"DHV1707-TestSubscriber-2\",\"subscriber-name\":\"ICORE CORE\",\"subscriber-type\":\"INFRA\",\"resource-version\":\"1498751754450\"},{\"global-customer-id\":\"DHV1707-TestSubscriber-1\",\"subscriber",
- "OK"
+ "all good",
+ ImmutableList.of(
+ new PresetAAIGetSubscribersGet(),
+ new PresetMSOOrchestrationRequestsManyStatusesGet(),
+ new PresetSDCGetServiceToscaModelGet("46401eec-35bd-4e96-ad0d-0356ff6b8c8d", "serviceCreationTest.zip"),
+ new PresetGetSchedulerChangeManagements()
+ ),
+ ImmutableList.of(new ExternalComponentStatus(ExternalComponentStatus.Component.AAI,
+ true,
+ new HttpRequestMetadata(HttpMethod.GET,
+ 200,
+ AAI_QUERY_PARMAS,
+ "{\"customer\":[{\"global-customer-id\":\"CAR_2020_ER\",\"subscriber-name\":\"CAR_2020_ER\",\"subscriber-type\":\"INFRA\",\"resource-version\":\"1494001902987\",\"relationship-list\":null},{\"global-customer-id\":\"21014aa2-526b-11e6-beb8-9e71128cae77\",\"subscriber-name\":\"JULIO ERICKSON\",\"subscriber-type\":\"INFRA\",\"resource-version\":\"1494001776295\",\"relationship-list\":null},{\"global-customer-id\":\"DHV1707-TestSubscriber-2\",\"subscriber-name\":\"DALE BRIDGES\",\"subscriber-type\":\"INFRA\",\"resource-version\":\"1498751754450\",\"relationsh",
+ "OK"
+ )
+ ), new ExternalComponentStatus(ExternalComponentStatus.Component.MSO,
+ true,
+ new HttpRequestMetadata(HttpMethod.GET,
+ 200,
+ MSO_QUERY_PARAMS,
+ "{ " +
+ " \"requestList\": [{ " +
+ " \"request\": { " +
+ " \"requestId\": \"rq1234d1-5a33-55df-13ab-12abad84e333\", " +
+ " \"startTime\": \"Thu, 04 Jun 2009 02:51:59 GMT\", " +
+ " \"instanceReferences\": { " +
+ " \"serviceInstanceId\": \"bc305d54-75b4-431b-adb2-eb6b9e546014\" " +
+ " }, " +
+ " \"requestScope\": \"vnf\", " +
+ " \"requestType\": \"updateInstance\", " +
+ " \"requestDetails\": { " +
+ " \"modelInfo\": { " +
+ " \"modelType\": \"service\", " +
+ " \"modelInvariantId\": \"sn5256d1-5a33-55df-13ab-12abad84e764\", " +
+ " \"modelVersionId\": \"ab6478e4-ea33-3346-ac12-ab1",
+ "OK"
+ )
+ ), new ExternalComponentStatus(ExternalComponentStatus.Component.SDC,
+ true,
+ new HttpRequestMetadata(HttpMethod.GET,
+ 200,
+ SDC_PATH_PARAMS,
+ "",
+ "OK"
+ )
+ ), new ExternalComponentStatus(ExternalComponentStatus.Component.SCHEDULER,
+ true,
+ new HttpRequestMetadata(HttpMethod.GET,
+ 200,
+ SCHEDULER_PATH,
+ StringUtils.substring(new PresetGetSchedulerChangeManagements().getResponseBody().toString(), 0, 500),
+ "OK"
)
- )
+ ))
},
{
- new PresetAAIGetSubscribersGetInvalidResponse(200),
- new ExternalComponentStatus(ExternalComponentStatus.Component.AAI,
+ "invalid json",
+ ImmutableList.of(
+ new PresetAAIGetSubscribersGetInvalidResponse(200),
+ new PresetMSOOrchestrationRequestsManyStatusesInvalidResponseGet(200),
+ new PresetSDCGetServiceToscaModelGetEmptyResult("46401eec-35bd-4e96-ad0d-0356ff6b8c8d"),
+ new PresetGetSchedulerChangeManagementInvalidResponse(200)
+ ),
+ ImmutableList.of(new ExternalComponentStatus(ExternalComponentStatus.Component.AAI,
+ false,
+ new HttpRequestMetadata(HttpMethod.GET,
+ 200,
+ AAI_QUERY_PARMAS,
+ "this payload is an invalid json",
+ "com.fasterxml.jackson.core.JsonParseException"
+ )
+ ), new ExternalComponentStatus(ExternalComponentStatus.Component.MSO,
+ false,
+ new HttpRequestMetadata(HttpMethod.GET,
+ 200,
+ MSO_QUERY_PARAMS,
+ "this payload is an invalid json",
+ "com.fasterxml.jackson.core.JsonParseException"
+ )
+ ), new ExternalComponentStatus(ExternalComponentStatus.Component.SDC,
false,
new HttpRequestMetadata(HttpMethod.GET,
200,
- "business/customers?subscriber-type=INFRA&depth=0",
+ SDC_PATH_PARAMS,
+ "",
+ "error reading model 46401eec-35bd-4e96-ad0d-0356ff6b8c8d from SDC"
+ )
+ ), new ExternalComponentStatus(ExternalComponentStatus.Component.SCHEDULER,
+ false,
+ new HttpRequestMetadata(HttpMethod.GET,
+ 200,
+ SCHEDULER_PATH,
"this payload is an invalid json",
- "org.codehaus.jackson.JsonParseException"
+ "javax.ws.rs.ProcessingException"
)
- )
+ ))
},
{
- new PresetAAIGetSubscribersGetInvalidResponse(500),
- new ExternalComponentStatus(ExternalComponentStatus.Component.AAI,
+ "bad http code",
+ ImmutableList.of(
+ new PresetAAIGetSubscribersGetInvalidResponse(500),
+ new PresetMSOOrchestrationRequestsManyStatusesInvalidResponseGet(406),
+ new PresetSDCGetServiceToscaModelGetInvalidResponse("46401eec-35bd-4e96-ad0d-0356ff6b8c8d", 404),
+ new PresetGetSchedulerChangeManagementInvalidResponse(400)
+ ),
+ ImmutableList.of(new ExternalComponentStatus(ExternalComponentStatus.Component.AAI,
false,
new HttpRequestMetadata(HttpMethod.GET,
500,
- "business/customers?subscriber-type=INFRA&depth=0",
+ AAI_QUERY_PARMAS,
"this payload is an invalid json",
"No subscriber received"
)
- )
+ ), new ExternalComponentStatus(ExternalComponentStatus.Component.MSO,
+ false,
+ new HttpRequestMetadata(HttpMethod.GET,
+ 406,
+ MSO_QUERY_PARAMS,
+ "this payload is an invalid json",
+ "org.apache.http.HttpException: Get with status=406 (200 or 202 expected), url= http"
+ )
+ ), new ExternalComponentStatus(ExternalComponentStatus.Component.SDC,
+ false,
+ new HttpRequestMetadata(HttpMethod.GET,
+ 404,
+ SDC_PATH_PARAMS,
+ "simulated error description from sdc",
+ "model 46401eec-35bd-4e96-ad0d-0356ff6b8c8d not found in SDC" +
+ " (consider updating vid probe configuration 'probe.sdc.model.uuid')"
+ )
+ ), new ExternalComponentStatus(ExternalComponentStatus.Component.SCHEDULER,
+ false,
+ new HttpRequestMetadata(HttpMethod.GET,
+ 400,
+ SCHEDULER_PATH,
+ "this payload is an invalid json",
+ "org.apache.http.HttpException: Get with status = 400, url = " + SCHEDULER_PATH
+ )
+ ))
}
};
}
@Test(dataProvider = "probePresetAndResponse")
- public void probeRequest_returnsResponseAsExpected(BasePreset preset, ExternalComponentStatus expectedStatus ){
- SimulatorApi.registerExpectationFromPreset(preset, CLEAR_THEN_SET);
+ public void probeRequest_returnsResponseAsExpected(String desc, Collection<BasePreset> presets, Collection<ExternalComponentStatus> expectedStatuses) {
+ SimulatorApi.registerExpectationFromPresets(presets, CLEAR_THEN_SET);
ResponseEntity<List<ExternalComponentStatus>> response = restTemplate.exchange(
uri + "/probe",
org.springframework.http.HttpMethod.GET,
null,
- new ParameterizedTypeReference<List<ExternalComponentStatus>>() {});
+ new ParameterizedTypeReference<List<ExternalComponentStatus>>() {
+ });
List<ExternalComponentStatus> probeResults = response.getBody();
- Assert.assertEquals(probeResults.size(),1);
- assertAaiGetAllSubscribersAsExpected(probeResults,expectedStatus);
-
+ Assert.assertEquals(4, probeResults.size());
+ assertResultAsExpected(ExternalComponentStatus.Component.AAI, probeResults, expectedStatuses);
+ assertResultAsExpected(ExternalComponentStatus.Component.SDC, probeResults, expectedStatuses);
+ assertResultAsExpected(ExternalComponentStatus.Component.MSO, probeResults, expectedStatuses);
+ assertResultAsExpected(ExternalComponentStatus.Component.SCHEDULER, probeResults, expectedStatuses);
}
- private void assertAaiGetAllSubscribersAsExpected(List<ExternalComponentStatus> probeResults,ExternalComponentStatus expectedStatus){
- Optional<ExternalComponentStatus> aaiGetAllSubscribersResult = probeResults.stream().filter(x -> x.getComponent()== ExternalComponentStatus.Component.AAI).findFirst();
- Assert.assertTrue(aaiGetAllSubscribersResult.isPresent());
- ExternalComponentStatus aaiGetAllSubscribersStatus = aaiGetAllSubscribersResult.get();
- Assert.assertEquals(aaiGetAllSubscribersStatus.isAvailable(),expectedStatus.isAvailable());
+ private void assertResultAsExpected(ExternalComponentStatus.Component component, List<ExternalComponentStatus> probeResults, Collection<ExternalComponentStatus> expectedStatuses) {
+ ExternalComponentStatus expectedStatus = expectedStatuses.stream().filter(x -> x.getComponent() == component)
+ .findFirst().orElseThrow(() -> new AssertionError("Missing setup for " + component + " expected result"));
+ ExternalComponentStatus componentStatus = probeResults.stream().filter(x -> x.getComponent() == component)
+ .findFirst().orElseThrow(() -> new AssertionError(component.name()+" result not found in response"));
+
+ Assert.assertThat("wrong metadata for " + component, requestMetadataReflected(componentStatus.getMetadata()),
+ is(requestMetadataReflected(expectedStatus.getMetadata())));
- MatcherAssert.assertThat(requestMetadataReflected(aaiGetAllSubscribersStatus.getMetadata()),is(requestMetadataReflected(expectedStatus.getMetadata())));
- MatcherAssert.assertThat(aaiGetAllSubscribersStatus.getMetadata().getUrl(), both(endsWith(expectedStatus.getMetadata().getUrl())).and(startsWith("http")));
+ Assert.assertThat("wrong url for " + component, componentStatus.getMetadata().getUrl(),
+ both(endsWith(expectedStatus.getMetadata().getUrl())).and(startsWith("http")));
- MatcherAssert.assertThat(aaiGetAllSubscribersStatus.getMetadata().getDescription(),
+ Assert.assertThat("wrong description for " + component, componentStatus.getMetadata().getDescription(),
anyOf(equalTo(expectedStatus.getMetadata().getDescription()), startsWith(expectedStatus.getMetadata().getDescription())));
+
+ Assert.assertThat("wrong status for " + component, componentStatus.isAvailable(), is(expectedStatus.isAvailable()));
}
//serialize fields except of fields we cannot know ahead of time
diff --git a/vid-automation/src/test/java/org/onap/vid/api/SampleApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/SampleApiTest.java
index 2b78cdb91..9d7a08120 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/SampleApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/SampleApiTest.java
@@ -11,8 +11,9 @@ import vid.automation.test.services.SimulatorApi;
import java.io.IOException;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static java.util.Collections.singletonList;
import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
public class SampleApiTest extends BaseApiTest {
diff --git a/vid-automation/src/test/java/org/onap/vid/api/SdcApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/SdcApiTest.java
index 0441da1d2..7735d59af 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/SdcApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/SdcApiTest.java
@@ -1,5 +1,16 @@
package org.onap.vid.api;
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonStringEquals;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNot.not;
+import static org.testng.Assert.assertFalse;
+import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND;
+import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET;
+import static vid.automation.test.services.SimulatorApi.registerExpectation;
+import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets;
+import static vid.automation.test.utils.ReadFile.loadResourceAsString;
+
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.collect.ImmutableList;
import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset;
@@ -11,22 +22,9 @@ import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import vid.automation.test.infra.FeatureTogglingTest;
import vid.automation.test.infra.Features;
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-import static net.javacrumbs.jsonunit.JsonMatchers.jsonStringEquals;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.either;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNot.not;
-import static org.testng.Assert.assertFalse;
-import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND;
-import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET;
-import static vid.automation.test.services.SimulatorApi.registerExpectation;
-import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets;
-
public class SdcApiTest extends BaseApiTest {
private static final String SDC_GET_SERVICE_MODEL = "/rest/models/services/";
@@ -35,17 +33,17 @@ public class SdcApiTest extends BaseApiTest {
private static final String A_LA_CARTE_INSTANTIATION_TYPE_UUID = "4d71990b-d8ad-4510-ac61-496288d9078e";
private static final String A_LA_CARTE_INSTANTIATION_TYPE_INVARIANT_UUID = "d27e42cf-087e-4d31-88ac-6c4b7585f800";
private static final String A_LA_CARTE_INSTANTIATION_TYPE_FILE_PATH = "csar15782222_instantiationTypeAlacarte_invariantUUIDMacro.zip";
- private static final String A_LA_CARTE_INSTANTIATION_TYPE_EXPECTED_RESPONSE = "{\"service\":{\"uuid\":\"4d71990b-d8ad-4510-ac61-496288d9078e\",\"invariantUuid\":\"d27e42cf-087e-4d31-88ac-6c4b7585f800\",\"name\":\"vidmacrofalsenaming\",\"version\":\"1.0\",\"toscaModelURL\":null,\"category\":\"Network L1-3\",\"serviceType\":\"\",\"serviceRole\":\"\",\"description\":\"vidmacrofalsenaming\",\"serviceEcompNaming\":\"false\",\"instantiationType\":\"A-La-Carte\",\"inputs\":{}},\"vnfs\":{},\"networks\":{\"MULTI_PROVIDER_PORT_GROUP 0\":{\"uuid\":\"e5d235de-2188-4f9f-a28c-fe38967883f2\",\"invariantUuid\":\"b0303003-0abb-454c-9119-8cbe2e09e003\",\"description\":\"Creates a neutron multi-provider VLAN network with dummy subnet\",\"name\":\"MULTI_PROVIDER_PORT_GROUP\",\"version\":\"1.0\",\"customizationUuid\":\"0fde4286-ee4c-439d-9556-74b6be6bbc42\",\"inputs\":{},\"commands\":{},\"properties\":{\"network_assignments\":\"{is_external_network=false, ipv4_subnet_default_assignment={min_subnets_count=1}, ecomp_generated_network_assignment=false, ipv6_subnet_default_assignment={min_subnets_count=1}}\",\"network_flows\":\"{is_network_policy=false, is_bound_to_vpn=false}\",\"network_scope\":\"GLOBAL\",\"network_ecomp_naming\":\"{ecomp_generated_naming=true}\",\"network_type\":\"MULTI_PROVIDER_PORT_GROUP\",\"network_technology\":\"MULTI_GROUP\",\"network_homing\":\"{ecomp_selected_instance_node_target=false}\"},\"type\":\"VL\",\"modelCustomizationName\":\"MULTI_PROVIDER_PORT_GROUP 0\"}},\"collectionResource\":{},\"configurations\":{},\"serviceProxies\":{},\"vfModules\":{},\"volumeGroups\":{},\"pnfs\":{}}";
+ private static final String A_LA_CARTE_INSTANTIATION_TYPE_EXPECTED_RESPONSE = "sdcApiTest/aLaCarteInstantiationTypeResponse.json";
private static final String MACRO_INSTANTIATION_TYPE_FILE_PATH = "csar15782222_instantiationTypeMacro_invariantUUIDAlacarte.zip";
private static final String MACRO_INSTANTIATION_TYPE_UUID = "4d71990b-d8ad-4510-ac61-496288d9078e";
private static final String MACRO_INSTANTIATION_TYPE_INVARIANT_UUID = "a8dcd72d-d44d-44f2-aa85-53aa9ca99cba";
- private static final String MACRO_INSTANTIATION_TYPE_EXPECTED_RESPONSE = "{\"service\":{\"uuid\":\"4d71990b-d8ad-4510-ac61-496288d9078e\",\"invariantUuid\":\"a8dcd72d-d44d-44f2-aa85-53aa9ca99cba\",\"name\":\"vidmacrofalsenaming\",\"version\":\"1.0\",\"toscaModelURL\":null,\"category\":\"Network L1-3\",\"serviceType\":\"\",\"serviceRole\":\"\",\"description\":\"vidmacrofalsenaming\",\"serviceEcompNaming\":\"false\",\"instantiationType\":\"Macro\",\"inputs\":{}},\"vnfs\":{},\"networks\":{\"MULTI_PROVIDER_PORT_GROUP 0\":{\"uuid\":\"e5d235de-2188-4f9f-a28c-fe38967883f2\",\"invariantUuid\":\"b0303003-0abb-454c-9119-8cbe2e09e003\",\"description\":\"Creates a neutron multi-provider VLAN network with dummy subnet\",\"name\":\"MULTI_PROVIDER_PORT_GROUP\",\"version\":\"1.0\",\"customizationUuid\":\"0fde4286-ee4c-439d-9556-74b6be6bbc42\",\"inputs\":{},\"commands\":{},\"properties\":{\"network_assignments\":\"{is_external_network=false, ipv4_subnet_default_assignment={min_subnets_count=1}, ecomp_generated_network_assignment=false, ipv6_subnet_default_assignment={min_subnets_count=1}}\",\"network_flows\":\"{is_network_policy=false, is_bound_to_vpn=false}\",\"network_scope\":\"GLOBAL\",\"network_ecomp_naming\":\"{ecomp_generated_naming=true}\",\"network_type\":\"MULTI_PROVIDER_PORT_GROUP\",\"network_technology\":\"MULTI_GROUP\",\"network_homing\":\"{ecomp_selected_instance_node_target=false}\"},\"type\":\"VL\",\"modelCustomizationName\":\"MULTI_PROVIDER_PORT_GROUP 0\"}},\"collectionResource\":{},\"configurations\":{},\"serviceProxies\":{},\"vfModules\":{},\"volumeGroups\":{},\"pnfs\":{}}";
+ private static final String MACRO_INSTANTIATION_TYPE_EXPECTED_RESPONSE = "sdcApiTest/macroInstantiationTypeResponse.json";
private static final String EMPTY_INSTANTIATION_TYPE_FILE_PATH = "csar15782222_instantiationTypeEmpty_invariantUUIDAlacarte.zip";
- private static final String EMPTY_INSTANTIATION_TYPE_EXPECTED_RESPONSE = "{\"service\":{\"uuid\":\"4d71990b-d8ad-4510-ac61-496288d9078e\",\"invariantUuid\":\"a8dcd72d-d44d-44f2-aa85-53aa9ca99cba\",\"name\":\"vidmacrofalsenaming\",\"version\":\"1.0\",\"toscaModelURL\":null,\"category\":\"Network L1-3\",\"serviceType\":\"\",\"serviceRole\":\"\",\"description\":\"vidmacrofalsenaming\",\"serviceEcompNaming\":\"false\",\"instantiationType\":\"ClientConfig\",\"inputs\":{}},\"vnfs\":{},\"networks\":{\"MULTI_PROVIDER_PORT_GROUP 0\":{\"uuid\":\"e5d235de-2188-4f9f-a28c-fe38967883f2\",\"invariantUuid\":\"b0303003-0abb-454c-9119-8cbe2e09e003\",\"description\":\"Creates a neutron multi-provider VLAN network with dummy subnet\",\"name\":\"MULTI_PROVIDER_PORT_GROUP\",\"version\":\"1.0\",\"customizationUuid\":\"0fde4286-ee4c-439d-9556-74b6be6bbc42\",\"inputs\":{},\"commands\":{},\"properties\":{\"network_assignments\":\"{is_external_network=false, ipv4_subnet_default_assignment={min_subnets_count=1}, ecomp_generated_network_assignment=false, ipv6_subnet_default_assignment={min_subnets_count=1}}\",\"network_flows\":\"{is_network_policy=false, is_bound_to_vpn=false}\",\"network_scope\":\"GLOBAL\",\"network_ecomp_naming\":\"{ecomp_generated_naming=true}\",\"network_type\":\"MULTI_PROVIDER_PORT_GROUP\",\"network_technology\":\"MULTI_GROUP\",\"network_homing\":\"{ecomp_selected_instance_node_target=false}\"},\"type\":\"VL\",\"modelCustomizationName\":\"MULTI_PROVIDER_PORT_GROUP 0\"}},\"collectionResource\":{},\"configurations\":{},\"serviceProxies\":{},\"vfModules\":{},\"volumeGroups\":{},\"pnfs\":{}}";
+ private static final String EMPTY_INSTANTIATION_TYPE_EXPECTED_RESPONSE = "sdcApiTest/emptyInstantiationTypeResponse.json";
private static final String BOTH_INSTANTIATION_TYPE_FILE_PATH = "csar15782222_instantiationTypeBoth_invariantUUIDAlacarte.zip";
@@ -53,13 +51,15 @@ public class SdcApiTest extends BaseApiTest {
private static final String MIN_MAX_INITIAL_UUID = "43f13072-fe50-496b-b673-7af075d10143";
private static final String MIN_MAX_INITIAL_INVARIANT_UUID = "35fb95d8-d1f0-4e46-99ac-e01b423e8e3f";
private static final String MIN_MAX_INITIAL_FILE_PATH = "min_max_initial_vfModule_csar_v4.0.zip";
- private static final String MIN_MAX_INITIAL_EXPECTED_RESPONSE = "{\"service\":{\"uuid\":\"43f13072-fe50-496b-b673-7af075d10143\",\"invariantUuid\":\"35fb95d8-d1f0-4e46-99ac-e01b423e8e3f\",\"name\":\"ADIOD vMX VPE BV Service 488 test\",\"version\":\"1.0\",\"toscaModelURL\":null,\"category\":\"Network L1-3\",\"serviceType\":\"\",\"serviceRole\":\"\",\"description\":\"Model Creation for PID 291247b . OAM Network Service Name : ADIOD vPE Tenant OAM Network 1 SRIOV Network Service Name : vPE ADIOD Provider Net 1\",\"serviceEcompNaming\":\"true\",\"instantiationType\":\"ClientConfig\",\"inputs\":{\"2017488adiodvpe20_ASN\":{\"type\":\"string\",\"description\":\"AV/PE\",\"entry_schema\":null,\"inputProperties\":null,\"constraints\":[],\"required\":true,\"default\":\"AV_vPE\"},\"2017488adiodvpe20_bandwidth\":{\"type\":\"string\",\"description\":\"Requested VPE bandwidth\",\"entry_schema\":null,\"inputProperties\":null,\"constraints\":[],\"required\":true,\"default\":\"10\"},\"2017488adiodvpe20_bandwidth_units\":{\"type\":\"string\",\"description\":\"Units of bandwidth\",\"entry_schema\":null,\"inputProperties\":null,\"constraints\":[],\"required\":true,\"default\":\"Gbps\"},\"2017488adiodvpe20_AIC_CLLI\":{\"type\":\"string\",\"description\":\"AIC Site CLLI\",\"entry_schema\":null,\"inputProperties\":null,\"constraints\":[],\"required\":true,\"default\":\"ATLMY8GA\"},\"2017488adiodvpe20_vnf_config_template_version\":{\"type\":\"string\",\"description\":\"VPE Software Version\",\"entry_schema\":null,\"inputProperties\":null,\"constraints\":[],\"required\":true,\"default\":\"17.2\"},\"2017488adiodvpe20_vnf_instance_name\":{\"type\":\"string\",\"description\":\"The hostname assigned to the vpe.\",\"entry_schema\":null,\"inputProperties\":null,\"constraints\":[],\"required\":true,\"default\":\"mtnj309me6\"}}},\"vnfs\":{\"2017 488 ADIOD vPE 2 0\":{\"uuid\":\"079266b1-fcf5-44ae-bc04-cc3215b28737\",\"invariantUuid\":\"e2dcd546-e647-4854-9ed9-e0a4d6880636\",\"description\":\"Name ADIOD vPE Description The Provider edge function for the ADIOD service supported by the Junipers VMX product Category Router Vendor Juniper Vendor Release code 17.2 Owners Mary Fragale Updated 9-25-17 for version 8.0 of the VLM \",\"name\":\"2017 488 ADIOD vPE 2\",\"version\":\"4.0\",\"customizationUuid\":\"2b4e9125-b607-49a3-81c7-9260f8ca32f4\",\"inputs\":{\"vnf_config_template_version\":{\"type\":\"string\",\"description\":\"VPE Software Version\",\"entry_schema\":null,\"inputProperties\":null,\"constraints\":[],\"required\":true,\"default\":\"17.2\"},\"bandwidth_units\":{\"type\":\"string\",\"description\":\"Units of bandwidth\",\"entry_schema\":null,\"inputProperties\":null,\"constraints\":[],\"required\":true,\"default\":\"Gbps\"},\"bandwidth\":{\"type\":\"string\",\"description\":\"Requested VPE bandwidth\",\"entry_schema\":null,\"inputProperties\":null,\"constraints\":[],\"required\":true,\"default\":\"10\"},\"AIC_CLLI\":{\"type\":\"string\",\"description\":\"AIC Site CLLI\",\"entry_schema\":null,\"inputProperties\":null,\"constraints\":[],\"required\":true,\"default\":\"ATLMY8GA\"},\"ASN\":{\"type\":\"string\",\"description\":\"AV/PE\",\"entry_schema\":null,\"inputProperties\":null,\"constraints\":[],\"required\":true,\"default\":\"AV_vPE\"},\"vnf_instance_name\":{\"type\":\"string\",\"description\":\"The hostname assigned to the vpe.\",\"entry_schema\":null,\"inputProperties\":null,\"constraints\":[],\"required\":true,\"default\":\"mtnj309me6\"}},\"commands\":{\"vnf_config_template_version\":{\"displayName\":\"vnf_config_template_version\",\"command\":\"get_input\",\"inputName\":\"2017488adiodvpe20_vnf_config_template_version\"},\"bandwidth_units\":{\"displayName\":\"bandwidth_units\",\"command\":\"get_input\",\"inputName\":\"2017488adiodvpe20_bandwidth_units\"},\"bandwidth\":{\"displayName\":\"bandwidth\",\"command\":\"get_input\",\"inputName\":\"2017488adiodvpe20_bandwidth\"},\"AIC_CLLI\":{\"displayName\":\"AIC_CLLI\",\"command\":\"get_input\",\"inputName\":\"2017488adiodvpe20_AIC_CLLI\"},\"ASN\":{\"displayName\":\"ASN\",\"command\":\"get_input\",\"inputName\":\"2017488adiodvpe20_ASN\"},\"vnf_instance_name\":{\"displayName\":\"vnf_instance_name\",\"command\":\"get_input\",\"inputName\":\"2017488adiodvpe20_vnf_instance_name\"}},\"properties\":{\"vmxvre_retype\":\"RE-VMX\",\"vnf_config_template_version\":\"get_input:2017488adiodvpe20_vnf_config_template_version\",\"sriov44_net_id\":\"48d399b3-11ee-48a8-94d2-f0ea94d6be8d\",\"int_ctl_net_id\":\"2f323477-6936-4d01-ac53-d849430281d9\",\"vmxvpfe_sriov41_0_port_mac\":\"00:11:22:EF:AC:DF\",\"int_ctl_net_name\":\"VMX-INTXI\",\"vmx_int_ctl_prefix\":\"128.0.0.0\",\"sriov43_net_id\":\"da349ca1-6de9-4548-be88-2d88e99bfef5\",\"sriov42_net_id\":\"760669ba-013d-4d9b-b0e7-4151fe2e6279\",\"sriov41_net_id\":\"25ad52d5-c165-40f8-b3b0-ddfc2373280a\",\"nf_type\":\"vPE\",\"vmxvpfe_int_ctl_ip_1\":\"128.0.0.16\",\"is_AVPN_service\":\"false\",\"vmx_RSG_name\":\"vREXI-affinity\",\"vmx_int_ctl_forwarding\":\"l2\",\"vmxvre_oam_ip_0\":\"10.40.123.5\",\"vmxvpfe_sriov44_0_port_mac\":\"00:11:22:EF:AC:DF\",\"vmxvpfe_sriov41_0_port_vlanstrip\":\"false\",\"vmxvpfe_sriov42_0_port_vlanfilter\":\"4001\",\"vmxvpfe_sriov44_0_port_unknownunicastallow\":\"true\",\"vmxvre_image_name_0\":\"VRE-ENGINE_17.2-S2.1.qcow2\",\"vmxvre_instance\":\"0\",\"vmxvpfe_sriov43_0_port_mac\":\"00:11:22:EF:AC:DF\",\"vmxvre_flavor_name\":\"ns.c1r16d32.v5\",\"vmxvpfe_volume_size_0\":\"40.0\",\"vmxvpfe_sriov43_0_port_vlanfilter\":\"4001\",\"nf_naming\":\"{ecomp_generated_naming=true}\",\"multi_stage_design\":\"false\",\"nf_naming_code\":\"tvpr\",\"vmxvre_name_0\":\"vREXI\",\"vmxvpfe_sriov42_0_port_vlanstrip\":\"false\",\"vmxvpfe_volume_name_0\":\"vPFEXI_FBVolume\",\"vmx_RSG_id\":\"bd89a33c-13c3-4a04-8fde-1a57eb123141\",\"vmxvpfe_image_name_0\":\"VPE_ROUTING-ENGINE_17.2R1-S2.1.qcow2\",\"vmxvpfe_sriov43_0_port_unknownunicastallow\":\"true\",\"vmxvpfe_sriov44_0_port_unknownmulticastallow\":\"true\",\"vmxvre_console\":\"vidconsole\",\"vmxvpfe_sriov44_0_port_vlanfilter\":\"4001\",\"vmxvpfe_sriov42_0_port_mac\":\"00:11:22:EF:AC:DF\",\"vmxvpfe_volume_id_0\":\"47cede15-da2f-4397-a101-aa683220aff3\",\"vmxvpfe_sriov42_0_port_unknownmulticastallow\":\"true\",\"vmxvpfe_sriov44_0_port_vlanstrip\":\"false\",\"vf_module_id\":\"123\",\"nf_function\":\"Firewall\",\"vmxvpfe_sriov43_0_port_unknownmulticastallow\":\"true\",\"vmxvre_int_ctl_ip_0\":\"128.0.0.1\",\"ecomp_generated_naming\":\"true\",\"AIC_CLLI\":\"get_input:2017488adiodvpe20_AIC_CLLI\",\"vnf_name\":\"mtnj309me6vre\",\"vmxvpfe_sriov41_0_port_unknownunicastallow\":\"true\",\"vmxvre_volume_type_1\":\"HITACHI\",\"vmxvpfe_sriov44_0_port_broadcastallow\":\"true\",\"vmxvre_volume_type_0\":\"HITACHI\",\"vmxvpfe_volume_type_0\":\"HITACHI\",\"vmxvpfe_sriov43_0_port_broadcastallow\":\"true\",\"bandwidth_units\":\"get_input:2017488adiodvpe20_bandwidth_units\",\"vnf_id\":\"123\",\"vmxvre_oam_prefix\":\"24\",\"availability_zone_0\":\"mtpocfo-kvm-az01\",\"ASN\":\"get_input:2017488adiodvpe20_ASN\",\"vmxvre_chassis_i2cid\":\"161\",\"vmxvpfe_name_0\":\"vPFEXI\",\"bandwidth\":\"get_input:2017488adiodvpe20_bandwidth\",\"availability_zone_max_count\":\"1\",\"vmxvre_volume_size_0\":\"45.0\",\"vmxvre_volume_size_1\":\"50.0\",\"vmxvpfe_sriov42_0_port_broadcastallow\":\"true\",\"vmxvre_oam_gateway\":\"10.40.123.1\",\"vmxvre_volume_name_1\":\"vREXI_FAVolume\",\"vmxvre_ore_present\":\"0\",\"vmxvre_volume_name_0\":\"vREXI_FBVolume\",\"vmxvre_type\":\"0\",\"vnf_instance_name\":\"get_input:2017488adiodvpe20_vnf_instance_name\",\"vmxvpfe_sriov41_0_port_unknownmulticastallow\":\"true\",\"oam_net_id\":\"b95eeb1d-d55d-4827-abb4-8ebb94941429\",\"vmx_int_ctl_len\":\"24\",\"vmxvpfe_sriov43_0_port_vlanstrip\":\"false\",\"vmxvpfe_sriov41_0_port_broadcastallow\":\"true\",\"vmxvre_volume_id_1\":\"6e86797e-03cd-4fdc-ba72-2957119c746d\",\"vmxvpfe_sriov41_0_port_vlanfilter\":\"4001\",\"nf_role\":\"MIS\",\"vmxvre_volume_id_0\":\"f4eacb79-f687-4e9d-b760-21847c8bb15a\",\"vmxvpfe_sriov42_0_port_unknownunicastallow\":\"true\",\"vmxvpfe_flavor_name\":\"ns.c20r16d25.v5\"},\"type\":\"VF\",\"modelCustomizationName\":\"2017 488 ADIOD vPE 2 0\",\"vfModules\":{\"2017488adiodvpe20..2017488AdiodVpe2..ADIOD_vPFE_BV..module-2\":{\"uuid\":\"13bea14d-9405-43c6-920b-97bab64b6a01\",\"invariantUuid\":\"83dc51de-a337-498e-9fee-763603a057b4\",\"customizationUuid\":\"a90865d5-6de0-4ef8-bf53-d45fa3edddfc\",\"description\":null,\"name\":\"2017488AdiodVpe2..ADIOD_vPFE_BV..module-2\",\"version\":\"1\",\"modelCustomizationName\":\"2017488AdiodVpe2..ADIOD_vPFE_BV..module-2\",\"properties\":{\"minCountInstances\":null,\"maxCountInstances\":null,\"initialCount\":null,\"vfModuleLabel\":\"ADIOD_vPFE_BV\"},\"inputs\":{},\"volumeGroupAllowed\":true},\"2017488adiodvpe20..2017488AdiodVpe2..ADIOD_vRE_BV..module-1\":{\"uuid\":\"3f6d5e51-a9a0-4c53-bb6d-be836767d96f\",\"invariantUuid\":\"54466b6d-e33c-4f4d-87e2-32bc5b103589\",\"customizationUuid\":\"dba1d1ff-77e2-4f4d-b1b4-1bed564f13b1\",\"description\":null,\"name\":\"2017488AdiodVpe2..ADIOD_vRE_BV..module-1\",\"version\":\"1\",\"modelCustomizationName\":\"2017488AdiodVpe2..ADIOD_vRE_BV..module-1\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":\"ADIOD_vRE_BV\"},\"inputs\":{},\"volumeGroupAllowed\":true},\"2017488adiodvpe20..2017488AdiodVpe2..ADIOD_base_vPE_BV..module-0\":{\"uuid\":\"0a45a870-3a19-4238-a72a-eadfc583d4fe\",\"invariantUuid\":\"c636b302-fba2-4ed7-9f3b-c99715b6bb2e\",\"customizationUuid\":\"a0b634e6-514e-4977-91dd-3b8c295e6bc8\",\"description\":null,\"name\":\"2017488AdiodVpe2..ADIOD_base_vPE_BV..module-0\",\"version\":\"1\",\"modelCustomizationName\":\"2017488AdiodVpe2..ADIOD_base_vPE_BV..module-0\",\"properties\":{\"minCountInstances\":1,\"maxCountInstances\":1,\"initialCount\":1,\"vfModuleLabel\":\"ADIOD_base_vPE_BV\"},\"inputs\":{},\"volumeGroupAllowed\":false}},\"volumeGroups\":{\"2017488adiodvpe20..2017488AdiodVpe2..ADIOD_vPFE_BV..module-2\":{\"uuid\":\"13bea14d-9405-43c6-920b-97bab64b6a01\",\"invariantUuid\":\"83dc51de-a337-498e-9fee-763603a057b4\",\"customizationUuid\":\"a90865d5-6de0-4ef8-bf53-d45fa3edddfc\",\"description\":null,\"name\":\"2017488AdiodVpe2..ADIOD_vPFE_BV..module-2\",\"version\":\"1\",\"modelCustomizationName\":\"2017488AdiodVpe2..ADIOD_vPFE_BV..module-2\",\"properties\":{\"minCountInstances\":null,\"maxCountInstances\":null,\"initialCount\":null,\"vfModuleLabel\":\"ADIOD_vPFE_BV\"},\"inputs\":{}},\"2017488adiodvpe20..2017488AdiodVpe2..ADIOD_vRE_BV..module-1\":{\"uuid\":\"3f6d5e51-a9a0-4c53-bb6d-be836767d96f\",\"invariantUuid\":\"54466b6d-e33c-4f4d-87e2-32bc5b103589\",\"customizationUuid\":\"dba1d1ff-77e2-4f4d-b1b4-1bed564f13b1\",\"description\":null,\"name\":\"2017488AdiodVpe2..ADIOD_vRE_BV..module-1\",\"version\":\"1\",\"modelCustomizationName\":\"2017488AdiodVpe2..ADIOD_vRE_BV..module-1\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":\"ADIOD_vRE_BV\"},\"inputs\":{}}},\"vfcInstanceGroups\":{}}},\"networks\":{},\"collectionResource\":{},\"configurations\":{},\"serviceProxies\":{},\"vfModules\":{\"2017488adiodvpe20..2017488AdiodVpe2..ADIOD_vPFE_BV..module-2\":{\"uuid\":\"13bea14d-9405-43c6-920b-97bab64b6a01\",\"invariantUuid\":\"83dc51de-a337-498e-9fee-763603a057b4\",\"customizationUuid\":\"a90865d5-6de0-4ef8-bf53-d45fa3edddfc\",\"description\":null,\"name\":\"2017488AdiodVpe2..ADIOD_vPFE_BV..module-2\",\"version\":\"1\",\"modelCustomizationName\":\"2017488AdiodVpe2..ADIOD_vPFE_BV..module-2\",\"properties\":{\"minCountInstances\":null,\"maxCountInstances\":null,\"initialCount\":null,\"vfModuleLabel\":\"ADIOD_vPFE_BV\"},\"inputs\":{},\"volumeGroupAllowed\":true},\"2017488adiodvpe20..2017488AdiodVpe2..ADIOD_base_vPE_BV..module-0\":{\"uuid\":\"0a45a870-3a19-4238-a72a-eadfc583d4fe\",\"invariantUuid\":\"c636b302-fba2-4ed7-9f3b-c99715b6bb2e\",\"customizationUuid\":\"a0b634e6-514e-4977-91dd-3b8c295e6bc8\",\"description\":null,\"name\":\"2017488AdiodVpe2..ADIOD_base_vPE_BV..module-0\",\"version\":\"1\",\"modelCustomizationName\":\"2017488AdiodVpe2..ADIOD_base_vPE_BV..module-0\",\"properties\":{\"minCountInstances\":1,\"maxCountInstances\":1,\"initialCount\":1,\"vfModuleLabel\":\"ADIOD_base_vPE_BV\"},\"inputs\":{},\"volumeGroupAllowed\":false},\"2017488adiodvpe20..2017488AdiodVpe2..ADIOD_vRE_BV..module-1\":{\"uuid\":\"3f6d5e51-a9a0-4c53-bb6d-be836767d96f\",\"invariantUuid\":\"54466b6d-e33c-4f4d-87e2-32bc5b103589\",\"customizationUuid\":\"dba1d1ff-77e2-4f4d-b1b4-1bed564f13b1\",\"description\":null,\"name\":\"2017488AdiodVpe2..ADIOD_vRE_BV..module-1\",\"version\":\"1\",\"modelCustomizationName\":\"2017488AdiodVpe2..ADIOD_vRE_BV..module-1\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":\"ADIOD_vRE_BV\"},\"inputs\":{},\"volumeGroupAllowed\":true}},\"volumeGroups\":{\"2017488adiodvpe20..2017488AdiodVpe2..ADIOD_vPFE_BV..module-2\":{\"uuid\":\"13bea14d-9405-43c6-920b-97bab64b6a01\",\"invariantUuid\":\"83dc51de-a337-498e-9fee-763603a057b4\",\"customizationUuid\":\"a90865d5-6de0-4ef8-bf53-d45fa3edddfc\",\"description\":null,\"name\":\"2017488AdiodVpe2..ADIOD_vPFE_BV..module-2\",\"version\":\"1\",\"modelCustomizationName\":\"2017488AdiodVpe2..ADIOD_vPFE_BV..module-2\",\"properties\":{\"minCountInstances\":null,\"maxCountInstances\":null,\"initialCount\":null,\"vfModuleLabel\":\"ADIOD_vPFE_BV\"},\"inputs\":{}},\"2017488adiodvpe20..2017488AdiodVpe2..ADIOD_vRE_BV..module-1\":{\"uuid\":\"3f6d5e51-a9a0-4c53-bb6d-be836767d96f\",\"invariantUuid\":\"54466b6d-e33c-4f4d-87e2-32bc5b103589\",\"customizationUuid\":\"dba1d1ff-77e2-4f4d-b1b4-1bed564f13b1\",\"description\":null,\"name\":\"2017488AdiodVpe2..ADIOD_vRE_BV..module-1\",\"version\":\"1\",\"modelCustomizationName\":\"2017488AdiodVpe2..ADIOD_vRE_BV..module-1\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":\"ADIOD_vRE_BV\"},\"inputs\":{}}},\"pnfs\":{}}";
-
private static final String MIN_MAX_INITIAL_UUID_OLD_CSAR = "245562de-3984-49ef-a708-6c9d7cfcabd1";
private static final String MIN_MAX_INITIAL_INVARIANT_UUID_OLD_CSAR = "24216d6-71d0-41c8-ac81-0c5acfee514a";
- private static final String MIN_MAX_INITIAL_FILE_PATH_OLD_CSAR = "service-VmmeRvpmsFeAic3011217Svc-csar.csar.zip";
- private static final String MIN_MAX_INITIAL_EXPECTED_RESPONSE_OLD_CSAR = "{\"service\":{\"uuid\":\"281b5f7d-c7ac-4ea9-92fb-2c1d625ca681\",\"invariantUuid\":\"a977af77-db15-4375-a637-e9b994ecd569\",\"name\":\"vMME_rVPMS_FE AIC3.0-11.2.1.7_SVC\",\"version\":\"1.0\",\"toscaModelURL\":null,\"category\":\"Mobility\",\"serviceType\":null,\"serviceRole\":null,\"description\":\"New service for vMME vProbe Front End AIC3.0 VPMS Radcom 11.2.1.7. Front End includes Qrouter, vProbe aff, vLB Agent aff and vLB.\",\"serviceEcompNaming\":\"true\",\"instantiationType\":null,\"inputs\":{}},\"vnfs\":{\"vMMEvProbe_FE_AIC3-11.2.1_VF 1\":{\"uuid\":\"245562de-3984-49ef-a708-6c9d7cfcabd1\",\"invariantUuid\":\"124216d6-71d0-41c8-ac81-0c5acfee514a\",\"description\":\" New service for vMME vProbe Front End AIC3.0 VPMS Radcom 11.2.1.7. Front End includes Qrouter, vProbe aff, vLB Agent aff and vLB. \",\"name\":\"vMMEvProbe_FE_AIC3-11.2.1_VF\",\"version\":\"1.0\",\"customizationUuid\":\"8293273d-0e76-4661-926f-06a01ad2e683\",\"inputs\":{},\"commands\":{},\"properties\":{},\"type\":null,\"modelCustomizationName\":\"vMMEvProbe_FE_AIC3-11.2.1_VF 1\",\"vfModules\":{\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vprobe_eph..module-1\":{\"uuid\":\"e67e5b39-1f3b-4692-beec-eda94a0375a5\",\"invariantUuid\":\"21c1b57d-a618-4397-a7f4-9c37169ea09b\",\"customizationUuid\":\"a7d59494-3710-4b05-b4cd-e45dadbdc7ac\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Add_On_Module_vprobe_eph..module-1\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vprobe_eph..module-1\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":null},\"inputs\":null,\"volumeGroupAllowed\":true},\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Base_Module..module-0\":{\"uuid\":\"59bb7d14-278f-4ff5-bd5a-1a720c8b0d19\",\"invariantUuid\":\"9b5589c2-e4d1-4456-a23b-e0001c349155\",\"customizationUuid\":\"b9d6f6e8-e24a-4ad9-b863-1c3f6757bfe7\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Base_Module..module-0\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Base_Module..module-0\",\"properties\":{\"minCountInstances\":1,\"maxCountInstances\":1,\"initialCount\":1,\"vfModuleLabel\":null},\"inputs\":null,\"volumeGroupAllowed\":false},\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlbagent_aff..module-2\":{\"uuid\":\"530e5e9f-2e82-4946-bf59-630f4d7ef4de\",\"invariantUuid\":\"d1fb14d9-0fa8-4ead-b5cc-be311c7a95bd\",\"customizationUuid\":\"c1f95365-716c-4f6c-9477-a8f760a2edce\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlbagent_aff..module-2\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlbagent_aff..module-2\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":null},\"inputs\":null,\"volumeGroupAllowed\":true},\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_qrouter..module-4\":{\"uuid\":\"064385f9-795b-4fcb-9e3b-51d7d0ccad80\",\"invariantUuid\":\"603e8f71-88ad-4bbf-9992-2e9a72a91e29\",\"customizationUuid\":\"3b5efcd3-d14d-4b0e-91cf-937db5aa65b5\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Add_On_Module_qrouter..module-4\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_qrouter..module-4\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":null},\"inputs\":null,\"volumeGroupAllowed\":true},\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlb..module-3\":{\"uuid\":\"85b712e0-af62-4255-aeb6-ec9ae0f4eb13\",\"invariantUuid\":\"cba59330-855a-460b-8856-f6bff0dac6c2\",\"customizationUuid\":\"962479d7-b5b7-4129-bf9f-bfe4775e7921\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlb..module-3\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlb..module-3\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":null},\"inputs\":null,\"volumeGroupAllowed\":true}},\"volumeGroups\":{\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vprobe_eph..module-1\":{\"uuid\":\"e67e5b39-1f3b-4692-beec-eda94a0375a5\",\"invariantUuid\":\"21c1b57d-a618-4397-a7f4-9c37169ea09b\",\"customizationUuid\":\"a7d59494-3710-4b05-b4cd-e45dadbdc7ac\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Add_On_Module_vprobe_eph..module-1\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vprobe_eph..module-1\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":null},\"inputs\":null},\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlbagent_aff..module-2\":{\"uuid\":\"530e5e9f-2e82-4946-bf59-630f4d7ef4de\",\"invariantUuid\":\"d1fb14d9-0fa8-4ead-b5cc-be311c7a95bd\",\"customizationUuid\":\"c1f95365-716c-4f6c-9477-a8f760a2edce\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlbagent_aff..module-2\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlbagent_aff..module-2\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":null},\"inputs\":null},\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_qrouter..module-4\":{\"uuid\":\"064385f9-795b-4fcb-9e3b-51d7d0ccad80\",\"invariantUuid\":\"603e8f71-88ad-4bbf-9992-2e9a72a91e29\",\"customizationUuid\":\"3b5efcd3-d14d-4b0e-91cf-937db5aa65b5\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Add_On_Module_qrouter..module-4\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_qrouter..module-4\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":null},\"inputs\":null},\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlb..module-3\":{\"uuid\":\"85b712e0-af62-4255-aeb6-ec9ae0f4eb13\",\"invariantUuid\":\"cba59330-855a-460b-8856-f6bff0dac6c2\",\"customizationUuid\":\"962479d7-b5b7-4129-bf9f-bfe4775e7921\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlb..module-3\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlb..module-3\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":null},\"inputs\":null}},\"vfcInstanceGroups\":{}}},\"networks\":{},\"collectionResource\":null,\"configurations\":null,\"serviceProxies\":null,\"vfModules\":{\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vprobe_eph..module-1\":{\"uuid\":\"e67e5b39-1f3b-4692-beec-eda94a0375a5\",\"invariantUuid\":\"21c1b57d-a618-4397-a7f4-9c37169ea09b\",\"customizationUuid\":\"a7d59494-3710-4b05-b4cd-e45dadbdc7ac\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Add_On_Module_vprobe_eph..module-1\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vprobe_eph..module-1\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":null},\"inputs\":null,\"volumeGroupAllowed\":true},\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Base_Module..module-0\":{\"uuid\":\"59bb7d14-278f-4ff5-bd5a-1a720c8b0d19\",\"invariantUuid\":\"9b5589c2-e4d1-4456-a23b-e0001c349155\",\"customizationUuid\":\"b9d6f6e8-e24a-4ad9-b863-1c3f6757bfe7\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Base_Module..module-0\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Base_Module..module-0\",\"properties\":{\"minCountInstances\":1,\"maxCountInstances\":1,\"initialCount\":1,\"vfModuleLabel\":null},\"inputs\":null,\"volumeGroupAllowed\":false},\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlbagent_aff..module-2\":{\"uuid\":\"530e5e9f-2e82-4946-bf59-630f4d7ef4de\",\"invariantUuid\":\"d1fb14d9-0fa8-4ead-b5cc-be311c7a95bd\",\"customizationUuid\":\"c1f95365-716c-4f6c-9477-a8f760a2edce\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlbagent_aff..module-2\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlbagent_aff..module-2\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":null},\"inputs\":null,\"volumeGroupAllowed\":true},\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_qrouter..module-4\":{\"uuid\":\"064385f9-795b-4fcb-9e3b-51d7d0ccad80\",\"invariantUuid\":\"603e8f71-88ad-4bbf-9992-2e9a72a91e29\",\"customizationUuid\":\"3b5efcd3-d14d-4b0e-91cf-937db5aa65b5\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Add_On_Module_qrouter..module-4\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_qrouter..module-4\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":null},\"inputs\":null,\"volumeGroupAllowed\":true},\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlb..module-3\":{\"uuid\":\"85b712e0-af62-4255-aeb6-ec9ae0f4eb13\",\"invariantUuid\":\"cba59330-855a-460b-8856-f6bff0dac6c2\",\"customizationUuid\":\"962479d7-b5b7-4129-bf9f-bfe4775e7921\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlb..module-3\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlb..module-3\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":null},\"inputs\":null,\"volumeGroupAllowed\":true}},\"volumeGroups\":{\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vprobe_eph..module-1\":{\"uuid\":\"e67e5b39-1f3b-4692-beec-eda94a0375a5\",\"invariantUuid\":\"21c1b57d-a618-4397-a7f4-9c37169ea09b\",\"customizationUuid\":\"a7d59494-3710-4b05-b4cd-e45dadbdc7ac\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Add_On_Module_vprobe_eph..module-1\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vprobe_eph..module-1\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":null},\"inputs\":null},\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlbagent_aff..module-2\":{\"uuid\":\"530e5e9f-2e82-4946-bf59-630f4d7ef4de\",\"invariantUuid\":\"d1fb14d9-0fa8-4ead-b5cc-be311c7a95bd\",\"customizationUuid\":\"c1f95365-716c-4f6c-9477-a8f760a2edce\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlbagent_aff..module-2\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlbagent_aff..module-2\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":null},\"inputs\":null},\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_qrouter..module-4\":{\"uuid\":\"064385f9-795b-4fcb-9e3b-51d7d0ccad80\",\"invariantUuid\":\"603e8f71-88ad-4bbf-9992-2e9a72a91e29\",\"customizationUuid\":\"3b5efcd3-d14d-4b0e-91cf-937db5aa65b5\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Add_On_Module_qrouter..module-4\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_qrouter..module-4\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":null},\"inputs\":null},\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlb..module-3\":{\"uuid\":\"85b712e0-af62-4255-aeb6-ec9ae0f4eb13\",\"invariantUuid\":\"cba59330-855a-460b-8856-f6bff0dac6c2\",\"customizationUuid\":\"962479d7-b5b7-4129-bf9f-bfe4775e7921\",\"description\":null,\"name\":\"VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlb..module-3\",\"version\":\"1\",\"modelCustomizationName\":\"vmmevprobe_fe_aic31121_vf1..VmmevprobeFeAic31121Vf..FE_Add_On_Module_vlb..module-3\",\"properties\":{\"minCountInstances\":0,\"maxCountInstances\":null,\"initialCount\":0,\"vfModuleLabel\":null},\"inputs\":null}},\"pnfs\":null}";
+ private static final String MIN_MAX_INITIAL_FILE_PATH_OLD_CSAR = "service-VflorenceRvpmsFeAic3011217Svc-csar.csar.zip";
+
+ private static final String GROUPING_SERVICE_ROLE_FILE_PATH = "csar15782222_instantiationTypeAlacarte_VnfGrouping.zip";
+ private static final String GROUPING_SERVICE_ROLE_UUID = "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc";
+ private static final String GROUPING_SERVICE_ROLE_INVARIANT_UUID = "7ee41ce4-4827-44b0-a48e-2707a59905d2";
+ private static final String GROUPING_SERVICE_ROLE_EXPECTED_RESPONSE = "VnfGroup/groupingServiceRoleResponse.json";
@BeforeClass
public void login() {
@@ -74,20 +74,22 @@ public class SdcApiTest extends BaseApiTest {
}
@Test
- public void getServiceModelALaCarteInstantiation() throws IOException, URISyntaxException {
+ public void getServiceModelALaCarteInstantiation() {
registerToSimulatorWithPresets(A_LA_CARTE_INSTANTIATION_TYPE_UUID, A_LA_CARTE_INSTANTIATION_TYPE_INVARIANT_UUID, A_LA_CARTE_INSTANTIATION_TYPE_FILE_PATH);
ResponseEntity<String> response = restTemplate.getForEntity(buildUri(SDC_GET_SERVICE_MODEL + A_LA_CARTE_INSTANTIATION_TYPE_UUID), String.class);
Assert.assertEquals(response.getStatusCode(), HttpStatus.OK);
- assertThat("The response is in the format of JSON", response.getBody(), either(is(A_LA_CARTE_INSTANTIATION_TYPE_EXPECTED_RESPONSE)).or(jsonStringEquals(A_LA_CARTE_INSTANTIATION_TYPE_EXPECTED_RESPONSE)));
+ String aLaCarteInstantiationTypeExpectedResponse = loadResourceAsString(A_LA_CARTE_INSTANTIATION_TYPE_EXPECTED_RESPONSE);
+ assertThat("The response is in the format of JSON", response.getBody(), is(jsonStringEquals(turnOffInstantiationUI(aLaCarteInstantiationTypeExpectedResponse))));
}
@Test
- public void getServiceModelMacroInstantiation() throws IOException, URISyntaxException {
+ public void getServiceModelMacroInstantiation() {
registerToSimulatorWithPresets(MACRO_INSTANTIATION_TYPE_UUID, MACRO_INSTANTIATION_TYPE_INVARIANT_UUID, MACRO_INSTANTIATION_TYPE_FILE_PATH);
ResponseEntity<String> response = restTemplate.getForEntity(buildUri(SDC_GET_SERVICE_MODEL + MACRO_INSTANTIATION_TYPE_UUID), String.class);
Assert.assertEquals(response.getStatusCode(), HttpStatus.OK);
- assertThat("The response is in the format of JSON", response.getBody(), either(is(MACRO_INSTANTIATION_TYPE_EXPECTED_RESPONSE)).or(jsonStringEquals(MACRO_INSTANTIATION_TYPE_EXPECTED_RESPONSE)));
+ String macroInstantiationTypeExpectedResponse = loadResourceAsString(MACRO_INSTANTIATION_TYPE_EXPECTED_RESPONSE);
+ assertThat("The response is in the format of JSON", response.getBody(), is(jsonStringEquals(turnOffInstantiationUI(macroInstantiationTypeExpectedResponse))));
}
@@ -96,8 +98,8 @@ public class SdcApiTest extends BaseApiTest {
registerToSimulatorWithPresets(MACRO_INSTANTIATION_TYPE_UUID, MACRO_INSTANTIATION_TYPE_INVARIANT_UUID, EMPTY_INSTANTIATION_TYPE_FILE_PATH);
ResponseEntity<String> response = restTemplate.getForEntity(buildUri(SDC_GET_SERVICE_MODEL + MACRO_INSTANTIATION_TYPE_UUID), String.class);
Assert.assertEquals(response.getStatusCode(), HttpStatus.OK);
- assertThat("The response is in the format of JSON", response.getBody(), either(is(EMPTY_INSTANTIATION_TYPE_EXPECTED_RESPONSE)).or(jsonStringEquals(EMPTY_INSTANTIATION_TYPE_EXPECTED_RESPONSE)));
-
+ String emptyInstantiationTypeExpectedResponse = loadResourceAsString(EMPTY_INSTANTIATION_TYPE_EXPECTED_RESPONSE);
+ assertThat("The response is in the format of JSON", response.getBody(), is(jsonStringEquals(turnOffInstantiationUI(emptyInstantiationTypeExpectedResponse))));
}
@Test
@@ -105,7 +107,8 @@ public class SdcApiTest extends BaseApiTest {
registerToSimulatorWithPresets(MACRO_INSTANTIATION_TYPE_UUID, MACRO_INSTANTIATION_TYPE_INVARIANT_UUID, BOTH_INSTANTIATION_TYPE_FILE_PATH);
ResponseEntity<String> response = restTemplate.getForEntity(buildUri(SDC_GET_SERVICE_MODEL + MACRO_INSTANTIATION_TYPE_UUID), String.class);
Assert.assertEquals(response.getStatusCode(), HttpStatus.OK);
- assertThat("The response is in the format of JSON", response.getBody(), either(is(MACRO_INSTANTIATION_TYPE_EXPECTED_RESPONSE)).or(jsonStringEquals(MACRO_INSTANTIATION_TYPE_EXPECTED_RESPONSE)));
+ String macroInstantiationTypeExpectedResponse = loadResourceAsString(MACRO_INSTANTIATION_TYPE_EXPECTED_RESPONSE);
+ assertThat("The response is in the format of JSON", response.getBody(), is(jsonStringEquals(turnOffInstantiationUI(macroInstantiationTypeExpectedResponse))));
}
@Test
@@ -113,7 +116,8 @@ public class SdcApiTest extends BaseApiTest {
registerToSimulatorWithPresets(MIN_MAX_INITIAL_UUID, MIN_MAX_INITIAL_INVARIANT_UUID, MIN_MAX_INITIAL_FILE_PATH);
ResponseEntity<String> response = restTemplate.getForEntity(buildUri(SDC_GET_SERVICE_MODEL + MIN_MAX_INITIAL_UUID), String.class);
Assert.assertEquals(response.getStatusCode(), HttpStatus.OK);
- assertThat("The response is in the format of JSON", response.getBody(), either(is(MIN_MAX_INITIAL_EXPECTED_RESPONSE)).or(jsonStringEquals(MIN_MAX_INITIAL_EXPECTED_RESPONSE)));
+ String minMaxInitialExpectedResponse = loadResourceAsString("sdcApiTest/minMaxInitialExpectedResponse.json");
+ assertThat("The response is in the format of JSON", response.getBody(), is(jsonStringEquals(turnOffInstantiationUI(minMaxInitialExpectedResponse))));
}
@Test
@@ -121,7 +125,18 @@ public class SdcApiTest extends BaseApiTest {
registerToSimulatorWithPresets(MIN_MAX_INITIAL_UUID_OLD_CSAR, MIN_MAX_INITIAL_INVARIANT_UUID_OLD_CSAR, MIN_MAX_INITIAL_FILE_PATH_OLD_CSAR);
ResponseEntity<String> response = restTemplate.getForEntity(buildUri(SDC_GET_SERVICE_MODEL + MIN_MAX_INITIAL_UUID_OLD_CSAR), String.class);
Assert.assertEquals(response.getStatusCode(), HttpStatus.OK);
- assertThat("The response is in the format of JSON", response.getBody(), either(is(MIN_MAX_INITIAL_EXPECTED_RESPONSE_OLD_CSAR)).or(jsonStringEquals(MIN_MAX_INITIAL_EXPECTED_RESPONSE_OLD_CSAR)));
+ String minMaxInitialExpectedResponseOldCsar = loadResourceAsString("sdcApiTest/minMaxInitialExpectedResponseOldCsar.json");
+ assertThat("The response is in the format of JSON", response.getBody(), is(jsonStringEquals(minMaxInitialExpectedResponseOldCsar)));
+ }
+
+ @Test
+ @FeatureTogglingTest(Features.FLAG_1902_VNF_GROUPING)
+ public void getServiceModelWithServiceRoleGrouping(){
+ registerToSimulatorWithPresets(GROUPING_SERVICE_ROLE_UUID, GROUPING_SERVICE_ROLE_INVARIANT_UUID, GROUPING_SERVICE_ROLE_FILE_PATH);
+ ResponseEntity<String> response = restTemplate.getForEntity(buildUri(SDC_GET_SERVICE_MODEL + GROUPING_SERVICE_ROLE_UUID), String.class);
+ Assert.assertEquals(response.getStatusCode(), HttpStatus.OK);
+ String groupingServiceRoleExpectedResponse = loadResourceAsString(GROUPING_SERVICE_ROLE_EXPECTED_RESPONSE);
+ assertThat("The response is in the format of JSON", response.getBody(), is(jsonStringEquals(groupingServiceRoleExpectedResponse)));
}
private void registerToSimulatorWithPresets(String uuid, String invariantUuid, String pathPath){
@@ -131,6 +146,15 @@ public class SdcApiTest extends BaseApiTest {
registerExpectationFromPresets(presets, CLEAR_THEN_SET);
}
+ private String turnOffInstantiationUI(String expectedJson) {
+ if (!Features.FLAG_5G_IN_NEW_INSTANTIATION_UI.isActive()) {
+ // replaces the instantiationUI field-value with "legacy", whatever it was
+ return expectedJson.replaceFirst("(\"instantiationUI\": *\")[^\"]*(\",)", "$1legacy$2");
+ } else {
+ return expectedJson;
+ }
+ }
+
@Test
public void withModelFromE2eWithToscaParserButNewFlow_requestModels_expectVnfRelatedVfModulesNotNull() {
@@ -139,8 +163,8 @@ public class SdcApiTest extends BaseApiTest {
volumeGroups, because a 'isNewFlow' value in org.onap.vid.asdc.parser.ToscaParserImpl
was always false because a coding error.
*/
- registerExpectation("get_sdc_catalog_services_VmmeRvpmsFeAic3011217Svc.json", CLEAR_THEN_SET);
- registerExpectation("aai_get_full_subscribers.json", APPEND);
+ registerExpectation("get_sdc_catalog_services_VflorenceRvpmsFeAic3011217Svc.json", CLEAR_THEN_SET);
+ registerExpectation("create_new_instance/aai_get_full_subscribers.json", APPEND);
final JsonNode response = restTemplate.getForObject(uri + "/rest/models/services/" + "245562de-3984-49ef-a708-6c9d7cfcabd1", JsonNode.class);
diff --git a/vid-automation/src/test/java/org/onap/vid/api/ServiceInstanceMsoApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/ServiceInstanceMsoApiTest.java
index ce290c89f..40ce80ba6 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/ServiceInstanceMsoApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/ServiceInstanceMsoApiTest.java
@@ -1,16 +1,21 @@
package org.onap.vid.api;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import java.io.IOException;
+import java.net.URISyntaxException;
import org.apache.commons.text.StringEscapeUtils;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOActivateFabricConfiguration;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOActivateFabricConfigurationErrorResponse;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeactivateAndCloudDelete;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeactivateAndCloudDeleteErrorResponse;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.testng.annotations.Test;
import vid.automation.test.infra.FeatureTogglingTest;
import vid.automation.test.infra.Features;
-import java.io.IOException;
-import java.net.URISyntaxException;
-
public class ServiceInstanceMsoApiTest extends BaseMsoApiTest{
//Urls
@@ -18,11 +23,15 @@ public class ServiceInstanceMsoApiTest extends BaseMsoApiTest{
public static final String MSO_DEACTIVATE_SERVICE_INSTANCE = "mso/mso_deactivate_service_instance/f36f5734-e9df-4fbf-9f35-61be13f028a1";
public static final String MSO_DELETE_SERVICE_INSTANCE = "mso/mso_delete_svc_instance/f36f5734-e9df-4fbf-9f35-61be13f028a1?serviceStatus=active";
public static final String MSO_UNASSIGN_SERVICE_INSTANCE = "mso/mso_delete_svc_instance/f36f5734-e9df-4fbf-9f35-61be13f028a1?serviceStatus=created";
+ public static final String MSO_ACTIVATE_FABRIC_CONFIGURATION = "mso/mso_activate_fabric_configuration/f36f5734-e9df-4fbf-9f35-61be13f028a1";
+ public static final String MSO_DEACTIVATE_AND_CLOUD_DELETE = "mso/mso_vfmodule_soft_delete/f36f5734-e9df-4fbf-9f35-61be13f028a1/vnfId/vfModuleId";
//Request Details
private static final String ACTIVATE_SERVICE_REQUEST_DETAILS = "registration_to_simulator/body_jsons/mso_request_activate_service_instance.json";
private static final String DEACTIVATE_SERVICE_REQUEST_DETAILS = "registration_to_simulator/body_jsons/mso_request_deactivate_service_instance.json";
private static final String DELETE_AND_UNASSIGN_SERVICE_REQUEST_DETAILS = "registration_to_simulator/body_jsons/mso_request_delete_or_unassign_service_instance.json";
+ private static final String ACTIVATE_FABRIC_CONFIGURATION_REQUEST_DETAILS = "registration_to_simulator/body_jsons/mso_request_activate_fabric_configuration.json";
+ private static final String DEACTIVATE_AND_CLOUD_DELETE_DATA = "registration_to_simulator/body_jsons/mso_request_deactivate_and_cloud_delete.json";
//Jsons
private static final String ACTIVATE_OK_JSON = "activate_service_instance.json";
@@ -35,7 +44,8 @@ public class ServiceInstanceMsoApiTest extends BaseMsoApiTest{
//Expected Responses
private static final String EXPECTED_SUCCESS_MSO_RESPONSE = "{\"requestReferences\": {\"instanceId\": \"f36f5734-e9df-4fbf-9f35-61be13f028a1\", \"requestId\": \"b6dc9806-b094-42f7-9386-a48de8218ce8\"}}";
- private static final String EXPECTED_ERROR_MSO_RESPONSE = "{\"error\":\"222\",\"message\":\"error message\"}";
+ private static final String EXPECTED_ERROR_MSO_RESPONSE = "{\"message\":\"error message\",\"error\":\"222\"}";
+
@Test
public void testActivateServiceInstanceSucceed() throws Exception {
@@ -118,4 +128,37 @@ public class ServiceInstanceMsoApiTest extends BaseMsoApiTest{
buildUri(MSO_DEACTIVATE_SERVICE_INSTANCE), requestBody, errorCode, EXPECTED_ERROR_MSO_RESPONSE, HttpMethod.POST);
}
+
+ @Test
+ public void testActivateFabricConfigurationSucceed() throws Exception {
+ String requestBody = TestUtils.convertRequest(objectMapper, ACTIVATE_FABRIC_CONFIGURATION_REQUEST_DETAILS);
+ callMsoWithFineRequest(new PresetMSOActivateFabricConfiguration("f36f5734-e9df-4fbf-9f35-61be13f028a1", "b6dc9806-b094-42f7-9386-a48de8218ce8"), buildUri(MSO_ACTIVATE_FABRIC_CONFIGURATION), requestBody,
+ HttpStatus.ACCEPTED.value(), EXPECTED_SUCCESS_MSO_RESPONSE, HttpMethod.POST);
+ }
+
+ @Test(dataProvider = "errorCodes")
+ public void testActivateFabricConfigurationFailed(int errorCode) throws IOException, URISyntaxException {
+ String requestBody = TestUtils.convertRequest(objectMapper, ACTIVATE_FABRIC_CONFIGURATION_REQUEST_DETAILS);
+ callMsoWithSimulatedErrorResponse(new PresetMSOActivateFabricConfigurationErrorResponse("f36f5734-e9df-4fbf-9f35-61be13f028a1", errorCode),
+ buildUri(MSO_ACTIVATE_FABRIC_CONFIGURATION), requestBody, errorCode, EXPECTED_ERROR_MSO_RESPONSE, HttpMethod.POST);
+ }
+
+ @Test
+ public void testDeactivateAndCloudDeleteSucceed() throws Exception {
+ String requestBody = TestUtils.convertRequest(objectMapper, DEACTIVATE_AND_CLOUD_DELETE_DATA);
+ callMsoWithFineRequest(ImmutableList.of(
+ new PresetMSODeactivateAndCloudDelete("f36f5734-e9df-4fbf-9f35-61be13f028a1", "vnfId", "vfModuleId", "b6dc9806-b094-42f7-9386-a48de8218ce8", "irma-aic"),
+ PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MTN6_TO_ATT_AIC),
+ buildUri(MSO_DEACTIVATE_AND_CLOUD_DELETE), requestBody,
+ HttpStatus.ACCEPTED.value(), EXPECTED_SUCCESS_MSO_RESPONSE, HttpMethod.POST);
+ }
+
+ @Test(dataProvider = "errorCodes")
+ public void testDeactivateAndCloudDeleteFailed(int errorCode) throws IOException, URISyntaxException {
+ String requestBody = TestUtils.convertRequest(objectMapper, DEACTIVATE_AND_CLOUD_DELETE_DATA);
+ callMsoWithSimulatedErrorResponse(ImmutableList.of(
+ new PresetMSODeactivateAndCloudDeleteErrorResponse("f36f5734-e9df-4fbf-9f35-61be13f028a1", "vnfId", "vfModuleId", errorCode, "irma-aic"),
+ PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MTN6_TO_ATT_AIC),
+ buildUri(MSO_DEACTIVATE_AND_CLOUD_DELETE), requestBody, errorCode, EXPECTED_ERROR_MSO_RESPONSE, HttpMethod.POST);
+ }
}
diff --git a/vid-automation/src/test/java/org/onap/vid/api/ServicePermissionsApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/ServicePermissionsApiTest.java
new file mode 100644
index 000000000..385ec9b0d
--- /dev/null
+++ b/vid-automation/src/test/java/org/onap/vid/api/ServicePermissionsApiTest.java
@@ -0,0 +1,63 @@
+package org.onap.vid.api;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import org.onap.sdc.ci.tests.datatypes.UserCredentials;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import vid.automation.test.Constants;
+import vid.automation.test.model.User;
+import vid.automation.test.services.SimulatorApi;
+
+public class ServicePermissionsApiTest extends BaseApiTest {
+
+ private final String emanuelSubscriberId = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb";
+ private final String uspVoiceSubscriberId = "e433710f-9217-458d-a79d-1c7aff376d89";
+
+ @BeforeClass
+ public void setAaiSubscribers() {
+ SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET);
+ }
+
+ @Test
+ public void servicePermissions_loginWithPermissions_1IsPermitted1NotPermitted() {
+ login(userCredentials(Constants.Users.EMANUEL_vWINIFRED));
+ assertPermissions(emanuelSubscriberId, "vRichardson", true);
+ assertPermissions(emanuelSubscriberId, "someNonexistent", false);
+ }
+
+ @Test
+ public void servicePermissions_loginPermissionsWithTenant_IsPermittedRegardlessOfTenant() {
+ login(userCredentials("Emanuel_with_tenant"));
+ assertPermissions(emanuelSubscriberId, "vWINIFRED", true);
+ }
+
+ @Test
+ public void servicePermissions_loginWithNoPermissionsAtAll_nothingIsPermitted() {
+ login(userCredentials(Constants.Users.READONLY));
+ assertPermissions(emanuelSubscriberId, "vRichardson", false);
+ assertPermissions(emanuelSubscriberId, "someNonexistent", false);
+ }
+
+ @Test
+ public void servicePermissions_serviceTypeWithSpace_isPermitted() {
+ login(userCredentials(Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA));
+ assertPermissions(uspVoiceSubscriberId, "TYLER SILVIA", true);
+ }
+
+ private UserCredentials userCredentials(String userName) {
+ User user = usersService.getUser(userName);
+ return new UserCredentials(user.credentials.userId, user.credentials.password, userName, "", "");
+ }
+
+ private void assertPermissions(final String subscriberId, final String serviceType, boolean isEditPermitted) {
+ final Map response = restTemplate.getForObject(uri + "/roles/service_permissions?subscriberId=" + subscriberId + "&serviceType=" + serviceType, Map.class);
+ assertThat(response, is(ImmutableMap.of(
+ "isEditPermitted", isEditPermitted
+ )));
+ }
+}
diff --git a/vid-automation/src/test/java/org/onap/vid/api/ServiceTreeApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/ServiceTreeApiTest.java
new file mode 100644
index 000000000..52aa2e388
--- /dev/null
+++ b/vid-automation/src/test/java/org/onap/vid/api/ServiceTreeApiTest.java
@@ -0,0 +1,370 @@
+package org.onap.vid.api;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.Multimap;
+import org.onap.simulator.presetGenerator.presets.aai.*;
+import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet;
+import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceMetadataGet;
+import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGet;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import vid.automation.test.services.SimulatorApi;
+
+import java.util.UUID;
+
+import static org.apache.commons.text.StringEscapeUtils.escapeJson;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET;
+
+public class ServiceTreeApiTest extends BaseApiTest {
+
+ private static final String API_URL = "/aai_get_service_instance_topology/{subscriberId}/{serviceType}/{serviceInstanceId}";
+
+ @BeforeClass
+ public void login() {
+ super.login();
+ }
+
+ @Test
+ public void serviceWithNoChildren_requestDoesSomething() {
+ final PresetAAIStandardQueryGet serviceInstance =
+ PresetAAIStandardQueryGet.ofServiceInstance("service-instance-id", "7a6ee536-f052-46fa-aa7e-2fca9d674c44", "service-instance-model-invariant-id", "global-customer-id", "service-instance-type", ImmutableMultimap.of());
+
+ SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
+ serviceInstance,
+ new PresetAAIModelsByInvariantIdGet(ImmutableList.of("service-instance-model-invariant-id")),
+ new PresetSDCGetServiceMetadataGet("7a6ee536-f052-46fa-aa7e-2fca9d674c44", "service-instance-model-invariant-id", "csar15782222_instantiationTypeMacroWithNetwork.zip"),
+ new PresetSDCGetServiceToscaModelGet("7a6ee536-f052-46fa-aa7e-2fca9d674c44", "csar15782222_instantiationTypeMacroWithNetwork.zip")
+ ), CLEAR_THEN_SET);
+ final String response = restTemplate.getForObject(buildUri(API_URL), String.class, "global-customer-id", "service-instance-type", "service-instance-id");
+
+ assertJsonEquals(response, "" +
+ "{" +
+ " \"instanceName\": \"" + escapeJson(serviceInstance.getInstanceName()) + "\"," +
+ " \"action\": \"None\"," +
+ " \"instanceId\": \"service-instance-id\"," +
+ " \"orchStatus\": \"GARBAGE DATA\"," +
+ " \"globalSubscriberId\": \"global-customer-id\"," +
+ " \"subscriptionServiceType\": \"service-instance-type\"," +
+ " \"owningEntityId\": null," +
+ " \"owningEntityName\": null," +
+ " \"productFamilyId\": null," +
+ " \"lcpCloudRegionId\": null," +
+ " \"tenantId\": null," +
+ " \"tenantName\": null," +
+ " \"aicZoneId\": null," +
+ " \"aicZoneName\": null," +
+ " \"projectName\": null," +
+ " \"rollbackOnFailure\": null," +
+ " \"modelInfo\": {" +
+ " \"modelInvariantId\": \"service-instance-model-invariant-id\"," +
+ " \"modelVersionId\": \"7a6ee536-f052-46fa-aa7e-2fca9d674c44\"," +
+ " \"modelName\": \"vf_vEPDG\"," +
+ " \"modelType\": \"service\"," +
+ " \"modelVersion\": \"2.0\"" +
+ " }," +
+ " \"vnfs\": {}," +
+ " \"networks\": {}," +
+ " \"vnfGroups\": {}," +
+ " \"validationCounter\": 0," +
+ " \"existingVNFCounterMap\": {}," +
+ " \"existingNetworksCounterMap\": {}," +
+ " \"existingVnfGroupCounterMap\": {}," +
+ " \"isALaCarte\": false" +
+ "}");
+ }
+
+ @Test
+ public void searchGroupMembers_expected4vnfs() {
+ PresetAAIStandardQueryGet instanceGroup1 = PresetAAIStandardQueryGet.ofInstanceGroup("L3-NETWORK", "SUB_INTERFACE", ImmutableMultimap.of());
+ PresetAAIStandardQueryGet instanceGroup2 = PresetAAIStandardQueryGet.ofInstanceGroup("LOAD-GROUP", "SERVICE-ACCESS", ImmutableMultimap.of());
+
+ PresetAAIStandardQueryGet vnfPreset1 =
+ PresetAAIStandardQueryGet.ofRelatedVnf(randUuid(), "7a6ee536-f052-46fa-aa7e-2fca9d674c44", "",
+ ImmutableMultimap.of("instance-group", instanceGroup1.getReqPath()));
+
+ PresetAAIStandardQueryGet vnfPreset2 =
+ PresetAAIStandardQueryGet.ofRelatedVnf(randUuid(), "eb5f56bf-5855-4e61-bd00-3e19a953bf02",
+ "\"in-maint\": true,", ImmutableMultimap.of());
+
+ PresetAAIStandardQueryGet vnfPreset3 =
+ PresetAAIStandardQueryGet.ofRelatedVnf(randUuid(), "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc", "",
+ ImmutableMultimap.of("instance-group", instanceGroup1.getReqPath()));
+
+ PresetAAIStandardQueryGet vnfPreset4 =
+ PresetAAIStandardQueryGet.ofRelatedVnf(randUuid(), "b7f2e8fb-ac71-4ea0-a801-06ef1479ea84",
+ "\"in-maint\": true,", ImmutableMultimap.of());
+
+ PresetAAIStandardQueryGet vnfPreset5 =
+ PresetAAIStandardQueryGet.ofRelatedVnf(randUuid(), "b7f2e8fb-ac71-4ea0-a801-06ef1479ea84",
+ "\"in-maint\": true,", ImmutableMultimap.of("instance-group", instanceGroup2.getReqPath()));
+
+ Multimap<String, String> serviceInstance1 = ImmutableMultimap.<String, String>builder()
+ .putAll("generic-vnf", vnfPreset1.getReqPath())
+ .putAll("generic-vnf", vnfPreset3.getReqPath())
+ .build();
+
+ Multimap<String, String> serviceInstance2 = ImmutableMultimap.<String, String>builder()
+ .putAll("generic-vnf", vnfPreset2.getReqPath())
+ .putAll("generic-vnf", vnfPreset4.getReqPath())
+ .putAll("generic-vnf", vnfPreset5.getReqPath())
+ .build();
+
+ PresetAAIGetServiceInstancesByInvariantId serviceInstancesList = new PresetAAIGetServiceInstancesByInvariantId(
+ "global-customer-id", "service-instance-type", "24632e6b-584b-4f45-80d4-fefd75fd9f14",
+ ImmutableMap.of("service-instance-id1", serviceInstance1,
+ "service-instance-id2", serviceInstance2));
+
+
+ SimulatorApi.registerExpectationFromPresets(
+ ImmutableList.of(serviceInstancesList,
+ vnfPreset1, instanceGroup1,
+ vnfPreset2,
+ vnfPreset3,
+ vnfPreset4,
+ vnfPreset5, instanceGroup2, //this vnf should be filtered out
+ new PresetAAIModelsByInvariantIdGet(ImmutableList.of("vnf-instance-model-invariant-id")),
+ new PresetAAIGetCloudRegionFromVnf(vnfPreset1.getInstanceId()),
+ new PresetAAIGetCloudRegionFromVnf(vnfPreset2.getInstanceId()),
+ new PresetAAIGetCloudRegionFromVnf(vnfPreset3.getInstanceId()),
+ new PresetAAIGetCloudRegionFromVnf(vnfPreset4.getInstanceId())
+ ), CLEAR_THEN_SET);
+
+ String api_url = "aai_search_group_members?subscriberId={subscriberId}&serviceType={serviceType}&serviceInvariantId={serviceInvariantId}" +
+ "&groupType={groupType}&groupRole={groupRole}";
+
+ final String response = restTemplate.getForObject(buildUri(api_url), String.class, "global-customer-id", "service-instance-type", "24632e6b-584b-4f45-80d4-fefd75fd9f14", "LOAD-GROUP", "SERVICE-ACCESS");
+
+ LOGGER.info(response);
+
+ String expected = TestUtils.convertRequest(objectMapper, "VnfGroup/searchMembersResponse.json");
+ expected = expected
+ .replace("VNF1_INSTANCE_NAME", vnfPreset1.getInstanceName())
+ .replace("VNF1_INSTANCE_ID", vnfPreset1.getInstanceId())
+ .replace("VNF1_INSTANCE_TYPE", vnfPreset1.getInstanceType())
+ .replace("VNF2_INSTANCE_NAME", vnfPreset2.getInstanceName())
+ .replace("VNF2_INSTANCE_ID", vnfPreset2.getInstanceId())
+ .replace("VNF2_INSTANCE_TYPE", vnfPreset2.getInstanceType())
+ .replace("VNF3_INSTANCE_NAME", vnfPreset3.getInstanceName())
+ .replace("VNF3_INSTANCE_ID", vnfPreset3.getInstanceId())
+ .replace("VNF3_INSTANCE_TYPE", vnfPreset3.getInstanceType())
+ .replace("VNF4_INSTANCE_NAME", vnfPreset4.getInstanceName())
+ .replace("VNF4_INSTANCE_ID", vnfPreset4.getInstanceId())
+ .replace("VNF4_INSTANCE_TYPE", vnfPreset4.getInstanceType());
+
+ assertJsonEquals(response, expected);
+ }
+
+ @Test
+ public void searchGroupMembers_expectedNoResult() {
+ PresetAAIGetServiceInstancesByInvariantId serviceInstancesList = new PresetAAIGetServiceInstancesByInvariantId(
+ "global-customer-id", "service-instance-type", "24632e6b-584b-4f45-80d4-fefd75fd9f14",
+ ImmutableMap.of("service-instance-id1", ImmutableMultimap.of(),
+ "service-instance-id2", ImmutableMultimap.of()));
+
+
+ SimulatorApi.registerExpectationFromPreset(serviceInstancesList, CLEAR_THEN_SET);
+
+ String api_url = "aai_search_group_members?subscriberId={subscriberId}&serviceType={serviceType}&serviceInvariantId={serviceInvariantId}" +
+ "&groupType={groupType}&groupRole={groupRole}";
+
+ final String response = restTemplate.getForObject(buildUri(api_url), String.class, "global-customer-id", "service-instance-type", "24632e6b-584b-4f45-80d4-fefd75fd9f14", "LOAD-GROUP", "SERVICE-ACCESS");
+
+ assertJsonEquals(response, "[]");
+ }
+
+ @Test
+ public void serviceWithMultiplePlys_responseIsReasonable() {
+
+ PresetAAIStandardQueryGet l3NetworkPreset1 =
+ PresetAAIStandardQueryGet.ofL3Network("CONTRAIL30_BASIC", "Assigned",
+ ImmutableMultimap.of());
+
+ PresetAAIStandardQueryGet vlanTag1 = PresetAAIStandardQueryGet.ofVlanTag(44);
+
+ PresetAAIStandardQueryGet l3NetworkPreset2 =
+
+ PresetAAIStandardQueryGet.ofL3Network("CONTRAIL30_BASIC", "Created",
+ ImmutableMultimap.of("vlan-tag", vlanTag1.getReqPath()));
+
+ PresetAAIStandardQueryGet l3NetworkPreset3 =
+ PresetAAIStandardQueryGet.ofL3Network("CONTRAIL30_BASIC", "Assigned", "nvtprov", "ddc3f20c-08b5-40fd-af72-c6d14636b986","94fdd893-4a36-4d70-b16a-ec29c54c184f",
+ ImmutableMultimap.of());
+
+ PresetAAIStandardQueryGet l3NetworkPreset4 =
+ PresetAAIStandardQueryGet.ofL3Network("CONTRAIL30_HIMELGUARD", "Created", "preprov", "ddc3f20c-08b5-40fd-af72-c6d14636b986","94fdd893-4a36-4d70-b16a-ec29c54c184f",
+ ImmutableMultimap.of());
+
+ PresetAAIStandardQueryGet volumeGroup1 =
+ PresetAAIStandardQueryGet.ofVolumeGroup("vSON_test", ImmutableMultimap.of());
+
+ PresetAAIStandardQueryGet instanceGroup1 = PresetAAIStandardQueryGet.ofInstanceGroup("L3-NETWORK", "Ruby Figueroa", ImmutableMultimap.of());
+
+ PresetAAIStandardQueryGet collection1 =
+ PresetAAIStandardQueryGet.ofCollectionResource("Assigned",
+ ImmutableMultimap.of("instance-group", instanceGroup1.getReqPath()));
+
+ PresetAAIStandardQueryGet vnfPreset1 =
+ PresetAAIStandardQueryGet.ofVnf(randUuid(),
+ ImmutableMultimap.of("l3-network", l3NetworkPreset1.getReqPath(), "l3-network", l3NetworkPreset2.getReqPath()));
+
+ PresetAAIStandardQueryGet vnfPreset2 =
+ PresetAAIStandardQueryGet.ofVnf(randUuid(), "d6557200-ecf2-4641-8094-5393ae3aae60","91415b44-753d-494c-926a-456a9172bbb9",
+ "\"in-maint\": true,", ImmutableMultimap.of("volume-group", volumeGroup1.getReqPath()));
+
+ PresetAAIGetVfModulesByVnf vfModules2 = new PresetAAIGetVfModulesByVnf(vnfPreset2.getInstanceId());
+
+ final PresetAAIStandardQueryGet serviceInstance =
+ PresetAAIStandardQueryGet.ofServiceInstance("service-instance-id", "6e59c5de-f052-46fa-aa7e-2fca9d674c44", "d27e42cf-087e-4d31-88ac-6c4b7585f800", "global-customer-id", "service-instance-type",
+ ImmutableMultimap.<String, String>builder()
+ .putAll("l3-network", l3NetworkPreset3.getReqPath(), l3NetworkPreset4.getReqPath())
+ .putAll("collection", collection1.getReqPath())
+ .putAll("generic-vnf", vnfPreset1.getReqPath(), vnfPreset2.getReqPath())
+ .build()
+ );
+
+ SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
+ serviceInstance,
+ l3NetworkPreset3, l3NetworkPreset4, vnfPreset1, vnfPreset2, collection1,
+ volumeGroup1, l3NetworkPreset1, l3NetworkPreset2, instanceGroup1,
+ vlanTag1, vfModules2,
+ new PresetAAIModelsByInvariantIdGet(ImmutableList.of("d27e42cf-087e-4d31-88ac-6c4b7585f800")),
+ new PresetGetSessionSlotCheckIntervalGet(),
+ new PresetAAIGetSubscribersGet(),
+ new PresetSDCGetServiceMetadataGet("6e59c5de-f052-46fa-aa7e-2fca9d674c44", "d27e42cf-087e-4d31-88ac-6c4b7585f800", "csar15782222_instantiationTypeMacroWithNetwork.zip"),
+ new PresetSDCGetServiceToscaModelGet("6e59c5de-f052-46fa-aa7e-2fca9d674c44", "csar15782222_instantiationTypeMacroWithNetwork.zip")
+ ), CLEAR_THEN_SET);
+
+ String expected = TestUtils.convertRequest(objectMapper, "aaiGetInstanceTopology/ServiceTreeWithMultipleChildren_serviceInstance.json");
+ expected = expected
+ .replace("SERVICE_INSTANCE_NAME", serviceInstance.getInstanceName())
+ .replace("VNF1_INSTANCE_NAME", vnfPreset1.getInstanceName())
+ .replace("VNF1_INSTANCE_ID", vnfPreset1.getInstanceId())
+ .replace("VNF1_INSTANCE_TYPE", vnfPreset1.getInstanceType())
+ .replace("VNF2_INSTANCE_NAME", vnfPreset2.getInstanceName())
+ .replace("VNF2_INSTANCE_ID", vnfPreset2.getInstanceId())
+ .replace("VNF2_INSTANCE_TYPE", vnfPreset2.getInstanceType())
+ .replace("NETWORK1_INSTANCE_NAME", l3NetworkPreset1.getInstanceName())
+ .replace("NETWORK1_INSTANCE_ID", l3NetworkPreset1.getInstanceId())
+ .replace("NETWORK2_INSTANCE_NAME", l3NetworkPreset2.getInstanceName())
+ .replace("NETWORK2_INSTANCE_ID", l3NetworkPreset2.getInstanceId())
+ .replace("NETWORK3_INSTANCE_NAME", l3NetworkPreset3.getInstanceName())
+ .replace("NETWORK3_INSTANCE_ID", l3NetworkPreset3.getInstanceId())
+ .replace("NETWORK4_INSTANCE_NAME", l3NetworkPreset4.getInstanceName())
+ .replace("NETWORK4_INSTANCE_ID", l3NetworkPreset4.getInstanceId());
+
+ String response = restTemplate.getForObject(buildUri(API_URL), String.class, "global-customer-id", "service-instance-type", "service-instance-id");
+
+ assertJsonEquals(response, expected);
+ }
+
+ @Test
+ public void serviceWithVnfGotError_exceptionIsThrown() {
+
+ PresetAAIStandardQueryGet vnfPreset =
+ PresetAAIStandardQueryGet.ofVnf(randUuid(),
+ ImmutableMultimap.of("l3-network", "/aai/v../I'm a wrong path"));
+
+ final PresetAAIStandardQueryGet serviceInstance =
+ PresetAAIStandardQueryGet.ofServiceInstance("service-instance-id", "7a6ee536-f052-46fa-aa7e-2fca9d674c44", "service-instance-model-invariant-id", "global-customer-id", "service-instance-type",
+ ImmutableMultimap.<String, String>builder()
+ .putAll("generic-vnf", vnfPreset.getReqPath())
+ .build()
+ );
+
+ SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
+ serviceInstance,
+ vnfPreset,
+ new PresetAAIModelsByInvariantIdGet(ImmutableList.of("service-instance-model-invariant-id")),
+ new PresetSDCGetServiceMetadataGet("7a6ee536-f052-46fa-aa7e-2fca9d674c44", "service-instance-model-invariant-id", "csar15782222_instantiationTypeMacroWithNetwork.zip"),
+ new PresetSDCGetServiceToscaModelGet("7a6ee536-f052-46fa-aa7e-2fca9d674c44", "csar15782222_instantiationTypeMacroWithNetwork.zip"),
+ new PresetGetSessionSlotCheckIntervalGet(),
+ new PresetAAIGetSubscribersGet()
+ ), CLEAR_THEN_SET);
+
+ final ResponseEntity<String> response = restTemplateErrorAgnostic.getForEntity(buildUri(API_URL), String.class, "global-customer-id", "service-instance-type", "service-instance-id");
+ assertThat(response.getBody(),containsString("AAI node fetching failed"));
+ assertThat(response.getStatusCode(), is(HttpStatus.INTERNAL_SERVER_ERROR));
+ }
+
+ @Test
+ public void serviceWithTwoVnfGroupsAndRelatedVnfs() {
+ PresetAAIStandardQueryGet relatedVnf1 =
+ PresetAAIStandardQueryGet.ofRelatedVnf(randUuid(), "7a6ee536-f052-46fa-aa7e-2fca9d674c44",
+ "", ImmutableMultimap.of());
+
+ PresetAAIStandardQueryGet relatedVnf2 =
+ PresetAAIStandardQueryGet.ofRelatedVnf(randUuid(), "d6557200-ecf2-4641-8094-5393ae3aae60",
+ "", ImmutableMultimap.of());
+
+ PresetAAIStandardQueryGet relatedVnf3 =
+ PresetAAIStandardQueryGet.ofRelatedVnf(randUuid(), "d6557200-ecf2-4641-8094-5393ae3aae60",
+ "", ImmutableMultimap.of());
+
+ final PresetAAIStandardQueryGet vnfGroup1 =
+ PresetAAIStandardQueryGet.ofInstanceGroup("vnfGroup-type", "Teresa Bradley",
+ ImmutableMultimap.<String, String>builder()
+ .putAll("generic-vnf", relatedVnf1.getReqPath(), relatedVnf2.getReqPath(), relatedVnf3.getReqPath())
+ .build()
+ );
+
+ final PresetAAIStandardQueryGet vnfGroup2 =
+ PresetAAIStandardQueryGet.ofInstanceGroup("vnfGroup-type", "Stanley Mccarthy", ImmutableMultimap.of());
+
+ final PresetAAIStandardQueryGet serviceInstance =
+ PresetAAIStandardQueryGet.ofServiceInstance("service-instance-id", "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc", "7ee41ce4-4827-44b0-a48e-2707a59905d2", "global-customer-id", "service-instance-type",
+ ImmutableMultimap.<String, String>builder()
+ .putAll("instance-group", vnfGroup1.getReqPath(),vnfGroup2.getReqPath())
+ .build()
+ );
+
+ SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
+ serviceInstance,
+ vnfGroup1,vnfGroup2, relatedVnf1, relatedVnf2, relatedVnf3,
+ new PresetAAIModelsByInvariantIdGet(ImmutableList.of("7ee41ce4-4827-44b0-a48e-2707a59905d2", "vnf-instance-model-invariant-id")),
+ new PresetGetSessionSlotCheckIntervalGet(),
+ new PresetAAIGetSubscribersGet(),
+ new PresetSDCGetServiceMetadataGet("4117a0b6-e234-467d-b5b9-fe2f68c8b0fc", "7ee41ce4-4827-44b0-a48e-2707a59905d2", "service-vnf-grouping-csar.zip"),
+ new PresetSDCGetServiceToscaModelGet("4117a0b6-e234-467d-b5b9-fe2f68c8b0fc", "service-vnf-grouping-csar.zip")
+ ), CLEAR_THEN_SET);
+
+ String expected = TestUtils.convertRequest(objectMapper, "VnfGroup/serviceWithVnfGroupsChildren_serviceInstance.json");
+ expected = expected
+ .replace("SERVICE_INSTANCE_NAME", serviceInstance.getInstanceName())
+ .replace("VNF_GROUP1_INSTANCE_ID", vnfGroup1.getInstanceId())
+ .replace("VNF_GROUP1_INSTANCE_NAME", vnfGroup1.getInstanceName())
+ .replace("VNF_GROUP1_INSTANCE_TYPE", vnfGroup1.getInstanceType())
+ .replace("VNF_GROUP1_INSTANCE_ROLE", vnfGroup1.getInstanceRole())
+
+ .replace("RELATED_VNF1_INSTANCE_ID", relatedVnf1.getInstanceId())
+ .replace("RELATED_VNF1_INSTANCE_NAME", relatedVnf1.getInstanceName())
+ .replace("RELATED_VNF1_INSTANCE_TYPE", relatedVnf1.getInstanceType())
+
+ .replace("RELATED_VNF2_INSTANCE_ID", relatedVnf2.getInstanceId())
+ .replace("RELATED_VNF2_INSTANCE_NAME", relatedVnf2.getInstanceName())
+ .replace("RELATED_VNF2_INSTANCE_TYPE", relatedVnf2.getInstanceType())
+
+ .replace("RELATED_VNF3_INSTANCE_ID", relatedVnf3.getInstanceId())
+ .replace("RELATED_VNF3_INSTANCE_NAME", relatedVnf3.getInstanceName())
+ .replace("RELATED_VNF3_INSTANCE_TYPE", relatedVnf3.getInstanceType())
+
+ .replace("VNF_GROUP2_INSTANCE_ID", vnfGroup2.getInstanceId())
+ .replace("VNF_GROUP2_INSTANCE_NAME", vnfGroup2.getInstanceName())
+ .replace("VNF_GROUP2_INSTANCE_TYPE", vnfGroup2.getInstanceType())
+ .replace("VNF_GROUP2_INSTANCE_ROLE", vnfGroup2.getInstanceRole());
+
+ final String response = restTemplate.getForObject(buildUri(API_URL), String.class, "global-customer-id", "service-instance-type", "service-instance-id");
+
+ assertJsonEquals(response, expected);
+ }
+
+ private String randUuid() {
+ return UUID.randomUUID().toString();
+ }
+}
diff --git a/vid-automation/src/test/java/org/onap/vid/api/TestUtils.java b/vid-automation/src/test/java/org/onap/vid/api/TestUtils.java
deleted file mode 100644
index 76c122c48..000000000
--- a/vid-automation/src/test/java/org/onap/vid/api/TestUtils.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.onap.vid.api;
-
-import org.codehaus.jackson.JsonParser;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.SerializationConfig;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
-import org.springframework.core.io.support.ResourcePatternResolver;
-import org.springframework.http.HttpStatus;
-
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.Response;
-import java.io.File;
-import java.io.IOException;
-import java.util.Map;
-import java.util.Scanner;
-
-/**
- * Created by Oren on 6/7/17.
- */
-public class TestUtils {
-
- protected static ObjectMapper objectMapper = new ObjectMapper();
-
- public static void assertStatusOK(Object request, WebTarget webTarget, Response response) throws IOException {
- assertHttpStatus(request, webTarget, response, HttpStatus.OK);
- }
-
- public static void assertHttpStatus(Object request, WebTarget webTarget, Response response, HttpStatus exceptedHttpStatus) throws IOException {
- objectMapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
-
- org.testng.Assert.assertEquals(response.getStatus(), exceptedHttpStatus.value(),
- String.format("Failed post URI: %s with request %s. Got Status:%d and body: %s",
- webTarget.getUri(),
- objectMapper.writeValueAsString(request),
- response.getStatus(),
- objectMapper.writeValueAsString(response.getEntity())));
- }
-
- public static String convertRequest(ObjectMapper objectMapper, String msoRequestDetailsFileName) {
-
- ClassLoader cl = pProbeMsoApiTest.class.getClassLoader();
- ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(cl);
- Resource[] resources;
- try {
- resources = resolver.getResources(msoRequestDetailsFileName);
- String content;
- File file = resources[0].getFile();
- content = new Scanner(file).useDelimiter("\\Z").next();
- objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
- return objectMapper.writeValueAsString(objectMapper.readValue(content, Object.class));
- }
- catch (IOException e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
-
- public static String getNestedPropertyInMap(Object item, String path) {
- return getNestedPropertyInMap(item, path, String.class, "/");
- }
-
- public static <T> T getNestedPropertyInMap(Object item, String path, Class<T> valueType) {
- return getNestedPropertyInMap(item, path, valueType, "/");
- }
-
- /*
- Use this method to extract item from Map that represent Json hierarchy (Map<String,Map>)
- */
- public static <T> T getNestedPropertyInMap(Object item, String path, Class<T> valueType, String delimeter) {
- String[] pathes = path.split(delimeter);
- return valueType.cast(getNestedPropertyInMap(item,pathes,0));
- }
-
- private static Object getNestedPropertyInMap(Object item, String[] pathes, int index) {
- if (index==pathes.length) {
- return item;
- }
- return getNestedPropertyInMap(((Map<String,Object>)item).get(pathes[index]), pathes, ++index);
- }
-}
diff --git a/vid-automation/src/test/java/org/onap/vid/api/VersionControllerApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/VersionControllerApiTest.java
new file mode 100644
index 000000000..4dc799193
--- /dev/null
+++ b/vid-automation/src/test/java/org/onap/vid/api/VersionControllerApiTest.java
@@ -0,0 +1,26 @@
+package org.onap.vid.api;
+
+import org.junit.Assert;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
+import org.testng.annotations.Test;
+
+import java.util.HashMap;
+
+public class VersionControllerApiTest extends BaseApiTest {
+
+ @Test
+ public void probeRequest_returnsResponseAsExpected() {
+ // without log-in
+ ResponseEntity<HashMap<String, String>> response = new RestTemplate().exchange(
+ uri + "/version",
+ org.springframework.http.HttpMethod.GET,
+ null,
+ new ParameterizedTypeReference<HashMap<String, String>>() {
+ });
+ HashMap<String,String> versionResults = response.getBody();
+ Assert.assertNotNull(versionResults.get("features"));
+ Assert.assertNotNull(versionResults.get("build"));
+ }
+}
diff --git a/vid-automation/src/test/java/org/onap/vid/api/VidConfigurationApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/VidConfigurationApiTest.java
index 38ce8613d..ec479d900 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/VidConfigurationApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/VidConfigurationApiTest.java
@@ -4,6 +4,7 @@ import org.springframework.http.ResponseEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import static java.util.Collections.singletonList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
diff --git a/vid-automation/src/test/java/org/onap/vid/api/pProbeAaiApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/pProbeAaiApiTest.java
index 1765645af..db10fdc57 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/pProbeAaiApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/pProbeAaiApiTest.java
@@ -1,6 +1,13 @@
package org.onap.vid.api;
+import static vid.automation.test.services.SimulatorApi.RegistrationStrategy;
+import static vid.automation.test.services.SimulatorApi.registerExpectation;
+
import com.google.common.collect.ImmutableMap;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
import org.apache.commons.text.StringEscapeUtils;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
@@ -9,14 +16,6 @@ import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-
-import static vid.automation.test.services.SimulatorApi.RegistrationStrategy;
-import static vid.automation.test.services.SimulatorApi.registerExpectation;
-
public class pProbeAaiApiTest extends BaseApiAaiTest {
@@ -36,7 +35,7 @@ public class pProbeAaiApiTest extends BaseApiAaiTest {
//URIs
private static final String GET_SERVICE_INSTANCE_PNFS = "aai_get_service_instance_pnfs/31739f3e-526b-11e6-beb8-9e71128cae77/AIM Transport/f36f5734-e9df-4fbf-9f35-61be13f028a1";
private static final String GET_SPECIFIC_PNF_URI = "aai_get_pnfs/pnf/DEAAI78";
- private static final String GET_PNF_BY_REGION = "aai_get_pnf_instances/e433710f-9217-458d-a79d-1c7aff376d89/VIRTUAL USP/8a84e59b-45fe-4851-8ff1-34225a0b32c3/83b458fd-5dd3-419b-a9e3-7335814a0911/AAIAIC25/Cisco/Nexus 3048-TP";
+ private static final String GET_PNF_BY_REGION = "aai_get_pnf_instances/e433710f-9217-458d-a79d-1c7aff376d89/TYLER SILVIA/8a84e59b-45fe-4851-8ff1-34225a0b32c3/83b458fd-5dd3-419b-a9e3-7335814a0911/JANET25/Cisco/Nexus 3048-TP";
@@ -109,7 +108,7 @@ public class pProbeAaiApiTest extends BaseApiAaiTest {
@Test
public void testGetPnfDataByRegion() throws Exception {
- String expected = "{\"results\":[{\"id\":\"901128280\",\"url\":\"/aai/v12/network/pnfs/pnf/AS-pnf2-10219--as988q\",\"properties\":{\"pnfName\":\"AS-pnf2-10219--as988q\",\"equipType\":\"Switch\",\"equipVendor\":\"Cisco\",\"equipModel\":\"Nexus3048-TP\",\"inMaint\":false,\"resourceVersion\":\"1508776538192\"},\"nodeType\":\"pnf\",\"relatedTo\":[{\"id\":\"532488360\",\"url\":\"/aai/v12/business/customers/customer/customer-10219-as988q/service-subscriptions/service-subscription/serviceSub2-test-10219-as988q/service-instances/service-instance/serviceIns2-test-10219-as988q\",\"nodeType\":\"service-instance\",\"relationshipLabel\":\"uses\"},{\"id\":\"860164248\",\"url\":\"/aai/v12/cloud-infrastructure/complexes/complex/complex-10219--as988q\",\"nodeType\":\"complex\",\"relationshipLabel\":\"locatedIn\"}]}],\"additionalProperties\":{}}";
+ String expected = "{\"results\":[{\"id\":\"901128280\",\"url\":\"/aai/v12/network/pnfs/pnf/AS-pnf2-10219--as988q\",\"properties\":{\"pnfName\":\"AS-pnf2-10219--as988q\",\"equipType\":\"Switch\",\"equipVendor\":\"Cisco\",\"equipModel\":\"Nexus3048-TP\",\"inMaint\":false,\"resourceVersion\":\"1508776538192\"},\"nodeType\":\"pnf\",\"relatedTo\":[{\"id\":\"532488360\",\"url\":\"/aai/v12/business/customers/customer/customer-10219-as988q/service-subscriptions/service-subscription/serviceSub2-test-10219-as988q/service-instances/service-instance/serviceIns2-test-10219-as988q\",\"node-type\":\"service-instance\",\"relationship-label\":\"uses\"},{\"id\":\"860164248\",\"url\":\"/aai/v12/cloud-infrastructure/complexes/complex/complex-10219--as988q\",\"node-type\":\"complex\",\"relationship-label\":\"locatedIn\"}]}]}";
callAaiWithSimulatedErrorResponse(GET_PNF_BY_REGION_RESPONSE,
ImmutableMap.of(),
buildUri(GET_PNF_BY_REGION), "",200,expected, HttpMethod.GET);
@@ -136,7 +135,7 @@ public class pProbeAaiApiTest extends BaseApiAaiTest {
@Test
public void testGetPnfDataByRegionNoResults() throws IOException, URISyntaxException {
final String registratedResult = "{\"results\":[]}";
- final String expectedResult ="{\"results\":[],\"additionalProperties\":{}}";
+ final String expectedResult ="{\"results\":[]}";
final int expectedResponseCode = 200;
callAaiWithSimulatedErrorResponse(GET_PNF_BY_REGION_RESPONSE_EMPTY,
ImmutableMap.of("500", Integer.toString(expectedResponseCode),"\"ERROR_PAYLOAD\"", StringEscapeUtils.escapeJson(registratedResult)),
diff --git a/vid-automation/src/test/java/org/onap/vid/api/pProbeMsoApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/pProbeMsoApiTest.java
index c082ef95a..534dc6934 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/pProbeMsoApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/pProbeMsoApiTest.java
@@ -1,7 +1,11 @@
package org.onap.vid.api;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.text.StringEscapeUtils;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId;
+import org.onap.simulator.presetGenerator.presets.mso.configuration.PresetMSOActOnConfiguration;
+import org.onap.simulator.presetGenerator.presets.mso.configuration.PresetMSOCreateConfiguration;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.testng.annotations.Test;
@@ -15,7 +19,7 @@ public class pProbeMsoApiTest extends BaseMsoApiTest{
private static final String MSO_REMOVE_RELATIONSHIP = "/mso/mso_remove_relationship/f36f5734-e9df-4fbf-9f35-61be13f028a1";
private static final String MSO_ADD_RELATIONSHIP = "/mso/mso_add_relationship/f36f5734-e9df-4fbf-9f35-61be13f028a1";
public static final String MSO_CREATE_CONFIGURATION = "mso/mso_create_configuration_instance/f36f5734-e9df-4fbf-9f35-61be13f028a1/configurations/";
- public static final String MSO_ACTIVATE_CONFIGURATION = "mso/mso_activate_configuration/f36f5734-e9df-4fbf-9f35-61be13f028a1/configurations/a53c9ca8-8986-44da-9e5e-9e4179e6c78a";
+ public static final String MSO_ACTIVATE_CONFIGURATION = "mso/mso_activate_configuration/c187e9fe-40c3-4862-b73e-84ff056205f6/configurations/9533-config-LB1113";
@@ -24,15 +28,12 @@ public class pProbeMsoApiTest extends BaseMsoApiTest{
//Request Details
private static final String CREATE_CONFIGURATION_REQUEST_DETAILS = "registration_to_simulator/body_jsons/mso_request_create_configuration.json";
-
+ private static final String ACTIVATE_CONFIGURATION_REQUEST_DETAILS = "registration_to_simulator/body_jsons/mso_request_activate_configuration.json";
//Jsons
private static final String DISSOCIATE_OK_JSON = "dissociate_pnf_from_service_instance.json";
private static final String DISSOCIATE_FAILED_JSON = "dissociate_pnf_from_service_instance_error.json";
private static final String ASSOCIATE_OK_JSON = "mso_add_relationships.json";
private static final String ASSOCIATE_FAILED_JSON = "mso_add_relationships_error.json";
- private static final String CREATE_CONFIGURATION_OK_JSON = "mso_create_configurations.json";
- private static final String CREATE_CONFIGURATION_FAILED_JSON = "mso_create_configurations_error.json";
- private static final String ACTIVATE_CONFIGURATION_OK_JSON = "mso_activate_configurations.json";
//Expected Responses
private static final String EXPECTED_SUCCESS_MSO_RESPONSE = "{\"requestReferences\": {\"instanceId\": \"f36f5734-e9df-4fbf-9f35-61be13f028a1\", \"requestId\": \"b6dc9806-b094-42f7-9386-a48de8218ce8\"}}";
@@ -73,25 +74,31 @@ public class pProbeMsoApiTest extends BaseMsoApiTest{
@Test
public void testCreateConfigurationSucceed() throws Exception {
String requestBody = TestUtils.convertRequest(objectMapper, CREATE_CONFIGURATION_REQUEST_DETAILS);
- callMsoWithFineRequest(CREATE_CONFIGURATION_OK_JSON, ImmutableMap.of(), buildUri(MSO_CREATE_CONFIGURATION),
- requestBody, HttpStatus.ACCEPTED.value(),EXPECTED_SUCCESS_MSO_RESPONSE , HttpMethod.POST);
+ callMsoWithFineRequest(ImmutableList.of(
+ new PresetMSOCreateConfiguration("f36f5734-e9df-4fbf-9f35-61be13f028a1"),
+ PresetAAIGetCloudOwnersByCloudRegionId.PRESET_AAIAIC25_TO_ATT_AIC
+ ),
+ buildUri(MSO_CREATE_CONFIGURATION), requestBody,
+ HttpStatus.ACCEPTED.value(), EXPECTED_SUCCESS_MSO_RESPONSE, HttpMethod.POST);
}
@Test
public void testActivateConfigurationSucceed() throws Exception {
- String requestBody = "" +
- "{" +
- " \"val\": \"dummy payload\"" +
- "}";
- callMsoWithFineRequest(ACTIVATE_CONFIGURATION_OK_JSON, ImmutableMap.of(), buildUri(MSO_ACTIVATE_CONFIGURATION),
- requestBody, HttpStatus.ACCEPTED.value(),EXPECTED_SUCCESS_MSO_RESPONSE , HttpMethod.POST);
+ String requestBody = TestUtils.convertRequest(objectMapper, ACTIVATE_CONFIGURATION_REQUEST_DETAILS);
+ callMsoWithFineRequest(ImmutableList.of(
+ new PresetMSOActOnConfiguration("activate", "b6dc9806-b094-42f7-9386-a48de8218ce8", "f36f5734-e9df-4fbf-9f35-61be13f028a1"),
+ PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MDT1_TO_ATT_NC
+ ),
+ buildUri(MSO_ACTIVATE_CONFIGURATION),
+ requestBody, HttpStatus.ACCEPTED.value(), EXPECTED_SUCCESS_MSO_RESPONSE, HttpMethod.POST);
}
@Test(dataProvider = "errorCodes")
public void testCreateConfigurationError(int errorCode) throws IOException, URISyntaxException {
String requestBody = TestUtils.convertRequest(objectMapper, CREATE_CONFIGURATION_REQUEST_DETAILS);
- callMsoWithSimulatedErrorResponse(CREATE_CONFIGURATION_FAILED_JSON,
- ImmutableMap.of("\"<ERROR_CODE>\"", Integer.toString(errorCode),"\"<ERROR_PAYLOAD>\"", StringEscapeUtils.escapeJson(EXPECTED_ERROR_MSO_RESPONSE)),
+ callMsoWithSimulatedErrorResponse(ImmutableList.of(
+ new PresetMSOCreateConfiguration("f36f5734-e9df-4fbf-9f35-61be13f028a1", errorCode, EXPECTED_ERROR_MSO_RESPONSE),
+ PresetAAIGetCloudOwnersByCloudRegionId.PRESET_AAIAIC25_TO_ATT_AIC),
buildUri(MSO_CREATE_CONFIGURATION), requestBody,errorCode,EXPECTED_ERROR_MSO_RESPONSE,HttpMethod.POST);
}
@@ -99,8 +106,9 @@ public class pProbeMsoApiTest extends BaseMsoApiTest{
@Test
public void testCreateConfigurationFail() throws Exception {
String requestBody = "498/*ht5ru7 mjhnb";
- callMsoWithSimulatedErrorResponse(CREATE_CONFIGURATION_FAILED_JSON,
- ImmutableMap.of("\"<ERROR_CODE>\"", 500),
+ callMsoWithSimulatedErrorResponse(ImmutableList.of(
+ new PresetMSOCreateConfiguration("f36f5734-e9df-4fbf-9f35-61be13f028a1", 500, EXPECTED_ERROR_MSO_RESPONSE),
+ PresetAAIGetCloudOwnersByCloudRegionId.PRESET_AAIAIC25_TO_ATT_AIC),
buildUri(MSO_CREATE_CONFIGURATION), requestBody,500,EXPECTED_ERROR_MSO_RESPONSE,HttpMethod.POST);
}
diff --git a/vid-automation/src/test/java/org/onap/vid/model/asyncInstantiation/JobAuditStatus.java b/vid-automation/src/test/java/org/onap/vid/model/asyncInstantiation/JobAuditStatus.java
deleted file mode 100644
index 7c1481562..000000000
--- a/vid-automation/src/test/java/org/onap/vid/model/asyncInstantiation/JobAuditStatus.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package org.onap.vid.model.asyncInstantiation;
-
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-
-import java.util.UUID;
-
-
-public class JobAuditStatus {
-
- public JobAuditStatus(){}
-
-
- public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source){
- this.jobId = jobId;
- this.jobStatus = jobStatus;
- this.source = source;
- this.isFinal = isFinal();
- }
-
- public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source, UUID requestId, String additionalInfo, Boolean isFinal) {
- this(jobId, jobStatus, source);
- this.requestId = requestId;
- this.additionalInfo = additionalInfo;
- this.isFinal = isFinal;
- }
-
-
-
- public enum SourceStatus {
- MSO,
- VID
- }
-
- private UUID jobId;
- private String jobStatus;
- private SourceStatus source;
- private UUID requestId;
- private String additionalInfo;
-
-
-
- private Boolean isFinal;
-
- public String getJobStatus() {
- return jobStatus;
- }
-
- public UUID getJobId() {
- return jobId;
- }
-
- public SourceStatus getSource() {
- return source;
- }
-
- public String getAdditionalInfo() {
- return additionalInfo;
- }
-
- public UUID getRequestId() {
- return requestId;
- }
-
-
-
- public Boolean isFinal(){
- return isFinal;
- }
-
- public void setFinal(Boolean aFinal) {
- isFinal = aFinal;
- }
-
- @Override
- public String toString() {
- return "JobAuditStatus{" +
- "jobId=" + jobId +
- ", jobStatus='" + jobStatus + '\'' +
- ", source=" + source +
- ", requestId=" + requestId +
- ", additionalInfo='" + additionalInfo + '\'' +
- ", isFinal=" + isFinal +
- '}';
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
-
- if (o == null || getClass() != o.getClass()) return false;
-
- JobAuditStatus that = (JobAuditStatus) o;
-
- return new EqualsBuilder()
- .append(jobId, that.jobId)
- .append(jobStatus, that.jobStatus)
- .append(source, that.source)
- .append(requestId, that.requestId)
- .append(additionalInfo, that.additionalInfo)
- .append(isFinal, that.isFinal)
- .isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(17, 37)
- .append(jobId)
- .append(jobStatus)
- .append(source)
- .append(requestId)
- .append(additionalInfo)
- .append(isFinal)
- .toHashCode();
- }
-
-
-
-
-
-}
diff --git a/vid-automation/src/test/java/org/onap/vid/model/asyncInstantiation/ServiceInfo.java b/vid-automation/src/test/java/org/onap/vid/model/asyncInstantiation/ServiceInfo.java
deleted file mode 100644
index 371aaf81e..000000000
--- a/vid-automation/src/test/java/org/onap/vid/model/asyncInstantiation/ServiceInfo.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.onap.vid.model.asyncInstantiation;
-
-
-import vid.automation.test.model.JobStatus;
-
-import java.util.Date;
-
-public class ServiceInfo {
-
- public String jobId;
- public String templateId;
- public String userId;
- public JobStatus jobStatus;
- public Date statusModifiedDate;
- public boolean hidden;
- public boolean pause;
- public String owningEntityId;
- public String owningEntityName;
- public String project;
- public String aicZoneId;
- public String aicZoneName;
- public String tenantId;
- public String tenantName;
- public String regionId;
- public String regionName;
- public String serviceType;
- public String subscriberName;
- public String serviceInstanceId;
- public String serviceInstanceName;
- public String serviceModelId;
- public String serviceModelName;
- public String serviceModelVersion;
- public Date createdBulkDate;
-
- public ServiceInfo(){
-
- }
-
- public ServiceInfo(String userId, JobStatus jobStatus, boolean pause, String owningEntityId, String owningEntityName, String project, String aicZoneId, String aicZoneName, String tenantId, String tenantName, String regionId, String regionName, String serviceType, String subscriberName, String serviceInstanceId, String serviceInstanceName, String serviceModelId, String serviceModelName, String serviceModelVersion, String jobId, String templateId) {
- this.userId = userId;
- this.jobStatus = jobStatus;
- this.pause = pause;
- this.owningEntityId = owningEntityId;
- this.owningEntityName = owningEntityName;
- this.project = project;
- this.aicZoneId = aicZoneId;
- this.aicZoneName = aicZoneName;
- this.tenantId = tenantId;
- this.tenantName = tenantName;
- this.regionId = regionId;
- this.regionName = regionName;
- this.serviceType = serviceType;
- this.subscriberName = subscriberName;
- this.serviceInstanceId = serviceInstanceId;
- this.serviceInstanceName = serviceInstanceName;
- this.serviceModelId = serviceModelId;
- this.serviceModelName = serviceModelName;
- this.serviceModelVersion = serviceModelVersion;
- this.jobId = jobId;
- this.templateId = templateId;
- }
-
- public JobStatus getJobStatus() {
- return jobStatus;
- }
-
- public String getServiceInstanceName() {
- return serviceInstanceName;
- }
-
- public String getJobId() {
- return jobId;
- }
-
-}
diff --git a/vid-automation/src/test/java/org/onap/vid/model/mso/ChangeManagementRequest.java b/vid-automation/src/test/java/org/onap/vid/model/mso/ChangeManagementRequest.java
index 91dd3ff27..00372c043 100644
--- a/vid-automation/src/test/java/org/onap/vid/model/mso/ChangeManagementRequest.java
+++ b/vid-automation/src/test/java/org/onap/vid/model/mso/ChangeManagementRequest.java
@@ -14,9 +14,9 @@ import java.util.Map;
public class ChangeManagementRequest {
public static class MsoChangeManagementRequest {
- public final static String SOFTWARE_UPDATE = "inPlaceSoftwareUpdate";
+ public static final String SOFTWARE_UPDATE = "inPlaceSoftwareUpdate";
public static final String REPLACE = "replace";
- public final static String CONFIG_UPDATE = "applyUpdatedConfig";
+ public static final String CONFIG_UPDATE = "applyUpdatedConfig";
}
diff --git a/vid-automation/src/test/java/org/onap/vid/model/mso/MsoResponseWrapper2.java b/vid-automation/src/test/java/org/onap/vid/model/mso/MsoResponseWrapper2.java
deleted file mode 100644
index 29fa931d5..000000000
--- a/vid-automation/src/test/java/org/onap/vid/model/mso/MsoResponseWrapper2.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.onap.vid.model.mso;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-@JsonPropertyOrder({
- "status",
- "entity"
-})
-
-/*
-This is a brother of MsoResponseWrapper. I (Ittay) think it's better.
-It is generic, immutable, and has some knowledge about RestObject.
-The serialized "entity" field may be either String or nested object.
- */
-public class MsoResponseWrapper2<T> implements MsoResponseWrapperInterface {
-
- final static ObjectMapper objectMapper = new ObjectMapper();
-
- private final int status;
- private final T entity;
- private final String raw;
-
- public MsoResponseWrapper2(RestObject<T> msoResponse) {
- this.status = msoResponse.getStatusCode();
- this.entity = msoResponse.get();
- this.raw = msoResponse.getRaw();
- }
-
- public MsoResponseWrapper2(
- @JsonProperty(value = "status", required = true) int status,
- @JsonProperty(value = "entity", required = true) T entity) {
- this.status = status;
- this.entity = entity;
- this.raw = null;
- }
-
- public int getStatus() {
- return status;
- }
-
- @Override
- @org.codehaus.jackson.annotate.JsonIgnore
- @com.fasterxml.jackson.annotation.JsonIgnore
- public String getResponse() {
- try {
- return objectMapper.writeValueAsString(this);
- } catch (JsonProcessingException e) {
- return getEntity() != null ? getEntity().toString() : null;
- }
- }
-
- @JsonProperty
- public Object getEntity() {
- return entity != null ? entity : raw;
- }
-
-}
diff --git a/vid-automation/src/test/java/org/onap/vid/model/mso/MsoResponseWrapperInterface.java b/vid-automation/src/test/java/org/onap/vid/model/mso/MsoResponseWrapperInterface.java
deleted file mode 100644
index eb305d2df..000000000
--- a/vid-automation/src/test/java/org/onap/vid/model/mso/MsoResponseWrapperInterface.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.onap.vid.model.mso;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public interface MsoResponseWrapperInterface {
- @JsonProperty("entity")
- Object getEntity();
-
- @JsonProperty("status")
- int getStatus();
-
- @org.codehaus.jackson.annotate.JsonIgnore
- @com.fasterxml.jackson.annotation.JsonIgnore
- String getResponse();
-}
diff --git a/vid-automation/src/test/java/org/onap/vid/model/mso/OperationalEnvironment.java b/vid-automation/src/test/java/org/onap/vid/model/mso/OperationalEnvironment.java
index 59e0e2f37..c51a91f65 100644
--- a/vid-automation/src/test/java/org/onap/vid/model/mso/OperationalEnvironment.java
+++ b/vid-automation/src/test/java/org/onap/vid/model/mso/OperationalEnvironment.java
@@ -1,7 +1,6 @@
package org.onap.vid.model.mso;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
public class OperationalEnvironment {
@@ -29,7 +28,6 @@ public class OperationalEnvironment {
this.relationshipList = relationshipList;
}
- @JsonProperty("operational-environment-id")
public String getOperationalEnvironmentId() {
return operationalEnvironmentId;
}
@@ -38,7 +36,6 @@ public class OperationalEnvironment {
this.operationalEnvironmentId = operationalEnvironmentId;
}
- @JsonProperty("operational-environment-name")
public String getOperationalEnvironmentName() {
return operationalEnvironmentName;
}
@@ -47,7 +44,6 @@ public class OperationalEnvironment {
this.operationalEnvironmentName = operationalEnvironmentName;
}
- @JsonProperty("operational-environment-type")
public String getOperationalEnvironmentType() {
return operationalEnvironmentType;
}
@@ -56,7 +52,6 @@ public class OperationalEnvironment {
this.operationalEnvironmentType = operationalEnvironmentType;
}
- @JsonProperty("operational-environment-status")
public String getOperationalEnvironmentStatus() {
return operationalEnvironmentStatus;
}
@@ -65,7 +60,6 @@ public class OperationalEnvironment {
this.operationalEnvironmentStatus = operationalEnvironmentStatus;
}
- @JsonProperty("tenant-context")
public String getTenantContext() {
return tenantContext;
}
@@ -74,7 +68,6 @@ public class OperationalEnvironment {
this.tenantContext = tenantContext;
}
- @JsonProperty("workload-context")
public String getWorkloadContext() {
return workloadContext;
}
@@ -83,7 +76,6 @@ public class OperationalEnvironment {
this.workloadContext = workloadContext;
}
- @JsonProperty("resource-version")
public String getResourceVersion() {
return resourceVersion;
}
@@ -92,7 +84,6 @@ public class OperationalEnvironment {
this.resourceVersion = resourceVersion;
}
- @JsonProperty("relationship-list")
public RelationshipList getRelationshipList() {
return relationshipList;
}
diff --git a/vid-automation/src/test/java/org/onap/vid/model/mso/OperationalEnvironmentList.java b/vid-automation/src/test/java/org/onap/vid/model/mso/OperationalEnvironmentList.java
index 1ff84d3a3..c063b9971 100644
--- a/vid-automation/src/test/java/org/onap/vid/model/mso/OperationalEnvironmentList.java
+++ b/vid-automation/src/test/java/org/onap/vid/model/mso/OperationalEnvironmentList.java
@@ -1,19 +1,16 @@
package org.onap.vid.model.mso;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
public class OperationalEnvironmentList {
- @JsonProperty("operational-environment")
public List<OperationalEnvironment> getOperationalEnvironment() {
return operationalEnvironment;
}
- @JsonProperty("operational-environment")
public void setOperationalEnvironment(List<OperationalEnvironment> operationalEnvironment) {
this.operationalEnvironment = operationalEnvironment;
}
diff --git a/vid-automation/src/test/java/org/onap/vid/model/mso/RelatedToProperty.java b/vid-automation/src/test/java/org/onap/vid/model/mso/RelatedToProperty.java
index 60fff94ab..e16c9db34 100644
--- a/vid-automation/src/test/java/org/onap/vid/model/mso/RelatedToProperty.java
+++ b/vid-automation/src/test/java/org/onap/vid/model/mso/RelatedToProperty.java
@@ -1,8 +1,6 @@
package org.onap.vid.model.mso;
-import org.codehaus.jackson.annotate.JsonProperty;
-
public class RelatedToProperty {
public String getPropertyKey() {
@@ -25,11 +23,9 @@ public class RelatedToProperty {
}
- @JsonProperty("property-key")
public String propertyKey;
- @JsonProperty("property-value")
public String propertyValue;
}
diff --git a/vid-automation/src/test/java/org/onap/vid/model/mso/Relationship.java b/vid-automation/src/test/java/org/onap/vid/model/mso/Relationship.java
index a8f0f22de..b83cd626d 100644
--- a/vid-automation/src/test/java/org/onap/vid/model/mso/Relationship.java
+++ b/vid-automation/src/test/java/org/onap/vid/model/mso/Relationship.java
@@ -1,22 +1,16 @@
package org.onap.vid.model.mso;
-import org.codehaus.jackson.annotate.JsonProperty;
-
import java.util.List;
public class Relationship {
- @JsonProperty("related-to")
public String relatedTo;
- @JsonProperty("related-link")
public String relatedLink;
- @JsonProperty("relationship-data")
public List<RelationshipData> relationshipData;
- @JsonProperty("related-to-property")
public List<RelatedToProperty> relatedToProperty;
diff --git a/vid-automation/src/test/java/org/onap/vid/model/mso/RelationshipData.java b/vid-automation/src/test/java/org/onap/vid/model/mso/RelationshipData.java
index 1e6ad2a19..aa81be72d 100644
--- a/vid-automation/src/test/java/org/onap/vid/model/mso/RelationshipData.java
+++ b/vid-automation/src/test/java/org/onap/vid/model/mso/RelationshipData.java
@@ -1,30 +1,22 @@
package org.onap.vid.model.mso;
-import org.codehaus.jackson.annotate.JsonProperty;
-
public class RelationshipData {
- @JsonProperty("relationship-key")
public String getRelationshipKey() {
return relationshipKey;
}
- @JsonProperty("relationship-key")
public void setRelationshipKey(String relationshipKey) {
this.relationshipKey = relationshipKey;
}
- @JsonProperty("relationship-value")
public String getRelationshipValue() {
return relationshipValue;
}
- @JsonProperty("relationship-value")
public void setRelationshipValue(String relationshipValue) {
this.relationshipValue = relationshipValue;
}
- @JsonProperty("relationship-key")
public String relationshipKey;
- @JsonProperty("relationship-value")
public String relationshipValue;
}
diff --git a/vid-automation/src/test/java/org/onap/vid/model/mso/RelationshipList.java b/vid-automation/src/test/java/org/onap/vid/model/mso/RelationshipList.java
index 56a077d5a..599a2b2bc 100644
--- a/vid-automation/src/test/java/org/onap/vid/model/mso/RelationshipList.java
+++ b/vid-automation/src/test/java/org/onap/vid/model/mso/RelationshipList.java
@@ -1,23 +1,18 @@
package org.onap.vid.model.mso;
-import org.codehaus.jackson.annotate.JsonProperty;
-
import java.util.List;
public class RelationshipList {
- @JsonProperty("relationship")
public List<Relationship> getRelationship() {
return relationship;
}
- @JsonProperty("relationship")
public void setRelationship(List<Relationship> relationship) {
this.relationship = relationship;
}
- @JsonProperty("relationship")
public List<Relationship> relationship;
diff --git a/vid-automation/src/test/java/org/onap/vid/model/mso/RequestInfo.java b/vid-automation/src/test/java/org/onap/vid/model/mso/RequestInfo.java
index d25acbd21..a1e476914 100644
--- a/vid-automation/src/test/java/org/onap/vid/model/mso/RequestInfo.java
+++ b/vid-automation/src/test/java/org/onap/vid/model/mso/RequestInfo.java
@@ -6,7 +6,6 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
-import javax.annotation.Generated;
import java.util.HashMap;
import java.util.Map;
@@ -16,7 +15,6 @@ import java.util.Map;
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
-@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({
"billingAccountNumber",
"callbackUrl",
diff --git a/vid-automation/src/test/java/org/onap/vid/model/mso/RequestParameters.java b/vid-automation/src/test/java/org/onap/vid/model/mso/RequestParameters.java
index d3574d7b5..9706f0d5d 100644
--- a/vid-automation/src/test/java/org/onap/vid/model/mso/RequestParameters.java
+++ b/vid-automation/src/test/java/org/onap/vid/model/mso/RequestParameters.java
@@ -6,14 +6,12 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
-import javax.annotation.Generated;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@JsonInclude(JsonInclude.Include.NON_NULL)
-@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({
"subscriptionServiceType",
"userParams"
diff --git a/vid-automation/src/test/java/org/onap/vid/model/mso/RestObject.java b/vid-automation/src/test/java/org/onap/vid/model/mso/RestObject.java
deleted file mode 100644
index b91ea410a..000000000
--- a/vid-automation/src/test/java/org/onap/vid/model/mso/RestObject.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * 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.onap.vid.model.mso;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.base.MoreObjects;
-
-import javax.ws.rs.core.Response;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-
-/**
- * The Class RestObject.
- *
- * @param <T> the generic type
- */
-public class RestObject<T> {
-
- final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
-
- final static ObjectMapper objectMapper = new ObjectMapper();
-
- /**
- * Generic version of the RestObject class.
- *
- */
- // T stands for "Type"
- private T t;
-
- // The string source of t, if available
- private String rawT;
-
- /** The status code. */
- private int statusCode= 0;
-
- public RestObject() {
- }
-
- public RestObject(Response cres, Class<?> tClass) {
-
- String rawEntity = null;
- try {
- cres.bufferEntity();
- rawEntity = cres.readEntity(String.class);
- T t = (T) objectMapper.readValue(rawEntity, tClass);
- this.set(t);
- }
- catch ( Exception e ) {
- try {
- this.setRaw(rawEntity);
- } catch (Exception e2) {
- }
- }
-
- int status = cres.getStatus();
- this.setStatusCode (status);
- }
-
-
- /**
- * Sets the.
- *
- * @param t the t
- */
- public void set(T t) { this.t = t; }
-
- /**
- * Gets the.
- *
- * @return the t
- */
- public T get() { return t; }
-
- /**
- * Sets the status code.
- *
- * @param v the new status code
- */
- public void setStatusCode(int v) { this.statusCode = v; }
-
- /**
- * Gets the status code.
- *
- * @return the status code
- */
- public int getStatusCode() { return this.statusCode; }
-
- public String getRaw() {
- return rawT;
- }
-
- public void setRaw(String rawT) {
- this.rawT = rawT;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("t", t)
- .add("rawT", rawT)
- .add("statusCode", statusCode)
- .toString();
- }
-}
-
diff --git a/vid-automation/src/test/java/org/onap/vid/model/mso/SubscriberInfo.java b/vid-automation/src/test/java/org/onap/vid/model/mso/SubscriberInfo.java
index 67cded838..80976f37d 100644
--- a/vid-automation/src/test/java/org/onap/vid/model/mso/SubscriberInfo.java
+++ b/vid-automation/src/test/java/org/onap/vid/model/mso/SubscriberInfo.java
@@ -6,7 +6,6 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
-import javax.annotation.Generated;
import java.util.HashMap;
import java.util.Map;
@@ -16,7 +15,6 @@ import java.util.Map;
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
-@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({
"globalSubscriberId",
"subscriberCommonSiteId",
diff --git a/vid-automation/src/test/java/org/onap/vid/model/mso/UserParam.java b/vid-automation/src/test/java/org/onap/vid/model/mso/UserParam.java
index 384e45631..0459b5a28 100644
--- a/vid-automation/src/test/java/org/onap/vid/model/mso/UserParam.java
+++ b/vid-automation/src/test/java/org/onap/vid/model/mso/UserParam.java
@@ -6,12 +6,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
-import javax.annotation.Generated;
import java.util.HashMap;
import java.util.Map;
@JsonInclude(JsonInclude.Include.NON_NULL)
-@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({
"name",
"value"
diff --git a/vid-automation/src/test/java/org/onap/vid/model/probe/ExternalComponentStatus.java b/vid-automation/src/test/java/org/onap/vid/model/probe/ExternalComponentStatus.java
index b247613d6..759f2e08c 100644
--- a/vid-automation/src/test/java/org/onap/vid/model/probe/ExternalComponentStatus.java
+++ b/vid-automation/src/test/java/org/onap/vid/model/probe/ExternalComponentStatus.java
@@ -1,7 +1,7 @@
package org.onap.vid.model.probe;
public class ExternalComponentStatus {
- public enum Component {AAI, MSO, SCHEDULER}
+ public enum Component {AAI, MSO, SDC, SCHEDULER}
private Component component;
private boolean available;
private HttpRequestMetadata metadata;
diff --git a/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java b/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java
index fd8f48279..7ca29f854 100644
--- a/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java
@@ -1,7 +1,17 @@
package org.onap.vid.more;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.junit.Assert.assertThat;
+
import com.fasterxml.jackson.databind.JsonNode;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
import org.onap.vid.api.BaseApiTest;
import org.springframework.web.client.RestTemplate;
@@ -9,20 +19,12 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import vid.automation.test.services.SimulatorApi;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-
public class LoggerFormatTest extends BaseApiTest {
- // See: https://wiki.web.att.com/display/KSAT/REST-based+Log+Checker
- private final static String logChecker = "http://eelflogcheck.it.att.com:31820/validate";
+ // See: https://www.openecomp.org/KSAT/REST-based+Log+Checker
+ private final static String logChecker = "http://eelf.onap.org:31820/validate";
+ private final Logger logger = LogManager.getLogger(LoggerFormatTest.class);
@BeforeClass
public void login() {
@@ -56,9 +58,9 @@ public class LoggerFormatTest extends BaseApiTest {
private void validateLogsFormat(String logName, String logType) {
String logLines = getLogLines(logName);
+ logger.info("logLines are: "+logLines);
JsonNode response = getCheckerResults(logType, logLines);
-
- System.out.println(response);
+ logger.info("Response is:" + response.toString());
double fieldscore = response.path("summary").path("score").path("fieldscore").asDouble();
double overall = response.path("summary").path("score").path("overallscore").asDouble();
diff --git a/vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java b/vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java
index 560538737..0a0045d4d 100644
--- a/vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java
+++ b/vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java
@@ -4,23 +4,22 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
+import org.junit.Assert;
+import org.onap.simulator.presetGenerator.presets.aaf.AAFGetBasicAuthPreset;
+import org.onap.simulator.presetGenerator.presets.aaf.AAFGetUrlServicePreset;
import org.onap.vid.api.BaseApiTest;
import org.onap.vid.api.OperationalEnvironmentControllerApiTest;
import org.onap.vid.api.ServiceInstanceMsoApiTest;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
+import org.springframework.http.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import vid.automation.test.services.SimulatorApi;
+import java.util.List;
import java.util.UUID;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.nullValue;
import static org.onap.vid.api.CategoryParametersApiTest.GET_CATEGORY_PARAMETER_PROPERTIES;
import static org.onap.vid.api.pProbeMsoApiTest.MSO_CREATE_CONFIGURATION;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;
@@ -49,7 +48,7 @@ public class RequestIdFilterInstalled extends BaseApiTest {
}
@Test
- public void frontendApi_doGET_RequestIdReceived() {
+ public void frontendApi_doGET_RequestIdReceived() throws InterruptedException {
final Pair<HttpEntity, String> responseAndUuid = makeRequest(
HttpMethod.GET,
@@ -62,7 +61,7 @@ public class RequestIdFilterInstalled extends BaseApiTest {
}
@Test
- public void frontendApi_doPOST_RequestIdReceived() {
+ public void frontendApi_doPOST_RequestIdReceived() throws InterruptedException {
final Pair<HttpEntity, String> responseAndUuid = makeRequest(
HttpMethod.POST,
@@ -87,14 +86,13 @@ public class RequestIdFilterInstalled extends BaseApiTest {
@Test(groups = { "worksOnlyWithLocalhostVID" })
- public void mopOwningEntityApi_doGET_RequestIdReceived() {
+ public void mopOwningEntityApi_doGET_RequestIdReceived() throws InterruptedException {
final Pair<HttpEntity, String> responseAndUuid = makeRequest(
HttpMethod.GET,
"/" + GET_CATEGORY_PARAMETER_PROPERTIES + "?familyName=PARAMETER_STANDARDIZATION",
null
);
-
assertThatUuidInResponseAndUuidIsInARecentLog(responseAndUuid);
/*
@@ -110,12 +108,18 @@ public class RequestIdFilterInstalled extends BaseApiTest {
}
@Test
- public void schedulerApi_doPOST_RequestIdReceived() {
+ public void schedulerApi_doPOST_RequestIdReceived() throws InterruptedException {
final String anyInstanceId = "any instance id";
SimulatorApi.registerExpectation(
"mso_in_place_software_update_ok.json",
ImmutableMap.of("SERVICE_INSTANCE_ID", anyInstanceId, "VNF_INSTANCE_ID", anyInstanceId), SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET);
+ SimulatorApi.registerExpectationFromPreset(
+ new AAFGetUrlServicePreset(),
+ SimulatorApi.RegistrationStrategy.APPEND);
+ SimulatorApi.registerExpectationFromPreset(
+ new AAFGetBasicAuthPreset(),
+ SimulatorApi.RegistrationStrategy.APPEND);
final Pair<HttpEntity, String> responseAndUuid = makeRequest(
HttpMethod.POST,
"/change-management/workflow/" + anyInstanceId,
@@ -126,7 +130,7 @@ public class RequestIdFilterInstalled extends BaseApiTest {
}
@Test
- public void healthcheck_doGET_RequestIdReceived(){
+ public void healthcheck_doGET_RequestIdReceived() {
final Pair<HttpEntity, String> responseAndUuid = makeRequest(
HttpMethod.GET, "/healthCheck", null
);
@@ -142,14 +146,16 @@ public class RequestIdFilterInstalled extends BaseApiTest {
// THIS TEST IS NOT JUST NICE TO HAVE, it also lets us know
// that the request/response ran through our "promise request
// id" filter, which is great!
- assertThat(response, not(nullValue()));
- assertThat(response.getHeaders().get(ECOMP_REQUEST_ID_ECHO), containsInAnyOrder(uuid));
+ Assert.assertNotNull(response);
+ List<String> ecompRequestIdHeaderValues = response.getHeaders().get(ECOMP_REQUEST_ID_ECHO);
+ Assert.assertNotNull(ecompRequestIdHeaderValues);
+ Assert.assertTrue(ecompRequestIdHeaderValues.contains(uuid));
}
private void assertThatTermIsInARecentLog(String uuid) {
final ImmutableList<String> logLines = ImmutableList.of(
- LoggerFormatTest.getLogLines("audit", 5, 0, restTemplate, uri),
- LoggerFormatTest.getLogLines("error", 5, 0, restTemplate, uri)
+ LoggerFormatTest.getLogLines("audit", 20, 0, restTemplate, uri),
+ LoggerFormatTest.getLogLines("error", 20, 0, restTemplate, uri)
);
// Assert that audit *OR* error has the uuid
@@ -164,13 +170,13 @@ public class RequestIdFilterInstalled extends BaseApiTest {
final String uuid = UUID.randomUUID().toString();
final HttpHeaders headers = new HttpHeaders();
headers.add(ECOMP_REQUEST_ID, uuid);
- headers.add(AUTHORIZATION, "Basic 123==");
+ headers.add(AUTHORIZATION, "Basic " + AAFGetBasicAuthPreset.VALID_AUTH_VALUE);
+ headers.setContentType(MediaType.APPLICATION_JSON);
- SimulatorApi.clearExpectations();
if (!StringUtils.isEmpty(expectationFilename)) {
SimulatorApi.registerExpectation(expectationFilename, APPEND);
}
- SimulatorApi.registerExpectation("aai_get_full_subscribers.json", APPEND);
+ SimulatorApi.registerExpectation("create_new_instance/aai_get_full_subscribers.json", APPEND);
SimulatorApi.registerExpectation("ecompportal_getSessionSlotCheckInterval.json", APPEND);
HttpEntity entity = new HttpEntity<>(body, headers);
diff --git a/vid-automation/src/test/java/org/onap/vid/more/SimulatorLoaderTest.java b/vid-automation/src/test/java/org/onap/vid/more/SimulatorLoaderTest.java
index bc550ae19..eff73cf70 100644
--- a/vid-automation/src/test/java/org/onap/vid/more/SimulatorLoaderTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/more/SimulatorLoaderTest.java
@@ -1,13 +1,7 @@
package org.onap.vid.more;
import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset;
-import org.onap.simulator.presetGenerator.presets.aai.PresetAAIBadBodyForGetServicesGet;
-import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetNetworkZones;
-import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetPNFByRegionErrorPut;
-import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetServicesGet;
-import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
-import org.onap.simulator.presetGenerator.presets.aai.PresetAAISearchNodeQueryEmptyResult;
-import org.onap.simulator.presetGenerator.presets.aai.PresetAAIServiceDesignAndCreationPut;
+import org.onap.simulator.presetGenerator.presets.aai.*;
import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet;
import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetUserGet;
import org.onap.simulator.presetGenerator.presets.mso.PresetActivateServiceInstancePost;
@@ -34,6 +28,7 @@ import java.util.List;
import java.util.Map;
import static org.testng.Assert.assertEquals;
+import static vid.automation.test.infra.ModelInfo.aLaCarteServiceCreationTest;
import static vid.automation.test.services.SimulatorApi.registerExpectationFromPreset;
import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets;
@@ -43,8 +38,9 @@ public class SimulatorLoaderTest extends BaseApiTest {
protected Invocation.Builder createSimulatorRequestBuilder(BasePreset preset) {
WebTarget webTarget = client.target(SimulatorApi.getSimulationUri() + preset.getReqPath());
webTarget = addQueryParamsToWebTarget(preset, webTarget);
- return webTarget.request()
+ Invocation.Builder builder = webTarget.request()
.accept("application/json");
+ return addHeadersToBuilder(preset, builder);
}
private WebTarget addQueryParamsToWebTarget(BasePreset preset, WebTarget webTarget) {
@@ -56,11 +52,16 @@ public class SimulatorLoaderTest extends BaseApiTest {
return webTarget;
}
+ private Invocation.Builder addHeadersToBuilder(BasePreset preset, Invocation.Builder builder) {
+ preset.getRequestHeaders().forEach((key,value)->builder.header(key,value));
+ return builder;
+ }
+
@DataProvider
public static Object[][] presetClassesWithPutPost(Method test) {
return new Object[][]{
{new PresetAAIGetPNFByRegionErrorPut()},
- {new PresetAAIServiceDesignAndCreationPut("a","b")},
+ {new PresetAAIServiceDesignAndCreationPut()},
{new PresetDeactivateServiceInstancePost()},
{new PresetActivateServiceInstancePost()},
{new PresetMSOCreateServiceInstancePost()}
@@ -87,11 +88,10 @@ public class SimulatorLoaderTest extends BaseApiTest {
{new PresetGetSessionSlotCheckIntervalGet()},
{new PresetGetUserGet()},
{new PresetAAIGetServicesGet()},
- {new PresetSDCGetServiceMetadataGet("a" , "b", "serviceCreationTest.zip")},
- {new PresetSDCGetServiceToscaModelGet( "a", "serviceCreationTest.zip")},
+ {new PresetSDCGetServiceMetadataGet(aLaCarteServiceCreationTest)},
+ {new PresetSDCGetServiceToscaModelGet( aLaCarteServiceCreationTest)},
{new PresetMSOOrchestrationRequestGet()},
{new PresetAAIGetNetworkZones()},
- {new PresetAAISearchNodeQueryEmptyResult()},
{new PresetAAIBadBodyForGetServicesGet("not a json")},
};
}