diff options
Diffstat (limited to 'bpmn/MSOMockServer/src/main/java/org')
6 files changed, 334 insertions, 1 deletions
diff --git a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseAAI.java b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseAAI.java index c4139c99cf..be1c19e05d 100644 --- a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseAAI.java +++ b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseAAI.java @@ -161,6 +161,12 @@ public class StubResponseAAI { .withHeader("Content-Type", "text/xml")));
}
+ public static void MockDeleteServiceInstance(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode){
+ stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse()
+ .withStatus(statusCode)));
+ }
+
public static void MockDeleteServiceInstance(String customer, String serviceSubscription, String resourceVersion, int statusCode){
stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "[?]resource-version=" +1234))
.willReturn(aResponse()
@@ -262,6 +268,15 @@ public class StubResponseAAI { /**
* Generic-Vnf Mock StubResponses below
*/
+
+ public static void MockGetGenericVnfById(String vnfId, String responseFile){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=1"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
public static void MockGetGenericVnfById(String vnfId, String responseFile, int statusCode){
stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
.willReturn(aResponse()
@@ -454,6 +469,44 @@ public class StubResponseAAI { .withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
+
+ public static void MockGetNetworkByIdWithDepth(String networkId, String responseFile, String depth) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId + "[?]depth=" + depth))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkCloudRegion(String responseFile, String cloudRegion) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/"+cloudRegion))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkByName(String networkName, String responseFile) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name="+networkName))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkByName_404(String responseFile, String networkName) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name="+networkName))
+ .willReturn(aResponse()
+ .withStatus(404)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkCloudRegion_404(String cloudRegion) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/"+cloudRegion))
+ .willReturn(aResponse()
+ .withStatus(404)));
+ }
public static void MockPutNetwork(String networkId, int statusCode, String responseFile) {
stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId))
@@ -478,6 +531,22 @@ public class StubResponseAAI { .withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
+
+ public static void MockGetNetworkVpnBinding(String responseFile, String vpnBinding) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/"+vpnBinding + "[?]depth=all"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkPolicy(String responseFile, String policy) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/"+policy + "[?]depth=all"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
public static void MockGetNetworkVpnBinding(String networkBindingId, String responseFile, int statusCode) {
stubFor(get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/" + networkBindingId))
@@ -495,6 +564,22 @@ public class StubResponseAAI { .withBodyFile(responseFile)));
}
+ public static void MockGetNetworkTableReference(String responseFile, String tableReference) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/"+tableReference + "[?]depth=all"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockPutNetworkIdWithDepth(String responseFile, String networkId, String depth) {
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/"+networkId+"[?]depth="+depth ))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
public static void MockGetNetworkPolicyfqdn(String networkPolicy, String responseFile, int statusCode) {
stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy[?]network-policy-fqdn=" + networkPolicy))
.willReturn(aResponse()
@@ -686,6 +771,18 @@ public class StubResponseAAI { .withStatus(statusCode)));
}
+ public static void MockGetVolumeGroupByName_404(String cloudRegionId, String volumeGroupName) {
+ stubFor(get(urlMatching("/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
+ .willReturn(aResponse()
+ .withStatus(404)));
+ }
+
+ public static void MockDeleteVolumeGroup(String cloudRegionId, String volumeGroupId, String resourceVersion) {
+ stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
/**
* VF-Module StubResponse below
* @param statusCode TODO
@@ -737,6 +834,30 @@ public class StubResponseAAI { .withStatus(statusCode)));
}
+ /* AAI Pserver Queries */
+ public static void MockGetPserverByVnfId(String vnfId, String responseFile, int statusCode) {
+ stubFor(put(urlMatching("/v10/query.*"))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetGenericVnfsByVnfId(String vnfId, String responseFile, int statusCode) {
+ stubFor(get(urlMatching("/v10/network/generic-vnfs/.*"))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "application/json; charset=utf-8")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockSetInMaintFlagByVnfId(String vnfId, int statusCode) {
+ stubFor(patch(urlMatching("/v10/network/generic-vnfs/.*"))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ ));
+ }
+
//// Deprecated Stubs below - to be deleted once unit test that reference them are refactored to use common ones above ////
@Deprecated
public static void MockGetVceById(){
diff --git a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java index 7eefa4bc39..f691043297 100644 --- a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java +++ b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java @@ -40,6 +40,14 @@ public class StubResponseDatabase { } + public static void MockUpdateRequestDB(String fileName){ + stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile(fileName))); + } + public static void mockUpdateRequestDB(int statusCode, String reponseFile) { stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter")) .willReturn(aResponse() @@ -61,5 +69,39 @@ public class StubResponseDatabase { .willReturn(aResponse() .withStatus(500))); } + + public static void MockGetVnfCatalogDataCustomizationUuid(String vnfModelCustomizationUuid, String responseFile){ + stubFor(get(urlEqualTo("/v2/serviceVnfs?vnfModelCustomizationUuid=" + vnfModelCustomizationUuid)) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "application/json") + .withBodyFile(responseFile))); + } + + public static void MockGetVfModuleByModelNameCatalogData(String vfModuleModelName, String responseFile){ + stubFor(get(urlEqualTo("/v2/vfModules?vfModuleModelName=" + vfModuleModelName)) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "application/json") + .withBodyFile(responseFile))); + } + + public static void MockGetServiceResourcesCatalogData(String serviceModelInvariantUuid, String serviceModelVersion, String responseFile){ + stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid + + "&serviceModelVersion=" + serviceModelVersion)) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "application/json") + .withBodyFile(responseFile))); + } + + public static void MockGetServiceResourcesCatalogData(String serviceModelInvariantUuid, String responseFile){ + stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid)) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "application/json") + .withBodyFile(responseFile))); + } + } diff --git a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseNetworkAdapter.java b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseNetworkAdapter.java index c81578a998..e496020ee0 100644 --- a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseNetworkAdapter.java +++ b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseNetworkAdapter.java @@ -64,6 +64,15 @@ public class StubResponseNetworkAdapter { .withStatus(500))); } + public static void MockNetworkAdapterPost(String responseFile, String requestContaining) { + stubFor(post(urlEqualTo("/networks/NetworkAdapter")) + .withRequestBody(containing(requestContaining)) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile(responseFile))); + } + public static void MockNetworkAdapter(String networkId, int statusCode, String responseFile) { stubFor(delete(urlEqualTo("/networks/NetworkAdapter/" + networkId)) .willReturn(aResponse() @@ -89,5 +98,21 @@ public class StubResponseNetworkAdapter { .withHeader("Content-Type", "text/xml") .withBodyFile(responseFile))); } - + + public static void MockNetworkAdapterRestRollbackDelete(String responseFile, String networkId) { + stubFor(delete(urlEqualTo("/networks/NetworkAdapter/"+networkId+"/rollback")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile(responseFile))); + } + + public static void MockNetworkAdapterRestPut(String responseFile, String networkId) { + stubFor(put(urlEqualTo("/networks/NetworkAdapter/"+networkId)) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile(responseFile))); + } + } diff --git a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponsePolicy.java b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponsePolicy.java new file mode 100644 index 0000000000..7093b649d4 --- /dev/null +++ b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponsePolicy.java @@ -0,0 +1,99 @@ +/*
+ * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.
+ */
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.mock;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.containing;
+import static com.github.tomakehurst.wiremock.client.WireMock.delete;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.patch;
+import static com.github.tomakehurst.wiremock.client.WireMock.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+
+/**
+ * Reusable Mock StubResponses for Policy
+ *
+ */
+public class StubResponsePolicy {
+
+ public static void setupAllMocks() {
+
+ }
+
+ // start of Policy mocks
+ public static void MockPolicyAbort() {
+ stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ .withRequestBody(containing("BB1"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile("policyAbortResponse.json")));
+
+ stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ .withRequestBody(containing("UPDVnfI"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile("policyAbortResponse.json")));
+
+ stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ .withRequestBody(containing("RPLVnfI"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile("policyAbortResponse.json")));
+
+
+ }
+
+ public static void MockPolicySkip() {
+ stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ .withRequestBody(containing("BB1"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile("Policy/policySkipResponse.json")));
+
+ stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ .withRequestBody(containing("UPDVnfI"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile("Policy/policySkipResponse.json")));
+
+ stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ .withRequestBody(containing("RPLVnfI"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile("Policy/policySkipResponse.json")));
+
+
+ }
+
+
+}
diff --git a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseSDNCAdapter.java b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseSDNCAdapter.java index 8e4b789366..230c9d4fbc 100644 --- a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseSDNCAdapter.java +++ b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseSDNCAdapter.java @@ -38,6 +38,19 @@ public class StubResponseSDNCAdapter { } + public static void mockSDNCAdapter_500() { + stubFor(post(urlEqualTo("/SDNCAdapter")) + .willReturn(aResponse() + .withStatus(500))); + } + + public static void mockSDNCAdapter_500(String requestContaining) { + stubFor(post(urlEqualTo("/SDNCAdapter")) + .withRequestBody(containing(requestContaining)) + .willReturn(aResponse() + .withStatus(500))); + } + public static void mockSDNCAdapter(int statusCode) { stubFor(post(urlEqualTo("/SDNCAdapter")) .willReturn(aResponse() diff --git a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseVNFAdapter.java b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseVNFAdapter.java index 7951a48184..f826db2bb5 100644 --- a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseVNFAdapter.java +++ b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseVNFAdapter.java @@ -30,6 +30,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.put; import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; /** * Please describe the StubResponseVNF.java class @@ -121,10 +122,42 @@ public class StubResponseVNFAdapter { .withHeader("Content-Type", "application/xml"))); } + public static void mockPutVNFVolumeGroupRollback(String volumeGroupId, int statusCode) { + stubFor(delete(urlMatching("/vnfs/v1/volume-groups/" + volumeGroupId + "/rollback")) + .willReturn(aResponse() + .withStatus(statusCode) + .withHeader("Content-Type", "application/xml"))); + } public static void mockPostVNFVolumeGroup(int statusCode) { stubFor(post(urlEqualTo("/vnfs/v1/volume-groups")) .willReturn(aResponse() .withStatus(statusCode) .withHeader("Content-Type", "application/xml"))); } + + public static void mockVNFAdapterRest(String vnfId) { + stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules")) + .willReturn(aResponse() + .withStatus(200))); + } + + public static void mockVNFAdapterRest_500(String vnfId) { + stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules")) + .willReturn(aResponse() + .withStatus(500))); + } + + public static void mockVfModuleDelete(String volumeGroupId) { + stubFor(delete(urlMatching("/vnfs/v1/volume-groups/"+ volumeGroupId)) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/xml"))); + } + + public static void mockVfModuleDelete(String volumeGroupId, int statusCode) { + stubFor(delete(urlMatching("/vnfs/v1/volume-groups/78987")) + .willReturn(aResponse() + .withStatus(statusCode) + .withHeader("Content-Type", "application/xml"))); + } } |