1 package org.onap.vid.api;
3 import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
4 import static org.hamcrest.CoreMatchers.containsString;
5 import static org.hamcrest.MatcherAssert.assertThat;
6 import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet.defaultPlacement;
7 import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet.ofL3Network;
8 import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet.ofServiceInstance;
9 import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet.ofVlanTag;
10 import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet.ofVnf;
11 import static org.onap.simulator.presetGenerator.presets.aai.PresetBaseAAICustomQuery.FORMAT.SIMPLE;
12 import static org.onap.simulator.presetGenerator.presets.ecompportal_att.EcompPortalPresetsUtils.getEcompPortalPresets;
13 import static org.testng.Assert.assertNotNull;
14 import static org.testng.Assert.assertTrue;
15 import static org.testng.AssertJUnit.assertEquals;
16 import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND;
17 import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET;
18 import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets;
19 import static vid.automation.test.utils.TestHelper.GET_SERVICE_MODELS_BY_DISTRIBUTION_STATUS;
21 import com.fasterxml.jackson.core.JsonProcessingException;
22 import com.google.common.collect.ImmutableList;
23 import com.google.common.collect.ImmutableMap;
24 import com.google.common.collect.ImmutableMultimap;
25 import java.io.IOException;
26 import java.lang.reflect.Method;
27 import java.net.URISyntaxException;
28 import java.util.List;
29 import java.util.UUID;
30 import net.javacrumbs.jsonunit.JsonAssert;
31 import net.javacrumbs.jsonunit.core.Configuration;
32 import net.javacrumbs.jsonunit.core.Option;
33 import org.apache.commons.text.StringEscapeUtils;
34 import org.apache.http.client.utils.URIBuilder;
35 import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset;
36 import org.onap.simulator.presetGenerator.presets.aai.AAIBaseGetL3NetworksByCloudRegionPreset;
37 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIBadBodyForGetServicesGet;
38 import org.onap.simulator.presetGenerator.presets.aai.PresetAAICloudRegionAndSourceFromConfigurationPut;
39 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId;
40 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetHomingForVfModule;
41 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetInstanceGroupsByCloudRegion;
42 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest;
43 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetInstanceGroupsByCloudRegionRequiredMissing;
44 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetL3NetworksByCloudRegion;
45 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetL3NetworksByCloudRegionSpecificState;
46 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetNetworkCollectionDetails;
47 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetNetworkCollectionDetailsInvalidRequest;
48 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetNetworkCollectionDetailsRequiredMissing;
49 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetPortMirroringSourcePorts;
50 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetPortMirroringSourcePortsError;
51 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetRelatedInstanceGroupsByVnfId;
52 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
53 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetVpnsByType;
54 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIModelVersionsByInvariantId;
55 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet;
56 import org.onap.simulator.presetGenerator.presets.aai.PresetBaseAAICustomQuery;
57 import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceMetadataGet;
58 import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGet;
59 import org.onap.vid.model.aai.AaiResponse;
60 import org.onap.vid.model.mso.OperationalEnvironmentList;
61 import org.onap.vid.more.LoggerFormatTest;
62 import org.onap.vid.more.LoggerFormatTest.LogName;
63 import org.springframework.core.ParameterizedTypeReference;
64 import org.springframework.http.HttpMethod;
65 import org.springframework.http.HttpStatus;
66 import org.springframework.http.ResponseEntity;
67 import org.springframework.web.client.HttpClientErrorException;
68 import org.springframework.web.client.HttpServerErrorException;
69 import org.springframework.web.util.UriComponentsBuilder;
70 import org.testng.AssertJUnit;
71 import org.testng.annotations.DataProvider;
72 import org.testng.annotations.Test;
73 import vid.automation.test.infra.FeatureTogglingTest;
74 import vid.automation.test.infra.Features;
75 import vid.automation.test.services.SimulatorApi;
76 import vid.automation.test.utils.TestHelper;
78 public class AaiApiTest extends BaseApiAaiTest {
80 private static final String AAI_HOMING_DATA_RESPONSE = "viewEdit/aaiHomingDataResponse.json";
81 public static final String GET_OPERATIONAL_ENVIRONMENTS_JSON = "get_operational_environments_aai.json";
82 public static final String GET_OPERATIONAL_ENVIRONMENTS_JSON_ERROR = "get_operational_environments_aai_error.json";
83 public static final String[] AAI_GET_SERVICES_ERROR_SIMULATOR_RESPONSES = {"getServicesAaiErrorResp.json", "create_new_instance/aai_get_full_subscribers.json"};
84 public static final String[] AAI_GET_SERVICES_FINE_SIMULATOR_RESPONSES = {"getServicesAaiFineResp.json", "create_new_instance/aai_get_full_subscribers.json"};
85 public static final String AAI_VNFS_FOR_CHANGE_MANAGEMENT_JSON = "changeManagement/get_vnf_data_by_globalid_and_service_type.json";
86 public static final String AAI_VNFS_FOR_CHANGE_MANAGEMENT_JSON_BY_PARAMS = "registration_to_simulator/changeManagement/get_vnf_data_by_globalid_and_service_type_reduced_response.json";
87 public static final String OPERATIONAL_ENVIRONMENT_TYPE = "VNF";
88 public static final String OPERATIONAL_ENVIRONMENT_STATUS = "Activate";
89 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";
90 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";
91 public static final String GET_AAI_SERVIES_EXPECTED_RESULT = "{\n" +
92 " \"services\": [{\n" +
93 " \"uuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\n" +
94 " \"invariantUUID\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\n" +
95 " \"name\": \"vSAMP10aDEV::base::module-0\",\n" +
96 " \"version\": \"2\",\n" +
97 " \"toscaModelURL\": null,\n" +
98 " \"category\": \"resource\",\n" +
99 " \"lifecycleState\": null,\n" +
100 " \"lastUpdaterUserId\": null,\n" +
101 " \"lastUpdaterFullName\": null,\n" +
102 " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
103 " \"orchestrationType\": null,\n" +
104 " \"artifacts\": null,\n" +
105 " \"resources\": null\n" +
107 " \"uuid\": \"797a6c41-0f80-4d35-a288-3920c4e06baa\",\n" +
108 " \"invariantUUID\": \"5b607929-6088-4614-97ef-cac817508e0e\",\n" +
109 " \"name\": \"CONTRAIL30_L2NODHCP\",\n" +
110 " \"version\": \"1.0\",\n" +
111 " \"toscaModelURL\": null,\n" +
112 " \"category\": \"resource\",\n" +
113 " \"lifecycleState\": null,\n" +
114 " \"lastUpdaterUserId\": null,\n" +
115 " \"lastUpdaterFullName\": null,\n" +
116 " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_ERROR\",\n" +
117 " \"orchestrationType\": null,\n" +
118 " \"artifacts\": null,\n" +
119 " \"resources\": null\n" +
121 " \"uuid\": \"f1bde010-cc5f-4765-941f-75f15b24f9fc\",\n" +
122 " \"invariantUUID\": \"0143d57b-a517-4de9-a0a1-eb76db51f402\",\n" +
123 " \"name\": \"BkVmxAv061917..base_vPE_AV..module-0\",\n" +
124 " \"version\": \"2\",\n" +
125 " \"toscaModelURL\": null,\n" +
126 " \"category\": \"resource\",\n" +
127 " \"lifecycleState\": null,\n" +
128 " \"lastUpdaterUserId\": null,\n" +
129 " \"lastUpdaterFullName\": null,\n" +
130 " \"orchestrationType\": null,\n" +
131 " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
132 " \"artifacts\": null,\n" +
133 " \"resources\": null\n" +
135 " \"uuid\": \"ipe-resource-id-ps-02\",\n" +
136 " \"invariantUUID\": \"ipe-resource-id-ps-02\",\n" +
137 " \"name\": \"abc\",\n" +
138 " \"version\": \"v1.0\",\n" +
139 " \"toscaModelURL\": null,\n" +
140 " \"category\": \"resource\",\n" +
141 " \"lifecycleState\": null,\n" +
142 " \"lastUpdaterUserId\": null,\n" +
143 " \"lastUpdaterFullName\": null,\n" +
144 " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
145 " \"orchestrationType\": null,\n" +
146 " \"artifacts\": null,\n" +
147 " \"resources\": null\n" +
149 " \"uuid\": \"lmoser410-connector-model-version-id\",\n" +
150 " \"invariantUUID\": \"lmoser410-connector-model-id\",\n" +
151 " \"name\": \"connector\",\n" +
152 " \"version\": \"v1.0\",\n" +
153 " \"toscaModelURL\": null,\n" +
154 " \"category\": \"widget\",\n" +
155 " \"lifecycleState\": null,\n" +
156 " \"lastUpdaterUserId\": null,\n" +
157 " \"lastUpdaterFullName\": null,\n" +
158 " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
159 " \"orchestrationType\": null,\n" +
160 " \"artifacts\": null,\n" +
161 " \"resources\": null\n" +
163 " \"uuid\": \"ff2ae348-214a-11e7-93ae-92361f002673\",\n" +
164 " \"invariantUUID\": \"3a97db99-c4bb-498a-a13a-38f65f1ced3d\",\n" +
165 " \"name\": \"vSAMP10aDEV::base::module-0\",\n" +
166 " \"version\": \"1.0\",\n" +
167 " \"toscaModelURL\": null,\n" +
168 " \"category\": \"resource\",\n" +
169 " \"lifecycleState\": null,\n" +
170 " \"lastUpdaterUserId\": null,\n" +
171 " \"lastUpdaterFullName\": null,\n" +
172 " \"orchestrationType\": null,\n" +
173 " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
174 " \"artifacts\": null,\n" +
175 " \"resources\": null\n" +
177 " \"uuid\": \"204c641a-3494-48c8-979a-86856f5fd32a\",\n" +
178 " \"invariantUUID\": \"3c504d40-b847-424c-9d25-4fb7e0a3e994\",\n" +
179 " \"name\": \"named-query-element\",\n" +
180 " \"version\": \"1.0\",\n" +
181 " \"toscaModelURL\": null,\n" +
182 " \"category\": \"widget\",\n" +
183 " \"lifecycleState\": null,\n" +
184 " \"lastUpdaterUserId\": null,\n" +
185 " \"lastUpdaterFullName\": null,\n" +
186 " \"orchestrationType\": null,\n" +
187 " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
188 " \"artifacts\": null,\n" +
189 " \"resources\": null\n" +
191 " \"uuid\": \"acba1f72-c6e0-477f-9426-ad190151e100\",\n" +
192 " \"invariantUUID\": \"93e56950-cb19-44e6-ace4-8b50f2d02e45\",\n" +
193 " \"name\": \"RG_6-19_Test\",\n" +
194 " \"version\": \"1.0\",\n" +
195 " \"toscaModelURL\": null,\n" +
196 " \"category\": \"resource\",\n" +
197 " \"lifecycleState\": null,\n" +
198 " \"lastUpdaterUserId\": null,\n" +
199 " \"lastUpdaterFullName\": null,\n" +
200 " \"orchestrationType\": null,\n" +
201 " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
202 " \"artifacts\": null,\n" +
203 " \"resources\": null\n" +
205 " \"uuid\": \"fc65e5e7-45c7-488a-b36d-f453ab3057fe\",\n" +
206 " \"invariantUUID\": \"ee448504-ceee-47db-8e1b-742115f219db\",\n" +
207 " \"name\": \"ciServicea268facd387e\",\n" +
208 " \"version\": \"1.0\",\n" +
209 " \"toscaModelURL\": null,\n" +
210 " \"category\": \"service\",\n" +
211 " \"lifecycleState\": null,\n" +
212 " \"lastUpdaterUserId\": null,\n" +
213 " \"lastUpdaterFullName\": null,\n" +
214 " \"orchestrationType\": null,\n" +
215 " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
216 " \"artifacts\": null,\n" +
217 " \"resources\": null\n" +
219 " \"uuid\": \"027948b6-25e2-4e39-b87d-d9f5797941de\",\n" +
220 " \"invariantUUID\": \"56f2d0d3-7943-4159-bf01-b82692ec035e\",\n" +
221 " \"name\": \"service_sanity_amir\",\n" +
222 " \"version\": \"2.0\",\n" +
223 " \"toscaModelURL\": null,\n" +
224 " \"category\": \"service\",\n" +
225 " \"lifecycleState\": null,\n" +
226 " \"lastUpdaterUserId\": null,\n" +
227 " \"lastUpdaterFullName\": null,\n" +
228 " \"orchestrationType\": null,\n" +
229 " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
230 " \"artifacts\": null,\n" +
231 " \"resources\": null\n" +
233 " \"uuid\": \"fbf96e3b-1804-4c89-bf5b-53acb7f2edc0\",\n" +
234 " \"invariantUUID\": \"56f2d0d3-7943-4159-bf01-b82692ec035e\",\n" +
235 " \"name\": \"service_sanity_amir\",\n" +
236 " \"version\": \"3.0\",\n" +
237 " \"toscaModelURL\": null,\n" +
238 " \"category\": \"service\",\n" +
239 " \"lifecycleState\": null,\n" +
240 " \"lastUpdaterUserId\": null,\n" +
241 " \"lastUpdaterFullName\": null,\n" +
242 " \"orchestrationType\": null,\n" +
243 " \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
244 " \"artifacts\": null,\n" +
245 " \"resources\": null\n" +
247 " \"readOnly\": false\n" +
249 private static final String AAI_GET_ACTIVE_NETWORKS = "/aai_get_active_networks";
251 private String getGetOperationEnvironmentsUri() {
252 return uri.toASCIIString() + "/get_operational_environments";
255 private String getAaiServicesUri() {
256 return uri.toASCIIString() + "/rest/models/services";
259 private String getGetOperationEnvironmentUriWithParameters() {
260 String url = getGetOperationEnvironmentsUri();
261 UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(url)
262 // Add query parameter
263 .queryParam("operationalEnvironmentStatus", OPERATIONAL_ENVIRONMENT_STATUS)
264 .queryParam("operationalEnvironmentType", OPERATIONAL_ENVIRONMENT_TYPE);
266 String urlWithParameters = builder.toUriString();
267 return urlWithParameters;
271 private AaiResponse<OperationalEnvironmentList> loginAndDoGetWithUrl(String url) {
272 ResponseEntity<AaiResponse<OperationalEnvironmentList>> responseEntity = restTemplate.exchange(
276 new ParameterizedTypeReference<AaiResponse<OperationalEnvironmentList>>() {});
277 AaiResponse<OperationalEnvironmentList> response = responseEntity.getBody();
282 public void testErrorGetOperationalEnvironments() {
283 //Register required response
284 SimulatorApi.registerExpectation(GET_OPERATIONAL_ENVIRONMENTS_JSON_ERROR, APPEND);
285 String url = getGetOperationEnvironmentsUri();
286 AaiResponse<OperationalEnvironmentList> response = loginAndDoGetWithUrl(url);
287 assertEquals(HttpStatus.INTERNAL_SERVER_ERROR.value(), response.getHttpCode());
288 assertEquals("simulated error text", response.getErrorMessage());
293 //This test requires a simulator which runs on VID
295 public void testSuccessGetOperationalEnvironments() {
296 //Register required response
297 String uuidOfOperationalEnvironment = "f07ca256-96dd-40ad-b4d2-7a77e2a974ed";
298 SimulatorApi.registerExpectation(GET_OPERATIONAL_ENVIRONMENTS_JSON, ImmutableMap.of("UUID_of_Operational_Environment", uuidOfOperationalEnvironment), APPEND);
299 String url = getGetOperationEnvironmentUriWithParameters();
300 AaiResponse<OperationalEnvironmentList> response = loginAndDoGetWithUrl(url);
301 assertEquals(HttpStatus.OK.value(), response.getHttpCode());
302 OperationalEnvironmentList list = response.getT();
303 assertNotNull(list.getOperationalEnvironment());
304 assertEquals(2, list.getOperationalEnvironment().size());
305 assertEquals(uuidOfOperationalEnvironment, list.getOperationalEnvironment().get(0).getOperationalEnvironmentId());
306 assertEquals(1, list.getOperationalEnvironment().get(0).getRelationshipList().getRelationship().size());
309 @Test(dataProvider = "errorCodes")
310 public void getServicesWitErrorResponse(int errorCode) throws IOException, URISyntaxException {
311 TestHelper.resetAaiCache(GET_SERVICE_MODELS_BY_DISTRIBUTION_STATUS, restTemplate, uri);
312 final String expectedResult = "{\"services\":[],\"readOnly\":false}";
314 callAaiWithSimulatedErrorResponse(AAI_GET_SERVICES_ERROR_SIMULATOR_RESPONSES,
315 ImmutableMap.of("500", Integer.toString(errorCode), "ERROR_PAYLOAD", StringEscapeUtils.escapeJson(expectedResult)),
316 getAaiServicesUri(), "", 200, expectedResult, HttpMethod.GET);
321 public void getServicesFineRequest() throws IOException, URISyntaxException {
322 TestHelper.resetAaiCache(GET_SERVICE_MODELS_BY_DISTRIBUTION_STATUS, restTemplate, uri);
323 callAaiWithSimulatedErrorResponse(AAI_GET_SERVICES_FINE_SIMULATOR_RESPONSES,
325 getAaiServicesUri(), "", 200, GET_AAI_SERVIES_EXPECTED_RESULT, HttpMethod.GET);
329 public void whenGetServicesErrorResponse_badResponseIsNotCached() throws IOException, URISyntaxException {
330 TestHelper.resetAaiCache(GET_SERVICE_MODELS_BY_DISTRIBUTION_STATUS, restTemplate, uri);
333 final String expectedErrorResult = "{\"services\":[],\"readOnly\":false}";
334 //call AAI with bad response by clear exceptions from simulator, bad response shall not be cached
335 callAaiWithSimulatedErrorResponse(new String[]{}, ImmutableMap.of(), getAaiServicesUri(), "", 200, expectedErrorResult, HttpMethod.GET);
337 //call AAI with fine response
338 callAaiWithSimulatedErrorResponse(AAI_GET_SERVICES_FINE_SIMULATOR_RESPONSES,
340 getAaiServicesUri(), "", 200, GET_AAI_SERVIES_EXPECTED_RESULT, HttpMethod.GET);
344 public static Object[][] errorCodes(Method test) {
345 return new Object[][]{
346 {500},{505}, {400}, {401}, {405}
351 public void whenThrowExceptionInsAaiResponseErrorAreLogged() {
352 String notAJson = "not a json";
353 SimulatorApi.registerExpectationFromPreset(new PresetAAIBadBodyForGetServicesGet(notAJson), CLEAR_THEN_SET);
354 SimulatorApi.registerExpectationFromPresets(getEcompPortalPresets(), APPEND);
355 SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), APPEND);
357 restTemplateErrorAgnostic.getForEntity(uri + "/aai_get_services", String.class);
358 String logLines = LoggerFormatTest.getLogLines(LogName.error, 15, 0, restTemplate, uri);
360 assertThat("not found in error log", logLines, containsString("Failed to parse aai response"));
361 assertThat("not found in error log", logLines, containsString(notAJson));
362 assertThat("not found in error log", logLines, containsString("GetServicesAAIRespone"));
367 public void portMirroringConfigData_givenValidAaiResponse_yieldCloudRegionId() {
368 SimulatorApi.registerExpectationFromPreset(new PresetAAICloudRegionAndSourceFromConfigurationPut("SOME-RANDOM-UUID", "THE-EXPECTED-REGION-ID"), CLEAR_THEN_SET);
370 final String response = restTemplate.getForObject(uri + "/aai_getPortMirroringConfigsData?configurationIds=" + "SOME-RANDOM-UUID", String.class);
372 final ImmutableMap<String, ImmutableMap<String, String>> expected = ImmutableMap.of(
373 "SOME-RANDOM-UUID", ImmutableMap.of(
374 "cloudRegionId", "THE-EXPECTED-REGION-ID"
377 assertResponse(expected, response);
381 [ ] Error responses from AAI (404 etc): descriptive error response, including what tried and what happened
382 [ ] malformed response from AAI: descriptive error response, including the payload
383 [ ] empty/missing value for configurationId: client-error http code
389 public void portMirroringSourcePorts_validAAIResponseWithSinglePort_yieldCorrectPortData() {
390 SimulatorApi.registerExpectationFromPreset(
391 new PresetAAIGetPortMirroringSourcePorts("CONFIGURATION-ID", "INTERFACE-ID", "INTERFACE-NAME", true),
395 final String response = restTemplate.getForObject(uri + "/aai_getPortMirroringSourcePorts?configurationIds=" + "CONFIGURATION-ID", String.class);
397 final ImmutableMap<String, ImmutableList> expected = ImmutableMap.of(
398 "CONFIGURATION-ID", ImmutableList.of(ImmutableMap.of(
399 "interfaceId", "INTERFACE-ID", "interfaceName", "INTERFACE-NAME", "isPortMirrored", true
402 assertResponse(expected, response);
406 public void portMirroringSourcePorts_nullValueForInterfaceId_yield200OkWithFineDescription() {
407 final PresetAAIGetPortMirroringSourcePorts preset = new PresetAAIGetPortMirroringSourcePorts("CONFIGURATION-ID", null, "INTERFACE-NAME", true);
408 SimulatorApi.registerExpectationFromPreset(
413 final String response = restTemplate.getForObject(uri + "/aai_getPortMirroringSourcePorts?configurationIds=" + "CONFIGURATION-ID", String.class);
415 final ImmutableMap<String, ImmutableList<ImmutableMap>> expected = ImmutableMap.of(
416 "CONFIGURATION-ID", ImmutableList.of(ImmutableMap.of(
417 "errorDescription", "Value of 'interface-id' is missing.",
418 "rawAaiResponse", preset.getResponseBody().toString()
421 assertResponse(expected, response);
425 public void portMirroringSourcePorts_given503ErrorAaiResponse_yield200OkWithErrorMsg() {
426 final PresetAAIGetPortMirroringSourcePortsError preset = new PresetAAIGetPortMirroringSourcePortsError("CONFIGURATION-ID", "INTERFACE-ID", "INTERFACE-NAME", true);
427 SimulatorApi.registerExpectationFromPreset(
432 final String response = restTemplate.getForObject(uri + "/aai_getPortMirroringSourcePorts?configurationIds=" + "CONFIGURATION-ID", String.class);
434 final ImmutableMap<String, ImmutableList<ImmutableMap>> expected = ImmutableMap.of(
435 "CONFIGURATION-ID", ImmutableList.of(ImmutableMap.of(
436 "errorDescription", "Got 503 from aai",
437 "rawAaiResponse", preset.getResponseBody()
440 assertResponse(expected, response);
444 public void portMirroringConfigData_given404ErrorAaiResponse_yield200OkWithErrorMsg() {
445 SimulatorApi.clearAll();
447 final String response = restTemplate.getForObject(uri + "/aai_getPortMirroringConfigsData?configurationIds=" + "SOME-RANDOM-UUID", String.class);
449 final ImmutableMap<String, ImmutableMap<String, String>> expected = ImmutableMap.of(
450 "SOME-RANDOM-UUID", ImmutableMap.of(
451 "errorDescription", "Got 404 from aai",
455 assertResponse(expected, response);
459 public void getNetworkCollectionDetailsByServiceInstanceId_yieldValidResponse() {
460 SimulatorApi.clearAll();
461 final PresetAAIGetNetworkCollectionDetails presetAAIGetNetworkCollectionDetails = new PresetAAIGetNetworkCollectionDetails("SOME-RANDOM-UUID");
462 SimulatorApi.registerExpectationFromPreset(presetAAIGetNetworkCollectionDetails, CLEAR_THEN_SET);
463 final String response = restTemplate.getForObject(uri + "/aai_get_network_collection_details/" + "SOME-RANDOM-UUID", String.class);
465 assertResponse(GET_NETWORK_COLLECTION_EXPECTED_RESPONSE, response);
469 public void getNetworkCollectionDetailsByServiceInstanceId_responseWithExtraFields_yieldValidResponse() {
470 SimulatorApi.clearAll();
471 final PresetAAIGetNetworkCollectionDetailsInvalidRequest presetAAIGetNetworkCollectionDetails = new PresetAAIGetNetworkCollectionDetailsInvalidRequest("SOME-RANDOM-UUID");
472 SimulatorApi.registerExpectationFromPreset(presetAAIGetNetworkCollectionDetails, CLEAR_THEN_SET);
473 final String response = restTemplate.getForObject(uri + "/aai_get_network_collection_details/" + "SOME-RANDOM-UUID", String.class);
475 assertResponse(GET_NETWORK_COLLECTION_EXPECTED_RESPONSE, response);
479 public void getNetworkCollectionDetailsByServiceInstanceId_given404ErrorAaiResponse_yield200OkWithErrorMsg() {
480 SimulatorApi.clearAll();
482 restTemplate.getForObject(uri + "/aai_get_network_collection_details/" + "SOME-RANDOM-UUID", String.class);
483 } catch (HttpClientErrorException e) {
484 assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
489 public void getNetworkCollectionDetailsByServiceInstanceId_responseWithRequiredMissing() {
490 SimulatorApi.clearAll();
491 final PresetAAIGetNetworkCollectionDetailsRequiredMissing presetAAIGetNetworkCollectionDetails = new PresetAAIGetNetworkCollectionDetailsRequiredMissing("SOME-RANDOM-UUID");
492 SimulatorApi.registerExpectationFromPreset(presetAAIGetNetworkCollectionDetails, CLEAR_THEN_SET);
494 restTemplate.getForObject(uri + "/aai_get_network_collection_details/" + "SOME-RANDOM-UUID", String.class);
495 } catch (HttpServerErrorException e) {
496 assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, e.getStatusCode());
501 public void getGetInstanceGroupsByCloudRegion_yieldValidResponse() {
502 SimulatorApi.clearAll();
503 final PresetAAIGetInstanceGroupsByCloudRegion presetAAIGetInstanceGroupsByCloudRegion = new PresetAAIGetInstanceGroupsByCloudRegion("CLOUD%20OWNER", "CLOUD-REGION-ID", "NETWORK%20FUNCTION");
504 SimulatorApi.registerExpectationFromPreset(presetAAIGetInstanceGroupsByCloudRegion, CLEAR_THEN_SET);
505 final String response = restTemplate.getForObject(uri + "/aai_get_instance_groups_by_cloudregion/" + "CLOUD OWNER" + "/" + "CLOUD-REGION-ID" + "/" + "NETWORK FUNCTION", String.class);
507 assertResponse(GET_INSTANCE_GROUPS_BY_CLOUDREGION_EXPECTED_RESPONSE, response);
511 public void getGetInstanceGroupsByCloudRegion_responseWithExtraFields_yieldValidResponse() {
512 SimulatorApi.clearAll();
513 final PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest presetAAIGetInstanceGroupsByCloudRegion = new PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest("CLOUD-OWNER", "CLOUD-REGION-ID", "NETWORK-FUNCTION");
514 SimulatorApi.registerExpectationFromPreset(presetAAIGetInstanceGroupsByCloudRegion, CLEAR_THEN_SET);
515 final String response = restTemplate.getForObject(uri + "/aai_get_instance_groups_by_cloudregion/" + "CLOUD-OWNER" + "/" + "CLOUD-REGION-ID" + "/" + "NETWORK-FUNCTION", String.class);
517 assertResponse(GET_INSTANCE_GROUPS_BY_CLOUDREGION_EXPECTED_RESPONSE, response);
521 public void getGetInstanceGroupsByCloudRegion_given404ErrorAaiResponse_yield200OkWithErrorMsg() {
522 SimulatorApi.clearAll();
524 restTemplate.getForObject(uri + "/aai_get_instance_groups_by_cloudregion/" + "CLOUD-OWNER" + "/" + "CLOUD-REGION-ID" + "/" + "NETWORK-FUNCTION", String.class);
525 } catch (HttpClientErrorException e) {
526 assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
531 public void getGetInstanceGroupsByCloudRegion_responseWithRequiredMissing() {
532 SimulatorApi.clearAll();
533 final PresetAAIGetInstanceGroupsByCloudRegionRequiredMissing presetAAIGetInstanceGroupsByCloudRegion = new PresetAAIGetInstanceGroupsByCloudRegionRequiredMissing("CLOUD-OWNER", "CLOUD-REGION-ID", "NETWORK-FUNCTION");
534 SimulatorApi.registerExpectationFromPreset(presetAAIGetInstanceGroupsByCloudRegion, CLEAR_THEN_SET);
536 restTemplate.getForObject(uri + "/aai_get_instance_groups_by_cloudregion/" + "CLOUD-OWNER" + "/" + "CLOUD-REGION-ID" + "/" + "NETWORK-FUNCTION", String.class);
537 } catch (HttpServerErrorException e) {
538 assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, e.getStatusCode());
543 public void portMirroringConfigData_emptyIdOnAaiResponse_yieldError() {
544 final PresetAAICloudRegionAndSourceFromConfigurationPut presetAAIResponseWitnProblem = new PresetAAICloudRegionAndSourceFromConfigurationPut("SOME-RANDOM-UUID", "");
545 SimulatorApi.registerExpectationFromPreset(presetAAIResponseWitnProblem, CLEAR_THEN_SET);
547 final String response = restTemplate.getForObject(uri + "/aai_getPortMirroringConfigsData?configurationIds=" + "SOME-RANDOM-UUID", String.class);
549 final ImmutableMap<String, ImmutableMap<String, String>> expected = ImmutableMap.of(
550 "SOME-RANDOM-UUID", ImmutableMap.of(
551 "errorDescription", "Node 'properties.cloud-region-id' of node-type 'cloud-region' is blank",
552 "rawAaiResponse", presetAAIResponseWitnProblem.getResponseBody().toString().replace(" ", "")
555 assertResponse(expected, response);
559 public void getGetRelatedInstanceGroupsByVnfId__yieldValidResponse() {
560 String vnfId = "some_vnf_id";
561 final PresetAAIGetRelatedInstanceGroupsByVnfId getRelatedInstanceGroupsByVnfId = new PresetAAIGetRelatedInstanceGroupsByVnfId(vnfId);
562 SimulatorApi.registerExpectationFromPreset(getRelatedInstanceGroupsByVnfId, CLEAR_THEN_SET);
564 final String response = restTemplate.getForObject(uri + "/aai_get_instance_groups_by_vnf_instance_id/" + vnfId,
567 assertResponse("[{\"type\":\"instance-group\",\"name\":\"instance group name\"},{\"type\":\"instance-group\",\"name\":\"instance group name\"}]", response);
571 public void getHomingDataForVfModule(){
572 String vnfId= "0846287b-65bf-45a6-88f6-6a1af4149fac", vfModuleId= "a9b70ac0-5917-4203-a308-0e6920e6d09b";
573 SimulatorApi.registerExpectationFromPreset(new PresetAAIGetHomingForVfModule(vnfId,vfModuleId), CLEAR_THEN_SET);
574 final String response = restTemplate.getForObject(uri + "/aai_get_homing_by_vfmodule/"+ vnfId +"/"+vfModuleId, String.class);
575 String exectedResponse = TestUtils.convertRequest(objectMapper, AAI_HOMING_DATA_RESPONSE);
576 assertResponse(exectedResponse,response);
580 public void getGetRelatedInstanceGroupsByVnfId__yield404NotFound() {
581 final PresetAAIGetRelatedInstanceGroupsByVnfId getRelatedInstanceGroupsByVnfId = new PresetAAIGetRelatedInstanceGroupsByVnfId("abcd");
582 SimulatorApi.registerExpectationFromPreset(getRelatedInstanceGroupsByVnfId, CLEAR_THEN_SET);
584 restTemplate.getForObject(uri + "/aai_get_instance_groups_by_vnf_instance_id/" + "dcba", String.class);
585 } catch (HttpClientErrorException e) {
586 assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
592 public void portMirroringConfigData_twoResponsesOneValidAndOneInvalid_yieldBothErrorAndOk() {
593 final PresetAAICloudRegionAndSourceFromConfigurationPut presetAAIResponseWitnProblem = new PresetAAICloudRegionAndSourceFromConfigurationPut("ANOTHER-RANDOM-UUID", "");
594 SimulatorApi.registerExpectationFromPreset(presetAAIResponseWitnProblem, CLEAR_THEN_SET);
595 SimulatorApi.registerExpectationFromPreset(new PresetAAICloudRegionAndSourceFromConfigurationPut("SOME-RANDOM-UUID", "THE-EXPECTED-REGION-ID"), APPEND);
597 final String response = restTemplate.getForObject(uri + "/aai_getPortMirroringConfigsData?configurationIds=" + "SOME-RANDOM-UUID,ANOTHER-RANDOM-UUID", String.class);
599 final ImmutableMap<String, ImmutableMap<String, Object>> expected = ImmutableMap.of(
600 "SOME-RANDOM-UUID", ImmutableMap.of(
601 "cloudRegionId", "THE-EXPECTED-REGION-ID"
603 "ANOTHER-RANDOM-UUID", ImmutableMap.of(
604 "errorDescription", "Node 'properties.cloud-region-id' of node-type 'cloud-region' is blank",
605 "rawAaiResponse", presetAAIResponseWitnProblem.getResponseBody().toString().replace(" ", "")
608 assertResponse(expected, response);
612 @FeatureTogglingTest(Features.FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS)
613 public void networksToVlans_simpleRequest_responseIsCorrect() {
614 // Prepare randomized values
615 // Some of these random values are persisted to match with the
616 // cypress preset "aaiGetNetworksToVlansByServiceInstance.json".
617 String globalCustomerId = UUID.randomUUID().toString();
618 String sdcModelUuid = "5a3ad576-c01d-4bed-8194-0e72b4a3d020";
619 String serviceType = "vMOG";
620 int vlanIdOuter = 34612;
621 int vlanIdOuter2 = 8568012;
622 int vlanIdOuter3 = 4;
624 // build hierarchical presets:
635 PresetAAIStandardQueryGet vlanTagPreset1 = ofVlanTag(vlanIdOuter);
636 PresetAAIStandardQueryGet vlanTagPreset2 = ofVlanTag(vlanIdOuter2);
637 PresetAAIStandardQueryGet vlanTagPreset3 = ofVlanTag(vlanIdOuter3);
639 PresetAAIStandardQueryGet l3NetworkPreset1 = ofL3Network("7989a6d2-ba10-4a5d-8f15-4520bc833090", "DDDEEEFFF", "Provider Network",
640 ImmutableMultimap.of("vlan-tag", vlanTagPreset1.getReqPath(), "vlan-tag", vlanTagPreset2.getReqPath()), "Failed");
641 PresetAAIStandardQueryGet l3NetworkPreset2 = ofL3Network("e8e2332e-1f84-4237-bc97-3b5b842f52e4","GGGHHHIII", "Network",
642 ImmutableMultimap.of("vlan-tag", vlanTagPreset3.getReqPath()), "Assigned");
644 PresetAAIStandardQueryGet serviceInstance = ofServiceInstance("9cdd1b2a-43a7-47bc-a88e-759ba2399f0b",
645 "7a6ee536-f052-46fa-aa7e-2fca9d674c44", "6e59c5de-f052-46fa-aa7e-2fca9d674c44", globalCustomerId, serviceType,
646 ImmutableMultimap.of("l3-network", l3NetworkPreset1.getReqPath(), "l3-network", l3NetworkPreset2.getReqPath()));
648 SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
649 serviceInstance, l3NetworkPreset1, l3NetworkPreset2, vlanTagPreset1, vlanTagPreset2, vlanTagPreset3,
650 new PresetSDCGetServiceMetadataGet(sdcModelUuid, UUID.randomUUID().toString(), "service-vl-with-5g-network-provider-alacarte.zip"),
651 new PresetSDCGetServiceToscaModelGet(sdcModelUuid, "service-vl-with-5g-network-provider-alacarte.zip")
655 final String response = restTemplate.getForObject(uri + "/aai/standardQuery/vlansByNetworks"
656 + "?serviceInstanceId=" + serviceInstance.getInstanceId()
657 + "&serviceType=" + serviceType
658 + "&globalCustomerId=" + globalCustomerId
659 + "&sdcModelUuid=" + sdcModelUuid
662 assertResponse(JsonAssert.when(Option.IGNORING_ARRAY_ORDER),
663 getResourceAsString("serviceWithNetwork/aaiGetNetworksToVlansByServiceInstance.json"),
668 @FeatureTogglingTest(Features.FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS)
669 public void networksWithVlansToVnf_simpleRequest_responseIsCorrect() {
670 // Prepare randomized values
671 // Some of these random values are persisted to match with the
672 // cypress preset "aaiGetNetworksWithVlansToVnfByServiceInstance.json".
673 String globalCustomerId = UUID.randomUUID().toString();
674 String sdcModelUuid = "5a3ad576-c01d-4bed-8194-0e72b4a3d020";
675 String serviceType = "vMOG";
676 int vlanIdOuter = 34123;
677 int vlanIdOuter2 = 65540;
678 int vlanIdOuter3 = 12345;
679 int vlanIdOuter4 = 67890;
680 int vlanIdOuter5 = 417695;
681 int vlanIdOuter6 = 783243;
683 // build hierarchical presets:
700 PresetAAIStandardQueryGet vlanTagPreset1 = ofVlanTag(vlanIdOuter);
701 PresetAAIStandardQueryGet vlanTagPreset2 = ofVlanTag(vlanIdOuter2);
702 PresetAAIStandardQueryGet vlanTagPreset3 = ofVlanTag(vlanIdOuter3);
703 PresetAAIStandardQueryGet vlanTagPreset4 = ofVlanTag(vlanIdOuter4);
704 PresetAAIStandardQueryGet vlanTagPreset5 = ofVlanTag(vlanIdOuter5);
705 PresetAAIStandardQueryGet vlanTagPreset6 = ofVlanTag(vlanIdOuter6);
707 PresetAAIStandardQueryGet l3NetworkPreset1 = ofL3Network("36517f3d-2bc2-48f5-aaf8-418520c54330","AAAAABBBBCCCC", "Provider Network",
708 ImmutableMultimap.of("vlan-tag", vlanTagPreset1.getReqPath(), "vlan-tag", vlanTagPreset2.getReqPath()), "Assigned");
710 PresetAAIStandardQueryGet l3NetworkPreset2 = ofL3Network("12347f3d-2bc2-48f5-aaf8-418520c54330","DDDEEEE", "Provider Network",
711 ImmutableMultimap.of("vlan-tag", vlanTagPreset3.getReqPath(), "vlan-tag", vlanTagPreset4.getReqPath()), "Created");
713 PresetAAIStandardQueryGet vnfPreset1 = ofVnf("c015cc0f-0f37-4488-aabf-53795fd93cd3",
714 ImmutableMultimap.of("l3-network", l3NetworkPreset1.getReqPath() , "l3-network", l3NetworkPreset2.getReqPath()),
717 PresetAAIStandardQueryGet l3NetworkPreset3 = ofL3Network("12aa7f3d-2bc2-48f5-aaf8-418520c54330","XXXYYYZZZ", "Network",
718 ImmutableMultimap.of("vlan-tag", vlanTagPreset5.getReqPath(), "vlan-tag", vlanTagPreset6.getReqPath()), "Created");
720 PresetAAIStandardQueryGet vnfPreset2 = ofVnf("c55da606-cf38-42c7-bc3c-be8e23b19299", ImmutableMultimap.of("l3-network", l3NetworkPreset3.getReqPath()),
723 PresetAAIStandardQueryGet serviceInstance = ofServiceInstance("9cdd1b2a-43a7-47bc-a88e-759ba2399f0b",
724 "7a6ee536-f052-46fa-aa7e-2fca9d674c44", "6e59c5de-f052-46fa-aa7e-2fca9d674c44", globalCustomerId, serviceType,
725 ImmutableMultimap.of("generic-vnf", vnfPreset1.getReqPath(), "generic-vnf", vnfPreset2.getReqPath()));
727 SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
728 serviceInstance, vnfPreset1, vnfPreset2, l3NetworkPreset1, l3NetworkPreset2, l3NetworkPreset3, vlanTagPreset1, vlanTagPreset2, vlanTagPreset3, vlanTagPreset4, vlanTagPreset5, vlanTagPreset6,
729 new PresetSDCGetServiceMetadataGet(sdcModelUuid, UUID.randomUUID().toString(), "service-vl-with-5g-network-provider-alacarte.zip"),
730 new PresetSDCGetServiceToscaModelGet(sdcModelUuid, "service-vl-with-5g-network-provider-alacarte.zip")
734 final String response = restTemplate.getForObject(uri + "/aai/standardQuery/vlansByNetworks"
735 + "?serviceInstanceId=" + serviceInstance.getInstanceId()
736 + "&serviceType=" + serviceType
737 + "&globalCustomerId=" + globalCustomerId
738 + "&sdcModelUuid=" + sdcModelUuid
741 assertResponse(JsonAssert.when(Option.IGNORING_ARRAY_ORDER),
742 getResourceAsString("serviceWithNetwork/aaiGetNetworksWithVlansToVnfByServiceInstance.json"),
746 @FeatureTogglingTest(value = Features.FLAG_FLASH_REDUCED_RESPONSE_CHANGEMG, flagActive = false)
748 public void getVnfDataByGlobalIdAndServiceType() {
750 SimulatorApi.registerExpectationFromPreset(new PresetBaseAAICustomQuery(
752 "business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances",
753 "query/vnf-topology-fromServiceInstance"
756 public Object getResponseBody() {
757 return getResourceAsString(
758 "registration_to_simulator/changeManagement/get_vnf_data_by_globalid_and_service_type_response.json");
762 String url = uri + "/get_vnf_data_by_globalid_and_service_type/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/vRichardson";
764 ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
766 assertResponse(JsonAssert.when(Option.IGNORING_ARRAY_ORDER),
767 getResourceAsString("registration_to_simulator/changeManagement/get_vnf_data_by_globalid_and_service_type_response.json"),
772 public void whenCallAaiThroughAAIRestInterface_thenRequestRecordedInMetricsLog() {
773 registerExpectationFromPresets(ImmutableList.of(
774 new PresetAAIGetVpnsByType(),
775 new PresetAAIGetSubscribersGet()
778 String url = uri + "/aai_get_vpn_list";
779 ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
780 final String requestId = response.getHeaders().getFirst("X-ECOMP-RequestID-echo");
781 LoggerFormatTest.assertHeadersAndMetricLogs(restTemplate, uri, requestId,"/network/vpn-bindings" , 1);
785 public void getVpnList() {
786 SimulatorApi.registerExpectationFromPreset(new PresetAAIGetVpnsByType(), CLEAR_THEN_SET);
787 String url = uri + "/aai_get_vpn_list";
788 ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
789 String expected = getResourceAsString("viewEdit/aaiGetVpnList.json");
790 assertThat(response.getBody(), jsonEquals(expected).when(Option.IGNORING_ARRAY_ORDER).when(Option.IGNORING_EXTRA_FIELDS));
794 public static Object[][] getActiveNetworkAaiStates() {
795 return new Object[][] {
796 {1, "viewEdit/aaiGetActiveNetworks.json"},
797 {2, "viewEdit/aaiGetActiveNetworks2.json"}
801 @Test(dataProvider = "getActiveNetworkAaiStates")
802 public void getActiveNetworks_givenSpecificAAIState_cypressPresetMatch(int state, String expectedResultFileName) {
803 SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
804 new PresetAAIGetL3NetworksByCloudRegionSpecificState(state),
805 PresetAAIGetCloudOwnersByCloudRegionId.PRESET_AUK51A_TO_ATT_NC
807 String url = uri + AAI_GET_ACTIVE_NETWORKS
808 + "?cloudRegion=" + AAIBaseGetL3NetworksByCloudRegionPreset.DEFAULT_CLOUD_REGION_ID
809 + "&tenantId=" + AAIBaseGetL3NetworksByCloudRegionPreset.DEFAULT_TENANT_ID;
810 String response = restTemplate.getForObject(url, String.class);
811 System.out.println("response = " + response);
812 String expected = getResourceAsString(expectedResultFileName);
813 assertThat(response, jsonEquals(expected));
817 public void getActiveNetworks() throws JsonProcessingException {
818 String networkRole = "Some role";
819 PresetAAIGetL3NetworksByCloudRegion presetAAIGetL3NetworksByCloudRegion = new PresetAAIGetL3NetworksByCloudRegion(networkRole);
820 List<BasePreset> presets = ImmutableList.of(
821 presetAAIGetL3NetworksByCloudRegion,
822 PresetAAIGetCloudOwnersByCloudRegionId.PRESET_AUK51A_TO_ATT_NC
824 SimulatorApi.registerExpectationFromPresets(presets, CLEAR_THEN_SET);
825 String url = uri + AAI_GET_ACTIVE_NETWORKS +
826 "?cloudRegion=" + presetAAIGetL3NetworksByCloudRegion.getCloudRegionId() +
827 "&tenantId=" + presetAAIGetL3NetworksByCloudRegion.getTenantId() +
828 "&networkRole=" + networkRole;
829 ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
831 assertResponse(JsonAssert.when(Option.IGNORING_EXTRA_FIELDS, Option.IGNORING_ARRAY_ORDER),
832 presetAAIGetL3NetworksByCloudRegion.getActiveNetworksWithNameAndRelatedToVpnBindingAsJsonString(),
837 public void getNewestModelVersionByInvariant() throws JsonProcessingException {
838 String invariantId = "f6342be5-d66b-4d03-a1aa-c82c3094c4ea";
840 SimulatorApi.registerExpectationFromPreset(new PresetAAIModelVersionsByInvariantId(), CLEAR_THEN_SET );
843 "/aai_get_newest_model_version_by_invariant/" + invariantId;
844 ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
846 assertTrue(response.toString().contains("the-newest-version"));
850 public void getNewestModelVersionByInvariant_modelNotExist_thenEmptyResponse() {
851 String invariantId = "f6342be5-d66b-4d03-a1aa-c82c3094c4ea";
853 SimulatorApi.registerExpectationFromPreset(new PresetAAIModelVersionsByInvariantId(), CLEAR_THEN_SET );
856 "/aai_get_newest_model_version_by_invariant/" + "model-not-exist";
857 ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
859 assertTrue(response.getStatusCode().is2xxSuccessful());
860 AssertJUnit.assertNull(response.getBody());
864 @FeatureTogglingTest(Features.FLAG_FLASH_REDUCED_RESPONSE_CHANGEMG)
865 public void getVnfsWithCustomQueryNewReducedResponse() throws URISyntaxException {
867 String globalCustomerId = "globalCustomerId1-360-as988q";
868 String serviceType = "TEST1-360";
869 String nfRole = "test360";
870 SimulatorApi.registerExpectationFromPreset(new PresetBaseAAICustomQuery(
872 "/business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/"
873 + serviceType + "/service-instances",
874 "query/vnfs-fromServiceInstance-filter?nfRole=" + nfRole
877 public Object getResponseBody() {
878 return getResourceAsString(
879 AAI_VNFS_FOR_CHANGE_MANAGEMENT_JSON_BY_PARAMS);
882 URIBuilder urlBuilder = new URIBuilder(uri + "/get_vnf_data_by_globalid_and_service_type/" + globalCustomerId + "/" + serviceType);
883 urlBuilder.addParameter("nfRole", nfRole);
884 ResponseEntity<String> response = restTemplate.getForEntity(urlBuilder.build().toString(), String.class);
885 assertTrue(response.getStatusCode().is2xxSuccessful());
886 assertThat(response.getBody(), jsonEquals(getResourceAsString(AAI_VNFS_FOR_CHANGE_MANAGEMENT_JSON_BY_PARAMS)));
889 private void assertResponse(Object expected, String response) {
890 assertResponse(Configuration.empty(), expected, response);
893 private void assertResponse(Configuration configuration, Object expected, String response) {
895 JsonAssert.assertJsonEquals(expected, response, configuration);
896 } catch (Exception | AssertionError e) {
897 System.err.println("response was: " + response);