diff options
author | Ittay Stern <ittay.stern@att.com> | 2019-03-11 09:34:34 +0200 |
---|---|---|
committer | Ittay Stern <ittay.stern@att.com> | 2019-03-17 17:02:43 +0200 |
commit | 66af8b9b391879be78660d6ccb0a1f1f9340b423 (patch) | |
tree | fc0d510f7ea28a437bcb1e3b950d1281ac88a4e4 /vid-automation/src/main/java/org | |
parent | 37ad0cc1d36ec6ff68ec39fcaaf2617eef7d08fe (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/main/java/org')
197 files changed, 18504 insertions, 635 deletions
diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/api/BaseRestUtils.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/api/BaseRestUtils.java new file mode 100644 index 000000000..f85225f36 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/api/BaseRestUtils.java @@ -0,0 +1,263 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.api; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.commons.codec.binary.Base64; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.onap.sdc.ci.tests.datatypes.http.HttpHeaderEnum; +import org.onap.sdc.ci.tests.datatypes.http.HttpRequest; +import org.onap.sdc.ci.tests.datatypes.http.RestResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class BaseRestUtils { + public static final String contentTypeHeaderData = "application/json"; + public static final String acceptHeaderData = "application/json"; + public static final String acceptJsonHeader = "application/json"; + public static final String acceptOctetHeader = "application/octet-stream"; + public static final String authorizationHeader = "Basic " + Base64.encodeBase64String("ci:123456".getBytes()); + public static final String acceptOctetStream = "application/octet-stream"; + public static final String ecomp = "onap"; + public static final String authorizationPrefixString = "Basic "; + + public static final String RESOURCE_COMPONENT_TYPE = "resources"; + public static final String PRODUCT_COMPONENT_TYPE = "products"; + public static final String SERVICE_COMPONENT_TYPE = "services"; + + public static final int STATUS_CODE_SUCCESS = 200; + public static final int STATUS_CODE_CREATED = 201; + public static final int STATUS_CODE_DELETE = 204; + public static final int STATUS_CODE_NOT_FOUND = 404; + public static final int STATUS_CODE_SUCCESS_NO_CONTENT = 204; + public static final int STATUS_CODE_SUCCESS_DELETE = 204; + public static final int STATUS_CODE_INVALID_CONTENT = 400; + public static final int STATUS_CODE_MISSING_DATA = 400; + public static final int STATUS_CODE_MISSING_INFORMATION = 403; + public static final int STATUS_CODE_RESTRICTED_ACCESS = 403; + public static final int STATUS_CODE_ALREADY_EXISTS = 409; + public static final int STATUS_CODE_RESTRICTED_OPERATION = 409; + public static final int STATUS_CODE_COMPONENT_NAME_EXCEEDS_LIMIT = 400; + public static final int STATUS_CODE_MISSING_COMPONENT_NAME = 400; + public static final int STATUS_CODE_UNSUPPORTED_ERROR = 400; + public static final int STATUS_CODE_IMPORT_SUCCESS = 201; + public static final int STATUS_CODE_UPDATE_SUCCESS = 200; + public static final int RESTRICTED_OPERATION = 409; + public static final int STATUS_CODE_GET_SUCCESS = 200; + + public static final String SUCCESS_MESSAGE = "OK"; + private static Logger logger = LoggerFactory.getLogger(BaseRestUtils.class.getName()); + + private static byte[] encodeBase64; + + // ************* PRIVATE METHODS ************************ + + protected static Map<String, String> prepareHeadersMap(String userId) { + return prepareHeadersMap(userId, acceptHeaderData); + } + + protected static Map<String, String> prepareHeadersMap(String userId, String accept) { + Map<String, String> headersMap = new HashMap<String, String>(); + if (contentTypeHeaderData != null) { + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData); + } + if (accept != null) { + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), accept); + } + if (userId != null) { + headersMap.put(HttpHeaderEnum.USER_ID.getValue(), userId); + } + + return headersMap; + } + + // send request + // GET + protected static RestResponse sendGet(String url, String userId) throws IOException { + return sendGet(url, userId, null); + } + + protected static RestResponse sendGet(String url, String userId, Map<String, String> additionalHeaders) + throws IOException { + Map<String, String> headersMap = prepareHeadersMap(userId); + if (additionalHeaders != null) { + headersMap.putAll(additionalHeaders); + } + + HttpRequest http = new HttpRequest(); + RestResponse getResourceResponse = http.httpSendGet(url, headersMap); + return getResourceResponse; + } + + public static RestResponse sendGetAndRemoveHeaders(String url, String userId, List<String> headersToRemove) + throws IOException { + Map<String, String> headersMap = prepareHeadersMap(userId); + if (headersToRemove != null) { + for (String header : headersToRemove) { + headersMap.remove(header); + } + } + + HttpRequest http = new HttpRequest(); + RestResponse getResourceResponse = http.httpSendGet(url, headersMap); + return getResourceResponse; + } + + // PUT + protected static RestResponse sendPut(String url, String userBodyJson, String userId, String cont) + throws IOException { + Map<String, String> headersMap = prepareHeadersMap(userId, cont); + + HttpRequest http = new HttpRequest(); + RestResponse updateResourceResponse = http.httpSendByMethod(url, "PUT", userBodyJson, headersMap); + return updateResourceResponse; + } + + // POST + public static RestResponse sendPost(String url, String userBodyJson, String userId, String accept) + throws IOException { + return sendPost(url, userBodyJson, userId, accept, null); + } + + protected static RestResponse sendPost(String url, String userBodyJson, String userId, String accept, + Map<String, String> additionalHeaders) throws IOException { + Map<String, String> headersMap = prepareHeadersMap(userId, accept); + if (additionalHeaders != null) { + headersMap.putAll(additionalHeaders); + } + HttpRequest http = new HttpRequest(); + RestResponse postResourceResponse = http.httpSendPost(url, userBodyJson, headersMap); + return postResourceResponse; + } + + // used form complex requests like import categories.. + protected static RestResponse sendPost(String url, HttpEntity entity, String userId, String accept) + throws IOException { + RestResponse postResponse = new RestResponse(); + CloseableHttpResponse response = null; + CloseableHttpClient client = null; + try { + client = HttpClients.createDefault(); + HttpPost httpPost = new HttpPost(url); + + httpPost.addHeader("USER_ID", userId); + httpPost.setEntity(entity); + response = client.execute(httpPost); + HttpEntity responseEntity = response.getEntity(); + int statusCode = response.getStatusLine().getStatusCode(); + + postResponse.setStatusCode(statusCode); + StringBuffer sb = new StringBuffer(); + try { + BufferedReader in = new BufferedReader(new InputStreamReader(responseEntity.getContent())); + String inputLine; + while ((inputLine = in.readLine()) != null) { + sb.append(inputLine); + } + in.close(); + } catch (Exception e) { + logger.debug("response body is null"); + } + postResponse.setResponse(sb.toString()); + } finally { + try { + if (response != null) { + response.close(); + } + + } catch (IOException e) { + logger.debug("failed to close client or response: ", e); + } + try { + if (client != null) { + client.close(); + } + } catch (IOException e) { + logger.debug("failed to close client or response: ", e); + } + } + return postResponse; + } + + // DELETE + protected static RestResponse sendDelete(String url, String userId) throws IOException { +// Map<String, String> headersMap = prepareHeadersMap(userId); + + return sendDelete(url, userId, null); + } + + protected static RestResponse sendDelete(String url, String userId, Map<String, String> additionalHeaders) throws IOException { + Map<String, String> headersMap = prepareHeadersMap(userId); + if (additionalHeaders != null) { + headersMap.putAll(additionalHeaders); + } + + HttpRequest http = new HttpRequest(); + RestResponse deleteResourceResponse = http.httpSendDelete(url, headersMap); + return deleteResourceResponse; + } + + /* + * // ------ protected static Boolean checkErrorCode(RestResponse + * deleteResponse) { if (deleteResponse.getErrorCode() == + * STATUS_CODE_SUCCESS || deleteResponse.getErrorCode() == + * STATUS_CODE_DELETE) { return true; } return false; } + * + * // *** STATUS CODE VALIDATION UTIITIES **** public static void + * checkStatusCode(RestResponse response, String assertMessage, boolean AND, + * int... statuses) { int statusCode = response.getErrorCode(); for (int + * status : statuses) { if (AND && statusCode != status) { + * Assert.fail(assertMessage + " status: " + statusCode); } else if + * (statusCode == status) { return; } } if (!AND) { + * Assert.fail(assertMessage + " status: " + statusCode); } } + * + * public static void checkDeleteResponse(RestResponse response) { + * checkStatusCode(response,"delete request failed",false,STATUS_CODE_DELETE + * ,STATUS_CODE_NOT_FOUND, STATUS_CODE_SUCCESS); // STATUS_CODE_SUCCESS for + * deActivate user } + * + * public static void checkCreateResponse(RestResponse response) { + * checkStatusCode(response, "create request failed", false, + * STATUS_CODE_CREATED); } + */ + public static String encodeUrlForDownload(String url) { + return url.replaceAll(" ", "%20"); + } + + public static Map<String, String> addAuthorizeHeader(String userName, String password) { + String userCredentials = userName + ":" + password; + encodeBase64 = Base64.encodeBase64(userCredentials.getBytes()); + String encodedUserCredentials = authorizationPrefixString + new String(encodeBase64); + Map<String, String> authorizationHeader = new HashMap<String, String>(); + authorizationHeader.put(HttpHeaderEnum.AUTHORIZATION.getValue(), encodedUserCredentials); + return authorizationHeader; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ArtifactAssetStructure.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ArtifactAssetStructure.java new file mode 100644 index 000000000..8eb4fa38b --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ArtifactAssetStructure.java @@ -0,0 +1,135 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +public class ArtifactAssetStructure { + + String artifactName; + String artifactType; + String artifactURL; + String artifactDescription; + int artifactTimeout;// optional + String artifactChecksum; + String artifactUUID; + String artifactVersion; + String generatedFromUUID;// optional + + public ArtifactAssetStructure(String artifactName, String artifactType, String artifactURL, + String artifactDescription, int artifactTimeout, String artifactChecksum, String artifactUUID, + String artifactVersion, String generatedFromUUID) { + super(); + this.artifactName = artifactName; + this.artifactType = artifactType; + this.artifactURL = artifactURL; + this.artifactDescription = artifactDescription; + this.artifactTimeout = artifactTimeout; + this.artifactChecksum = artifactChecksum; + this.artifactUUID = artifactUUID; + this.artifactVersion = artifactVersion; + this.generatedFromUUID = generatedFromUUID; + } + + public ArtifactAssetStructure() { + super(); + // TODO Auto-generated constructor stub + } + + public String getArtifactName() { + return artifactName; + } + + public void setArtifactName(String artifactName) { + this.artifactName = artifactName; + } + + public String getArtifactType() { + return artifactType; + } + + public void setArtifactType(String artifactType) { + this.artifactType = artifactType; + } + + public String getArtifactURL() { + return artifactURL; + } + + public void setArtifactURL(String artifactURL) { + this.artifactURL = artifactURL; + } + + public String getArtifactDescription() { + return artifactDescription; + } + + public void setArtifactDescription(String artifactDescription) { + this.artifactDescription = artifactDescription; + } + + public int getArtifactTimeout() { + return artifactTimeout; + } + + public void setArtifactTimeout(int artifactTimeout) { + this.artifactTimeout = artifactTimeout; + } + + public String getArtifactChecksum() { + return artifactChecksum; + } + + public void setArtifactChecksum(String artifactChecksum) { + this.artifactChecksum = artifactChecksum; + } + + public String getArtifactUUID() { + return artifactUUID; + } + + public void setArtifactUUID(String artifactUUID) { + this.artifactUUID = artifactUUID; + } + + public String getArtifactVersion() { + return artifactVersion; + } + + public void setArtifactVersion(String artifactVersion) { + this.artifactVersion = artifactVersion; + } + + public String getGeneratedFromUUID() { + return generatedFromUUID; + } + + public void setGeneratedFromUUID(String generatedFromUUID) { + this.generatedFromUUID = generatedFromUUID; + } + + @Override + public String toString() { + return "ArtifactAssetStructure [artifactName=" + artifactName + ", artifactType=" + artifactType + + ", artifactURL=" + artifactURL + ", artifactDescription=" + artifactDescription + ", artifactTimeout=" + + artifactTimeout + ", artifactChecksum=" + artifactChecksum + ", artifactUUID=" + artifactUUID + + ", artifactVersion=" + artifactVersion + ", generatedFromUUID=" + generatedFromUUID + "]"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/AssetStructure.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/AssetStructure.java new file mode 100644 index 000000000..345181d6c --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/AssetStructure.java @@ -0,0 +1,122 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +public class AssetStructure { + + private String uuid; + private String invariantUUID; + private String name; + private String version; + private String toscaModelURL; + private String category; + private String lifecycleState; + private String lastUpdaterUserId; + + public AssetStructure() { + super(); + } + + public AssetStructure(String uuid, String invariantUUID, String name, String version, String toscaModelURL, + String category, String lifecycleState, String lastUpdaterUserId) { + super(); + this.uuid = uuid; + this.invariantUUID = invariantUUID; + this.name = name; + this.version = version; + this.toscaModelURL = toscaModelURL; + this.category = category; + this.lifecycleState = lifecycleState; + this.lastUpdaterUserId = lastUpdaterUserId; + } + + @Override + public String toString() { + return "AssetStructure [uuid=" + uuid + ", invariantUUID=" + invariantUUID + ", name=" + name + ", version=" + + version + ", toscaModelURL=" + toscaModelURL + ", category=" + category + ", lifecycleState=" + + lifecycleState + ", lastUpdaterUserId=" + lastUpdaterUserId + "]"; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getInvariantUUID() { + return invariantUUID; + } + + public void setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getToscaModelURL() { + return toscaModelURL; + } + + public void setToscaModelURL(String toscaModelURL) { + this.toscaModelURL = toscaModelURL; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(String lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + public void setLastUpdaterUserId(String lastUpdaterUserId) { + this.lastUpdaterUserId = lastUpdaterUserId; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/CanvasElement.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/CanvasElement.java new file mode 100644 index 000000000..a17c38c7f --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/CanvasElement.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.onap.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems; + +public final class CanvasElement { + private final String uniqueId; + private ImmutablePair<Integer, Integer> location; + private LeftPanelCanvasItems normativeElementType; + private String elementType; + + CanvasElement(String name, ImmutablePair<Integer, Integer> location, LeftPanelCanvasItems canvasItem) { + super(); + this.uniqueId = name; + this.location = location; + normativeElementType = canvasItem; + } + + CanvasElement(String name, ImmutablePair<Integer, Integer> location, String canvasItem) { + super(); + this.uniqueId = name; + this.location = location; + elementType = canvasItem; + } + + public String getUniqueId() { + return uniqueId; + } + + public ImmutablePair<Integer, Integer> getLocation() { + return location; + } + + public void setLocation(ImmutablePair<Integer, Integer> location) { + this.location = location; + } + + public LeftPanelCanvasItems getNormativeElementType() { + return normativeElementType; + } + + public String getElementType() { + return elementType; + } +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/CanvasManager.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/CanvasManager.java new file mode 100644 index 000000000..999a63bb3 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/CanvasManager.java @@ -0,0 +1,268 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.UUID; +import java.util.stream.Collectors; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.onap.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems; +import org.onap.sdc.ci.tests.execute.setup.ExtentTestActions; +import org.onap.sdc.ci.tests.execute.setup.SetupCDTest; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.StaleElementReferenceException; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import org.testng.Assert; + +import com.aventstack.extentreports.Status; + +public final class CanvasManager { + private Map<String, CanvasElement> canvasElements; + private Actions actions; + private WebElement canvas; + private int reduceCanvasWidthFactor; + private CanvasElement canvasElement; + // Offsets Are used to find upper right corner of canvas element in order to + // connect links + private static final int CANVAS_ELEMENT_Y_OFFSET = 30; + private static final int CANVAS_ELEMENT_X_OFFSET = 18; // 14 - 27 + + private CanvasManager() { + canvasElements = new HashMap<>(); + actions = new Actions(GeneralUIUtils.getDriver()); + canvas = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.CANVAS.getValue()); + try { + WebElement webElement = GeneralUIUtils + .getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.CANVAS_RIGHT_PANEL.getValue()); + reduceCanvasWidthFactor = webElement.getSize().width; + } catch (Exception e) { + reduceCanvasWidthFactor = 0; + } + } + + public static CanvasManager getCanvasManager() { + return new CanvasManager(); + } + + public List<CanvasElement> getCanvasElements() { + return canvasElements.values().stream().collect(Collectors.toList()); + } + + private void addCanvasElement(CanvasElement element) { + canvasElements.put(element.getUniqueId(), element); + } + + private void moveElementOnCanvas(CanvasElement canvasElement, ImmutablePair<Integer, Integer> newLocation) + throws Exception { + GeneralUIUtils.waitForLoader(); + actions.moveToElement(canvas, canvasElement.getLocation().left, canvasElement.getLocation().right); + actions.clickAndHold(); + actions.moveToElement(canvas, newLocation.left, newLocation.right); + actions.release(); + actions.perform(); + canvasElement.setLocation(newLocation); + GeneralUIUtils.waitForLoader(); + + } + + public void moveToFreeLocation(String containerName) { + int maxWait = 5000; + int sumOfWaiting = 0; + int napPeriod = 200; + boolean isKeepWaiting = false; + while (!isKeepWaiting) { + ImmutablePair<Integer, Integer> freePosition = getFreePosition(); + actions.moveToElement(canvas, freePosition.left, freePosition.right); + actions.clickAndHold(); + actions.release(); + actions.perform(); + isKeepWaiting = GeneralUIUtils.getWebElementByTestID("selectedCompTitle").getText() + .equals(containerName); + sumOfWaiting += napPeriod; + if (sumOfWaiting > maxWait) { + Assert.fail("Can't click on VF"); + } + } + } + + public void clickOnCanvaElement(CanvasElement canvasElement) { + actions.moveToElement(canvas, canvasElement.getLocation().left, canvasElement.getLocation().right); + actions.clickAndHold(); + actions.release(); + actions.perform(); + actions.click().perform(); + GeneralUIUtils.ultimateWait(); + ExtentTestActions.log(Status.INFO, String.format("Canvas element %s selected", canvasElement.getElementType())); + } + + public void moveElementOnCanvas(CanvasElement canvasElement) throws Exception { + moveElementOnCanvas(canvasElement, getFreePosition()); + } + + public void deleteElementFromCanvas(CanvasElement canvasElement) throws Exception { + GeneralUIUtils.waitForLoader(); + actions.moveToElement(canvas, canvasElement.getLocation().left, canvasElement.getLocation().right); + actions.click(); + actions.perform(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.DELETE_INSTANCE_BUTTON.getValue()) + .click(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.OK.getValue()).click(); + canvasElements.remove(canvasElement.getUniqueId()); + GeneralUIUtils.ultimateWait(); + if (canvasElement.getElementType().contains("-")){ + ExtentTestActions.log(Status.INFO, String.format("Canvas element %s removed", canvasElement.getElementType().split("-")[4])); + } + else{ + ExtentTestActions.log(Status.INFO, String.format("Canvas element %s removed", canvasElement.getElementType())); + } + } + + private WebElement findClickElement(String dataTestId) { + int attempts = 0; + while (attempts < 2) { + try { + return GeneralUIUtils.getWebElementByTestID(dataTestId); + } catch (StaleElementReferenceException e) { + } + attempts++; + } + return null; + } + + public CanvasElement createElementOnCanvas(String elementName) throws Exception { + String actionDuration = GeneralUIUtils.getActionDuration(() -> { + try { + canvasElement = createElementOnCanvasWithoutDuration(elementName); + } catch (Exception e) { + e.printStackTrace(); + } + }); + + if (canvasElement != null){ + ExtentTestActions.log(Status.INFO, String.format("The element %s should now be on the canvas", elementName), actionDuration); + } + return canvasElement; + } + + private CanvasElement createElementOnCanvasWithoutDuration(String elementDataTestId) throws Exception { + try { + WebElement element = findClickElement(elementDataTestId); + ImmutablePair<Integer, Integer> freePosition = getFreePosition(); + actions.moveToElement(element, 20, 20); + actions.clickAndHold(); + actions.moveToElement(canvas, freePosition.left, freePosition.right); + actions.release(); + actions.perform(); + GeneralUIUtils.ultimateWait(); + String uniqueId = elementDataTestId + "_" + UUID.randomUUID().toString(); + CanvasElement canvasElement = new CanvasElement(uniqueId, freePosition, elementDataTestId); + addCanvasElement(canvasElement); + GeneralUIUtils.ultimateWait(); + return canvasElement; + } + catch (Exception e) { + System.out.println("Can't create element on canvas"); + e.printStackTrace(); + } + return null; + } + + public CanvasElement createElementOnCanvas(LeftPanelCanvasItems canvasItem) throws Exception { + return createElementOnCanvas(canvasItem.getValue()); + } + + private ImmutablePair<Integer, Integer> getFreePosition() { + ImmutablePair<Integer, Integer> randomPosition = null; + boolean freePosition = false; + int minSpace = 150; + while (!freePosition) { + ImmutablePair<Integer, Integer> tempRandomPosition = getRandomPosition(); + freePosition = !canvasElements.values().stream().map(e -> e.getLocation()) + .filter(e -> Math.abs(e.left - tempRandomPosition.left) < minSpace + && Math.abs(e.right - tempRandomPosition.right) < minSpace) + .findAny().isPresent(); + randomPosition = tempRandomPosition; + } + return randomPosition; + } + + private ImmutablePair<Integer, Integer> getRandomPosition() { + int edgeBuffer = 50; + Random random = new Random(); + int xElement = random.nextInt(canvas.getSize().width - 2 * edgeBuffer - reduceCanvasWidthFactor) + edgeBuffer; + int yElement = random.nextInt(canvas.getSize().height - 2 * edgeBuffer) + edgeBuffer; + return new ImmutablePair<Integer, Integer>(xElement, yElement); + } + + public void linkElements(CanvasElement firstElement, CanvasElement secondElement) throws Exception { + ExtentTestActions.log(Status.INFO, String.format("Linking between the %s instance and the %s instance.", firstElement.getElementType(), secondElement.getElementType())); + drawSimpleLink(firstElement, secondElement); + selectReqAndCapAndConnect(); + ExtentTestActions.log(Status.INFO, String.format("The instances %s and %s should now be connected.", firstElement.getElementType(), secondElement.getElementType())); + } + + private void selectReqAndCapAndConnect() throws Exception { + // Select First Cap + GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.LinkMenuItems.LINK_ITEM_CAP.getValue()).get(0).click(); + // Select First Req + GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.LinkMenuItems.LINK_ITEM_REQ.getValue()).get(0).click(); + // Connect + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.LinkMenuItems.CONNECT_BUTTON.getValue()).click(); + + GeneralUIUtils.waitForLoader(); + } + + private void drawSimpleLink(CanvasElement firstElement, CanvasElement secondElement) throws Exception { + int yOffset = CANVAS_ELEMENT_Y_OFFSET; + int xOffset = CANVAS_ELEMENT_X_OFFSET; + + actions.moveToElement(canvas, firstElement.getLocation().left + xOffset, + firstElement.getLocation().right - yOffset); + + actions.clickAndHold(); + actions.moveToElement(canvas, secondElement.getLocation().left + xOffset, secondElement.getLocation().right - yOffset); + actions.release(); + actions.perform(); + GeneralUIUtils.ultimateWait(); + } + + public String updateElementNameInCanvas(CanvasElement canvasElement, String newInstanceName) throws Exception { + GeneralUIUtils.ultimateWait();; + clickOnCanvaElement(canvasElement); + WebElement updateInstanceName = GeneralUIUtils.getWebElementBy(By.id("editPencil")); + updateInstanceName.click(); + WebElement instanceNameField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.INSTANCE_NAME_FIELD.getValue()); + String oldInstanceName = instanceNameField.getAttribute("value"); + instanceNameField.clear(); + instanceNameField.sendKeys(newInstanceName); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.OK.getValue()).click(); + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("w-sdc-modal-resource-instance-name")); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Name of element instance changed from %s to %s", oldInstanceName, newInstanceName)); + return oldInstanceName; + } +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ComponentReqDetails.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ComponentReqDetails.java new file mode 100644 index 000000000..86d23e870 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ComponentReqDetails.java @@ -0,0 +1,272 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +import java.util.ArrayList; +import java.util.List; + +import org.onap.sdc.ci.tests.devObjects.CategoryDefinition; +import org.onap.sdc.ci.tests.devObjects.LifecycleStateEnum; +import org.onap.sdc.ci.tests.devObjects.SubCategoryDefinition; + +public abstract class ComponentReqDetails { + + protected String name; + protected String description; + protected List<String> tags = new ArrayList<>(); + protected String contactId; + protected String icon; + protected String uniqueId; + protected String creatorUserId; + protected String creatorFullName; + protected String lastUpdaterUserId; + protected String lastUpdaterFullName; + protected Long creationDate; + protected Long lastUpdateDate; + protected LifecycleStateEnum lifecycleState; + protected String version; + protected String UUID; + protected List<CategoryDefinition> categories; + protected String projectCode; + protected String csarUUID; + protected String csarVersion; + protected String importedToscaChecksum; + protected String invariantUUID; + + public String getCsarVersion() { + return csarVersion; + } + + public void setCsarVersion(String csarVersion) { + this.csarVersion = csarVersion; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + tags.add(name); + } + + public List<String> getTags() { + return tags; + } + + public void setTags(List<String> tags) { + this.tags = tags; + } + + // public String getCategory() { + // return category; + // } + // + public String getContactId() { + return contactId; + } + + public void setContactId(String contactId) { + this.contactId = contactId; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getUniqueId() { + return uniqueId; + } + + public void setUniqueId(String uniqueId) { + this.uniqueId = uniqueId; + } + + public void setCreatorUserId(String creatorUserId) { + this.creatorUserId = creatorUserId; + } + + public void setCreatorFullName(String creatorFullName) { + this.creatorFullName = creatorFullName; + } + + public void setLastUpdaterUserId(String lastUpdaterUserId) { + this.lastUpdaterUserId = lastUpdaterUserId; + } + + public void setLastUpdaterFullName(String lastUpdaterFullName) { + this.lastUpdaterFullName = lastUpdaterFullName; + } + + public void setCreationDate(Long creationDate) { + this.creationDate = creationDate; + } + + public void setLastUpdateDate(Long lastUpdateDate) { + this.lastUpdateDate = lastUpdateDate; + } + + public void setLifecycleState(LifecycleStateEnum lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public void setUUID(String uUID) { + this.UUID = uUID; + } + + public String getCreatorUserId() { + return creatorUserId; + } + + public String getCreatorFullName() { + return creatorFullName; + } + + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + public String getLastUpdaterFullName() { + return lastUpdaterFullName; + } + + public Long getCreationDate() { + return creationDate; + } + + public Long getLastUpdateDate() { + return lastUpdateDate; + } + + public LifecycleStateEnum getLifecycleState() { + return lifecycleState; + } + + public String getUUID() { + return UUID; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List<CategoryDefinition> getCategories() { + return categories; + } + + public void setCategories(List<CategoryDefinition> categories) { + this.categories = categories; + } + + public void removeAllCategories() { + this.categories = new ArrayList<>(); + } + + public void addCategoryChain(String category, String subCategory) { + if (category != null || subCategory != null) { + if (categories == null) { + categories = new ArrayList<>(); + } + CategoryDefinition selectedCategory = null; + for (CategoryDefinition categoryDef : categories) { + if (categoryDef.getName().equals(category)) { + selectedCategory = categoryDef; + } + } + if (selectedCategory == null) { + selectedCategory = new CategoryDefinition(); + selectedCategory.setName(category); + categories.add(selectedCategory); + } + if (subCategory != null) { + List<SubCategoryDefinition> subcategories = selectedCategory.getSubcategories(); + if (subcategories == null) { + subcategories = new ArrayList<>(); + selectedCategory.setSubcategories(subcategories); + } + SubCategoryDefinition selectedSubcategory = null; + for (SubCategoryDefinition subcategory : subcategories) { + if (subcategory.getName().equals(subCategory)) { + selectedSubcategory = subcategory; + } + } + if (selectedSubcategory == null) { + selectedSubcategory = new SubCategoryDefinition(); + selectedSubcategory.setName(subCategory); + subcategories.add(selectedSubcategory); + } + } + } + } + + public void addCategory(String category) { + addCategoryChain(category, null); + } + + public String getProjectCode() { + return projectCode; + } + + public void setProjectCode(String projectCode) { + this.projectCode = projectCode; + } + + public String getCsarUUID() { + return csarUUID; + } + + public void setCsarUUID(String csarUUID) { + this.csarUUID = csarUUID; + } + + public String getImportedToscaChecksum() { + return importedToscaChecksum; + } + + public void setImportedToscaChecksum(String importedToscaChecksum) { + this.importedToscaChecksum = importedToscaChecksum; + } + + public String getInvariantUUID() { + return invariantUUID; + } + + public void setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/Configuration.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/Configuration.java new file mode 100644 index 000000000..d6a6c1f17 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/Configuration.java @@ -0,0 +1,325 @@ +package org.onap.sdc.ci.tests.datatypes; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; + +import org.yaml.snakeyaml.Yaml; + +public class Configuration { + + private String beHost; + private String feHost; + private int bePort; + private int fePort; + private String url; + private String remoteTestingMachineIP; + private int remoteTestingMachinePort; + private boolean remoteTesting; + private String browser; + private String systemUnderDebug; + private String reportDBhost; + private int reportDBport; + private boolean captureTraffic; + private boolean useBrowserMobProxy; + private String stopOnClassFailure; + private String reportFileName; + private String reportFolder; + private int numOfAttemptsToRefresh; + private boolean rerun; + private String windowsDownloadDirectory; + private String screenshotFolder; + private String harFilesFolder; + private boolean useCustomLogin; + private String geckoDriverPath; + + public Configuration(String url) { + super(); + basicInit(url, false); + } + + public Configuration(String url, boolean useCustomLogin) { + super(); + basicInit(url, useCustomLogin); + } + + private void basicInit(String url, boolean useCustomLogin) { + this.remoteTesting = false; + this.captureTraffic = false; + this.useBrowserMobProxy = false; + this.reportFolder = "." + File.separator + "ExtentReport" + File.separator; + this.reportFileName = "UI_Extent_Report.html"; + this.screenshotFolder = reportFolder + "screenshots" + File.separator; + this.harFilesFolder = reportFolder + "har_files" + File.separator; + this.browser = "firefox"; + this.url = url; + this.numOfAttemptsToRefresh = 2; + this.useCustomLogin = useCustomLogin; + this.geckoDriverPath = null; + } + + public String getGeckoDriverPath(){ + return this.geckoDriverPath; } + + public void setGeckoDriverPath(String geckoDriverPath){ this.geckoDriverPath = geckoDriverPath; } + + public String getBeHost() { + return beHost; + } + + public void setBeHost(String beHost) { + this.beHost = beHost; + } + + + public String getFeHost() { + return feHost; + } + + + public void setFeHost(String feHost) { + this.feHost = feHost; + } + + + public int getBePort() { + return bePort; + } + + + public void setBePort(int bePort) { + this.bePort = bePort; + } + + + public int getFePort() { + return fePort; + } + + + public void setFePort(int fePort) { + this.fePort = fePort; + } + + + public String getUrl() { + return url; + } + + + public void setUrl(String url) { + this.url = url; + } + + + public String getRemoteTestingMachineIP() { + return remoteTestingMachineIP; + } + + + public void setRemoteTestingMachineIP(String remoteTestingMachineIP) { + this.remoteTestingMachineIP = remoteTestingMachineIP; + } + + + public int getRemoteTestingMachinePort() { + return remoteTestingMachinePort; + } + + + public void setRemoteTestingMachinePort(int remoteTestingMachinePort) { + this.remoteTestingMachinePort = remoteTestingMachinePort; + } + + + public boolean isRemoteTesting() { + return remoteTesting; + } + + + public void setRemoteTesting(boolean remoteTesting) { + this.remoteTesting = remoteTesting; + } + + + public String getBrowser() { + return browser; + } + + + public void setBrowser(String browser) { + this.browser = browser; + } + + + public String getSystemUnderDebug() { + return systemUnderDebug; + } + + + public void setSystemUnderDebug(String systemUnderDebug) { + this.systemUnderDebug = systemUnderDebug; + } + + + public String getReportDBhost() { + return reportDBhost; + } + + + public void setReportDBhost(String reportDBhost) { + this.reportDBhost = reportDBhost; + } + + + public int getReportDBport() { + return reportDBport; + } + + + public void setReportDBport(int reportDBport) { + this.reportDBport = reportDBport; + } + + + public boolean isCaptureTraffic() { + return captureTraffic; + } + + + public void setCaptureTraffic(boolean captureTraffic) { + this.captureTraffic = captureTraffic; + } + + + public boolean isUseBrowserMobProxy() { + return useBrowserMobProxy; + } + + + public void setUseBrowserMobProxy(boolean useBrowserMobProxy) { + this.useBrowserMobProxy = useBrowserMobProxy; + } + + + public String getStopOnClassFailure() { + return stopOnClassFailure; + } + + + public void setStopOnClassFailure(String stopOnClassFailure) { + this.stopOnClassFailure = stopOnClassFailure; + } + + + public String getReportFileName() { + return reportFileName; + } + + + public void setReportFileName(String reportFileName) { + this.reportFileName = reportFileName; + } + + + public String getReportFolder() { + return reportFolder; + } + + + public void setReportFolder(String reportFolder) { + this.reportFolder = reportFolder; + } + + + public int getNumOfAttemptsToRefresh() { + return numOfAttemptsToRefresh; + } + + + public void setNumOfAttemptsToRefresh(int numOfAttemptsToRefresh) { + this.numOfAttemptsToRefresh = numOfAttemptsToRefresh; + } + + + public boolean isRerun() { + return rerun; + } + + + public void setRerun(boolean rerun) { + this.rerun = rerun; + } + + + + + public String getWindowsDownloadDirectory() { + return windowsDownloadDirectory; + } + + public void setWindowsDownloadDirectory(String windowsDownloadDirectory) { + this.windowsDownloadDirectory = windowsDownloadDirectory; + } + + public String getScreenshotFolder() { + return screenshotFolder; + } + + public void setScreenshotFolder(String screenshotFolder) { + this.screenshotFolder = screenshotFolder; + } + + public String getHarFilesFolder() { + return harFilesFolder; + } + + public void setHarFilesFolder(String harFilesFolder) { + this.harFilesFolder = harFilesFolder; + } + + public boolean isUseCustomLogin() { + return useCustomLogin; + } + + public void setUseCustomLogin(boolean useCustomLogin) { + this.useCustomLogin = useCustomLogin; + } + + public synchronized static Configuration loadConfigFile(File configFile) { + return loadConfigFile(configFile, Configuration.class); + } + + public Configuration(){ + super(); + } + + public synchronized static <T> T loadConfigFile(File configFile, Class<T> clazz){ + InputStream in = null; + T config = null; + try { + String absolutePath = configFile.getAbsolutePath(); + in = Files.newInputStream(Paths.get(absolutePath)); + Yaml yaml = new Yaml(); + config = yaml.loadAs(in, clazz); + + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + return config; + } + + + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/CsarArtifacts.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/CsarArtifacts.java new file mode 100644 index 000000000..43dd8dfe3 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/CsarArtifacts.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +public class CsarArtifacts { + + private String artifactType; + private String artifactName; + + public CsarArtifacts() { + super(); + } + + public CsarArtifacts(String artifactName, String artifactType) { + super(); + this.artifactName = artifactName; + this.artifactType = artifactType; + } + + @Override + public String toString() { + return "AssetStructure [artifactName=" + artifactName + ", artifactType=" + artifactType + "]"; + } + + public String getArtifactType() { + return artifactType; + } + + public void setArtifactType(String artifactType) { + this.artifactType = artifactType; + } + + public String getArtifactName() { + return artifactName; + } + + public void setArtifactName(String artifactName) { + this.artifactName = artifactName; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/DataTestIdEnum.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/DataTestIdEnum.java new file mode 100644 index 000000000..98b184b93 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/DataTestIdEnum.java @@ -0,0 +1,835 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +import java.util.Arrays; +import java.util.List; + +public final class DataTestIdEnum { + private DataTestIdEnum() { + } + + public enum Dashboard { + IMPORT_AREA("importButtonsArea"), + ADD_AREA("AddButtonsArea"), + BUTTON_ADD_VF("createResourceButton"), + BUTTON_ADD_SERVICE("createServiceButton"), + IMPORT_VFC("importVFCbutton"), + IMPORT_VF("importVFbutton"), + IMPORT_VFC_FILE("file-importVFCbutton"), + IMPORT_VF_FILE("file-importVFbutton"), + BUTTON_ADD_PRODUCT("createProductButton"); + + private String value; + + public String getValue() { + return value; + } + + private Dashboard(String value) { + this.value = value; + } + } + + public enum LifeCyleChangeButtons { + CREATE("create/save"), + CHECK_IN("check_in"), + SUBMIT_FOR_TESTING("submit_for_testing"), + START_TESTING("start_testing"), + ACCEPT("accept"), + CHECKOUT("check_out"); + + private String value; + + public String getValue() { + return value; + } + + private LifeCyleChangeButtons(String value) { + this.value = value; + } + } + + public enum DistributionChangeButtons { + APPROVE("approve"), + REJECT("reject"), + DISTRIBUTE("distribute"), + MONITOR("monitor"), + APPROVE_MESSAGE("checkindialog"), + RE_DISTRIBUTE("redistribute"); + + private String value; + + public String getValue() { + return value; + } + + private DistributionChangeButtons(String value) { + this.value = value; + } + } + + public enum InformationalArtifactsPlaceholders { + CLOUD_QUESTIONNAIRE("Cloud Questionnaire (completed)"), + FEATURES("Features"), + VENDOR_TEST_RESULT("Vendor Test Result"), + TEST_SCRIPTS("Test Scripts"), + RESOURCE_SECURITY_TEMPLATE("Resource Security Template"), + HEAT_TEMPLATE_FROM_VENDOR("HEAT Template from Vendor"), + CAPACITY("Capacity"); + + private String value; + + public String getValue() { + return value; + } + + private InformationalArtifactsPlaceholders(String value) { + this.value = value; + } + } + + public enum ModalItems { + BROWSE_BUTTON("browseButton"), + ADD("Add"), + DESCRIPTION("description"), + SUMBIT_FOR_TESTING_MESSAGE("changeLifeCycleMessage"), + OK("OK"), + CANCEL("Cancel"), + ACCEP_TESTING_MESSAGE("checkindialog"); + + private String value; + + public String getValue() { + return value; + } + + private ModalItems(String value) { + this.value = value; + } + } + + public enum LeftPanelCanvasItems { + BLOCK_STORAGE("BlockStorage"), + CINDER_VOLUME("CinderVolume"), + COMPUTE("Compute"), + LOAD_BALANCER("LoadBalancer"), + NOVA_SERVER("NovaServer"), + OBJECT_STORAGE("ObjectStorage"), + NEUTRON_PORT("NeutronPort"), + PORT("Port"), DATABASE("Database"), + NETWORK("Network"); + + private String value; + + public String getValue() { + return value; + } + + private LeftPanelCanvasItems(String value) { + this.value = value; + } + } + + public enum LinkMenuItems { + CANCEL_BUTTON("link-menu-button-cancel"), + CONNECT_BUTTON("link-menu-button-connect"), + LINK_ITEM_CAP("link-item-capabilities"), + LINK_ITEM_REQ("link-item-requirements"), + LINK_MENU("link-menu-open"); + + private String value; + + public String getValue() { + return value; + } + + private LinkMenuItems(String value) { + this.value = value; + } + } + + public enum GeneralCanvasItems { + CANVAS("canvas"), + CANVAS_RIGHT_PANEL("w-sdc-designer-sidebar-head"), + DELETE_INSTANCE_BUTTON("e-sdc-small-icon-delete"), + UPDATE_INSTANCE_NAME("e-sdc-small-icon-update"), + INSTANCE_NAME_FIELD("instanceName"); + + private String value; + + public String getValue() { + return value; + } + + private GeneralCanvasItems(String value) { + this.value = value; + } + } + + public enum ResourceMetadataEnum { + RESOURCE_NAME("name"), + DESCRIPTION("description"), + CATEGORY("selectGeneralCategory"), + VENDOR_NAME("vendorName"), + VENDOR_RELEASE("vendorRelease"), + TAGS("i-sdc-tag-input"), + CONTACT_ID("contactId"), + ICON(" iconBox"), + TAGS_TABLE("i-sdc-tag-text"); + private String value; + + public String getValue() { + return value; + } + + private ResourceMetadataEnum(String value) { + this.value = value; + } + } + + public enum GeneralElementsEnum { + CREATE_BUTTON("create/save"), + CHECKIN_BUTTON("check_in"), + CHECKOUT_BUTTON("check_out"), + SUBMIT_FOR_TESTING_BUTTON("submit_for_testing"), + DELETE_VERSION_BUTTON("delete_version"), + REVERT_BUTTON("revert"), + LIFECYCLE_STATE("formlifecyclestate"), + VERSION_HEADER("versionHeader"), + OK("OK"), + UPLOAD_FILE_INPUT("browseButton"); + + private String value; + + public String getValue() { + return value; + } + + private GeneralElementsEnum(String value) { + this.value = value; + } + } + + public enum ArtifactPageEnum { + ADD_DEPLOYMENT_ARTIFACT("add-deployment-artifact-button"), + ADD_INFORMATIONAL_ARTIFACT("add-information-artifact-button"), + DOWNLOAD_ARTIFACT_ENV("download_env_"), + ADD_ANOTHER_ARTIFACT("add-another-artifact-button"), + EDIT_ARTIFACT("edit_"), //upload env file by its label(via deployment artifact view)/displayName(via Canvas) + DELETE_ARTIFACT("delete_"), + DOWNLOAD_ARTIFACT("download_"), + GET_DEPLOYMENT_ARTIFACT_DESCRIPTION("description"), + GET_INFORMATIONAL_ARTIFACT_DESCRIPTION("Description"), + OK("OK"), + TYPE("artifactType_"), + DEPLOYMENT_TIMEOUT("timeout_"), + VERSION("artifactVersion_"), + UUID("artifactUUID_"), + EDIT_PARAMETERS_OF_ARTIFACT("edit-parameters-of-"), + ARTIFACT_NAME("artifactDisplayName_"), + UPLOAD_HEAT_ENV_PARAMETERS("uplaodEnv_"), + VERSION_ENV("artifactEnvVersion_"); + private String value; + + public String getValue() { + return value; + } + + private ArtifactPageEnum(String value) { + this.value = value; + } + } + + public enum PropertiesPageEnum { + + ADD_NEW_PROPERTY("addGrey"), + EDIT_PROPERTY("edit_"), + DELETE_PROPERTY("delete_"), + PROPERTY_NAME("propertyName_"), + PROPERTY_DESCRIPTION("propertyDescription_"), + PROPERTY_TYPE("propertyType_"), + ENTRY_SCHEMA("propertySchema_"), + ADD("Add"), CANCEL("Cancel"), + DONE("Done"), + PROPERTY_ROW("propertyRow"), + SAVE("Save"), + POPUP_FORM("sdc-edit-property-container"); + private String value; + + public String getValue() { + return value; + } + + private PropertiesPageEnum(String value) { + this.value = value; + } + } + + public enum PropertiesPopupEnum { + + PROPERTY_NAME("propertyName"), + PROPERTY_VALUE("defaultvalue"), + PROPERTY_BOOLEAN_VALUE("booleantype"), + PROPERTY_DESCRIPTION("description"), + PROPERTY_TYPE("propertyType"), + ENTRY_SCHEMA("schema-type"), + CANCEL("Cancel"), + SAVE("Save"), + POPUP_FORM("sdc-edit-property-container"), + ADD("Add"), + DONE("Done"), + PROPERTY_RADIO_BUTTON_CONTAINER("propertyRadioButton_"), + RADIO_BUTTON_CLASS("tlv-radio-label"); + private String value; + + public String getValue() { + return value; + } + + private PropertiesPopupEnum(String value) { + this.value = value; + } + } + + public enum AdminPageTabs { + USER_MANAGEMENT("usermanagmenttab"), + CATEGORY_MANAGEMENT("categorymanagmenttab"); + + private String value; + + public String getValue() { + return value; + } + + private AdminPageTabs(String value) { + this.value = value; + } + } + + public enum UserManagementEnum { + + SEARCH_BOX("searchbox"), + NEW_USER_FIELD("newuserId"), + ROLE_SELECT("selectrole"), + CREATE_BUTTON("creategreen"), + CLASS__USER_MANAGEMENT_TABLE("sdc-user-management-table"), + ROW_TABLE("row_"), + FIRST_NAME("firstName_"), + LAST_NAME("lastName__"), + USER_ID("userId_"), + EMAIL("email_"), + ROLE("role_"), + LAST_ACTIVE("lastActive_"), + UPDATE_ROLE("selectRole_"), + UPDATE_USER_BUTTON("updateUser_"), + SAVE_USER("save_"), + DELETE_USER("delete_"), + ; + + + private String value; + + public String getValue() { + return value; + } + + private UserManagementEnum(String value) { + this.value = value; + } + } + + public enum CategoryManagement { + + SERVICE_CATEGORY_HEADER("servicecategoryheader"), + RESOURCE_CATEGORY_HEADER("resourcecategoryheader"), + SERVICE_CATEGORY_LIST("servicecategory"), + RESOURCE_CATEGORY_LIST("resourcecategory"), + NEW_CATEGORY_BUTTON("newcategory"), + NEW_SUB_CATEGORY_BUTTON("newsubcategory"), + NEW_CATEGORY_NAME("i-sdc-form-input"); + + private String value; + + public String getValue() { + return value; + } + + private CategoryManagement(String value) { + this.value = value; + } + } + + + + public enum MainMenuButtons { + HOME_BUTTON("main-menu-button-home"), + CATALOG_BUTTON("main-menu-button-catalog"), + ONBOARD_BUTTON("main-menu-button-onboard"), + SEARCH_BOX("main-menu-input-search"), + REPOSITORY_ICON("repository-icon"); + private String value; + + public String getValue() { + return value; + } + + private MainMenuButtons(String value) { + this.value = value; + } + } + + public enum MainMenuButtonsFromInsideFrame { + HOME_BUTTON("breadcrumbs-button-0"); + private String value; + + public String getValue() { + return value; + } + + private MainMenuButtonsFromInsideFrame(String value) { + this.value = value; + } + } + + public enum MenuOptionsEnum { + EDIT("Edit"), + CHECK_IN("Check in"), + CHECK_OUT("Check out"), + VIEW("View"), + SUBMIT_FOR_TEST("Submit For Test"), + ACCEPT("Accept"), + REJECT("Reject"), + START_TEST("Start test"), + DISTREBUTE("Distribute"); + + private String value; + + public String getValue() { + return value; + } + + private MenuOptionsEnum(String value) { + this.value = value; + } + } + + public enum StepsEnum { + GENERAL("Generalstep"), + ICON("Iconstep"), + DEPLOYMENT_ARTIFACT("Deployment Artifactstep"), + INFORMATION_ARTIFACT("Information Artifactstep"), + PROPERTIES("Propertiesstep"), + COMPOSITION("Compositionstep"), + ACTIVITY_LOG("Activity Logstep"), + DEPLOYMENT_VIEW("Deploymentstep"), + TOSCA_ARTIFACTS("TOSCA Artifactsstep"), + MONITOR("Monitor step"), + MANAGEMENT_WORKFLOW("Management Workflowstep"), + INPUTS("Inputsstep"), + HIERARCHY("Hierarchystep"); + + private String value; + + public String getValue() { + return value; + } + + private StepsEnum(String value) { + this.value = value; + } + } + + public enum ArtifactPopup { + + BROWSE("browseButton"), + ARTIFACT_DESCRIPTION("description"), + ARTIFACT_LABEL("artifactLabel"), + ARTIFACT_TYPE("artifacttype"), + OK("OK"), + SAVE("Save"), + DONE_BUTTON("Done"), + CANCEL_BUTTON("Cancel"), + URL("input[class^='i-sdc-form-input']"), + MODAL_WINDOW("sdc-add-artifact"); + + private String value; + + public String getValue() { + return value; + } + + private ArtifactPopup(String value) { + this.value = value; + } + } + + public enum ServiceMetadataEnum { + SERVICE_NAME("name"), DESCRIPTION("description"), CATEGORY("selectGeneralCategory"), PROJECT_CODE("projectCode"), TAGS("i-sdc-tag-input"), CONTACT_ID("contactId"), ICON(" iconBox"); + + private String value; + + public String getValue() { + return value; + } + + private ServiceMetadataEnum(String value) { + this.value = value; + } + } + + public enum ProductMetadataEnum { + PRODUCT_NAME("name"), + FULL_NAME("fullName"), + DESCRIPTION("description"), + PROJECT_CODE("projectCode"), + TAGS("i-sdc-tag-input"), + ATT_CONTACT("attContact"), + ICON(" iconBox"); + + private String value; + + public String getValue() { + return value; + } + + private ProductMetadataEnum(String value) { + this.value = value; + } + } + + public enum DashboardCardEnum { + ASSET_TYPE("asset-type"), LIFECYCLE_STATE("span[class^='w-sdc-dashboard-card-info-lifecycleState']"), + INFO_NAME("div.sdc-tile-content-info-item-name"), + VERSION("div[class^='w-sdc-dashboard-card-info-user']"), + DASHBOARD_CARD("div[class^='w-sdc-dashboard-card ']"), + ASSET_TYPE_CSS("span[data-tests-id='asset-type']"); + + private String value; + + public String getValue() { + return value; + } + + private DashboardCardEnum(String value) { + this.value = value; + } + } + + public enum CatalogPageLeftPanelCategoryCheckbox { + GENERIC_CHECKBOX("span[data-tests-id='checkbox-resourcenewcategory.generic']"), + NETWORK_L2_3("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3']"), + NETWORK_L4_PLUS("span[data-tests-id='checkbox-resourcenewcategory.networkl4+']"), + NETWORK_CONNECTIVITY("span[data-tests-id='checkbox-resourcenewcategory.networkconnectivity']"), + APPLICATION_L4_PLUS("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+']"), + DCAE("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent']"); + + private String value; + + public String getValue() { + return value; + } + + private CatalogPageLeftPanelCategoryCheckbox(String value) { + this.value = value; + } + } + + public enum CatalogPageLeftPanelFilterTitle { + TYPE("span[data-tests-id='typeFilterTitle']"), + CATEGORIES("span[data-tests-id='categoriesFilterTitle']"), + STATUS("span[data-tests-id='statusFilterTitle']"); + + private String value; + + public String getValue() { + return value; + } + + private CatalogPageLeftPanelFilterTitle(String value) { + this.value = value; + } + } + + public enum CatalogPageLeftPanelSubCategoryCheckbox { + COMMON_NETWORK_RESOURCES("span[data-tests-id='checkbox-resourcenewcategory.networkl4+.commonnetworkresources']"), + ROUTER("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3.router']"), + WAN_CONNECTORS("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3.wanconnectors']"), + LAN_CONNECTORS("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3.lanconnectors']"), + INFRASTRUCTERE_NETWORKl2_3("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3.infrastructure']"), + GATEWAY("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3.gateway']"), + NETWORK_ELEMENTS("span[data-tests-id='checkbox-resourcenewcategory.generic.networkelements']"), + ABSTRACT("span[data-tests-id='checkbox-resourcenewcategory.generic.abstract']"), + RULES("span[data-tests-id='checkbox-resourcenewcategory.generic.rules']"), + DATABASE("span[data-tests-id='checkbox-resourcenewcategory.generic.database']"), + INFRASTRUCTERE_GENERIC("span[data-tests-id='checkbox-resourcenewcategory.generic.infrastructure']"), + VIRTUAL_LINKS("span[data-tests-id='checkbox-resourcenewcategory.networkconnectivity.virtuallinks']"), + CONNECTION_POINTS("span[data-tests-id='checkbox-resourcenewcategory.networkconnectivity.connectionpoints']"), + APPLICATION_SERVER("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.applicationserver']"), + CALL_CONTROL("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.callcontrol']"), + MEDIASERVERS("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.mediaservers']"), + WEBSERVER("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.webserver']"), + LOAD_BALANCER("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.loadbalancer']"), + BORDER_ELEMENT("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.borderelement']"), + DATABASE_APPLIVATION_L4_PLUS("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.database']"), + FIREWALL("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.firewall']"), + DATABASE_DCAE("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.database']"), + POLICY("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.policy']"), + MICROSERVICE("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.microservice']"), + SOURCE("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.source']"), + COLLECTOR("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.collector']"), + UTILITY("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.utility']"), + ANALYTICS("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.analytics']"); + + private String value; + + public String getValue() { + return value; + } + + private CatalogPageLeftPanelSubCategoryCheckbox(String value) { + this.value = value; + } + } + + public enum CompositionScreenEnum { + + CHANGE_VERSION("changeVersion", Arrays.asList()), + DEPLOYMENT_ARTIFACT_TAB("deployment-artifact-tab", Arrays.asList("Deployment Artifacts")), + ADD_ARTIFACT("add_Artifact_Button", Arrays.asList()), + SEARCH_ASSET("searchAsset", Arrays.asList()), + PROPERTIES_AND_ATTRIBUTES_TAB("properties-and-attributes-tab",Arrays.asList()), + MENU_INPUTS("sub-menu-button-inputs",Arrays.asList()), + MENU_TRIANGLE_DROPDOWN("triangle-dropdown", Arrays.asList()), + ARTIFACTS_LIST("artifactName", Arrays.asList()), + INFORMATION_ARTIFACTS("button[tooltip-content='Information Artifacts']", Arrays.asList("Informational Artifacts")), + API("button[tooltip-content='API']", Arrays.asList("API Artifacts")), + INFORMATION("button[tooltip-content='Information']", Arrays.asList("General Info", "Additional Information", "Tags")), + COMPOSITION("button[tooltip-content='Composition']", Arrays.asList("Composition")), + INPUTS("button[tooltip-content='Inputs']", Arrays.asList("")), + REQUIREMENTS_AND_CAPABILITIES("button[tooltip-content='Requirements and Capabilities']", Arrays.asList()), + INFORMATION_TAB("information-tab", Arrays.asList()), + CUSTOMIZATION_UUID("rightTab_customizationModuleUUID", Arrays.asList()); + + private String value; + private List<String> title; + + public String getValue() { + return value; + } + + public List<String> getTitle() { + return title; + } + + private CompositionScreenEnum(String value, List<String> title) { + this.value = value; + this.title = title; + } + } + + public enum ToscaArtifactsScreenEnum { + + TOSCA_MODEL("download-Tosca Model"), + TOSCA_TEMPLATE("download-Tosca Template"), + ARTIFACT_VERSION("version-"), + ARTIFACT_NAME("name-"), + ARTIFACT_TYPE("type-"), + ARTIFACT_DETAILS("details-"), + DOWNLOAD_ARTIFACT("download-"), + DOWNLOAD_CSAR("download-Tosca Model"); + + private String value; + + public String getValue() { + return value; + } + + private ToscaArtifactsScreenEnum(String value) { + this.value = value; + } + } + + public enum InformationalArtifactsService { + AFFINITY_RULES("artifact_Display_Name-Affinity Rules"), + CONTROL_LOOP_FUNCTIONS("artifact_Display_Name-Control Loop Functions"), + DEPLOYMENT_VOTING_RECORD("artifact_Display_Name-Deployment Voting Record"), + DIMENSIONING_INFO("artifact_Display_Name-Dimensioning Info"), + DISTRIBUTION_INSTRUCTION("artifact_Display_Name-Distribution Instructions"), + ENGINEERING_RULES("artifact_Display_Name-Engineering Rules (ERD)"), + OPERATIONAL_POLICES("artifact_Display_Name-Operational Policies"), + SERVICE_ARTIFACT_PLAN("artifact_Display_Name-Service Artifact Plan"), + SERVICE_QUESTIONNAIRE("artifact_Display_Name-Service Questionnaire"), + SERVICE_SECURITY_TEMPLATE("artifact_Display_Name-Service Security Template"), + SERVICE_SPECIFIC_POLICIES("artifact_Display_Name-Service-specific Policies"), + SUMMARY_OF_IMPACTS_TO_ECOMP("artifact_Display_Name-Summary of impacts to ECOMP elements,OSSs, BSSs"), + TD_CERTIFICATION_TEST_RESULTS("artifact_Display_Name-TD Certification Test Results"); + + private String value; + + public String getValue() { + return value; + } + + private InformationalArtifactsService(String value) { + this.value = value; + } + } + + public enum APIArtifactsService { + + CONFIGURATION("artifact_Display_Name-Configuration"), + INSTANTIATION("artifact_Display_Name-Instantiation"), + LOGGING("artifact_Display_Name-Logging"), + MONITORING("artifact_Display_Name-Monitoring"), + REPORTING("artifact_Display_Name-Reporting"), + TESTING("artifact_Display_Name-Testing"); + + private String value; + + public String getValue() { + return value; + } + + private APIArtifactsService(String value) { + this.value = value; + } + } + + public enum DeploymentArtifactCompositionRightMenu { + ARTIFACT_NAME("artifactName-"), + ARTIFACT_DISPLAY_NAME("artifact_Display_Name-"), + DOWNLOAD("download_"), + DELETE("delete_"), + ADD_ARTIFACT_BUTTON("add_Artifact_Button"), + EDIT_PARAMETERS_OF_ARTIFACT("edit-parameters-of-"), + ARTIFACT_ITEM("artifact-item-"), + ARTIFACT_ENV("heat_env_"); + + private String value; + + public String getValue() { + return value; + } + + private DeploymentArtifactCompositionRightMenu(String value) { + this.value = value; + } + + } + + public enum InputsScreenService { + ADD_SELECTED_INPUTS_BTN("add-inputs-to-service-button"), + VF_INSTANCE_ROWS("expand-collapse[expanded-selector^='.vf-instance-list.']"), + VF_INSTANCE_ROW_NAME("span[class^='title-text']"), + VF_INSTANCE_INPUTS("div[class^='vf-instance-list ']"), + VF_INSTANCE_INPUT("div[class^='input-row ng-scope']"), + VF_INSTNCE_PROPERTY_NAME("div[class^='title-text']"), + INPUT_CHECKBOX("span[class^='tlv-checkbox-label']"), + SERVICE_INPUT_ROW("div[class^='service-input-row input-row']"), + DELETE_INPUT_BTN("span[class$='remove-input-icon']"), + RESOURCE_INSTANCE_PROPERTY_NAME("propertyName_"), + RESOURCE_INSTANCE_PROPERTY_TYPE("propertyType_"), + RESOURCE_INSTANCE_PROPERTY_CHECKBOX("propertyCheckbox_"), + SERVICE_INPUTS_DELETE_BUTTON("deleteInput_") + ; + + private String value; + + public String getValue() { + return value; + } + + private InputsScreenService(String value) { + this.value = value; + } + + } + + public enum DeploymentScreen { + MODULES("span[class^='expand-collapse-title-text']"), + MEMBERS("div[class^='expand-collapse-sub-title']"), + PROPERTIES("list-of-Properties"), + ARTIFACTS("list-of-Artifacts"), + BUTTON_PROPERTIES("div[data-tests-id='list-of-Properties'] span[class^='hand']"), + BUTTON_ARTIFACTS("div[data-tests-id='list-of-Artifacts'] span[class^='hand']"), + PROPERTY_NAMES("div[data-tests-id='selected-module-property-name'] span"), + PROPERTY_TYPES("selected-module-property-type"), + PROPERTY_SCHEMA_TYPE("selected-module-property-schema-type"), + ARTIFACT_NAME("selected-module-artifact-name"), + ARTIFACT_UUID("selected-module-artifact-uuid"), + ARTIFACT_VERSION("selected-module-artifact-version"), + PENCIL_ICON("edit-name-popover-icon"), + MODULE_NAME("selected-module-name"), + MODULE_ID("selected-module-group-uuid"), + RESOURCE_NAME_ON_POPOVER("popover-vfinstance-name"), + MODULE_NAME_ON_POPOVER("popover-module-name"), + NAME_INPUT("popover-heat-name"), + SAVE("popover-save-button"), + CANCEL("popover-close-button"), + X_BUTTON("popover-x-button"); + + private String value; + + public String getValue() { + return value; + } + + private DeploymentScreen(String value) { + this.value = value; + } + } + + public enum ImportVfRepository { + SEARCH("onboarding-search"), + IMPORT_VSP("import-csar"), + DOWNLOAD_CSAR("download-csar"), + UPDATE_VSP("update-csar"); + + private String value; + + public String getValue() { + return value; + } + + private ImportVfRepository(String value) { + this.value = value; + } + } + + public enum EnvParameterView { + SEARCH_ENV_PARAM_NAME("search-env-param-name"), + ENV_CURRENT_VALUE("value-field-of-"),//value-field-of-oam_volume_name_0 - parameter name + ENV_DEFAULT_VALUE("default-value-of-");// default-value-of-vnf_name + + private String value; + + public String getValue() { + return value; + } + + private EnvParameterView(String value) { + this.value = value; + } + } + + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/LocalLoginFieldsIds.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/LocalLoginFieldsIds.java new file mode 100644 index 000000000..a3ede39cb --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/LocalLoginFieldsIds.java @@ -0,0 +1,30 @@ +package org.onap.sdc.ci.tests.datatypes; + +public class LocalLoginFieldsIds { + + private String userIdFieldName; + private String passwordFieldName; + + + public LocalLoginFieldsIds(String userIdFieldName, String passwordFieldName) { + super(); + this.userIdFieldName = userIdFieldName; + this.passwordFieldName = passwordFieldName; + } + + + public String getUserIdFieldName() { + return userIdFieldName; + } + public void setUserIdFieldName(String userIdFieldName) { + this.userIdFieldName = userIdFieldName; + } + public String getPasswordFieldName() { + return passwordFieldName; + } + public void setPasswordFieldName(String passwordFieldName) { + this.passwordFieldName = passwordFieldName; + } + + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/PropertyHeatMetaDefinition.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/PropertyHeatMetaDefinition.java new file mode 100644 index 000000000..a39dffc13 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/PropertyHeatMetaDefinition.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +public class PropertyHeatMetaDefinition { + + String name; + boolean value; + + public PropertyHeatMetaDefinition() { + super(); + } + + + + public String getName() { + return name; + } + + + + public void setName(String name) { + this.name = name; + } + + + + public boolean getValue() { + return value; + } + + + + public void setValue(boolean value) { + this.value = value; + } + + + + @Override + public String toString() { + return "PropertyHeatMetaDefinition [name=" + name + ", value=" + value + "]"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceAssetStructure.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceAssetStructure.java new file mode 100644 index 000000000..3fef99183 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceAssetStructure.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +public class ResourceAssetStructure extends AssetStructure { + + private String subCategory; + private String resourceType; + protected String lastUpdaterFullName; + protected String toscaResourceName; + + public ResourceAssetStructure() { + super(); + } + + public ResourceAssetStructure(String uuid, String invariantUUID, String name, String version, String toscaModelURL, + String category, String lifecycleState, String lastUpdaterUserId) { + super(uuid, invariantUUID, name, version, toscaModelURL, category, lifecycleState, lastUpdaterUserId); + } + + @Override + public String toString() { + return "ResourceAssetStructure [subCategory=" + subCategory + ", resourceType=" + resourceType + "]"; + } + + public String getLastUpdaterFullName() { + return lastUpdaterFullName; + } + + public void setLastUpdaterFullName(String lastUpdaterFullName) { + this.lastUpdaterFullName = lastUpdaterFullName; + } + + public String getToscaResourceName() { + return toscaResourceName; + } + + public void setToscaResourceName(String toscaResourceName) { + this.toscaResourceName = toscaResourceName; + } + + public String getSubCategory() { + return subCategory; + } + + public void setSubCategory(String subCategory) { + this.subCategory = subCategory; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceDetailedAssetStructure.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceDetailedAssetStructure.java new file mode 100644 index 000000000..7d5914b00 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceDetailedAssetStructure.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +import java.util.List; + +public class ResourceDetailedAssetStructure extends ResourceAssetStructure { + + private List<ResourceInstanceAssetStructure> resources; + private List<ArtifactAssetStructure> artifacts; + + public ResourceDetailedAssetStructure() { + super(); + } + + public ResourceDetailedAssetStructure(String lastUpdaterFullName, String toscaResourceName, + List<ResourceInstanceAssetStructure> resources, List<ArtifactAssetStructure> artifacts) { + super(); + this.lastUpdaterFullName = lastUpdaterFullName; + this.toscaResourceName = toscaResourceName; + this.resources = resources; + this.artifacts = artifacts; + } + + public List<ResourceInstanceAssetStructure> getResources() { + return resources; + } + + public void setResources(List<ResourceInstanceAssetStructure> resources) { + this.resources = resources; + } + + public List<ArtifactAssetStructure> getArtifacts() { + return artifacts; + } + + public void setArtifacts(List<ArtifactAssetStructure> artifacts) { + this.artifacts = artifacts; + } + + @Override + public String toString() { + return "ResourceDetailedAssetStructure [lastUpdaterFullName=" + lastUpdaterFullName + ", toscaResourceName=" + + toscaResourceName + ", resources=" + resources + ", artifacts=" + artifacts + ", toString()=" + + super.toString() + ", getSubCategory()=" + getSubCategory() + ", getResourceType()=" + + getResourceType() + ", getUuid()=" + getUuid() + ", getInvariantUUID()=" + getInvariantUUID() + + ", getName()=" + getName() + ", getVersion()=" + getVersion() + ", getToscaModelURL()=" + + getToscaModelURL() + ", getCategory()=" + getCategory() + ", getLifecycleState()=" + + getLifecycleState() + ", getLastUpdaterUserId()=" + getLastUpdaterUserId() + ", getClass()=" + + getClass() + ", hashCode()=" + hashCode() + "]"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceExternalReqDetails.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceExternalReqDetails.java new file mode 100644 index 000000000..f6d354c1e --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceExternalReqDetails.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +import java.util.List; + +import org.onap.sdc.ci.tests.devObjects.ResourceTypeEnum; + +public class ResourceExternalReqDetails extends ComponentReqDetails { + String vendorName; + String vendorRelease; + String category; + String subcategory; + + private String resourceType = ResourceTypeEnum.VFC.toString(); // Default + // value + public ResourceExternalReqDetails() { + super(); + } + + + public ResourceExternalReqDetails(String resourceName, String description, List<String> tags, + String vendorName, String vendorRelease, String contactId, String icon, + String resourceType, String resourceCategory, String resourceSubcategory) { + super(); + this.resourceType = resourceType; + this.name = resourceName; + this.description = description; + this.tags = tags; + this.vendorName = vendorName; + this.vendorRelease = vendorRelease; + this.contactId = contactId; + this.icon = icon; + this.category = resourceCategory; + this.subcategory = resourceSubcategory; + } + + public String getVendorName() { + return vendorName; + } + + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + + public String getVendorRelease() { + return vendorRelease; + } + + public void setVendorRelease(String vendorRelease) { + this.vendorRelease = vendorRelease; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getSubcategory() { + return subcategory; + } + + public void setSubcategory(String subcategory) { + this.subcategory = subcategory; + } + + + @Override + public String toString() { + return "ResourceReqDetails [name=" + name + ", vendorName=" + vendorName + + ", vendorRelease=" + vendorRelease + ", version=" + version + + ", resourceType=" + resourceType + ", category=" + category + ", subcategory=" + subcategory +"]"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceInstanceAssetStructure.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceInstanceAssetStructure.java new file mode 100644 index 000000000..5019d19b7 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceInstanceAssetStructure.java @@ -0,0 +1,116 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +import java.util.List; + +public class ResourceInstanceAssetStructure { + + String resourceInstanceName; + String resourceName; + String resourceInvariantUUID; + String resourceVersion; + String resoucreType; + String resourceUUID; + List<ArtifactAssetStructure> artifacts; + + public ResourceInstanceAssetStructure() { + super(); + } + + public ResourceInstanceAssetStructure(String resourceInstanceName, String resourceName, + String resourceInvariantUUID, String resourceVersion, String resoucreType, String resourceUUID, + List<ArtifactAssetStructure> artifacts) { + super(); + this.resourceInstanceName = resourceInstanceName; + this.resourceName = resourceName; + this.resourceInvariantUUID = resourceInvariantUUID; + this.resourceVersion = resourceVersion; + this.resoucreType = resoucreType; + this.resourceUUID = resourceUUID; + this.artifacts = artifacts; + } + + public String getResourceInstanceName() { + return resourceInstanceName; + } + + public void setResourceInstanceName(String resourceInstanceName) { + this.resourceInstanceName = resourceInstanceName; + } + + public String getResourceName() { + return resourceName; + } + + public void setResourceName(String resourceName) { + this.resourceName = resourceName; + } + + public String getResourceInvariantUUID() { + return resourceInvariantUUID; + } + + public void setResourceInvariantUUID(String resourceInvariantUUID) { + this.resourceInvariantUUID = resourceInvariantUUID; + } + + public String getResourceVersion() { + return resourceVersion; + } + + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + } + + public String getResoucreType() { + return resoucreType; + } + + public void setResoucreType(String resoucreType) { + this.resoucreType = resoucreType; + } + + public String getResourceUUID() { + return resourceUUID; + } + + public void setResourceUUID(String resourceUUID) { + this.resourceUUID = resourceUUID; + } + + public List<ArtifactAssetStructure> getArtifacts() { + return artifacts; + } + + public void setArtifacts(List<ArtifactAssetStructure> artifacts) { + this.artifacts = artifacts; + } + + @Override + public String toString() { + return "ResourceInstanceAssetStructure [resourceInstanceName=" + resourceInstanceName + ", resourceName=" + + resourceName + ", resourceInvariantUUID=" + resourceInvariantUUID + ", resourceVersion=" + + resourceVersion + ", resoucreType=" + resoucreType + ", resourceUUID=" + resourceUUID + ", artifacts=" + + artifacts + "]"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceReqDetails.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceReqDetails.java new file mode 100644 index 000000000..7a3dbd469 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceReqDetails.java @@ -0,0 +1,194 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +import java.util.List; + +import org.onap.sdc.ci.tests.devObjects.ResourceTypeEnum; + +public class ResourceReqDetails extends ComponentReqDetails { + List<String> derivedFrom; + String vendorName; + String vendorRelease; + + // Unsettable/unupdatable fields + + Boolean isAbstract; + Boolean isHighestVersion; + String cost; + String licenseType; + String toscaResourceName; + + private String resourceType = ResourceTypeEnum.VFC.toString(); // Default + // value + + public ResourceReqDetails() { + super(); + } + + + public ResourceReqDetails(String resourceName, String description, List<String> tags, String category, + List<String> derivedFrom, String vendorName, String vendorRelease, String contactId, String icon) { + this(resourceName, description, tags, category, derivedFrom, vendorName, vendorRelease, contactId, icon, + ResourceTypeEnum.VFC.toString()); + } + + // new + public ResourceReqDetails(String resourceName, String description, List<String> tags, String category, + List<String> derivedFrom, String vendorName, String vendorRelease, String contactId, String icon, + String resourceType) { + super(); + this.resourceType = resourceType; + this.name = resourceName; + this.description = description; + this.tags = tags; + // this.category = category; + this.derivedFrom = derivedFrom; + this.vendorName = vendorName; + this.vendorRelease = vendorRelease; + this.contactId = contactId; + this.icon = icon; + if (category != null) { + String[] arr = category.split("/"); + if (arr.length == 2) { + addCategoryChain(arr[0], arr[1]); + } + } + this.toscaResourceName = resourceName; + } + + public ResourceReqDetails(ResourceReqDetails originalResource, String version) { + super(); + this.name = originalResource.getName(); + this.description = originalResource.getDescription(); + this.tags = originalResource.getTags(); + // this.category = originalResource.getCategory(); + this.derivedFrom = originalResource.getDerivedFrom(); + this.vendorName = originalResource.getVendorName(); + this.vendorRelease = originalResource.getVendorRelease(); + this.contactId = originalResource.getContactId(); + this.icon = originalResource.getIcon(); + this.version = version; + this.uniqueId = originalResource.getUniqueId(); + this.categories = originalResource.getCategories(); + this.toscaResourceName = originalResource.getToscaResourceName(); + this.resourceType = originalResource.getResourceType(); + } + + public ResourceReqDetails(String resourceName, List<String> derivedFrom, String vendorName, String vendorRelease, + String resourceVersion, Boolean isAbstract, Boolean isHighestVersion, String cost, String licenseType, + String resourceType) { + super(); + this.name = resourceName; + this.derivedFrom = derivedFrom; + this.vendorName = vendorName; + this.vendorRelease = vendorRelease; + this.version = resourceVersion; + this.isAbstract = isAbstract; + this.isHighestVersion = isHighestVersion; + this.cost = cost; + this.licenseType = licenseType; + this.resourceType = resourceType; + this.toscaResourceName = resourceName; + } + + public String getToscaResourceName() { + return toscaResourceName; + } + + public void setToscaResourceName(String toscaResourceName) { + this.toscaResourceName = toscaResourceName; + } + + public List<String> getDerivedFrom() { + return derivedFrom; + } + + public void setDerivedFrom(List<String> derivedFrom) { + this.derivedFrom = derivedFrom; + } + + public String getVendorName() { + return vendorName; + } + + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + + public String getVendorRelease() { + return vendorRelease; + } + + public void setVendorRelease(String vendorRelease) { + this.vendorRelease = vendorRelease; + } + + public String getCost() { + return cost; + } + + public void setCost(String cost) { + this.cost = cost; + } + + public String getLicenseType() { + return licenseType; + } + + public void setLicenseType(String licenseType) { + this.licenseType = licenseType; + } + + // Unupdatable fields - to check that they are not updated + public void setIsAbstract(Boolean isAbstract) { + this.isAbstract = isAbstract; + } + + public void setIsHighestVersion(Boolean isHighestVersion) { + this.isHighestVersion = isHighestVersion; + } + + public Boolean getIsAbstract() { + return isAbstract; + } + + public Boolean getIsHighestVersion() { + return isHighestVersion; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + @Override + public String toString() { + return "ResourceReqDetails [name=" + name + ", derivedFrom=" + derivedFrom + ", vendorName=" + vendorName + + ", vendorRelease=" + vendorRelease + ", version=" + version + ", isAbstract=" + isAbstract + + ", isHighestVersion=" + isHighestVersion + ", cost=" + cost + ", licenseType=" + licenseType + + ", resourceType=" + resourceType + "]"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceRespJavaObject.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceRespJavaObject.java new file mode 100644 index 000000000..525ca794c --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ResourceRespJavaObject.java @@ -0,0 +1,369 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +import java.util.List; + +import org.onap.sdc.ci.tests.devObjects.CategoryDefinition; + +public class ResourceRespJavaObject { + String uniqueId; + String name; + String version; + String creatorUserId; + String creatorFullName; + String lastUpdaterUserId; + String lastUpdaterFullName; + String description; + String icon; + List<String> tags; + String isHighestVersion; + String creationDate; + String lastUpdateDate; + // String category; + String lifecycleState; + List<String> derivedFrom; + String vendorName; + String vendorRelease; + String contactId; + String abstractt; + String highestVersion; + List<String> artifacts; + List<String> interfaces; + String uuid; + String cost; + String licenseType; + String resourceType; + List<CategoryDefinition> categories; + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public ResourceRespJavaObject(String uniqueId, String resourceName, String resourceVersion, String creatorUserId, + String creatorFullName, String lastUpdaterUserId, String lastUpdaterFullName, String description, + String icon, List<String> tags, String isHighestVersion, String creationDate, String lastUpdateDate, + String category, String lifecycleState, List<String> derivedFrom, String vendorName, String vendorRelease, + String contactId, String abstractt, String highestVersion, List<String> artifacts, List<String> interfaces, + String uuid, String cost, String licenseType, String resourceType) { + super(); + this.uniqueId = uniqueId; + this.name = resourceName; + this.version = resourceVersion; + this.creatorUserId = creatorUserId; + this.creatorFullName = creatorFullName; + this.lastUpdaterUserId = lastUpdaterUserId; + this.lastUpdaterFullName = lastUpdaterFullName; + this.description = description; + this.icon = icon; + this.tags = tags; + this.isHighestVersion = isHighestVersion; + this.creationDate = creationDate; + this.lastUpdateDate = lastUpdateDate; + // this.category = category; + this.lifecycleState = lifecycleState; + this.derivedFrom = derivedFrom; + this.vendorName = vendorName; + this.vendorRelease = vendorRelease; + this.contactId = contactId; + this.abstractt = abstractt; + this.highestVersion = highestVersion; + this.artifacts = artifacts; + this.interfaces = interfaces; + this.uuid = uuid; + this.cost = cost; + this.licenseType = licenseType; + this.resourceType = resourceType; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getCost() { + return cost; + } + + public void setCost(String cost) { + this.cost = cost; + } + + public String getLicenseType() { + return licenseType; + } + + public void setLicenseType(String licenseType) { + this.licenseType = licenseType; + } + + public String getUuid() { + return uuid; + } + + public String setUuid() { + return uuid; + } + + public List<String> getInterfaces() { + return interfaces; + } + + public void setInterfaces(List<String> interfaces) { + this.interfaces = interfaces; + } + + public List<String> getArtifacts() { + return artifacts; + } + + public void setArtifacts(List<String> artifacts) { + this.artifacts = artifacts; + } + + public ResourceRespJavaObject() { + super(); + // TODO Auto-generated constructor stub + } + + // public ResourceRespJavaObject(String uniqueId, String resourceName, + // String resourceVersion, String creatorUserId, + // String creatorFullName, String lastUpdaterUserId, + // String lastUpdaterFullName, String description, String icon, + // List<String> tags, String isHighestVersion, String creationDate, + // String lastUpdateDate, String category, String lifecycleState, + // List<String> derivedFrom, String vendorName, String vendorRelease, + // String contactId, String abstractt, String highestVersion) { + // super(); + // this.uniqueId = uniqueId; + // this.resourceName = resourceName; + // this.resourceVersion = resourceVersion; + // this.creatorUserId = creatorUserId; + // this.creatorFullName = creatorFullName; + // this.lastUpdaterUserId = lastUpdaterUserId; + // this.lastUpdaterFullName = lastUpdaterFullName; + // this.description = description; + // this.icon = icon; + // this.tags = tags; + // this.isHighestVersion = isHighestVersion; + // this.creationDate = creationDate; + // this.lastUpdateDate = lastUpdateDate; + // this.category = category; + // this.lifecycleState = lifecycleState; + // this.derivedFrom = derivedFrom; + // this.vendorName = vendorName; + // this.vendorRelease = vendorRelease; + // this.contactId = contactId; + // this.abstractt = abstractt; + // this.highestVersion = highestVersion; + // } + public String getUniqueId() { + return uniqueId; + } + + public void setUniqueId(String uniqueId) { + this.uniqueId = uniqueId; + } + + public String getName() { + return name; + } + + public void setName(String resourceName) { + this.name = resourceName; + } + + public String getVersion() { + return version; + } + + public void setVersion(String resourceVersion) { + this.version = resourceVersion; + } + + public String getCreatorUserId() { + return creatorUserId; + } + + public void setCreatorUserId(String creatorUserId) { + this.creatorUserId = creatorUserId; + } + + public String getCreatorFullName() { + return creatorFullName; + } + + public void setCreatorFullName(String creatorFullName) { + this.creatorFullName = creatorFullName; + } + + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + public void setLastUpdaterUserId(String lastUpdaterUserId) { + this.lastUpdaterUserId = lastUpdaterUserId; + } + + public String getLastUpdaterFullName() { + return lastUpdaterFullName; + } + + public void setLastUpdaterFullName(String lastUpdaterFullName) { + this.lastUpdaterFullName = lastUpdaterFullName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public List<String> getTags() { + return tags; + } + + public void setTags(List<String> tags) { + this.tags = tags; + } + + public String getIsHighestVersion() { + return isHighestVersion; + } + + public void setIsHighestVersion(String isHighestVersion) { + this.isHighestVersion = isHighestVersion; + } + + public String getCreationDate() { + return creationDate; + } + + public void setCreationDate(String creationDate) { + this.creationDate = creationDate; + } + + public String getLastUpdateDate() { + return lastUpdateDate; + } + + public void setLastUpdateDate(String lastUpdateDate) { + this.lastUpdateDate = lastUpdateDate; + } + + // public String getCategory() { + // return category; + // } + // public void setCategory(String category) { + // this.category = category; + // } + public String getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(String lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public List<String> getDerivedFrom() { + return derivedFrom; + } + + public void setDerivedFrom(List<String> derivedFrom) { + this.derivedFrom = derivedFrom; + } + + public String getVendorName() { + return vendorName; + } + + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + + public String getVendorRelease() { + return vendorRelease; + } + + public void setVendorRelease(String vendorRelease) { + this.vendorRelease = vendorRelease; + } + + public String getContactId() { + return contactId; + } + + public void setContactId(String contactId) { + this.contactId = contactId; + } + + public String getAbstractt() { + return abstractt; + } + + public void setAbstractt(String abstractt) { + this.abstractt = abstractt; + } + + public String getHighestVersion() { + return highestVersion; + } + + public void setHighestVersion(String highestVersion) { + this.highestVersion = highestVersion; + } + + public List<CategoryDefinition> getCategories() { + return categories; + } + + public void setCategories(List<CategoryDefinition> categories) { + this.categories = categories; + } + + @Override + public String toString() { + return "ResourceRespJavaObject [uniqueId=" + uniqueId + ", resourceName=" + name + ", resourceVersion=" + + version + ", creatorUserId=" + creatorUserId + ", creatorFullName=" + creatorFullName + + ", lastUpdaterUserId=" + lastUpdaterUserId + ", lastUpdaterFullName=" + lastUpdaterFullName + + ", description=" + description + ", icon=" + icon + ", tags=" + tags + ", isHighestVersion=" + + isHighestVersion + ", creationDate=" + creationDate + ", lastUpdateDate=" + lastUpdateDate + + ", lifecycleState=" + lifecycleState + ", derivedFrom=" + derivedFrom + ", vendorName=" + vendorName + + ", vendorRelease=" + vendorRelease + ", contactId=" + contactId + ", abstractt=" + abstractt + + ", highestVersion=" + highestVersion + ", artifacts=" + artifacts + ", interfaces=" + interfaces + + ", uuid=" + uuid + ", cost=" + cost + ", licenseType=" + licenseType + ", resourceType=" + + resourceType + "]"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ServiceAssetStructure.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ServiceAssetStructure.java new file mode 100644 index 000000000..cfe7addbe --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ServiceAssetStructure.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +public class ServiceAssetStructure extends AssetStructure { + + private String distributionStatus; + + public ServiceAssetStructure() { + super(); + } + + public ServiceAssetStructure(String uuid, String invariantUUID, String name, String version, String toscaModelURL, + String category, String lifecycleState, String lastUpdaterUserId) { + super(uuid, invariantUUID, name, version, toscaModelURL, category, lifecycleState, lastUpdaterUserId); + } + + @Override + public String toString() { + return "ServiceAssetStructure [distributionStatus=" + distributionStatus + "]"; + } + + public String getDistributionStatus() { + return distributionStatus; + } + + public void setDistributionStatus(String distributionStatus) { + this.distributionStatus = distributionStatus; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ServiceDetailedAssetStructure.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ServiceDetailedAssetStructure.java new file mode 100644 index 000000000..f699aa3f0 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ServiceDetailedAssetStructure.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +import java.util.List; + +public class ServiceDetailedAssetStructure extends ServiceAssetStructure { + + String lastUpdaterFullName; + List<ResourceInstanceAssetStructure> resources; + List<ArtifactAssetStructure> artifacts; + + public ServiceDetailedAssetStructure() { + super(); + } + + public ServiceDetailedAssetStructure(String uuid, String invariantUUID, String name, String version, + String toscaModelURL, String category, String lifecycleState, String lastUpdaterUserId) { + super(uuid, invariantUUID, name, version, toscaModelURL, category, lifecycleState, lastUpdaterUserId); + } + + public ServiceDetailedAssetStructure(String lastUpdaterFullName, List<ResourceInstanceAssetStructure> resources, + List<ArtifactAssetStructure> artifacts) { + super(); + this.lastUpdaterFullName = lastUpdaterFullName; + this.resources = resources; + this.artifacts = artifacts; + } + + public String getLastUpdaterFullName() { + return lastUpdaterFullName; + } + + public void setLastUpdaterFullName(String lastUpdaterFullName) { + this.lastUpdaterFullName = lastUpdaterFullName; + } + + public List<ResourceInstanceAssetStructure> getResources() { + return resources; + } + + public void setResources(List<ResourceInstanceAssetStructure> resources) { + this.resources = resources; + } + + public List<ArtifactAssetStructure> getArtifacts() { + return artifacts; + } + + public void setArtifacts(List<ArtifactAssetStructure> artifacts) { + this.artifacts = artifacts; + } + + @Override + public String toString() { + return "ServiceDetailedAssetStructure [lastUpdaterFullName=" + lastUpdaterFullName + ", resources=" + resources + + ", artifacts=" + artifacts + "]"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ServiceDistributionStatus.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ServiceDistributionStatus.java new file mode 100644 index 000000000..783e0175d --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ServiceDistributionStatus.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +public class ServiceDistributionStatus { + + private String distributionID; + private String timestamp; + private String userId; + private String deployementStatus; + + public ServiceDistributionStatus() { + super(); + // TODO Auto-generated constructor stub + } + + public ServiceDistributionStatus(String distributionID, String timestamp, String userId, String deployementStatus) { + super(); + this.distributionID = distributionID; + this.timestamp = timestamp; + this.userId = userId; + this.deployementStatus = deployementStatus; + } + + @Override + public String toString() { + return "ServiceDistributionStatus [distributionID=" + distributionID + ", timestamp=" + timestamp + ", userId=" + userId + ", deployementStatus=" + deployementStatus + "]"; + } + + public String getDistributionID() { + return distributionID; + } + + public void setDistributionID(String distributionID) { + this.distributionID = distributionID; + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getDeployementStatus() { + return deployementStatus; + } + + public void setDeployementStatus(String deployementStatus) { + this.deployementStatus = deployementStatus; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ServiceReqDetails.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ServiceReqDetails.java new file mode 100644 index 000000000..6dc804987 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ServiceReqDetails.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +import java.util.ArrayList; + +import org.onap.sdc.ci.tests.devObjects.CategoryDefinition; + +public class ServiceReqDetails extends ComponentReqDetails { + + public ServiceReqDetails(String serviceName, String category, ArrayList<String> tags, String description, + String contactId, String icon) { + this.name = serviceName; + // this.category = category; + this.tags = tags; + this.description = description; + this.contactId = contactId; + this.icon = icon; + projectCode = "12345"; + CategoryDefinition categoryDefinition = new CategoryDefinition(); + categoryDefinition.setName(category); + categories = new ArrayList<>(); + categories.add(categoryDefinition); + + } + + public ServiceReqDetails() { + contactId = "aa1234"; + projectCode = "12345"; + } + + public ServiceReqDetails(ServiceReqDetails a, String newServiceName) { + a.setName(newServiceName); + } + + @Override + public String toString() { + return "ServiceDetails [name=" + name + ", category=" + getCategory() + ", tags=" + tags + ", description=" + + description + ", contactId=" + contactId + ", icon=" + icon + "]"; + } + + public ServiceReqDetails(ServiceReqDetails aService) { + this(aService.getName(), aService.getCategory(), (ArrayList<String>) aService.getTags(), + aService.getDescription(), aService.getContactId(), aService.getIcon()); + uniqueId = aService.getUniqueId(); + version = aService.getVersion(); + } + + public String getCategory() { + if (categories != null && categories.size() >= 1) { + return categories.get(0).getName(); + } + return null; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ServiceRespJavaObject.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ServiceRespJavaObject.java new file mode 100644 index 000000000..c401c4ec0 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/ServiceRespJavaObject.java @@ -0,0 +1,267 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +import java.util.ArrayList; + +public class ServiceRespJavaObject { + + String category; + String creatorUserId; + String creatorFullName; + String lastUpdaterUserId; + String lastUpdaterFullName; + String serviceName; + String version; + String creationDate; + String icon; + String name; + String description; + ArrayList<String> tags; + String uniqueId; + String lastUpdateDate; + String contactId; + String vendorName; + String vendorRelease; + String lifecycleState; + String highestVersion; + ArrayList<String> artifacts; + ArrayList<String> ResourceInstances; + ArrayList<String> ResourceInstancesRelations; + + public ServiceRespJavaObject() { + super(); + // TODO Auto-generated constructor stub + } + + public ServiceRespJavaObject(String category, String creatorUserId, String creatorFullName, + String lastUpdaterUserId, String lastUpdaterFullName, String serviceName, String version, + String creationDate, String icon, String name, String description, ArrayList<String> tags, String uniqueId, + String lastUpdateDate, String contactId, String vendorName, String vendorRelease, String lifecycleState, + String highestVersion, ArrayList<String> artifacts, ArrayList<String> resourceInstances, + ArrayList<String> resourceInstancesRelations) { + super(); + this.category = category; + this.creatorUserId = creatorUserId; + this.creatorFullName = creatorFullName; + this.lastUpdaterUserId = lastUpdaterUserId; + this.lastUpdaterFullName = lastUpdaterFullName; + this.serviceName = serviceName; + this.version = version; + this.creationDate = creationDate; + this.icon = icon; + this.name = name; + this.description = description; + this.tags = tags; + this.uniqueId = uniqueId; + this.lastUpdateDate = lastUpdateDate; + this.contactId = contactId; + this.vendorName = vendorName; + this.vendorRelease = vendorRelease; + this.lifecycleState = lifecycleState; + this.highestVersion = highestVersion; + this.artifacts = artifacts; + ResourceInstances = resourceInstances; + ResourceInstancesRelations = resourceInstancesRelations; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getCreatorUserId() { + return creatorUserId; + } + + public void setCreatorUserId(String creatorUserId) { + this.creatorUserId = creatorUserId; + } + + public String getCreatorFullName() { + return creatorFullName; + } + + public void setCreatorFullName(String creatorFullName) { + this.creatorFullName = creatorFullName; + } + + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + public void setLastUpdaterUserId(String lastUpdaterUserId) { + this.lastUpdaterUserId = lastUpdaterUserId; + } + + public String getLastUpdaterFullName() { + return lastUpdaterFullName; + } + + public void setLastUpdaterFullName(String lastUpdaterFullName) { + this.lastUpdaterFullName = lastUpdaterFullName; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getCreationDate() { + return creationDate; + } + + public void setCreationDate(String creationDate) { + this.creationDate = creationDate; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public ArrayList<String> getTags() { + return tags; + } + + public void setTags(ArrayList<String> tags) { + this.tags = tags; + } + + public String getUniqueId() { + return uniqueId; + } + + public void setUniqueId(String uniqueId) { + this.uniqueId = uniqueId; + } + + public String getLastUpdateDate() { + return lastUpdateDate; + } + + public void setLastUpdateDate(String lastUpdateDate) { + this.lastUpdateDate = lastUpdateDate; + } + + public String getContactId() { + return contactId; + } + + public void setContactId(String contactId) { + this.contactId = contactId; + } + + public String getVendorName() { + return vendorName; + } + + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + + public String getVendorRelease() { + return vendorRelease; + } + + public void setVendorRelease(String vendorRelease) { + this.vendorRelease = vendorRelease; + } + + public String getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(String lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public String getHighestVersion() { + return highestVersion; + } + + public void setHighestVersion(String highest) { + this.highestVersion = highest; + } + + public ArrayList<String> getArtifacts() { + return artifacts; + } + + public void setArtifacts(ArrayList<String> artifacts) { + this.artifacts = artifacts; + } + + public ArrayList<String> getResourceInstances() { + return ResourceInstances; + } + + public void setResourceInstances(ArrayList<String> resourceInstances) { + ResourceInstances = resourceInstances; + } + + public ArrayList<String> getResourceInstancesRelations() { + return ResourceInstancesRelations; + } + + public void setResourceInstancesRelations(ArrayList<String> resourceInstancesRelations) { + ResourceInstancesRelations = resourceInstancesRelations; + } + + @Override + public String toString() { + return "ServiceRespJavaObject [category=" + category + ", creatorUserId=" + creatorUserId + ", creatorFullName=" + + creatorFullName + ", lastUpdaterUserId=" + lastUpdaterUserId + ", lastUpdaterFullName=" + + lastUpdaterFullName + ", serviceName=" + serviceName + ", version=" + version + ", creationDate=" + + creationDate + ", icon=" + icon + ", name=" + name + ", description=" + description + ", tags=" + tags + + ", uniqueId=" + uniqueId + ", lastUpdateDate=" + lastUpdateDate + ", contactId=" + contactId + + ", vendorName=" + vendorName + ", vendorRelease=" + vendorRelease + ", lifecycleState=" + + lifecycleState + ", lifecycleState=" + lifecycleState + ", artifacts=" + artifacts + + ", ResourceInstances=" + ResourceInstances + ", ResourceInstancesRelations=" + + ResourceInstancesRelations + "]"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/TopMenuButtonsEnum.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/TopMenuButtonsEnum.java new file mode 100644 index 000000000..f688d33b0 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/TopMenuButtonsEnum.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +public enum TopMenuButtonsEnum { + + HOME("main-menu-button-home"), CATALOG("main-menu-button-catalog"), ON_BOARDING("main-menu-button-onboard"); + + private String value; + private String value2; + + public String getButton() { + return value; + } + + private TopMenuButtonsEnum(String value) { + this.value = value; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/User.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/User.java new file mode 100644 index 000000000..5201de0f1 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/User.java @@ -0,0 +1,189 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; + +public class User { + public static final String FORCE_DELETE_HEADER_FLAG = "FORCE_DELETE"; + + private String firstName; + + private String lastName; + + private String userId; + + private String email; + + private String role; + + private Long lastLoginTime; + + + public User() { + } + + public User(String firstName, String lastName, String userId, String emailAddress, String role, + Long lastLoginTime) { + this.firstName = firstName; + this.lastName = lastName; + this.userId = userId; + this.email = emailAddress; + this.role = role; + this.lastLoginTime = lastLoginTime; + + } + + public void copyData(User other) { + this.firstName = other.getFirstName(); + this.lastName = other.getLastName(); + this.userId = other.getUserId(); + this.email = other.getEmail(); + this.role = other.getRole(); + this.lastLoginTime = other.getLastLoginTime(); + + } + + public User(User aUser) { + this(aUser.getFirstName(), aUser.getLastName(), aUser.getUserId(), aUser.getEmail(), aUser.getRole(), + aUser.getLastLoginTime()); + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getFullName() { + return this.getFirstName() + " " + this.getLastName(); + } + + public void setLastLoginTime() { + DateTime now = new DateTime(DateTimeZone.UTC); + this.lastLoginTime = now.getMillis(); + } + + public void setLastLoginTime(Long time) { + this.lastLoginTime = time; + } + + public Long getLastLoginTime() { + return this.lastLoginTime; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((userId == null) ? 0 : userId.hashCode()); + result = prime * result + ((email == null) ? 0 : email.hashCode()); + result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); + result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); + result = prime * result + ((role == null) ? 0 : role.hashCode()); + result = prime * result + ((lastLoginTime == null) ? 0 : lastLoginTime.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + User other = (User) obj; + if (userId == null) { + if (other.userId != null) + return false; + } else if (!userId.equals(other.userId)) + return false; + if (email == null) { + if (other.email != null) + return false; + } else if (!email.equals(other.email)) + return false; + if (firstName == null) { + if (other.firstName != null) + return false; + } else if (!firstName.equals(other.firstName)) + return false; + if (lastName == null) { + if (other.lastName != null) + return false; + } else if (!lastName.equals(other.lastName)) + return false; + if (role == null) { + if (other.role != null) + return false; + } else if (!role.equals(other.role)) + return false; + if (lastLoginTime == null) { + if (other.lastLoginTime != null) + return false; + } else if (!lastLoginTime.equals(other.lastLoginTime)) + return false; + return true; + } + + @Override + public String toString() { + return "User [firstName=" + firstName + ", lastName=" + lastName + ", userId=" + userId + ", email=" + email + + ", role=" + role + ", last login time=" + lastLoginTime + "]"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/UserCredentials.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/UserCredentials.java new file mode 100644 index 000000000..5dec39541 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/UserCredentials.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +public class UserCredentials extends User { + + private String password; + + public UserCredentials(String userId, String password, String firstname, String lastname, String role) { + super(); + setUserId(userId); + this.password = password; + setFirstName(firstname); + setLastName(lastname); + setRole(role); + } + + public UserCredentials() { + super(); + } + + public UserCredentials(User user) { + super(); + this.copyData(user); + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/UserRoleEnum.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/UserRoleEnum.java new file mode 100644 index 000000000..793280aa0 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/UserRoleEnum.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes; + +public enum UserRoleEnum { + + ADMIN("jh0003", "Jimmy", "Hendrix"), DESIGNER("cs0008", "Carlos", "Santana"), DESIGNER2("me0009", "Melissa","Etheridge"), TESTER("jm0007", "Joni", "Mitchell"), ADMIN4("km2000", "Kot", "May"), + GOVERNOR("gv0001","David", "Shadmi"), OPS("op0001", "Steve", "Regev"), PRODUCT_STRATEGIST1("ps0001", "Eden","Rozin"), PRODUCT_STRATEGIST2("ps0002", "Ella", "Kvetny"), PRODUCT_STRATEGIST3("ps0003", "Geva", "Alon"), + PRODUCT_MANAGER1("pm0001", "Teddy", "Isashar"), PRODUCT_MANAGER2("pm0002", "Sarah", "Bettens"); + private String userId; + private String firstName; + private String lastName; + private String userName; + + private UserRoleEnum(String userId, String userName) { + this.userId = userId; + this.userName = userName; + } + + private UserRoleEnum(String userId, String firstName, String lastName) { + this.userId = userId; + this.firstName = firstName; + this.lastName = lastName; + this.userName = firstName + " " + lastName; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/HeaderData.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/HeaderData.java new file mode 100644 index 000000000..4dfdbad8b --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/HeaderData.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes.http; + +public class HeaderData { + String contentMd5; + String contentType; + String HttpCspUserId; + String HttpCspFirstName; + String HttpCspLastName; + String HttpCspWsType; + String HttpIvRemoteAddress; + String HttpIvUser; + + public HeaderData() { + super(); + } + + public HeaderData(String contentMd5, String contentType, String httpCspUserId, String httpCspFirstName, + String httpCspLastName, String httpCspWsType, String httpIvRemoteAddress, String httpIvUser) { + super(); + this.contentMd5 = contentMd5; + this.contentType = contentType; + HttpCspUserId = httpCspUserId; + HttpCspFirstName = httpCspFirstName; + HttpCspLastName = httpCspLastName; + HttpCspWsType = httpCspWsType; + HttpIvRemoteAddress = httpIvRemoteAddress; + HttpIvUser = httpIvUser; + } + + public String getContentMd5() { + return contentMd5; + } + + public void setContentMd5(String contentMd5) { + this.contentMd5 = contentMd5; + } + + public String getContentType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + + public String getHttpCspUserId() { + return HttpCspUserId; + } + + public void setHttpCspUserId(String httpCspUserId) { + HttpCspUserId = httpCspUserId; + } + + public String getHttpCspFirstName() { + return HttpCspFirstName; + } + + public void setHttpCspFirstName(String httpCspFirstName) { + HttpCspFirstName = httpCspFirstName; + } + + public String getHttpCspLastName() { + return HttpCspLastName; + } + + public void setHttpCspLastName(String httpCspLastName) { + HttpCspLastName = httpCspLastName; + } + + public String getHttpCspWsType() { + return HttpCspWsType; + } + + public void setHttpCspWsType(String httpCspWsType) { + HttpCspWsType = httpCspWsType; + } + + public String getHttpIvRemoteAddress() { + return HttpIvRemoteAddress; + } + + public void setHttpIvRemoteAddress(String httpIvRemoteAddress) { + HttpIvRemoteAddress = httpIvRemoteAddress; + } + + public String getHttpIvUser() { + return HttpIvUser; + } + + public void setHttpIvUser(String httpIvUser) { + HttpIvUser = httpIvUser; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/HeaderValue.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/HeaderValue.java new file mode 100644 index 000000000..e09a97251 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/HeaderValue.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes.http; + +public enum HeaderValue { + + APPLICATION_JSON("application/json"); + + String value; + + private HeaderValue(String value) { + this.value = value; + } + + public String getValue() { + + return value; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/HttpHeaderEnum.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/HttpHeaderEnum.java new file mode 100644 index 000000000..e57c5a449 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/HttpHeaderEnum.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes.http; + +public enum HttpHeaderEnum { + + Content_MD5("Content-MD5"), + USER_ID("USER_ID"), + HTTP_CSP_FIRSTNAME("HTTP_CSP_FIRSTNAME"), + HTTP_CSP_LASTNAME("HTTP_CSP_LASTNAME"), + HTTP_CSP_WSTYPE("HTTP_CSP_WSTYPE"), + HTTP_IV_REMOTE_ADDRESS("HTTP_IV_REMOTE_ADDRESS"), + HTTP_IV_USER("HTTP_IV_USER"), + HTTP_CSP_EMAIL("HTTP_CSP_EMAIL"), + CONTENT_TYPE("Content-Type"), + ACCEPT("Accept"), + X_ECOMP_REQUEST_ID_HEADER("X-ECOMP-RequestID"), + CACHE_CONTROL("Cache-Control"), + X_ECOMP_INSTANCE_ID("X-ECOMP-InstanceID"), + AUTHORIZATION("Authorization"), + CONTENT_LENGTH("Content-Length"), + CONTENT_DISPOSITION("Content-Disposition"), + HOST("Host"), + X_ECOMP_SERVICE_ID_HEADER("X-ECOMP-ServiceID"), + WWW_AUTHENTICATE("WWW-Authenticate"), + ECOMP_PASSWORD("password"), + ECOMP_USERNAME("username"); + + String value; + + private HttpHeaderEnum(String value) { + this.value = value; + } + + public String getValue() { + + return value; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/HttpRequest.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/HttpRequest.java new file mode 100644 index 000000000..4f831b187 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/HttpRequest.java @@ -0,0 +1,889 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes.http; + +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.StringWriter; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URL; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Scanner; + +import javax.net.ssl.HttpsURLConnection; + +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.io.IOUtils; +import org.apache.http.HttpEntity; +import org.apache.http.annotation.NotThreadSafe; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.entity.mime.content.FileBody; +import org.apache.http.entity.mime.content.StringBody; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.onap.sdc.ci.tests.datatypes.http.RestResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gson.Gson; + +public class HttpRequest { + static Logger logger = LoggerFactory.getLogger(HttpRequest.class.getName()); + + public RestResponse httpSendGet(String url, Map<String, String> headers) throws IOException { + + RestResponse restResponse = new RestResponse(); + url = url.replaceAll("\\s", "%20"); + URL obj = new URL(url); + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + // optional default is GET + con.setRequestMethod("GET"); + // add request header + if (headers != null) { + for (Entry<String, String> header : headers.entrySet()) { + String key = header.getKey(); + String value = header.getValue(); + con.setRequestProperty(key, value); + } + + } + + int responseCode = con.getResponseCode(); + logger.debug("Send GET http request, url: {}",url); + logger.debug("Response Code: {}",responseCode); + + StringBuffer response = new StringBuffer(); + String result; + + try { + + result = IOUtils.toString(con.getInputStream()); + response.append(result); + + } catch (Exception e) { + } + + try { + + result = IOUtils.toString(con.getErrorStream()); + response.append(result); + + } catch (Exception e) { + } + + logger.debug("Response body: {}" ,response); + + // print result + + restResponse.setStatusCode(responseCode); + + if (response != null) { + restResponse.setResponse(response.toString()); + } + + restResponse.setStatusCode(responseCode); + Map<String, List<String>> headerFields = con.getHeaderFields(); + restResponse.setHeaderFields(headerFields); + String responseMessage = con.getResponseMessage(); + restResponse.setResponseMessage(responseMessage); + + con.disconnect(); + + return restResponse; + } + + public RestResponse httpsSendGet(String url, Map<String, String> headers) throws IOException { + + RestResponse restResponse = new RestResponse(); + URL obj = new URL(url); + HttpsURLConnection con = (HttpsURLConnection) obj.openConnection(); + // optional default is GET + con.setRequestMethod("GET"); + // add request header + if (headers != null) { + for (Entry<String, String> header : headers.entrySet()) { + String key = header.getKey(); + String value = header.getValue(); + con.setRequestProperty(key, value); + } + + } + + int responseCode = con.getResponseCode(); + logger.debug("Send GET http request, url: {}",url); + logger.debug("Response Code: {}",responseCode); + + StringBuffer response = new StringBuffer(); + try { + BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + } catch (Exception e) { + logger.debug("response body is null"); + } + + String result; + + try { + + result = IOUtils.toString(con.getErrorStream()); + response.append(result); + + } catch (Exception e2) { + // result = null; + } + logger.debug("Response body: {}",response); + + // print result + + restResponse.setStatusCode(responseCode); + + if (response != null) { + restResponse.setResponse(response.toString()); + } + + restResponse.setStatusCode(responseCode); + // restResponse.setResponse(result); + Map<String, List<String>> headerFields = con.getHeaderFields(); + restResponse.setHeaderFields(headerFields); + String responseMessage = con.getResponseMessage(); + restResponse.setResponseMessage(responseMessage); + + con.disconnect(); + + return restResponse; + } + + public RestResponse httpSendByMethod(String url, String method, String body, Map<String, String> headers) + throws IOException { + + RestResponse restResponse = new RestResponse(); + URL obj = new URL(url); + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + + // add request method + con.setRequestMethod(method); + + // add request headers + if (headers != null) { + for (Entry<String, String> header : headers.entrySet()) { + String key = header.getKey(); + String value = header.getValue(); + con.setRequestProperty(key, value); + } + + } + if (body != null && !body.isEmpty() && !method.equals("DELETE")) { + // Send post request + con.setDoOutput(true); + DataOutputStream wr = new DataOutputStream(con.getOutputStream()); + wr.writeBytes(body); + wr.flush(); + wr.close(); + } + + // con.connect(); + + int responseCode = con.getResponseCode(); + logger.debug("Send {} http request, url: {}",method,url); + logger.debug("Response Code: {}",responseCode); + + StringBuffer response = new StringBuffer(); + + try { + BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + } catch (Exception e) { + // response = null; + logger.debug("response body is null"); + } + + String result; + try { + + result = IOUtils.toString(con.getErrorStream()); + response.append(result); + + } catch (Exception e2) { + result = null; + } + logger.debug("Response body: {}",response); + + // print result + + restResponse.setStatusCode(responseCode); + // if (response == null) { + // restResponse.setResponse(null); + // } else { + // restResponse.setResponse(response.toString()); + // } + + if (response != null) { + restResponse.setResponse(response.toString()); + } + Map<String, List<String>> headerFields = con.getHeaderFields(); + restResponse.setHeaderFields(headerFields); + String responseMessage = con.getResponseMessage(); + restResponse.setResponseMessage(responseMessage); + + con.disconnect(); + return restResponse; + + } + + public RestResponse sendHttpPost(String url, String body, Map<String, String> headers) throws IOException { + + RestResponse restResponse = new RestResponse(); + URL obj = new URL(url); + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + + // add request method + con.setRequestMethod("POST"); + + // add request headers + if (headers != null) { + for (Entry<String, String> header : headers.entrySet()) { + String key = header.getKey(); + String value = header.getValue(); + con.setRequestProperty(key, value); + } + } + + // Send post request + if (body != null) { + con.setDoOutput(true); + DataOutputStream wr = new DataOutputStream(con.getOutputStream()); + wr.writeBytes(body); + wr.flush(); + wr.close(); + } + + // con.connect(); + + int responseCode = con.getResponseCode(); + logger.debug("Send POST http request, url: {}",url); + logger.debug("Response Code: {}",responseCode); + + StringBuffer response = new StringBuffer(); + try { + BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + } catch (Exception e) { + logger.debug("response body is null"); + } + + String result; + + try { + + result = IOUtils.toString(con.getErrorStream()); + response.append(result); + + } catch (Exception e2) { + result = null; + } + logger.debug("Response body: {}",response); + + // print result + + restResponse.setStatusCode(responseCode); + + if (response != null) { + restResponse.setResponse(response.toString()); + } + + Map<String, List<String>> headerFields = con.getHeaderFields(); + restResponse.setHeaderFields(headerFields); + String responseMessage = con.getResponseMessage(); + restResponse.setResponseMessage(responseMessage); + + con.disconnect(); + return restResponse; + + } + + public RestResponse httpSendPost(String url, String body, Map<String, String> headers) throws IOException { + return httpSendPost(url, body, headers, "POST"); + } + + public RestResponse httpSendPut(String url, String body, Map<String, String> headers) throws IOException { + return httpSendPost(url, body, headers, "PUT"); + } + + public RestResponse httpSendPost(String url, String body, Map<String, String> headers, String methodType) + throws IOException { + + RestResponse restResponse = new RestResponse(); + URL obj = new URL(url); + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + + // add request method + con.setRequestMethod(methodType); + + // add request headers + if (headers != null) { + for (Entry<String, String> header : headers.entrySet()) { + String key = header.getKey(); + String value = header.getValue(); + con.setRequestProperty(key, value); + } + } + + // Send post request + if (body != null) { + con.setDoOutput(true); + DataOutputStream wr = new DataOutputStream(con.getOutputStream()); + wr.writeBytes(body); + wr.flush(); + wr.close(); + } + + // con.connect(); + + int responseCode = con.getResponseCode(); + logger.debug("Send POST http request, url: {}",url); + logger.debug("Response Code: {}",responseCode); + + StringBuffer response = new StringBuffer(); + try { + BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + } catch (Exception e) { + logger.debug("response body is null"); + } + + String result; + + try { + + result = IOUtils.toString(con.getErrorStream()); + response.append(result); + + } catch (Exception e2) { + result = null; + } + logger.debug("Response body: {}",response); + + // print result + + restResponse.setStatusCode(responseCode); + + if (response != null) { + restResponse.setResponse(response.toString()); + } + + Map<String, List<String>> headerFields = con.getHeaderFields(); + restResponse.setHeaderFields(headerFields); + String responseMessage = con.getResponseMessage(); + restResponse.setResponseMessage(responseMessage); + + con.disconnect(); + return restResponse; + + } + + public RestResponse httpSendDeleteWithBody2(String url, String body, Map<String, String> headers) + throws ClientProtocolException, IOException { + + CloseableHttpClient httpclient = HttpClients.createDefault(); + RestResponse restResponse = new RestResponse(); + HttpDeleteWithBody httpDelete = new HttpDeleteWithBody(url); + + // add request headers + if (headers != null) { + for (Entry<String, String> header : headers.entrySet()) { + String key = header.getKey(); + String value = header.getValue(); + httpDelete.addHeader(key, value); + } + } + + // add body to request + StringEntity input = new StringEntity(body, ContentType.APPLICATION_JSON); + httpDelete.setEntity(input); + + // execute request + CloseableHttpResponse response = httpclient.execute(httpDelete); + + restResponse.setStatusCode(response.getStatusLine().getStatusCode()); + + return restResponse; + } + + public RestResponse httpSendDeleteWithBody(String url, String body, Map<String, String> headers) + throws IOException { + + RestResponse restResponse = new RestResponse(); + URL obj = new URL(url); + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + + // add request method + con.setRequestMethod("DELETE"); + + // add request headers + if (headers != null) { + for (Entry<String, String> header : headers.entrySet()) { + String key = header.getKey(); + String value = header.getValue(); + con.setRequestProperty(key, value); + } + } + + // Send post request + con.setDoOutput(true); + DataOutputStream wr = new DataOutputStream(con.getOutputStream()); + wr.writeBytes(body); + wr.flush(); + wr.close(); + + // con.connect(); + + int responseCode = con.getResponseCode(); + logger.debug("Send DELETE http request, url: {}",url); + logger.debug("Response Code: {}",responseCode); + + StringBuffer response = new StringBuffer(); + try { + BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + } catch (Exception e) { + logger.debug("response body is null"); + } + + String result; + + try { + + result = IOUtils.toString(con.getErrorStream()); + response.append(result); + + } catch (Exception e2) { + result = null; + } + logger.debug("Response body: {}", response); + + // print result + + restResponse.setStatusCode(responseCode); + + if (response != null) { + restResponse.setResponse(response.toString()); + } + + Map<String, List<String>> headerFields = con.getHeaderFields(); + restResponse.setHeaderFields(headerFields); + String responseMessage = con.getResponseMessage(); + restResponse.setResponseMessage(responseMessage); + + con.disconnect(); + return restResponse; + + } + + public RestResponse httpSendPostWithOutBody(String url, Map<String, String> headers) throws IOException { + + RestResponse restResponse = new RestResponse(); + URL obj = new URL(url); + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + + // add request method + con.setRequestMethod("POST"); + + // add request headers + if (headers != null) { + for (Entry<String, String> header : headers.entrySet()) { + String key = header.getKey(); + String value = header.getValue(); + con.setRequestProperty(key, value); + } + } + + // con.connect(); + + int responseCode = con.getResponseCode(); + logger.debug("Send POST http request, url: {}",url); + logger.debug("Response Code: {}",responseCode); + + StringBuffer response = new StringBuffer(); + + try { + BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + } catch (Exception e) { + // response = null; + logger.debug("response body is null"); + } + + String result; + try { + + result = IOUtils.toString(con.getErrorStream()); + response.append(result); + + } catch (Exception e2) { + result = null; + } + logger.debug("Response body: {}",response); + + // print result + + restResponse.setStatusCode(responseCode); + // if (response == null) { + // restResponse.setResponse(null); + // } else { + // restResponse.setResponse(response.toString()); + // } + + if (response != null) { + restResponse.setResponse(response.toString()); + } + + Map<String, List<String>> headerFields = con.getHeaderFields(); + restResponse.setHeaderFields(headerFields); + String responseMessage = con.getResponseMessage(); + restResponse.setResponseMessage(responseMessage); + + con.disconnect(); + return restResponse; + + } + + public RestResponse httpSendPostMultipart(String url, Map<String, String> headers, String jsonLocation, + String zipLocation) throws IOException { + + Gson gson = new Gson(); + String gsonToSend = null; + RestResponse restResponse = new RestResponse(); + BufferedReader br = null; + // + // + // + // + // try { + // + // String sCurrentLine; + // + // br = new BufferedReader(new FileReader(jsonLocation)); + // + // while ((sCurrentLine = br.readLine()) != null) { + // System.out.println(sCurrentLine); + // } + // + // } catch (IOException e) { + // e.printStackTrace(); + // } finally { + // try { + // if (br != null)br.close(); + // gsonToSend = br.toString(); + // } catch (IOException ex) { + // ex.printStackTrace(); + // } + // } + + gsonToSend = new Scanner(new File(jsonLocation)).useDelimiter("\\Z").next(); + logger.debug("gsonToSend: {}",gsonToSend); + + MultipartEntityBuilder mpBuilder = MultipartEntityBuilder.create(); + mpBuilder.addPart("resourceZip", new FileBody(new File(zipLocation))); + mpBuilder.addPart("resourceMetadata", new StringBody(gsonToSend, ContentType.APPLICATION_JSON)); + + HttpPost httpPost = new HttpPost(url); + httpPost.addHeader("USER_ID", "adminid"); + httpPost.setEntity(mpBuilder.build()); + + CloseableHttpClient client = HttpClients.createDefault(); + CloseableHttpResponse response = client.execute(httpPost); + try { + logger.debug("----------------------------------------"); + logger.debug("response.getStatusLine(): {}",response.getStatusLine()); + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { + logger.debug("Response content length: {}",resEntity.getContentLength()); + } + EntityUtils.consume(resEntity); + } finally { + + response.close(); + client.close(); + } + + restResponse.setStatusCode(response.getStatusLine().getStatusCode()); + restResponse.setResponse(response.getEntity().toString()); + + return restResponse; + + } + + public RestResponse httpSendPostWithAuth(String url, String body, Map<String, String> headers, String username, + String password) throws IOException { + + String userPassword = username + ":" + password; + String encoding = Base64.encodeBase64String(userPassword.getBytes()); + RestResponse restResponse = new RestResponse(); + URL obj = new URL(url); + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + + // add request method + con.setRequestMethod("POST"); + + con.setRequestProperty("Authorization", "Basic " + encoding); + + // add request headers + if (headers != null) { + for (Entry<String, String> header : headers.entrySet()) { + String key = header.getKey(); + String value = header.getValue(); + con.setRequestProperty(key, value); + } + + } + + // Send post request + con.setDoOutput(true); + DataOutputStream wr = new DataOutputStream(con.getOutputStream()); + wr.writeBytes(body); + wr.flush(); + wr.close(); + + // con.connect(); + + int responseCode = con.getResponseCode(); + logger.debug("Send POST http request, url: {}",url); + logger.debug("Response Code: {}",responseCode); + + StringBuffer response = new StringBuffer(); + try { + BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + } catch (Exception e) { + response = null; + + } + logger.debug("Response body: {}",response); + + // print result + + restResponse.setStatusCode(responseCode); + if (response == null) { + restResponse.setResponse(null); + } else { + restResponse.setResponse(response.toString()); + } + + Map<String, List<String>> headerFields = con.getHeaderFields(); + restResponse.setHeaderFields(headerFields); + String responseMessage = con.getResponseMessage(); + restResponse.setResponseMessage(responseMessage); + + con.disconnect(); + return restResponse; + + } + + public RestResponse httpSendDelete(String url, Map<String, String> headers) throws IOException { + + RestResponse restResponse = new RestResponse(); + URL obj = new URL(url); + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + + if (headers != null) { + for (Entry<String, String> header : headers.entrySet()) { + String key = header.getKey(); + String value = header.getValue(); + con.setRequestProperty(key, value); + } + + } + + con.setDoOutput(true); + con.setRequestMethod("DELETE"); + int responseCode = con.getResponseCode(); + logger.debug("Send DELETE http request, url: {}",url); + logger.debug("Response Code: {}",responseCode); + + StringBuffer response = new StringBuffer(); + + try { + BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + } catch (Exception e) { + logger.debug("response body is null"); + } + + String result; + + try { + + result = IOUtils.toString(con.getErrorStream()); + response.append(result); + + } catch (Exception e2) { + result = null; + } + logger.debug("Response body: {}",response); + + // print result + + restResponse.setStatusCode(responseCode); + + if (response != null) { + restResponse.setResponse(response.toString()); + } + + restResponse.setStatusCode(con.getResponseCode()); + Map<String, List<String>> headerFields = con.getHeaderFields(); + restResponse.setHeaderFields(headerFields); + String responseMessage = con.getResponseMessage(); + restResponse.setResponseMessage(responseMessage); + + con.disconnect(); + + return restResponse; + } + + public static RestResponse sendHttpPostWithEntity(HttpEntity requestEntity, String url, Map<String, String> headers) + throws IOException, ClientProtocolException { + CloseableHttpResponse response = null; + CloseableHttpClient client = HttpClients.createDefault(); + try { + HttpPost httpPost = new HttpPost(url); + RestResponse restResponse = new RestResponse(); + for (Entry<String, String> entry : headers.entrySet()) { + httpPost.addHeader(entry.getKey(), entry.getValue()); + } + + httpPost.setEntity(requestEntity); + response = client.execute(httpPost); + HttpEntity responseEntity = response.getEntity(); + String responseBody = null; + if (responseEntity != null) { + InputStream instream = responseEntity.getContent(); + StringWriter writer = new StringWriter(); + IOUtils.copy(instream, writer); + responseBody = writer.toString(); + try { + + } finally { + instream.close(); + } + } + + restResponse.setStatusCode(response.getStatusLine().getStatusCode()); + restResponse.setResponse(responseBody); + + return restResponse; + + } finally { + closeResponse(response); + closeHttpClient(client); + + } + } + + private static void closeHttpClient(CloseableHttpClient client) { + try { + if (client != null) { + client.close(); + } + } catch (IOException e) { + logger.debug("failed to close client or response: ", e); + } + } + + private static void closeResponse(CloseableHttpResponse response) { + try { + if (response != null) { + response.close(); + } + } catch (IOException e) { + logger.debug("failed to close client or response: ", e); + } + } + + @NotThreadSafe + class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase { + public static final String METHOD_NAME = "DELETE"; + + public String getMethod() { + return METHOD_NAME; + } + + public HttpDeleteWithBody(final String uri) { + super(); + setURI(URI.create(uri)); + } + + public HttpDeleteWithBody(final URI uri) { + super(); + setURI(uri); + } + + public HttpDeleteWithBody() { + super(); + } + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/MustHeaders.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/MustHeaders.java new file mode 100644 index 000000000..e9a87ed1d --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/MustHeaders.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes.http; + +import java.util.HashMap; +import java.util.Map; + +public class MustHeaders { + + private Map<String, String> headers = new HashMap<String, String>(); + + public MustHeaders(HeaderData headerData) { + + super(); + headers.put(HttpHeaderEnum.Content_MD5.getValue(), headerData.getContentMd5()); + headers.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), headerData.getContentType()); + headers.put(HttpHeaderEnum.ACCEPT.getValue(), headerData.getContentType()); + headers.put(HttpHeaderEnum.USER_ID.getValue(), headerData.getHttpCspUserId()); + headers.put(HttpHeaderEnum.HTTP_CSP_FIRSTNAME.getValue(), headerData.getHttpCspFirstName()); + headers.put(HttpHeaderEnum.HTTP_CSP_LASTNAME.getValue(), headerData.getHttpCspLastName()); + headers.put(HttpHeaderEnum.HTTP_CSP_WSTYPE.getValue(), headerData.getHttpCspWsType()); + headers.put(HttpHeaderEnum.HTTP_IV_REMOTE_ADDRESS.getValue(), headerData.getHttpIvRemoteAddress()); + headers.put(HttpHeaderEnum.HTTP_IV_USER.getValue(), headerData.getHttpIvUser()); + + } + + public MustHeaders() { + super(); + } + + public Map<String, String> getMap() { + return headers; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/RestResponse.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/RestResponse.java new file mode 100644 index 000000000..8974b74c1 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/http/RestResponse.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.datatypes.http; + +import java.util.List; +import java.util.Map; + +public class RestResponse { + + Integer statusCode; + String response; + Map<String, List<String>> headerFields; + String responseMessage; + + public RestResponse() { + super(); + } + + public RestResponse(Integer errorCode, String response, Map<String, List<String>> headerFields, + String responseMessage) { + super(); + this.statusCode = errorCode; + this.response = response; + this.headerFields = headerFields; + this.responseMessage = responseMessage; + } + + public Integer getStatusCode() { + return statusCode; + } + + public void setStatusCode(Integer errorCode) { + this.statusCode = errorCode; + } + + public String getResponse() { + return response; + } + + public void setResponse(String response) { + this.response = response; + } + + public Map<String, List<String>> getHeaderFields() { + return headerFields; + } + + public void setHeaderFields(Map<String, List<String>> headerFields) { + this.headerFields = headerFields; + } + + public String getResponseMessage() { + return responseMessage; + } + + public void setResponseMessage(String responseMessage) { + this.responseMessage = responseMessage; + } + + @Override + public String toString() { + return "RestResponse [errorCode=" + statusCode + ", response=" + response + ", headerFields=" + headerFields + + ", responseMessage=" + responseMessage + "]"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/CategoryDataDefinition.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/CategoryDataDefinition.java new file mode 100644 index 000000000..0c673e62d --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/CategoryDataDefinition.java @@ -0,0 +1,111 @@ +package org.onap.sdc.ci.tests.devObjects; + + +import java.io.Serializable; +import java.util.List; + +public class CategoryDataDefinition extends ToscaDataDefinition implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 2882352060242714427L; + + private String name; + private String normalizedName; + private String uniqueId; + private List<String> icons; + + public CategoryDataDefinition() { + + } + + public CategoryDataDefinition(CategoryDataDefinition c) { + this.name = c.name; + this.normalizedName = c.normalizedName; + this.uniqueId = c.uniqueId; + this.icons = c.icons; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getNormalizedName() { + return normalizedName; + } + + public void setNormalizedName(String normalizedName) { + this.normalizedName = normalizedName; + } + + public String getUniqueId() { + return uniqueId; + } + + public void setUniqueId(String uniqueId) { + this.uniqueId = uniqueId; + } + + public List<String> getIcons() { + return icons; + } + + public void setIcons(List<String> icons) { + this.icons = icons; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((normalizedName == null) ? 0 : normalizedName.hashCode()); + result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode()); + result = prime * result + ((icons == null) ? 0 : icons.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CategoryDataDefinition other = (CategoryDataDefinition) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (normalizedName == null) { + if (other.normalizedName != null) + return false; + } else if (!normalizedName.equals(other.normalizedName)) + return false; + if (uniqueId == null) { + if (other.uniqueId != null) + return false; + } else if (!uniqueId.equals(other.uniqueId)) + return false; + if (icons == null) { + if (other.icons != null) + return false; + } else if (!icons.equals(other.icons)) + return false; + return true; + } + + @Override + public String toString() { + return "CategoryDataDefinition [name=" + name + ", normalizedName=" + normalizedName + ", uniqueId=" + uniqueId + + ", icons=" + icons + "]"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/CategoryDefinition.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/CategoryDefinition.java new file mode 100644 index 000000000..ef65a2de2 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/CategoryDefinition.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.devObjects; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +public class CategoryDefinition extends CategoryDataDefinition implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 6552733796860992476L; + + List<SubCategoryDefinition> subcategories; + + public CategoryDefinition() { + super(); + } + + public CategoryDefinition(CategoryDataDefinition c) { + super(c); + } + + public List<SubCategoryDefinition> getSubcategories() { + return subcategories; + } + + public void setSubcategories(List<SubCategoryDefinition> subcategories) { + this.subcategories = subcategories; + } + + public void addSubCategory(SubCategoryDefinition subcategory) { + if (subcategories == null) { + subcategories = new ArrayList<SubCategoryDefinition>(); + } + subcategories.add(subcategory); + } + + @Override + public String toString() { + return super.toString() + " CategoryDefinition [subcategories=" + subcategories + "]"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/GraphPropertyEnum.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/GraphPropertyEnum.java new file mode 100644 index 000000000..b393b9160 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/GraphPropertyEnum.java @@ -0,0 +1,103 @@ +package org.onap.sdc.ci.tests.devObjects; + +import java.util.ArrayList; +import java.util.List; + + + +public enum GraphPropertyEnum { +// field name class type unique indexed +// stored in graph index + UNIQUE_ID ("uid", String.class, true, true), + LABEL ("nodeLabel", String.class, false, true), + JSON ("json", String.class, false, false), + METADATA ("metadata", String.class, false, false), + VERSION ("version", String.class, false, true), + STATE ("state", String.class, false, true), + IS_HIGHEST_VERSION ("highestVersion", Boolean.class, false, true), + IS_DELETED ("deleted", Boolean.class, false, true), + NORMALIZED_NAME ("normalizedName", String.class, false, true), + NAME ("name", String.class, false, true), + TOSCA_RESOURCE_NAME ("toscaResourceName", String.class, false, true), + DISTRIBUTION_STATUS ("distributionStatus", String.class, false, false), + RESOURCE_TYPE ("resourceType", String.class, false, true), + COMPONENT_TYPE ("componentType", String.class, false, true), + UUID ("uuid", String.class, false, true), + SYSTEM_NAME ("systemName", String.class, false, true), + IS_ABSTRACT ("abstract", Boolean.class, false, true), + INVARIANT_UUID ("invariantUuid", String.class, false, true), + CSAR_UUID ("csarUuid", String.class, false, true), + //used for user (old format, no json for users) + USERID ("userId", String.class, true, true), + ROLE ("role", String.class, false, false), + FIRST_NAME ("firstName", String.class, false, false), + LAST_NAME ("lastName", String.class, false, false), + EMAIL ("email", String.class, false, false), + LAST_LOGIN_TIME ("lastLoginTime", Long.class, false, false), + //used for category (old format, no json for categories) + ICONS ("icons", String.class, false, false); + + private String property; + private Class clazz; + private boolean unique; + private boolean indexed; + + GraphPropertyEnum(String property, Class clazz, boolean unique, boolean indexed) { + this.property = property; + this.clazz = clazz; + this.unique = unique; + this.indexed = indexed; + } + + public static GraphPropertyEnum getByProperty(String property){ + for(GraphPropertyEnum currProperty :GraphPropertyEnum.values()){ + if(currProperty.getProperty().equals(property)){ + return currProperty; + } + } + return null; + } + + public String getProperty() { + return property; + } + + public void setProperty(String property) { + this.property = property; + } + + public Class getClazz() { + return clazz; + } + + public void setClazz(Class clazz) { + this.clazz = clazz; + } + + public boolean isUnique() { + return unique; + } + + public void setUnique(boolean unique) { + this.unique = unique; + } + + public boolean isIndexed() { + return indexed; + } + + public void setIndexed(boolean indexed) { + this.indexed = indexed; + } + + public static List<String> getAllProperties() { + + List<String> arrayList = new ArrayList<String>(); + + for (GraphPropertyEnum graphProperty : GraphPropertyEnum.values()) { + arrayList.add(graphProperty.getProperty()); + } + + return arrayList; + } +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/GroupingDataDefinition.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/GroupingDataDefinition.java new file mode 100644 index 000000000..cdb45c5c6 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/GroupingDataDefinition.java @@ -0,0 +1,112 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.devObjects; + +import java.io.Serializable; + +public class GroupingDataDefinition extends ToscaDataDefinition implements Serializable { + /** + * + */ + private static final long serialVersionUID = 2641475929148843849L; + + private String name; + private String normalizedName; + private String uniqueId; + + public GroupingDataDefinition() { + + } + + public GroupingDataDefinition(GroupingDataDefinition c) { + this.name = c.name; + this.normalizedName = c.normalizedName; + this.uniqueId = c.uniqueId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getNormalizedName() { + return normalizedName; + } + + public void setNormalizedName(String normalizedName) { + this.normalizedName = normalizedName; + } + + public String getUniqueId() { + return uniqueId; + } + + public void setUniqueId(String uniqueId) { + this.uniqueId = uniqueId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((normalizedName == null) ? 0 : normalizedName.hashCode()); + result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + GroupingDataDefinition other = (GroupingDataDefinition) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (normalizedName == null) { + if (other.normalizedName != null) + return false; + } else if (!normalizedName.equals(other.normalizedName)) + return false; + if (uniqueId == null) { + if (other.uniqueId != null) + return false; + } else if (!uniqueId.equals(other.uniqueId)) + return false; + return true; + } + + @Override + public String toString() { + return "GroupingDataDefinition [name=" + name + ", normalizedName=" + normalizedName + ", uniqueId=" + uniqueId + + "]"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/GroupingDefinition.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/GroupingDefinition.java new file mode 100644 index 000000000..7b04d2307 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/GroupingDefinition.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.devObjects; + +public class GroupingDefinition extends GroupingDataDefinition { + + public GroupingDefinition() { + super(); + } + + public GroupingDefinition(GroupingDataDefinition g) { + super(g); + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/JsonPresentationFields.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/JsonPresentationFields.java new file mode 100644 index 000000000..d17755207 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/JsonPresentationFields.java @@ -0,0 +1,193 @@ +package org.onap.sdc.ci.tests.devObjects; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + + +//@JsonDeserialize(using = MyDeserializer.class) + +public enum JsonPresentationFields { + UNIQUE_ID ("uniqueId", GraphPropertyEnum.UNIQUE_ID), + HIGHEST_VERSION ("highestVersion", GraphPropertyEnum.IS_HIGHEST_VERSION), + LIFECYCLE_STATE ("lifecycleState", GraphPropertyEnum.STATE), + CREATION_DATE ("creationDate", null), + LAST_UPDATE_DATE ("lastUpdateDate", null), + SYSTEM_NAME ("systemName", GraphPropertyEnum.SYSTEM_NAME), + NAME ("name", GraphPropertyEnum.NAME), + VERSION ("version", GraphPropertyEnum.VERSION), + NORMALIZED_NAME ("normalizedName", GraphPropertyEnum.NORMALIZED_NAME), + UUID ("UUID", GraphPropertyEnum.UUID), + RESOURCE_TYPE ("resourceType", GraphPropertyEnum.RESOURCE_TYPE), + COMPONENT_TYPE ("componentType", GraphPropertyEnum.COMPONENT_TYPE), + IS_DELETED ("isDeleted", GraphPropertyEnum.IS_DELETED), + ECOMP_GENERATED_NAMING ("ecompGeneratedNaming", null), + NAMING_POLICY ("namingPolicy", null), + TOSCA_RESOURCE_NAME ("toscaResourceName", GraphPropertyEnum.TOSCA_RESOURCE_NAME), + DESCRIPTION ("description", null), + TYPE ("type", null), + DERIVED_FROM ("derivedFrom", null), + VENDOR_NAME ("vendorName", null), + VENDOR_RELEASE ("vendorRelease", null), + CONFORMANCE_LEVEL ("conformanceLevel", null), + ICON ("icon", null), + TAGS ("tags", null), + INVARIANT_UUID ("invariantUuid", GraphPropertyEnum.INVARIANT_UUID), + CSAR_UUID ("csarUuid", GraphPropertyEnum.CSAR_UUID), + CSAR_VERSION ("csarVersion", null), + IMPORTED_TOSCA_CHECKSUM ("importedToscaChecksum", null), + CONTACT_ID ("contactId", null), + PROJECT_CODE ("projectCode", null), + DISTRIBUTION_STATUS ("distributionStatus", GraphPropertyEnum.DISTRIBUTION_STATUS), + DERIVED_FROM_GENERIC_TYPE ("derivedFromGenericType", null), + DERIVED_FROM_GENERIC_VERSION ("derivedFromGenericVersion", null), + + ////Artifact + ARTIFACT_TYPE ("artifactType", null), + ARTIFACT_REF ("artifactRef", null), + ARTIFACT_REPOSITORY ("artifactRepository", null), + ARTIFACT_CHECKSUM ("artifactChecksum", null), + ARTIFACT_CREATOR ("artifactCreator", null), + USER_ID_CREATOR ("userIdCreator", null), + USER_ID_LAST_UPDATER ("userIdLastUpdater", null), + CREATOR_FULL_NAME ("creatorFullName", null), + UPDATER_FULL_NAME ("updaterFullName", null), + + ES_ID ("esId", null), + ARTIFACT_LABEL ("artifactLabel", null), + IS_ABSTRACT ("mandatory", null), + ARTIFACT_DISPLAY_NAME ("artifactDisplayName", null), + API_URL ("apiUrl", null), + SERVICE_API ("serviceApi", null), + ARTIFACT_VERSION ("artifactVersion", null), + ARTIFACT_UUID ("artifactUUID", null), + PAYLOAD_UPDATE_DATE ("payloadUpdateDate", null), + HEAT_PARAMS_UPDATE_DATE ("heatParamsUpdateDate", null), + GENERATED ("generated", null), + ARTIFACT_GROUP_TYPE ("artifactGroupType", null), + ARTIFACT_TIMEOUT ("timeout", null), + REQUIRED_ARTIFACTS ("requiredArtifacts", null), + DUPLICATED ("duplicated", null), + HEAT_PARAMETERS ("heatParameters", null), + GENERATED_FROM_ID ("generatedFromId", null), + + + // end artifacts + + + //property + DEFINITION ("definition", null), + DEFAULT_VALUE ("defaultValue", null), + REQUIRED ("required", null), + PASSWORD ("password", null), + CONSTRAINTS ("constraints", null), + PROPERTIES ("properties", null), + PROPERTY ("property", null), + SCHEMA ("schema", null), + VALUE ("value", null), + PARENT_UNIQUE_ID ("parentUniqueId", null), + + COMPONENT_INSTANCES ("componentInstances", null), + RELATIONS ("relations", null), + + //attribute + STATUS ("status", null), + //capability + VALID_SOURCE_TYPE ("validSourceTypes", null), + CREATION_TIME ("creationTime", null), + MODIFICATION_TIME ("modificationTime", null), + CAPABILITY_SOURCES ("capabilitySources", null), + MAX_OCCURRENCES ("maxOccurrences", null), + MIN_OCCURRENCES ("minOccurrences", null), + OWNER_NAME ("ownerName", null), + OWNER_ID ("ownerId", null), + LEFT_OCCURRENCES ("leftOccurences", null), + CAPABILITY_ID ("capabiltyId", null), + PATH ("path", null), + SOURCE ("source", null), + + //Requirement + CAPAPILITY ("capability", null), + NODE ("node", null), + RELATIONSHIP ("relationship", null), + VALID_SOURCE_TYPES ("validSourceTypes", null), + REQUIREMENT_ID ("requirementId", null), + + //Relation + CAPABILTY_OWNER_ID ("capabilityOwnerId", null), + REQUIREMENT_OWNER_ID ("requirementOwnerId", null), + FROM_ID ("fromId", null), + TO_ID ("toId", null), + REQUIREMENT ("requirement", null), + + //Groups + + GROUP_INVARIANT_UUID ("invariantUUID", null), + GROUP_UUID ("groupUUID", null), + GROUP_MEMBER ("members", null), + GROUP_ARTIFACTS ("artifacts", null), + GROUP_ARTIFACTS_UUID ("artifactsUuid", null), + GROUP_PROPERTIES ("properties", null), + GROUP_UNIQUE_ID ("groupUid", null), + POS_X ("posX", null), + POS_Y ("posY", null), + PROPERTY_VALUE_COUNTER ("propertyValueCounter", null), + CUSTOMIZATION_UUID ("customizationUUID", null), + GROUP_NAME ("groupName", null), + GROUP_INSTANCE_ARTIFACTS ("groupInstanceArtifacts", null), + GROUP_INSTANCE_ARTIFACTS_UUID ("groupInstanceArtifactsUuid", null), + GROUP_INSTANCE_PROPERTIES ("groupInstancesProperties", null), + + ; + + + private String presentation; + private GraphPropertyEnum storedAs; + + JsonPresentationFields(String presentation, GraphPropertyEnum storedAs) { + this.presentation = presentation; + this.storedAs = storedAs; + } + + @JsonValue + public String getPresentation() { + return presentation; + } + + public void setPresentation(String presentation) { + this.presentation = presentation; + } + + public GraphPropertyEnum getStoredAs() { + return storedAs; + } + + public void setStoredAs(GraphPropertyEnum storedAs) { + this.storedAs = storedAs; + } + + public static String getPresentationByGraphProperty(GraphPropertyEnum property) { + for(JsonPresentationFields currPresentation : JsonPresentationFields.values()){ + if(currPresentation.getStoredAs() == property){ + return currPresentation.getPresentation(); + } + } + return null; + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return presentation; + } + + @JsonCreator + public static JsonPresentationFields getByPresentation(String presentation) { + for (JsonPresentationFields inst : JsonPresentationFields.values()) { + if (inst.getPresentation().equals(presentation)) { + return inst; + } + } + return null; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/LifecycleStateEnum.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/LifecycleStateEnum.java new file mode 100644 index 000000000..e17222cf2 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/LifecycleStateEnum.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.devObjects; + +public enum LifecycleStateEnum { + + READY_FOR_CERTIFICATION, + + CERTIFICATION_IN_PROGRESS, + + CERTIFIED, + + NOT_CERTIFIED_CHECKIN, + + NOT_CERTIFIED_CHECKOUT; + + public static LifecycleStateEnum findState(String state) { + + for (LifecycleStateEnum lifecycleStateEnum : LifecycleStateEnum.values()) { + if (lifecycleStateEnum.name().equals(state)) { + return lifecycleStateEnum; + } + } + return null; + } +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/ResourceTypeEnum.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/ResourceTypeEnum.java new file mode 100644 index 000000000..549968205 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/ResourceTypeEnum.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.devObjects; + +/** + * Resource Type Enum + * @author mshitrit + * + */ +public enum ResourceTypeEnum { + + VFC("VFC (Virtual Function Component)"), VF("VF"/* (Virtual Function)" */), CP("CP (Connection Point)"), + VL( "VL (Virtual Link)"), VFCMT("VFCMT (VFC Monitoring Template)"), ABSTRACT("Abstract (Generic VFC/VF/Service Type)"); + + private String value; + + private ResourceTypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static ResourceTypeEnum getType(String type) { + for (ResourceTypeEnum e : ResourceTypeEnum.values()) { + if (e.name().equals(type)) { + return e; + } + } + return null; + } + + public static ResourceTypeEnum getTypeByName(String type) { + for (ResourceTypeEnum e : ResourceTypeEnum.values()) { + if (e.name().equalsIgnoreCase(type)) { + return e; + } + } + return null; + } +/** + * Returns ResourceTypeEnum matching to received String ignore case + * @param type + * @return + */ + public static ResourceTypeEnum getTypeIgnoreCase(String type) { + for (ResourceTypeEnum e : ResourceTypeEnum.values()) { + if (e.name().toLowerCase().equals(type.toLowerCase())) { + return e; + } + } + return null; + } + /** + * Checks if enum exist with given type + * @param type + * @return + */ + public static boolean containsName(String type) { + + for (ResourceTypeEnum e : ResourceTypeEnum.values()) { + if (e.name().equals(type)) { + return true; + } + } + return false; + } + /** + * Checks if enum exist with given type ignare case + * @param type + * @return + */ + public static boolean containsIgnoreCase(String type) { + + for (ResourceTypeEnum e : ResourceTypeEnum.values()) { + if (e.name().toLowerCase().equals(type.toLowerCase())) { + return true; + } + } + return false; + } +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/SubCategoryDataDefinition.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/SubCategoryDataDefinition.java new file mode 100644 index 000000000..0eb76014e --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/SubCategoryDataDefinition.java @@ -0,0 +1,128 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.devObjects; + +import java.io.Serializable; +import java.util.List; + +public class SubCategoryDataDefinition extends ToscaDataDefinition implements Serializable { + /** + * + */ + private static final long serialVersionUID = 8279397988497086676L; + + private String name; + private String normalizedName; + private String uniqueId; + private List<String> icons; + + public SubCategoryDataDefinition() { + + } + + public SubCategoryDataDefinition(SubCategoryDataDefinition c) { + this.name = c.name; + this.normalizedName = c.normalizedName; + this.uniqueId = c.uniqueId; + this.icons = c.icons; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getNormalizedName() { + return normalizedName; + } + + public void setNormalizedName(String normalizedName) { + this.normalizedName = normalizedName; + } + + public String getUniqueId() { + return uniqueId; + } + + public void setUniqueId(String uniqueId) { + this.uniqueId = uniqueId; + } + + public List<String> getIcons() { + return icons; + } + + public void setIcons(List<String> icons) { + this.icons = icons; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((normalizedName == null) ? 0 : normalizedName.hashCode()); + result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode()); + result = prime * result + ((icons == null) ? 0 : icons.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SubCategoryDataDefinition other = (SubCategoryDataDefinition) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (normalizedName == null) { + if (other.normalizedName != null) + return false; + } else if (!normalizedName.equals(other.normalizedName)) + return false; + if (uniqueId == null) { + if (other.uniqueId != null) + return false; + } else if (!uniqueId.equals(other.uniqueId)) + return false; + if (icons == null) { + if (other.icons != null) + return false; + } else if (!icons.equals(other.icons)) + return false; + return true; + } + + @Override + public String toString() { + return "SubCategoryDataDefinition [name=" + name + ", normalizedName=" + normalizedName + ", uniqueId=" + + uniqueId + ", icons=" + icons + "]"; + } +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/SubCategoryDefinition.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/SubCategoryDefinition.java new file mode 100644 index 000000000..b45ce4fa1 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/SubCategoryDefinition.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.devObjects; + +import java.util.ArrayList; +import java.util.List; + +public class SubCategoryDefinition extends SubCategoryDataDefinition { + + private List<GroupingDefinition> groupings; + + public SubCategoryDefinition() { + super(); + } + + public SubCategoryDefinition(SubCategoryDataDefinition subCategory) { + super(subCategory); + } + + public List<GroupingDefinition> getGroupings() { + return groupings; + } + + public void setGroupings(List<GroupingDefinition> groupingDefinitions) { + this.groupings = groupingDefinitions; + } + + public void addGrouping(GroupingDefinition groupingDefinition) { + if (groupings == null) { + groupings = new ArrayList<GroupingDefinition>(); + } + groupings.add(groupingDefinition); + } + + @Override + public String toString() { + return super.toString() + " SubCategoryDefinition [groupings=" + groupings + "]"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/ToscaDataDefinition.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/ToscaDataDefinition.java new file mode 100644 index 000000000..c4fa53b5d --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/devObjects/ToscaDataDefinition.java @@ -0,0 +1,79 @@ +package org.onap.sdc.ci.tests.devObjects; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import fj.data.Either; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.stream.Collectors; + +public abstract class ToscaDataDefinition { + + protected Map<String, Object> toscaPresentation; + + + public ToscaDataDefinition(){ + toscaPresentation = new HashMap<String, Object>(); + } + @JsonCreator + public ToscaDataDefinition(Map<String, Object> art){ + toscaPresentation = art; + } + @JsonValue + public Object getToscaPresentationValue(JsonPresentationFields name) { + if (toscaPresentation != null && toscaPresentation.containsKey(name.getPresentation())) { + return toscaPresentation.get(name.getPresentation()); + } + return null; + } + + public void setToscaPresentationValue(JsonPresentationFields name, Object value) { + if (toscaPresentation == null && value !=null) { + toscaPresentation = new HashMap<String, Object>(); + } + toscaPresentation.put(name.getPresentation(), value); + + } + public void setOwnerIdIfEmpty(String ownerId){ + if ( getOwnerId() == null ){ + setOwnerId(ownerId); + } + } + public void setOwnerId(String ownerId){ + setToscaPresentationValue(JsonPresentationFields.OWNER_ID, ownerId); + } + + public String getOwnerId(){ + return (String) getToscaPresentationValue(JsonPresentationFields.OWNER_ID); + } + + + //default merge function for merging data maps - implement where needed and use mergeDataMaps method where applicable instead of map1.putAll(map2) + public <T extends ToscaDataDefinition> T mergeFunction(T other, boolean allowDefaultValueOverride){ + other.setOwnerId(getOwnerId()); + return other; + } + + public static <T extends ToscaDataDefinition> Either<Map<String, T>, String> mergeDataMaps(Map<String, T> map1, Map<String, T> map2){ + return mergeDataMaps(map1, map2, false); + } + + //return Either.right(item key) if an illegal merge was attempted (overriding data type is forbidden) + public static <T extends ToscaDataDefinition> Either<Map<String, T>, String> mergeDataMaps(Map<String, T> map1, Map<String, T> map2, boolean allowDefaultValueOverride){ + for(Entry<String, T> entry : map2.entrySet()){ + map1.merge(entry.getKey(), entry.getValue(), (item1, item2) -> item1.mergeFunction(item2, allowDefaultValueOverride)); + //validate merge success + if(!map1.containsKey(entry.getKey())) + return Either.right(entry.getKey()); + } + return Either.left(map1); + } + + public static <T extends ToscaDataDefinition> Map<String, T> listToMapByName(List<T> dataList) { + return null == dataList? new HashMap<>() : dataList.stream() + .collect(Collectors.toMap(p -> (String)p.getToscaPresentationValue(JsonPresentationFields.NAME), p -> p)); + } +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/DriverFactory.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/DriverFactory.java new file mode 100644 index 000000000..e8c386bb2 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/DriverFactory.java @@ -0,0 +1,132 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.execute.setup; + + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FilenameFilter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; + +import org.apache.commons.io.FileUtils; +import org.onap.sdc.ci.tests.datatypes.Configuration; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.utilities.FileHandling; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.firefox.FirefoxProfile; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeSuite; + + +public abstract class DriverFactory { + + private static ThreadLocal<WebDriverThread> driverThread; + private static List<WebDriverThread> webDriverThreadPool = Collections.synchronizedList(new ArrayList<WebDriverThread>()); + private static Configuration configuration; + private static final String GECKO_DRIVER_KEY = "webdriver.gecko.driver"; + + protected abstract UserCredentials getUserCredentials(); + protected abstract Configuration getEnvConfiguration(); + + public DriverFactory() { + + try { + configuration = getEnvConfiguration(); + + //Set geko driver path for firefox + if(configuration.getGeckoDriverPath() != null){ + System.setProperty(GECKO_DRIVER_KEY, configuration.getGeckoDriverPath()); + } else { + throw new RuntimeException("Gecko driver path is null. Make sure to provide path to the gecko driver executable"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + @BeforeSuite(alwaysRun = true) + public static void instantiateDriverObject() { + + + File basePath = new File(FileHandling.getBasePath()); + File[] listFiles = basePath.listFiles(new FilenameFilter() { + + @Override + public boolean accept(File basePath, String name) { + return name.startsWith(WebDriverThread.AUTOMATION_DOWNLOAD_DIR); + } + }); + Arrays.asList(listFiles).forEach(e -> FileHandling.deleteDirectory(e.getAbsolutePath())); + + + + driverThread = new ThreadLocal<WebDriverThread>() { + @Override + protected WebDriverThread initialValue() { + WebDriverThread webDriverThread = new WebDriverThread(configuration); + webDriverThreadPool.add(webDriverThread); + return webDriverThread; + } + }; + } + + public static WebDriver getDriver() throws Exception { + return driverThread.get().getDriver(); + } + + public static FirefoxProfile getDriverFirefoxProfile() throws Exception { + return driverThread.get().getFirefoxProfile(); + } + + @AfterSuite(alwaysRun = true) + public static void quitDriverAfterSuite() throws Exception { + for (WebDriverThread webDriverThread : webDriverThreadPool) { + if (webDriverThread.getDriver() != null) + webDriverThread.quitDriver(); + } + deleteDownloadDirs(); + } + + private static void deleteDownloadDirs() throws IOException { +// System.gc(); + HashMap<Long,WindowTest> windowMap = WindowTestManager.getWholeMap(); + for (WindowTest win : windowMap.values()){ + String downloadDirectory = win.getDownloadDirectory(); + FileUtils.deleteDirectory(new File(downloadDirectory)); + } + } + + public static void quitDriver() throws Exception{ + driverThread.get().quitDriver(); + driverThread.remove(); + WindowTestManager.removeWindowTest(); + } + public static Configuration getConfiguration() { + return configuration; + } + + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/ExtentManager.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/ExtentManager.java new file mode 100644 index 000000000..c835648b5 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/ExtentManager.java @@ -0,0 +1,177 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.execute.setup; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; + +import org.onap.sdc.ci.tests.datatypes.Configuration; +import org.onap.sdc.ci.tests.utilities.FileHandling; +import org.testng.ITestContext; + +import com.aventstack.extentreports.ExtentReports; +import com.aventstack.extentreports.reporter.ExtentHtmlReporter; +import com.aventstack.extentreports.reporter.ExtentXReporter; +import com.aventstack.extentreports.reporter.configuration.Protocol; +import com.aventstack.extentreports.reporter.configuration.Theme; + +public class ExtentManager { + + private static final String VERSIONS_INFO_FILE_NAME = "versions.info"; + private static ExtentReports extent; + private static ExtentHtmlReporter htmlReporter; + private static ExtentXReporter extentxReporter; + private static final String icon = "$(document).ready(function() {" +"\n"+ + "$('.brand-logo').html('').prepend(\"<span><img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQ4AAAB7CAYAAACFKW5jAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABaAAAAWgBwI7h9AAAAB3RJTUUH3wwXFAQf1clFIAAANNxJREFUeNrtnXeYXVXV/z+n3To101ImvZFGQiCANKUoSBEFebEj1hcb2MWC+lpAbGD5CaKoiL2ggIgoRUIgQAohJCG9TTLJ9Dszt52y9++PfSeZTO6duXfmTkk4n+eZJ5Nbztn7zNnrrL32Wt8NPj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+PgOjjXYDhpX7WgkZMD2qY2qQFtDlSkSvjlsaGJpGUIeQAS1pyb60hMurRrv1Pj5jFnO0G1As9PvbmBiEDkeS8CSmpuEhCOi6FTW0sAYhiTRNTTM8JBoaGmDpSEODoK65EQM7YpLCCCVC97ciAUODuSU6UpO88Jpxo91NH58xwTHtcSx6vJ2DKUlTSlBVVqKVesnqlrSosaWcFTa0eXFX1nmSmrChjTc1qoCIKwlJ1W8NkDoITUPokAQ6U0I2uYL9FZZ+UNfYnvDkhoWlRnNdhIMP7HWcsqDOonKDsK7znzPLRvsS+PiMCsec4VjwWDvNaUFTh8eS8VbFvpSc4Qh5esJjKbBASDnDlZTqGmEpQQ7yPLoGSGxdIx4xtEZbyhdrA/pGIVk+ParveEt9qOH69d3i1AqTcbg8eE71aF8aH58RY8wbjresjbGiCTzpsb/JYUF9oKwpJZekhLzQkfJMIVnkCMoBY7BGIl90DQyNeEjXdhsaz4UN7V9TwvozK88p31Pzzza5uNykOqDzh2Wlo33ZfHyGlTFrOC58opMGT9DuCG6YGdG/ty0xxxby4pTgEkfKpa6gYrgNRX9ogKHhBHVta4WlPR4xtPtmRPXn/7U73XlGfYCoAf8+o2K0L6OPz7AwJg3H/Mc6aEoLFpUawe0J79RuV76525WXuYLpYrQblwUNCOh0Rk3tuQpL/119WHv4yS3O/lNnBji53OQnS6Kj3UQfn6IypgzHOcvb2ZWQnFRpWavbnDM6XfmelJCXOIKq0fQuCsHScKOmtqbE1H41K2r89Yl9qQPvmh3hnqX+9MXn+GHMGI4TH+vgX2eEtLOXJ09sscUHEx5XOUJWHysGoy+mhltmas9OCOl3/E998O9rO9yub82PMLf0uFkB93kFM+qG44HGNF/dnCSoU7s9Lt4bc+UHUp6cdqwajL6EdS01OaI/eOY469t3nxR9PuFJGTX10W6Wj8+QGFXDIaUE0M5d0XnW+k73pg5HnutJjNG+KMVG12Ba2NjzwWnB2z89O/xLDdoANG3U7baPz6AYlUeflLLHaES++nLius1d3m/bbHnB8Wg0AISEnXFvyv0H7Fu2x727gaU918HH51hkxA1Hr8EyrdkW31vZ7n67MSXqj/chJDXY3O1Zrba8HPgN8DYg2MuI+vgcM4yo4eg1QM4B7m1Kyw++2OlFRvsijEznoTaoMyGkA5wA/AT4IlDR59r4+Ix5Rsxw/L4hBWAAbwF+AZz5SprhmzpcPSnIpNChS14GfBa4HZjSYgu+uTkx2s308cmLETEc5yzvoMrSw2khrwN+AMwAmBrROXPc8b88qQNXTQxy3bQgxpHW0gLeCdxZFdAXfn5jguWtzmg318dnQIbdcLz26U7Chla+KuZ+xRbcAtT0vBc1NL4wJ8yp48zBV6ONZSSUmxrXzwzx/UURaoJZL7cGXPTPg/Yvrq4PvursPzT50xafMc+wGo4LVnRQH9LKG5LiyxNC+g0lpnZU7vXicpO7TyrhqkkBwoZ2fBgQCRFD47xai7uXlnDz/Ah1wf4v9ZOt7ikr2pw73v+qstO1n+z3jYfPmGbYwgyvf6aTqREt+uAB58uTw/rH/rSsNNhrfn8Una7kvkabn+5KsabDJeUNdwuLTGacjwtonFppcs3kIBfWBai0Bu5AhyO58rkuHm92mFFirHltrfXedTH3hWfOqRjtXvn4ZGVYhuWtWxK80CmsZ9rsT+9JiC9+bGYo/J2F0bzcm4NpwWPNDvc12qxsd9mXEoieyraxZER6OQSllsacEoPzqi0uGW+xtNyk1MyvsRL4xZ40H30xTsKT6BrMiBj/vaQu8J7tCXfHg6eXj3ZPfXyOouhD8SMvdHLj3BL99c90XrM17t2edGXpdxZG+OSscEHHSQvJ1m7Bs+0uT7Q4rIm57E4IEp7kCC9+JIxJn/OFdI1JYZ1ZUZ1lFSbnVFssLjOoCeoFN+fxFof3v9DN9m5xqC+mBnNLjL9cNSn4walhvfXaqaER6KSPT/4UdUlDSon221bWd3WdtyfpfS3pSVUSOojBHdQ1FpYZLCwzuGZKkH0pwY64x/pOj7Uxl21xwYGUoDktSAiJK6CYYQFNU0uoYV2jOqgxKaQzM2qwoFT9zIoa1Id1FZcZJI81O1y/Pn6E0QBwJWxPiDf+p9nZ8+mZoS883+4ml1Ue/6tPPscORX1ev3ZFDFfI2eu7vN+12PJkACR8dk6Ym+dHinYyiYoLtNmCVluyJynYkxQcTAmaMq/FHElaSBwJXsagmErBK/OvRkCHgK5haRDQIWRolJka5abGuIDG1IjBlLBOVUCjOqBTbmlF6UNaSP683+amTUl2xL2cf4VKS+u+bHzg479aWvJzQPq1LT5jhaLdiQ812fx2T7r0v63OHftT4m09gxUJ59da/PXUUsrynPcPlZQnSQpwhcRD1YqAKjbTAV3T0FEehaH1/CgDMtzsSgh+uCPJz3eniTmy37+ABiwsM3Z+aW7kf66aGFjlGw6fsULR/N/X11jaFzcm3tmUFld6fWICz7e7PN7icPn4wIh0KmRohIzMyccIHY7k/gM2P9ihVo1kHs2TwM6EmL4z7n0RuFZK2e4bD5+xQFHyOKSUfH5jYv7BlPh4WhDs+36nI7llS5It3d5gDn9ME3PUtOStq7r433VxVre7BaWqdDuS3UlxkSO4llGqZvbx6UuxbsRQxNA+1u7IWVnf1WBlu8snNyTYmxyLqqHF50Ba8Ku9af5nVRfXrOnm4YMOSU8OygnalxLBtJAfBZb4iWE+Y4EhT1UyN/IFC8uM/xnolv7HAZuPAN9eEGFOyfEnvZEW8HKXy0NNDvftt1nX6WJ7HN7+aZBICbrGNOB64DopZcKfsviMJkMyHBmjUQVcf3qlWbGk3OCZVjfnIJHA/QdsmtKCr5wQ4fwaixGKlw4bnoQ9ScEzbQ4PHHBY3uqwLyVUZ4doMHqYEtYJ6RrAG4G/PN5s3z/a/fZ5ZTOk2zpjON4P/BAIPnDA5n0vxGlKif6PLKEmpPOeKUHeOzXI7Oix5X2khVoCXtPh8Z9mm+WtLjsSHk6Pd1FEgrrGL5eW8JZJKrAsJI90OOLqXzekO26Y+cqQMvEZewz6Ns8YjQnAfcBpoJ6+9+xNc+PGBAcHMh4ZTigxuHpSgCsmBplXYmCNwfCfI6HdFmzu9lgT81je6rA25tGQ9NRUZEhXsh8kLKs0+ftppT0CQOxLitSdu1Mf+sbWxC/EG2qGeAIfn8ExVMPxQZS+xqF1Vk/CAwdsvrgpwYZOb+AzZFz6yWGdc6stLqixOL3SHHJW5mAREuKepM2WbI17bOzyeCHmsibmsjchaHN6bUg7zM0L6Ro/PjHKtVODh061Nuby4RfjK84cZ17+7QXRVj/W4TMaDCrGkTEa1cDb6WU0QCVTvXFCgFlRg1u2Jrmv0Sbh9rOakHl9b0Jwz540v9+XZmJI56Ryk6UVJovKDE4oMai0NEpMjUiRjIktIOFJ4p6kOS3ZnfTYHvfY1i3YFvfYnvBoSUs63SyGYgTGqga8tT7AVZMCR5zuYFqytds7pdLSzr9xY+KPw98SnwLp+XMd18tfgxoCpz3Zwcqzy98M3APkrF7rdiV/O2Dz4x0pVnW4uCLPM/a65BFTo9zSmBDUmRLRmRDUqQ3q1AY1qgIapaZOqan0L/Q+9R62kKQ96HKVAYi5klZb0pxWaelNaUFDStBqC5KeMiSMdAFdDi6tC/DjxVGmhI+cu31ra5IvbExwQqnxt1sXRt92SV0gOXqt9EEJUy0CFgNTgCjqzkkCDcALmZ+m0W5oMSnY45BS8udGO5ry5NUhQ+u35LXE1HhHfZDzqi3+2mhz7940L8Rc0gMFEXu9l/AkCU/SmBSs6Tj8uqEfrjnpSSXv7bXLjA0QEjzAkxJPcrhEP8f5RjXZVIKlw5snBbl5XuQoo9HpSh5rcfAkHEzLs//YkF4spFypj73pylnANeTOE4qjAupbBzjOFcAlo9D+DuA2YG8/n5kEvBV4MzAfKCH73dMNbAR+B/yW/AxIFfAZlFc/0vwX5RD0S8GG4/vbkzzR6i4bH9Bee1aVldd3JoZ0PjI9xJsnBHik2eEP+2yebXdoTWce7/nc930+4x0qXivQIxxzYyyDhPEhnQ/PCPGh6SHGZSmc+W+Lw8o2tdzd4YhxOxPiMg1WjnbT+2AC1wLvGeBzu4DvDfCZU/M4znDQDPya7IZDQ6n0fw04k4GTKEsy/VgKXAx8HliVx3feBtSPQt8FeRiOgtcw6sO6tqXLu+jZdrdghZnxIZ13TQ7yh1NK+PtpZXx+bpjTxvUSvTmuZ4U5kFBmalw1KcDvl5Vw4+xwVqPRlBb8YEeKTkddJE+i7Ut5F/xkZ2qsLa1MQw2sgbgYGGgn7tGqUXDIfTe+Dvg5cDaFjR8TeC1wF5kNuQbAHaW+53XNC/Y4VnV445psce7L3R5CZTQWTImpceY4kzPHmdwwQ/Bip8cTLQ6rOlw2dnkcSIvDy5wwdr2EwZJZSaoL6rym2uTt9UHOrbYoyZENlxZw+44UT7Q4h66FBNpsuWBlu7tESvnvMbS68mpgah6fOwkVF3hqtBtcADOAbwIzh3CMJShv5RqgZbQ7NFgKMhxSSi5d2XWiLZi3ocuj3ZFUBYZ2w9YEdc6v0Tm/xiLuSfYkBC/EXFbHPF7qVII9TWml/OX1jU+MmbEy0IU7/GvU1JhbYvC6WovLJwRYUm70ZIVmxZFw1+4UP9qRwu3zDOz2ZKTZFucD/x7tLmaIoDyJfOaw44CLgBUcG76mAbwbNfD7w830p79rcAFwGWp/oWOSgj2Odke8KunJ0p78hvNr8otz5EPU0JhXajCv1OCt9Wo1pNVWS6Uvd3lsjwt2Jz12JQSNKUG3K0l6kBIy96030salTztChlr9mVdqsKzC5Owqi5MqDMYHB/Zy0wLu3JXiKy8n1BSlT19cgbY/KZa91OWVA7ER7mk25gJnFPD516HygMbaikO2u6YOuJzc05O9wN+A9aipzhzgysy/fQmgAr9/AHLtwjVaj8W8zluQ4eh2ZUBDe5WUELMlv99nc1aVRR5jYFCUmhqlpsa0iM6rM4HYlJDEXYi5ksaUoCEp2J8SHEyrn6a04GBaJXAlPUlSqFUZZ5hny4aupmAlhkZtUGdmVGdeqcGiMpOFpQaTwnpBQkZtjuS27Ulu256iK4fgj1QrRgufb3enoG7Y0URDGYLaAr6zABU4fDDH+w65B1Y2LLI/6QWQJj/Ppmcpta9/Ox8Vv8lGM/BR4IE+3/s3Ksg6Kct3FqKCn1uyvCcz/U7m2WYdCJJ90DuZn3zQADufDxZkODQYb2rMEJn//L0xzVsmBYrqdQxESNcIBaAqoDEjcqTFcgTYUmILiLuSFlvSYgtabEGbncnhyEgLdjoqt6PLzUgMCnCkxJXZtUsNDayMzGDE0KiwlCcxIaQzMaQf+ndSSOWZRA3lbQyG9Z0e/7c5wd8bbZyeYrkcpDwqyi1toZRy/SjHOcpRU49sj5Fu1I3d90aJoJZb/0n2oNwfgLV5nl+ilkffkuW9PcD/AW15HiuV+U5vJpM7mPtQ5qevsfkvagn201m+U0luw9GCqoTOtxipFvgy2Q3Ub1CeUD5owM58PliQ4Qga2vSpEX0KLeoUzWnJzVuTzC81DtVSjCaWDhYaUQMqLY36MKip6WGEVMlhQspMfgekPUlKQNKTpAXILEY+oGvKaBlKwNjSD8sNDiZAnI1OV4n+fHdbko35pOsDZaYWmBU1lgC/Z3RjBUtRAc++eMAvUUHTRVnePxeVOJXtht2U+cmXE3O83okyTgeG0L8w2f8iHvAI2Z/qAvgPyhvpK1UfILdhSFBY3Koe+DjZDccG4O9D6HdW8jYcmTTzBadVmtF796bp8TqeaHb45pYkN8+P5FwVGEvoGqh4bq+2jnK7XQkr2xxu25HioQOFCf5MDutMi+jzUDdhfJS6oKO8jWxL9C3Ar1BP8WyGYwZqaTOvJ90Q2jdU7Zl0jtcFcLCf7+WaJLvkOS3Is3+5GBZ5/ELdhPkX1lra3FLj0LPNA362O8XXtyTpco+F4PjYQUhY3eHy0RfjXPV8N3/ZZ5MU+RsNTYMl5QZlpjYDKBvFrtShchSysQp4CfXEzxbAtVDTlWJsHpPrBtQZerAxRvaBbgCz+vnePDhaThM1fWsuQp9BGa/++l50CjloGJg5I2rw3inBI8rfU0JllH755YSqHvXpF1eqKtcbNyZ403Nd3LEzxYF0fjIEvSm3tJ74Uh2FBSWLzRmoFZW+COBfKG9jTeYnG2cCs4vQjly6lMWQVNpDdsOno+IqdVneOxGV+Zrt3Ps4Oo4yWCRj2HBUAHUa8O4pIS6sDRzRVFvAj3akuO6F7lekKHE+JDzJ8laHD63r5rKVXdy6LcneROEGAwAJZ42zWFJugjLqkwZxlGLQ4zFkq1tqRAUIQQ26B8nuuo9H5TYMlVyGoxgex2ZUvCAbZwEf43CluI6K3fyM7HEfULGPjiL0GTJlWf30vegUctByMkU3VQGNr84Ls7DMOMJ4OBL+uN/mHau7efCAjfPK0CUekIak4J69ad62ups3PdfFXbvS7OsRbR7k7Rw2Nd45OUipqZEWMrSy3c0nW3M4mIYKfGbjOQ6vGkhUEHF/ls8ZqBjJUKdbw+lxdAJ/JHsQ1AQ+hMrbqEMVqN0DLMtxrPWoZdpiPWFHfKpSSOCkDLWEBMDScpPvLYpy3bo427uPXAF4vt3l3Wu6efvkIB+eHjouhYkHIuZIVnW4/KvJ4ZEmh03dxREuBkDC62stLqpTq5vb48K4ZWuyLiEkkWIt8eTPa1CrIn3xgIdR05QetgJPonRc+nIKKni6YghtGU6PQ6LU7q4mu6GsAG5GTUFOJffY2g18FlUxWyxGfKpSiOGooM86/GtrLH6wKMr16+Ns6208NGh1JD/YkeLRZof3TA1x9aQAk8bAku1wEvckW7o9Hm12+GeTw+oOl5jdqwK4GGNawpSIzqdmhQ8llD3V6vBsmzsupDaoG0k/LwxcSvb7qAFY3ue1NCpJ6kqODoZWoryOpxn8snJ/+cPFuPoHgFuAE8ge05hK/3U661FG4+EitKVvv8es4ajM1oiL6ywiRpRPvpRgTcfRCucbOj0+syHO7xrSvL0+yOUTLKZHjh8PpMuVbO72+G+Ly2MtNms6PA6mhUoiK9bt2ouoqfG52WFOy2xCnfQkDx100DRqV7d7AY58wg83C8jozWZhJbA9y+tPoeIFi/u83pN5+gMGv9ownB5HD0+jvIW6Ar7johLEvgS8WKR29O33mDUc0VyNeE21xT0nl/ClTQkeOGAfWYylqSSrVe1Kt/Onuw3eNCHApXUBFpUZx0TuR2+UiI5gQ5fHilaHFW0uL3Z6NPc2FjAslQaWBh+eEeLdU4KHks7WxjxWtLlEDMpXxdyR3tL+tWRfzXFRy6/Zli8bUSstJ2a5SvNRbv4/Btme4Yxx9PAqVLp4vhwEfgz8P6C1SG3oy9j1OJrSIloTzK01taDU4K4lJdyxK8WPd6Ro7Ktyrqm8hU2dHpu6kvx0V4qlFSavrw1w5jiTuaXGiG1KXQieVBmd2+IeL8Y8VrSpKciOhCqyY5iNRQ+WBh+YFuLG2eFDIs4pIbl7T4qWtGBaVA82pcVIzgUrUZWw2Xq9m9yxCoFaXXk/vWJmGUqA16MMy2D0KIbT4wijYjM3ouQC82U5SrCov+S8bHUmWqY/NgNP3cau4bi3IV37jvqgXttPRVtVQLnRZ44zuX1HikeanKOFijO/t9iSRw6qwGFtUOeEEoNXjTM5rdJkYZnBhKB+lI7ocONJNRjbbMmOuMembo+1MY91MZedCXHYq+jVj2GvYZQQNuBDM0J8cU6Eil4iP/886PCX/XZPM4wRaE1vlpI7xXsFynjkYh3wPGpq0pfzUEvL/X2/n6uVlaF6HJUog/EhlOddCK8D3gXcSXbDthRVZ1KSpc0vomIiafpnIMOhUeRyhLwNx0MHHX121OCyAXacNzQ1dVlaYfLgAZuf7U7zTJtLKlsadeb/TWlBU0rwZItDyNAYH9KYHjFYVGYwt8RgWkRnWsSgKqDqRYIGBLTBGZWeQri0p4KZB9OCPQnBrqRge9xjc7fHnoQqjGvPthXCSA5NCXUhnU/NCnHd9BDRXkVz2+IeX9+SpMOWPdNBGfdGLPlOR+VuZFs+TaOCf/1VZHaigqQXcPQTsScFfTCGo2eu3/evNBSPoxK1WvJeBpe+XYaKbexGxTl6EwA+ALwhx3e3kp/nJRjhPI68L8TBtLAfOODw+rpAXqUdZabG2+qDXFgb4OEmJVT8dJt7SPoulxFJCcmuuGRXXPB4s1K8KsmU15ebGnUhnbqgRpWlUxXQKLNUKXuJqR3RLg9whTpetyuJe9DhqCrZNlsZjGZbEHeh25Mk+6bLj4ah6CGjrPaqKpMvzInwulqL3oW2bbbkpk1J1vYKRnsS1xUjVuQ2ETg/x3s7UQHEgfgPKnNyWp/Xgyij9CcGftL2JZfhGKzHEUZ5Gv0ZjRZUwPfUzHXJxgTUakwjR1b7LiC30WhGCRznk+sxdqcqpkb838223NAV1BaX5W94qwIab68Pctn4AM+0udzXaPNYi8OuuHc4QSyHEemh25V0O5JG4OWuo6+jnlE813p9USJ79CoQ/V3W0TQQfcm0cWpU592Tg7xvWoj6PkvYcU/yrW1J/rw/fUSXBHRPCGkjpVOZK8Uc4AnyS6XeDDxGdjHiM1H1HxvyOE5vih3jeBNwHbnHyUvAF1BG8ApULCNX/GMR8K1Mfxsyr12Eyprti4fSNc3HAMNYNhwBXduzJ+m59+61rYXzTQqVmigzNS6stTi/xmJvUvB4i8M/Dtisjrk0JMVhWcABNm7KhpBgD6R4PhYMQy4yzR4f0nnDhAD/Oy3I4jLzqKlYypN8d1uKH25P0bckKOnJfcsqzZFYig2gcjeyFW45KKOxkPz28NuMcsX73oeTULGOQg1HrgE0GI9jMvAJjo499LAWZVSezfz/d6j4x80cHfTt4Xzgq6gS+HJUPku2dq1AbR+Rb/Xs2F2OnR4x9u+IC/c3DWnryokBTq8c3MqfqcH0iM70KUHeXh9kR1ztxfpYi8MLMY/dCXGkFOBYHvBDJeNUT4noXFwX4JopQU4uN7Pun9vlSm7ZmuT27SlVQdsLS4fqgN68LuaORPLXdFQMIhsmKt36E3key6SvYIqiJ4byC1QVab7kGkCD8Tgu5+hckx52ATdw2GiA8hLuRhmPr5Ld4OjAO1Bp92Vk1y9NAneQPTU/F2M3OPrxmaFYY0p0PdnihL+7LcnPTyoZ8vJpUOeQxui1U0M0JAWbulye7/BY1eGyucujISWUPsXxYkgyxqLM1FhcbnJxncWldQHmlRo5vbiDacHXNif52e4U6SymIaRr4txqs/VjM8JcP/w9OI/c+31oqAzjYnAyyr1/poDvFCuPowS11JxtfLiovIzlWd5zUPkapcDnyC4VEOCwIlg2o7kJeLzAazV2pyqnVZqxyycEmp9td2ofPODw891pPjYjVPCUJRdWjycSCXBxnRLqbUh6bI0L1sVcNnR57Ih77E4q6b+UJ4+W+BuLRiXTRkOHSktnQanB2VUm59VYLC4zGTeASvyGLo8vbkrwQKOdPUomoT6kpy4dH9g1AtKB/Q2oYlMNXEjhhiOXx1EItSgdjWw0oVZHcg3UFPAdlOdxPX32Vs4QzPHdNCq2Uah489idqgAdb54YaL6/0ea/zQ63bk0yp0TnkrpAAYfIn6AOM6MGM6MGF9VaCAntjtIM3ZUQbOry2JXwaEwJ9qWUYHGrrfRD7VyXcTjHVZ/zBQyosHRmZ0SLT64wWVZhMiOqNtAeCEfAPw7afOXlBOtiuWUEdQ1eV2slLqix9g540KEzn9wp5sPBhcCPyH//kWLlcZSTO07RRP+KX6CSvb6BUmX7IPmPs3+gYiWFTjlHvKy+EMPRNSWs7/7YzBBrYy4HUoLPbEgwztJ51bjhfwDpmlqhqQqo3esvqlX1drZQmZ2drlI835sUHEgppfOmzJJrU1qJFic9JUjsCCWm4wglTlzw7C+zV62pKy3SoK4EjCeGdKZFdGZGDeaXGiwoNZkc1hkX0Aq6a3cmPH68M8Uvdqdps/tRBJMwOapz9aRgU8TQBrqZh4qGGsgjuZ/pIlTVbL5FYcWKcVj0e9XzIsbhxK53MvAAPgB8F2gf5LUaiTqdQxQy4iWw+ZI6i/dPC/H9jKDuR9fHuWNxlFMqRrpMQhHQoTqgUR0wmNGneM6VaiUiJSQpT+VrxDLq5j0q5zFHbZ9gS4ntKU0RL4vMuaFphA2lsh42lGhxmalRFdAZZ2lUB3XKTY0SE4KDTHeNOUqs+Ec7k6yLeeoO7edQmgZXTwxySoW5A5VUNZz0bKCUrUVp8pfgz9oV1NO577GjqCDpI+T3FO7P1yzkj5Ikd/5EBdlFi7LRisr8DKFWUPobJLsYeBPugfqejdH1ODRNQ0r5UlDX7E/NDAU2dXk8dMBmdbvL/66Lc9vCKGdVjY7xyNm5TPJYyZgMfhwm7kmebHH4ya40/25ysmfZ9kXCnFKDa5WM4yYK239kMJxC9uIuG7Ut4vMM/skWROVDnJzlvXNRwdh8ckP6C44WMoC6Uepc2aYrFaiktYY8j3UQ+CkqqNxfjcti4COo5dzBLKuPTcORYSvQOD6kT/32gggxR7Ci1WV1u8t71nbztXkRrpyYX2apj0pse7zF4Zd70jza4ijtjjyfjRFT45OzQswtNWzgBYZ3awQDVXyWLcV8F0rFfDAp4r05EVW30bf3s1HSfL/N4xjFyuNoz/Rnepb3ylGJYc+RX57FKcBXgKoBPhdGLWN3A7dRuAc3ZqUDQVnZ7QDzSw1uXxTl5Ew+x9Zujw+t6+abW5JqXu6Tk/0pwa8zUoLvXN3NX/fbxJw8vIwMGvCW+gBvqw8CtKcFw70Z00Rya4I+g1K9GipPkn26FUBNV4J5HKNYqwud5N4ISkeloL+H/h+8Zqbdd5P/zvYlwOdRe9QWIlozpjVHQVnDQ8tjJ1eY3LWkhFdXW6CpGoqvb05wzdpunm5zEb79OETCkzzX7vLVlxNc9mwX73uhmwcabWJu/gYDAKmKCL80J0JY13iyxdl/w/p4sWT2c3EW2Xdod1Dp1sVIdV8PvFzg+fvSXxykkHtdoAKyXTneL0dNzz6BynLtPciDqCnXt1EJbIsojArg68BVFHZnjNngaA9PoebTEYCTyg3uOinKjRszWxYKeLDR5oWYy3unBHn3lBDTIsNi9MY8CU+yMyF4qtXhHwcdnm13aVJbxQ0uCVrCSRUm310YYVpEZ1WHy81bk+v+tTmV73LlYOh54mdLZtrDkdmTQ6EN5XVkW+7tSUEfSKezv+BooTfhSlQtzeU53q8EvobKBH0eZfQqUbKCp5G74I1MG7ei0tqzBVprgVtRD+oHyY+xG+PIBEjXoZSrl/S8PjtqcOfiEuaVJPnRzhQdtqQhobId/9po8+4pQa6aGGRy+Pg3IDFHif482ery72aHlzpd9qcytThDKaiTsLDc4EcnRjmp3KQ5Lbh5S9Le0OU9EqwLuIWWkRbATNQTPxvPoWIcxUCgMiav4+h07Z4Yy6/I7QX0HCMXhd58ncD3UTGKXFtPBFAeRaFexUvA+1Cxkk+QPUlscub8CZQBy+f6FaPfeTEYj+Mgaq+MJb1frApo3DQ3wsIyg1u3plgTU1OV9TGPz25IcO9emysnBrhsfIB5JUbWeoxjkbgn2Z8UrImpNPnn2l1e7vaOFv0ZirMo4eRKk9sWRjljnIkj4Ac7UjzR6uycV2o83XB2xXB2MVeKuYfa33Qoy7B9WQtsI3sNx6moMvSV/V+pomZQLkd5FbdQvFT6nagVpOdQRX4VKDW0bDGNWcDtqJjKcwP0e8wbjp7dud5LnyeDpcPVk4KcXGFy2/YUv21I026rJKu1HS5rYy4/3ZXi3BqLi2pVoVx9WD+mVmE6XaXlsbHTY3XMZW2Hx0tdLo0pSbq3kE6RVC414Nwai+8sjHBSuYmQ8Mu9aX60M0W5pT16UXVw71D2ExiAKKoSNttNvZfC0sHzoRk1FV6S5b1xKDWtZ8ltHIo5Vek53t2ZY97E0Da9kqjB/3kO16LEUCI/JcDbcrRxIapS9n2oOFB/bc3G2DAcmenKs6inQ9YqyVlRg+8ujHJxXYAf7kjyeItDOpNOsych+NXuNL9vsJkW0TljnKrbOKXCZEpYyQWOFWwBLbbKSN3QpSQEN3UrlbCmdB/xn2IrmksIGWrTpS/ODTMlrKuNPRptbtqUICXoPiGk/21n0hvOitglwOk53lsN7Cjy+TyUW/4Bjnbfeypmf0JuFXRJdiNnUNgqRW8c4C7U9PwzqH1k8k0A62E/aoOmn3L05totqIK4EuCNOb5/Kqqw7v0oL6UQ+suCHTSDzdhq73bl/WFDO9PQslu0oK62Tji90uS+Rpu796RY1XF4U6K0kGzu8tjc5XFvQ5rxQZ0Ty0xOrTQ5vdJkdonB+KB2SJh3OJFApyNpslW6+ta4qoXZFvfYmRDsSXh0uZIjitaHYeuD3g2aEVV7p7xzcpASU0MCf2+0+eRLcQ6kBOND+qolZdbzdywpVAKzIKaSe6XjTxRvt/XePIcKCGYLLnZlXs9lONpQXlCkz+tphpZZK1ECRS+i0u6vQsU+xtNnr6FeJFCKX4+jCteeJ3c26j7gk6iM1Z7ckd5ygE6mDZeg8kv6JohJVFVttmncywxDjs+gbn0pJbdsSS4+s8p86Kwqa2I+BzmYFjx00OHXe9M81+4S73la9/5yZrUhYmhMDuvMiOrMLzWYX2oyI6JTG9SpDmiUWxpmRnN0oHMLUEpgUq1yxBxJW0ZCsCEl2BH32BEX7EkKGlKCgymlB+L1NRIjgVSJXZeNt/jkrDDLMmn8noQ/7U/z6ZcSNCQFloE3t8T4yEuNyTt4+8QhnrRfguQeGP2lZQ8FDbWCk8tDSJF7+dfIfLfvX0xmvles9oZQ8Yc5KI3U8ahSeoHyIPagPIvdqOBxvnGg3tfbI/v0I5fqeYjcMgBFF3ga9JCI3t8SvGJS8Ccfnxm69qTy/B2XNlvydJvDn/crCcF9SaHyPbL9qXsaqamNiKosjXEBncqARnVAoyagU2YqvdHenokjJEkhibtk6lFU5WwsU6PS4ajfU57kKOGwUdIYNXU4rdLkuukhLh8fOLTfTMKT3Lkrzc1bEjSnVc5HpaWtP63SvOT2RaV755YeJ1HmY5+eO+cVkb00+GFy135OnxM5a0bU+MvXTgjXzogWNoV0BGzu9ni0xeGxZofnO1TF7VHbD/RmIN3QfD47tF4XF6nK70+uMHlHfZArJwao67X9xL6U4Ftbk/xsd1rFUzSwdLy5UeNzvz+57DsLK46fHfF8ji2GNITu3Jm07tmb/t7EkP6R7y6MDjpPI+FJNnV5PN7i8Eyby+qYy/6kyC1mfCyTMWhllsaZ40yumhTk4jrrCIMhJDze4vDVzUlWtDpH+KuTQvraC2oCb6gL6g23LowUdm4fnyIxpCF5yTMxrpgYXHTXrtR99WF95m0Lo0waYpJX0pPsTgqebXd5ts1lVYfL9oSn6l+OVfnATLutjDjR+TUWl45XO9iV9lmLbkwJ7t6T5ic7U+xLHrkbXoWlpS+osT72p2WlPx0BtS8fn5wM+e6TUmq/3pv+1Pe2p745Oayb318YYWaB05ZcCAltjlp9WRVzWdXusr7TY19K0GqLI6UDx9I46tWusKkCvadVmpxfbXF2tcnU8NH6oklP8kizw/e2pVjR5hyZaYrSAXldrfXgh6eH3vly3O24fobvbfiMHkMebq6QGBoT/rjP/sPnNyXOnhTSuW2RSlYqNraAmCPYFld5FS9ktEj3JQVNtlAVpiNtTPqcL2JoTMgogZ1WqeQCl5SbTAzpBLI4Y46AZ9odfrorzT8O2od2ZuuNDlwxMdD8iZnht57x345HuaKQrUt9fIpPUYbWj3cm+dC00KV/3Gff8/GX4pXVAY1b5ke4sDYwrHu/isxer01pya6E2utV5V8I9ic9mjK7ttkiy+rJEK+anjES1QGNuqCSC1xYarC43GRuic6EUP/JbLaAtTGXe/am+ct+m4N9N+nOoANvmhjwbpwdvvXkCvPLgONPU3xGm6LcgVLNGQKe5Na/N9ofveGluJ7y4OMzQ7xvapCa4MgtGUrUU7zNOaw9ui8l2J3w2JPRI+12JUkBtpBZS/91DSxdI9Dzb0ZTtNzUqA4qQzElrDMprFMbUEai1NTyUnzvdiXPdbjcuzfNPw86HMhhMHr+OFdODPCNeZGn55QYb5GwV/eNhs8YoGh3YcZ4TJbwm4ebnLM/+VKcLV0e59ZYfGJmmPNrrKyu+kjSY1SSGR1SR2TPsOkRIrY0DUtXWzcE9PwSzrIhJOxNCh5tcfjrfptn2pz+RYhRm3e/tT7IN+ZFmqaE9WuE5GFjON03H58CKOqdmDEe5wG/Xt3hTvzcxgT/aXKoDGhcOTHA+6eGWFphHlNFbUOh2Zas7nB5+KDNv5sdtnZn9svtr/+Z7NEPTAvyhTlhpzqgfwP4hqaN2L6wPj4DMhyGQ0cVKX27ISlKbt2W5O7daeKOZGJE500TAry1PsjJFQah4+wJKiQ02YJ1MY8nWx0ebXbY2OXR5WRJr896AWFCSOezc8J8YGqQsKH9Fvgo0ObHNXzGEkW/GzPGI4ySP7s+5Unjj/ttvrMtyfqYKhWoCemcX23x5okBzqoyj0h+OtbodlUMZU2Hy1NtLk+3uWyPF2AsenFqpcn/nRDhtTUWmsYzmtqPY7tvNHzGGsNyR2aMRxVKhORtgLa52+OHO1L8fl+a1rQaVGFTY1GpwWtrLc6ttlhUZlA7xo1IzJEcSAu2dHs835HJLelSwj090gGFaoiWWRrvmBzkU7PCTIvo7E6IXZ2ueNeJZeZy32j4jEWG7a7MGI+pqJ23LwQ0W8CTrQ4/3ZXikSZH5V1kWlFqapxQYnBKhcmrxqnch0lhnUqrsF3QikmXq3aD259SZfYvdqrl3q1xj+bM/rWDzmaVavVmWaXJJ2aGuXyChY7GYy1O2+Mtzg3fumnXvfLP86VvOHzGIsNtOECVH98BnN/zQtyTPNXq8puGNI80OSqHoRemDjVBnRkRnRNKDRaXmcwtMRgf0qkNaoyzdEx96NJGErXbW7crabMFzbakISnYHle5IDsSHnsSgsa0IOX1KrUf6lWTMDWic+3UEO+ZorRYW23Jr/amuh466Hzu0fWpO9+9IOj9cnglAX18Bs2wPs56GY95KPmz83u/nxbwQszlj/tUTsO2hIfT293vcUgyy6FVmWSr2qDap7U6oFNhqbL6qKERMVS+RTCHupArJUlP5Xg0ppSR2J8StNhKn6PZFnS5Eq+vcmWxrpKE2pDOFRMCfGBa8FB27eoOl9t3pGKrO9ybtnaJn9RHDGfn6yqG80/j4zMkht0P7uN53A5cfNRngN0JwdNtDvc12qxoU9sIZH3C903Y0o78VdNU/kXfBRuJ2hPW65270c+xincBVJsmhnQuHR/gXZODLKswsXQVL/ndvjS/2JNubk6LL0wKa7+IpTV3/QUVw/K38PEpFiM2gc4YkCmo1Za3kkO2MOlJtsUFK1od/tXs8Hy7y8G0OCzbdyxM+TMGKWhozCs1eNOEAG8Yb7GgVBkMV8LTbQ7f357iuXZ32+SwfuMPFkf/+vEXu8XT51QO7dw+PiPAiA7DjPEYB3xWwHW6klvLSc+GRk+3uSxvdVjV4bI3oVLGR6cH/XVO/WPoMCmkc8Y4i8vGW7y62mJS6PDEaVOXx527Uvxxv40j5PMLy8xPPn5m2fIbXopz+6KSQZ7cx2dkGfFhJ6Uk4cnQupj3fk9y04Iyo7rSGrgZjlC6pes6XVa2uazucNkSFzSnBZ3u6FbFllqqIvbkCpNXV5mcXWUxI6ofSnCTqL11/7DP5t69afYkPbcupP9lbtS46ZGNiS3fObeCT80qVDjbx2f0GJXntSMk1p2N5gUnRi+dXWJ86dVV5tLzqq2CiuHinqTVlmzp9lgbUzodW7o9DqQELY5UYsi5dtjojwEqaDWl+UlNUGdOZvn41EqThaUGNUGd3l1IC8mLnR5/2mfzt0ab7XGPkKG1zIzqt79hQuD/PdbktN04O8QbJobw8TmWGDVH/9KVncyMaDzc5M60dD5bH9LfcnFdoPSiOouZEaPgcnxHqKlNY1qwOyHYm1QVsbuT6vd2R9Ltqp90piq2x0bomlraNTRVCRvQVVVsMFMVW2oqj2JmRJXPT4voTIsY1AS1o9LmJdCQFDzT5nL/ASXI3JgU6BqyOqivnB7Rv/G3ZSX//MLmpLj7pNLCOunjM0YY1QjBOU910pj0uKDGDD3a4l7W5crPVFraKa+psrh4vMXJFSodfSiN9KQqn+92JR0ZlfOUUEuzPQs+hga6pmFqaj+YoK6WdMO6UlcP6sqo5CrO8yQcSAtejHk83KSMxdZuoXZ206DE1JprgvrP5kb1Hz+8Pbnvo4tL+OGJfjzD59hl1EOLUkres6abX+xIcuXU0ORn2933tdry3YbGlDlRg7OqTM6qsjixzGBKWB+RDZoGQkg1VdqVEKyNufy3Ram0b48LEr32iwkbWrzS0v45Oaz/6OdLS5766Lq4d2qFxbd8kWGfY5zRH4UZ3vp8FwlP8rfTSrXTnoydtDsh3t9qiytcSa2lQ31IZ26JwbJKkxPLTKZHdCaHlYBOQM9PRGcwOEKpjLU5kt0Jj5e7PdbFPF6MuezOJJD1zjfRgJChpSstbfnUiH7XKZXmQw802t03zApz/fQQfgq5z/HAmLuLr9/QzQP7Hc6uMq2Vbe7p7Y54R6fDJSkhJ/UEJQIGjLN0qgIaUyMG0yNK43NCSCly1QQ1yjIGxeonNV2gJPxSQpL2VIxEbeCkpjX7kmqnt+0Jj8aUSkvvcGRWkWQdCBlavNzSnpoS1n89r9T4x1/22x1XTArwKz+W4XOcMeYMRw9nLu9gS7fHOyYHzYcOOItabXlFSshL00LOcwTBbKsflg5hQ+3qFtBV7MLsJzbhSBXr8DJbRLpCrYTYmbiI6CsPluU4GVnBhgpLe3xqxPjz7Kj+xIMHnM4zq0z+cmrZaF9GH59hYcwajh5e/VQH2+OChguf4pQnzpnQ5ohXdzjy9SmPM1wpp9oiy96mgxUlzvNqBFQA9WCJqa2psLR/zY7qj15dH9zy9c1Je3ZU5++nlflTEp/jmmPm7j5neSfNtkeXC5fWBaw1Mbu+xZanJ1zOTgq51BZM9aSsdYSamRRR0BxDBTq7TJ09tQF9o6nxxLSI8Vx9SN9457Z44uzxQWZGDX651J+S+LwyOGYMRw/jH9jH1LIoaaG2PvjdyaXGDRsSEUtjzr6kNytsaEsTnlzQbMvagMYENCpTHkFbSKOnv7n2t5YgLA0R0LUEcCBssH9CSN8LPDcxpG8aH9I3XjUx2HrpEx326yar2dIZ5QG+utDP+vR5ZXHMGY7enL68i1Jd0JiWVFoaqztc4peO47MbEta6Lq+kxNDqW21RtS3uhbtdWV1uaVODulZqaRi9Ku/TmqZ1t9ui5UBatpQYxKdFjXh9SG8I6TT+YVmpo922z3v96aWMD+lIqXFulck1U/1sT59XLse04ejLHTuSbOwSrIo5TI4YmEBTWvByt8fedhfWxeHmBmAb8CJQAcZ58I4aOKMcakyqQio7dGZER5OSoKlzTrXFtVN8Q+Hj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+PzSuP/AzE1e5ONHe7vAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE1LTEyLTIzVDIwOjA0OjMxKzAwOjAwHarZDQAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxNS0xMi0yM1QyMDowNDozMSswMDowMGz3YbEAAABNdEVYdHNvZnR3YXJlAEltYWdlTWFnaWNrIDYuOS4yLTcgUTE2IHg4Nl82NCAyMDE1LTEyLTAyIGh0dHA6Ly93d3cuaW1hZ2VtYWdpY2sub3Jnbo4WPwAAAEp0RVh0c3ZnOmJhc2UtdXJpAGZpbGU6Ly8vdG1wL3ZpZ25ldHRlL2MxZDQ0ZGY2LWM1ZDYtNDkwMC04ZDBhLWQ0OWVmMzBiZGE3MS5zdmd90CehAAAAGHRFWHRUaHVtYjo6RG9jdW1lbnQ6OlBhZ2VzADGn/7svAAAAGHRFWHRUaHVtYjo6SW1hZ2U6OkhlaWdodAAyNjLFg9PDAAAAF3RFWHRUaHVtYjo6SW1hZ2U6OldpZHRoADU3Mz0hlMwAAAAZdEVYdFRodW1iOjpNaW1ldHlwZQBpbWFnZS9zdme/73BOAAAAF3RFWHRUaHVtYjo6TVRpbWUAMTQ1MDkwMTA3McPsyX0AAAAPdEVYdFRodW1iOjpTaXplADBCQpSiPuwAAABIdEVYdFRodW1iOjpVUkkAZmlsZTovLy90bXAvdmlnbmV0dGUvYzFkNDRkZjYtYzVkNi00OTAwLThkMGEtZDQ5ZWYzMGJkYTcxLnN2Z4N+SbEAAAAASUVORK5CYII=' style='display: block; margin-left: auto; margin-right: auto; margin-top: 7px; width: 89px;'/></span>\").width(\"120px\").css(\"float\",\"left\").css(\"padding-left\",\"0\");$('.report-name').css(\"font-weight\",\"bold\");"+"\n"+ + "})"; + + public enum suiteNameXml { + + TESTNG_FAILED_XML_NAME("testng-failed.xml"); + + suiteNameXml(String value) { + this.value = value; + } + + private String value; + + public String getValue() { + return value; + } + + } + + public synchronized static ExtentReports setReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception { + String dbIp = DriverFactory.getConfiguration().getReportDBhost(); + int dbPort = DriverFactory.getConfiguration().getReportDBport(); + + if (extent == null) { + extentxReporter = new ExtentXReporter(dbIp, dbPort); + extent = new ExtentReports(); + initAndSetExtentHtmlReporter(filePath, htmlFile, isAppend); + + if(extentxReporter.config().getReportObjectId() != null){ + setExtentXReporter(isAppend); + }else{ + extentxReporter.stop(); + } + } + return extent; + } + + public synchronized static void setExtentXReporter(Boolean isAppend){ + extentxReporter.setAppendExisting(isAppend); + extent.attachReporter(extentxReporter); + } + + public synchronized static void initAndSetExtentHtmlReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception{ + htmlReporter = new ExtentHtmlReporter(filePath + htmlFile); + setConfiguration(htmlReporter); + htmlReporter.setAppendExisting(isAppend); + extent.attachReporter(htmlReporter); + } + + public synchronized static ExtentReports getReporter() { + return extent; + } + + public static void initReporter(Configuration config, ITestContext context) throws Exception { + String envData = config.getUrl(); + String suiteName = getSuiteName(context); + String filepath = config.getReportFolder(); + String htmlFile = config.getReportFileName(); + + if(suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())){ + if (config.isUseBrowserMobProxy()){ + setTrafficCaptue(config); + } + + setReporter(filepath, htmlFile, true); + suiteName = FileHandling.getKeyByValueFromPropertyFormatFile(filepath + VERSIONS_INFO_FILE_NAME, "suiteName"); + }else{ + FileHandling.deleteDirectory(SetupCDTest.getReportFolder()); + FileHandling.createDirectory(filepath); + setReporter(filepath, htmlFile, false); + createVersionsInfoFile(filepath , VERSIONS_INFO_FILE_NAME, envData, suiteName); + } + reporterDataDefinition(envData, suiteName); + } + + private static void createVersionsInfoFile(String path, String file, String envData, String suiteName) throws FileNotFoundException, IOException { + File myFoo = new File(path + file); + FileOutputStream fooStream = new FileOutputStream(myFoo, false); // true to append + String versions = ("env=\""+ envData + "\"\n" + "suiteName=\""+ suiteName+ "\"\n"); + byte[] myBytes = versions.getBytes(); + fooStream.write(myBytes); + fooStream.close(); + } + + private static void reporterDataDefinition(String envData, String suiteNameFromVersionInfoFile) throws Exception { + extent.setSystemInfo("Host Name Address", FileHandling.getExecutionHostAddress()); + extent.setSystemInfo("ExecutedOn", envData); + extent.setSystemInfo("SuiteName", suiteNameFromVersionInfoFile); + } + + public static void reporterDataDefinition(HashMap<String, String> addedSystemInfo){ + Iterator<String> iterator = addedSystemInfo.keySet().iterator(); + while(iterator.hasNext()){ + String key = iterator.next(); + String value = addedSystemInfo.get(key); + extent.setSystemInfo(key, value); + } + } + + public static String getSuiteName(ITestContext context) { + String suitePath = context.getSuite().getXmlSuite().getFileName(); + if(suitePath != null){ + File file = new File(suitePath); + String suiteName = file.getName(); + return suiteName; + } + return null; + } + + public synchronized static ExtentHtmlReporter setConfiguration(ExtentHtmlReporter htmlReporter) throws Exception { + + htmlReporter.config().setTheme(Theme.STANDARD); + htmlReporter.config().setEncoding("UTF-8"); + htmlReporter.config().setProtocol(Protocol.HTTPS); + htmlReporter.config().setDocumentTitle("Automation Report"); + htmlReporter.config().setChartVisibilityOnOpen(true); + htmlReporter.config().setReportName("Automation Report"); + htmlReporter.config().setChartVisibilityOnOpen(false); + htmlReporter.config().setJS(icon); + return htmlReporter; + } + + public static void closeReporter(){ + extent.flush(); + } + + public static void setTrafficCaptue(Configuration config) { + config.setCaptureTraffic(true); + } +} + diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/ExtentTestActions.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/ExtentTestActions.java new file mode 100644 index 000000000..e5eac5e24 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/ExtentTestActions.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.execute.setup; + +import java.io.File; +import java.io.IOException; +import java.util.UUID; + +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; + +import com.aventstack.extentreports.ExtentTest; +import com.aventstack.extentreports.MediaEntityBuilder; +import com.aventstack.extentreports.Status; +import com.aventstack.extentreports.markuputils.ExtentColor; +import com.aventstack.extentreports.markuputils.Markup; +import com.aventstack.extentreports.markuputils.MarkupHelper; + +public class ExtentTestActions { + + public static void log(Status logStatus, Markup mark){ + ExtentTest test = ExtentTestManager.getTest(); + test.log(logStatus, mark); + } + + public static void log(Status logStatus, String message){ + ExtentTest test = ExtentTestManager.getTest(); + test.log(logStatus, message); + } + + public static void log(Status logStatus, String message, String duration){ + log(logStatus, message + addDurationTag(duration)); + } + + public static void log(Status logStatus, Throwable throwabel){ + ExtentTest test = ExtentTestManager.getTest(); + test.log(logStatus, throwabel); + } + + public static void addTag(Status logStatus, String message){ + Markup m = null; + switch(logStatus){ + case PASS: + m = MarkupHelper.createLabel(message, ExtentColor.GREEN); + break; + case FAIL: + m = MarkupHelper.createLabel(message, ExtentColor.RED); + break; + case SKIP: + m = MarkupHelper.createLabel(message, ExtentColor.BLUE); + break; + case FATAL: + m = MarkupHelper.createLabel(message, ExtentColor.BROWN); + break; + default: + break; + } + + if (m != null){ + log(logStatus, m); + } + } + + public static String addScreenshot(Status logStatus, String screenshotName, String message) throws IOException{ + String imageFilePath = null; + String uuid = UUID.randomUUID().toString(); + String[] stringArray = uuid.split("-"); + screenshotName = screenshotName + "-" + stringArray[stringArray.length - 1]; + try { + File imageFile = GeneralUIUtils.takeScreenshot(screenshotName, SetupCDTest.getScreenshotFolder()); + imageFilePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFile.toURI()).getPath(); + } catch (IOException e) { + e.printStackTrace(); + } + + ExtentTest test = ExtentTestManager.getTest(); + test.log(logStatus, message, MediaEntityBuilder.createScreenCaptureFromPath(imageFilePath).build()); + return imageFilePath; + } + + private static String addDurationTag(String duration){ + return "<td width=\"80px\">" + duration + "</td>"; + } + + public static String addLinkTag(String fileName, String pathToFile){ + return String.format("<a download=\"%s\" href=\"%s\">HAR file</a>", fileName, pathToFile); + } + + public static void addFileToReportAsLink(File harFile, String pathToFileFromReportDirectory, String message) { + log(Status.INFO, message, addLinkTag(harFile.getName(), pathToFileFromReportDirectory)); + } + + + + + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/ExtentTestManager.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/ExtentTestManager.java new file mode 100644 index 000000000..faecb815e --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/ExtentTestManager.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.execute.setup; + +import java.util.HashMap; + +import com.aventstack.extentreports.ExtentReports; +import com.aventstack.extentreports.ExtentTest; + +public class ExtentTestManager { + + private static HashMap<Long, ExtentTest> extentTestMap = new HashMap<Long, ExtentTest>(); + private static ExtentReports extent = ExtentManager.getReporter(); + + public static synchronized ExtentTest getTest() { + return extentTestMap.get(Thread.currentThread().getId()); + } + + public static synchronized void endTest() { +// extent.endTest(extentTestMap.get(Thread.currentThread().getId())); + extent.flush(); + } + + public static synchronized ExtentTest startTest(String testName) { + return startTest(testName, ""); + } + + public static synchronized ExtentTest startTest(String testName, String desc) { + ExtentTest test = extent.createTest(testName, desc); + extentTestMap.put(Thread.currentThread().getId(), test); + + return test; + } + + public static synchronized <T> void assignCategory(Class<T> clazz){ + String[] parts = clazz.getName().split("\\."); + String lastOne1 = parts[parts.length-1]; + String lastOne2 = parts[parts.length-2]; + getTest().assignCategory(lastOne2 + "-" + lastOne1); + } +} + diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/MobProxy.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/MobProxy.java new file mode 100644 index 000000000..a2d427bc6 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/MobProxy.java @@ -0,0 +1,103 @@ +package org.onap.sdc.ci.tests.execute.setup; + +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.ProxySelector; +import java.net.SocketAddress; +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; + +import org.slf4j.LoggerFactory; + +import com.aventstack.extentreports.ExtentTest; +import com.github.markusbernhardt.proxy.ProxySearch; +import com.github.markusbernhardt.proxy.ProxySearch.Strategy; +import com.github.markusbernhardt.proxy.util.PlatformUtil; +import com.github.markusbernhardt.proxy.util.PlatformUtil.Platform; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.LoggerContext; +import net.lightbody.bmp.BrowserMobProxyServer; + +public class MobProxy { + + private static HashMap<Long, BrowserMobProxyServer> mobProxyServerMap = new HashMap<Long, BrowserMobProxyServer>(); + public static InetSocketAddress localProxyAddress = getProxy(); + + public static InetSocketAddress getProxy(){ + setLogger(); + + ProxySearch proxySearch = new ProxySearch(); +// proxySearch.addStrategy(Strategy.JAVA); +// proxySearch.addStrategy(Strategy.BROWSER); +// proxySearch.addStrategy(Strategy.OS_DEFAULT); +// proxySearch.addStrategy(Strategy.ENV_VAR); + if (PlatformUtil.getCurrentPlattform() == Platform.WIN) { + proxySearch.addStrategy(Strategy.IE); + proxySearch.addStrategy(Strategy.FIREFOX); + proxySearch.addStrategy(Strategy.JAVA); + } else if (PlatformUtil.getCurrentPlattform() == Platform.LINUX) { + proxySearch.addStrategy(Strategy.GNOME); + proxySearch.addStrategy(Strategy.KDE); + proxySearch.addStrategy(Strategy.FIREFOX); + proxySearch.addStrategy(Strategy.ENV_VAR); + return null; + } else { + proxySearch.addStrategy(Strategy.OS_DEFAULT); + } + ProxySelector proxySelector = proxySearch.getProxySelector(); + + ProxySelector.setDefault(proxySelector); + URI home = URI.create("http://www.google.com"); + System.out.println("ProxySelector: " + proxySelector); + System.out.println("URI: " + home); + List<Proxy> proxyList = proxySelector.select(home); + String host = null; + String port = null; + if (proxyList != null && !proxyList.isEmpty()) { + for (Proxy proxy : proxyList) { + System.out.println(proxy); + SocketAddress address = proxy.address(); + if (address instanceof InetSocketAddress) { + host = ((InetSocketAddress) address).getHostName(); + port = Integer.toString(((InetSocketAddress) address).getPort()); + System.setProperty("http.proxyHost", host); + System.setProperty("http.proxyPort", port); + } + } + } + InetSocketAddress address = new InetSocketAddress(host, Integer.parseInt(port)); + return address; + } + + // set logger for all classes connected to MobProxy + public static void setLogger() { + LoggerContext lc = (LoggerContext) LoggerFactory. getILoggerFactory(); +// lc.getLogger("ROOT").setLevel(Level.DEBUG); + for(Logger logger:lc.getLoggerList()){ + logger.setLevel(Level.INFO); + } + } + + public static synchronized void setProxyServer() { + BrowserMobProxyServer server = new BrowserMobProxyServer(); + server.setTrustAllServers(true); + if (localProxyAddress != null){ + server.setChainedProxy(localProxyAddress); + server.start(); + } else { + server.start(); + // filter firefox requests to mozilla when system proxy is absent + server.blacklistRequests(".*mozilla.*", 200); + } + mobProxyServerMap.put(Thread.currentThread().getId(), server); + } + + public static synchronized BrowserMobProxyServer getPoxyServer() { + return mobProxyServerMap.get(Thread.currentThread().getId()); + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/OnboardCSVReport.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/OnboardCSVReport.java new file mode 100644 index 000000000..c64edff21 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/OnboardCSVReport.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.execute.setup; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintWriter; + +public class OnboardCSVReport { + + private StringBuilder sb; + private PrintWriter pw; + + public OnboardCSVReport(String filepath, String filename) { + sb = new StringBuilder(); + try { + File csvFile = new File(filepath + filename); + pw = new PrintWriter(csvFile); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + + } + + public StringBuilder appendStringToFile(String content) { + return sb.append(content + ","); + } + + public void openNewRow() { + sb.append("\n"); + } + + public void writeRow(String... content) { + for (String str : content) { + appendStringToFile(str); + } + openNewRow(); + } + + public void closeFile() { + pw.write(sb.toString()); + pw.close(); + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/ReportAfterTestManager.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/ReportAfterTestManager.java new file mode 100644 index 000000000..ee16ddc76 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/ReportAfterTestManager.java @@ -0,0 +1,129 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.execute.setup; + +import java.io.IOException; + +import org.onap.sdc.ci.tests.execute.setup.ExtentManager.suiteNameXml; +import org.testng.ITestContext; +import org.testng.ITestResult; + +import com.aventstack.extentreports.Status; + +public class ReportAfterTestManager extends ExtentTestActions { + + private static String testName; + private static Throwable throwable; + private static int status; + + private static void logSuccessAfterTest(){ + final Status logStatus = Status.PASS; + addTag(logStatus, "Success"); + try{ + String message = "Finished the test with the following screenshot : "; + addScreenshotToReport(logStatus, testName, message); + }catch(Exception e){ + log(logStatus, "SUCCESS - The following exepction occured : " + e.getMessage()); + } + } + + private static void logFailAfterTest(){ + addTag(Status.FAIL, "Failure"); + try{ + log(Status.ERROR, "ERROR - The following exepction occured : "); + log(Status.ERROR, throwable); + String message = "Failure is described in the following screenshot : "; + addScreenshotToReport(Status.FAIL, testName, message); + }catch(Exception e){ + log(Status.ERROR, "ERROR - The following exepction occured : " + e.getMessage()); + } + } + + private static void logSkipAfterTest(){ + final Status logStatus = Status.SKIP; + addTag(logStatus, "Skipped"); + try{ + log(logStatus, "SKIP - The following exepction occured : "); + log(logStatus, throwable); + String message = "Skip is described in the following screenshot : "; + addScreenshotToReport(logStatus, testName, message); + }catch(Exception e){ + log(logStatus, "SKIP - The following exepction occured : " + e.getMessage()); + } + } + private static void logFatalAfterTest(){ + final Status logStatus = Status.FATAL; + addTag(logStatus, "Fatal"); + try{ + log(logStatus, "FATAL - The following exepction occured : "); + log(logStatus, throwable); + String message = "Fatal is described in the following screenshot : "; + addScreenshotToReport(logStatus, testName, message); + }catch(Exception e){ + log(logStatus, "FATAL - The following exepction occured : " + e.getMessage()); + } + } + + private static String addScreenshotToReport(Status logStatus, String testName, String message) throws IOException{ + + String addedValueFromDataProvider = WindowTestManager.getWindowMap().getAddedValueFromDataProvider(); + if (addedValueFromDataProvider != null){ + addedValueFromDataProvider = addedValueFromDataProvider.replace(":", "-"); + testName = testName + "...." + addedValueFromDataProvider; + } + + return addScreenshot(logStatus, testName, message); + } + + public static void report(ITestResult result, ITestContext context){ + + testName = result.getName(); + throwable = result.getThrowable(); + status = result.getStatus(); + + String suiteName = ExtentManager.getSuiteName(context); + + switch(status){ + case ITestResult.SUCCESS: + logSuccessAfterTest(); + break; + + case ITestResult.FAILURE: + + if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) { + logFatalAfterTest(); + }else{ + logFailAfterTest(); + } + break; + + case ITestResult.SKIP: + logSkipAfterTest(); + break; + + default: + break; + } + + } + +} + diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/Retry.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/Retry.java new file mode 100644 index 000000000..b74ef14da --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/Retry.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.execute.setup; + +import org.testng.Assert; +import org.testng.IRetryAnalyzer; +import org.testng.ITestResult; +import org.testng.annotations.Test; + +public class Retry implements IRetryAnalyzer { + private int retryCount = 0; + private int maxRetryCount = 1; + + public boolean retry(ITestResult result) { + + if (retryCount < maxRetryCount) { + retryCount++; + return true; + } + return false; + } + + + + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/SetupCDTest.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/SetupCDTest.java new file mode 100644 index 000000000..bb6a19a36 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/SetupCDTest.java @@ -0,0 +1,356 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.execute.setup; + +import java.io.File; +import java.io.IOException; +import java.util.UUID; + +import org.onap.sdc.ci.tests.datatypes.Configuration; +import org.onap.sdc.ci.tests.datatypes.User; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.datatypes.UserRoleEnum; +import org.onap.sdc.ci.tests.execute.setup.ExtentManager.suiteNameXml; +import org.onap.sdc.ci.tests.run.StartTest; +import org.onap.sdc.ci.tests.utilities.FileHandling; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.WebElement; +import org.testng.Assert; +import org.testng.ITestContext; +import org.testng.ITestResult; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Test; + +import com.aventstack.extentreports.ExtentTest; +import com.aventstack.extentreports.Status; + +import net.lightbody.bmp.core.har.Har; + +public abstract class SetupCDTest extends DriverFactory { + + private static final String RE_RUN = "<html><font color=\"red\">ReRun - </font></html>"; + + /**************** PRIVATES ****************/ + private static String url; + + protected static ITestContext myContext; + + /**************** METHODS ****************/ + public static ExtentTest getExtendTest() { + return ExtentTestManager.getTest(); + } + + public static WindowTest getWindowTest() { + return WindowTestManager.getWindowMap(); + } + + public static String getScreenshotFolder() { + return getConfiguration().getScreenshotFolder(); + } + + public static String getHarFilesFolder() { + return getConfiguration().getHarFilesFolder(); + } + + public static String getReportFolder(){ + return getConfiguration().getReportFolder(); + } + + public static String getReportFilename(){ + return getConfiguration().getReportFileName(); + } + + protected abstract UserCredentials getUserCredentials(); + protected abstract Configuration getEnvConfiguration(); + protected abstract void loginToLocalSimulator(UserCredentials userCredentials); + + + + /**************** BEFORE ****************/ + + @BeforeSuite(alwaysRun = true) + public void setupBeforeSuite(ITestContext context) throws Exception { + setUrl(); + initReport(context); + } + + private void initReport(ITestContext context) throws Exception { + myContext = context; + ExtentManager.initReporter(getConfiguration(), context); + } + + @BeforeMethod(alwaysRun = true) + public void setBrowserBeforeTest(java.lang.reflect.Method method, ITestContext context) throws Exception { + boolean emptyDataProvider = isDataProviderEmpty(method); + if (emptyDataProvider) { + System.out.println("ExtentReport instance started from BeforeMethod..."); + String suiteName = ExtentManager.getSuiteName(context); + if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) { + ExtentTestManager.startTest(RE_RUN + method.getName()); + } else { + ExtentTestManager.startTest(method.getName()); + } + + ExtentTestManager.assignCategory(this.getClass()); + setBrowserBeforeTest(getUserCredentials()); + } else { + System.out.println("ExtentReport instance started from Test..."); + } + + getConfiguration().setWindowsDownloadDirectory(getWindowTest().getDownloadDirectory()); + + if (getConfiguration().isCaptureTraffic()) { + try { + MobProxy.getPoxyServer().newHar(method.getName() + ".har"); + } catch (Throwable e) { + e.printStackTrace(); + } + } + } + + private boolean isDataProviderEmpty(java.lang.reflect.Method method) { + return method.getAnnotation(Test.class).dataProvider().isEmpty(); + } + + /**************** AFTER ****************/ + @AfterMethod(alwaysRun = true) + public void quitAfterTest(ITestResult result, ITestContext context) throws Exception { + + try { + ReportAfterTestManager.report(result, context); + GeneralUIUtils.closeErrorMessage(); + } finally { + + if (getConfiguration().isCaptureTraffic()) { +// addTrafficFileToReport(result); + } + + ExtentTestManager.endTest(); + ExtentManager.closeReporter(); + FileHandling.cleanCurrentDownloadDir(); + } + + } + + @AfterSuite(alwaysRun = true) + public void afterSuite() throws Exception { + if (getConfiguration().isUseBrowserMobProxy()) { + MobProxy.getPoxyServer().stop(); + } + } + + protected static String setUrl() { + url = getConfiguration().getUrl(); + if (url == null) { + String message = "no URL found"; + System.out.println(message); + Assert.fail(message); + } + return url; + } + + public static void navigateToUrl(String url) throws Exception { + try { + System.out.println("Deleting cookies..."); + deleteCookies(); + + System.out.println("Navigating to URL : " + url); + getDriver().navigate().to(url); + GeneralUIUtils.waitForLoader(); + + System.out.println("Zooming out..."); + GeneralUIUtils.windowZoomOutUltimate(); + + } catch (Exception e) { + String msg = "Browser is unreachable"; + System.out.println(msg); + e.printStackTrace(); + getExtendTest().log(Status.ERROR, msg); + Assert.fail(msg); + } + } + + private static void deleteCookies() throws Exception { + getDriver().manage().deleteAllCookies(); + Thread.sleep(1000); + + int attempts = 0; + final int max_attempts = 3; + + while (!getDriver().manage().getCookies().isEmpty() && attempts < max_attempts) { + getExtendTest().log(Status.INFO, + "Trying to delete cookies one more time - " + (attempts + 1) + "/" + max_attempts + "attempts"); + String deleteCookiesJS = "document.cookie.split(';').forEach(function(c) { document.cookie = c.replace(/^ +/, '').replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/'); });"; + ((JavascriptExecutor) getDriver()).executeScript(deleteCookiesJS); + attempts++; + + if (attempts == max_attempts) { + String msg = "Did not delete cookies, can't login with the userId " + + WindowTestManager.getWindowMap().getUserCredentials().getUserId(); + System.out.println(msg); + getExtendTest().log(Status.ERROR, msg); + Assert.fail(msg); + } + } + } + + protected void loginToSystem(UserCredentials userCredentials) throws Exception { + if (getConfiguration().isUseCustomLogin()) { + loginToLocalSimulator(userCredentials); + } + else { + sendUserAndPasswordKeys(userCredentials); + WebElement submitButton = GeneralUIUtils.getWebElementBy(By.name("btnSubmit"), 30); + submitButton.click(); + WebElement buttonOK = GeneralUIUtils.getWebElementBy(By.name("successOK"), 30); + Assert.assertTrue(buttonOK.isDisplayed(), "OK button is not displayed."); + buttonOK.click(); + } + GeneralUIUtils.ultimateWait(); + getWindowTest().setUserCredentials(userCredentials); + } + + private void setRefreshAttempts(int refreshAttempts) { + getWindowTest().setRefreshAttempts(refreshAttempts); + } + + private void sendUserAndPasswordKeys(UserCredentials userCredentials) { + System.out.println("Login with the userId : " + userCredentials.getUserId()); + WebElement userNameTextbox = GeneralUIUtils.getWebElementBy(By.name("userid")); + userNameTextbox.sendKeys(userCredentials.getUserId()); + WebElement passwordTextbox = GeneralUIUtils.getWebElementBy(By.name("password")); + passwordTextbox.sendKeys(userCredentials.getPassword()); + } + + public void loginWithUser(UserCredentials userCredentials) { + try { + getExtendTest().log(Status.INFO, String.format("Login with the userId %s", userCredentials.getUserId())); + loginToSystem(userCredentials); + } catch (Exception e) { + throw new RuntimeException(e); + } finally { + getWindowTest().setPreviousUser(getWindowTest().getUserCredentials().getUserId()); + } + } + + private void setUser(UserCredentials userCredentials) { + User user = new User(); + user.setUserId(userCredentials.getUserId()); + user.setFirstName(userCredentials.getFirstName()); + user.setRole(userCredentials.getRole()); + user.setLastName(userCredentials.getLastName()); + getWindowTest().setUserCredentials(userCredentials); + } + + public User getUser() { + return getWindowTest().getUserCredentials(); + } + + private void setBrowserBeforeTest(UserCredentials userCredentials) { + System.out.println(String.format("Setup before test with the userId %s.", userCredentials.getUserId())); + try { + System.out.println("Previous userId is : " + getWindowTest().getPreviousUser() + " ; Current userId is : " + userCredentials.getUserId()); + if (!getWindowTest().getPreviousUser().toLowerCase().equals(userCredentials.getUserId())) { + System.out.println("User IDs are different. navigating and login."); + navigateAndLogin(userCredentials); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void navigateAndLogin(UserCredentials userCredentials) throws Exception { + int refreshAttempts = getWindowTest().getRefreshAttempts() != 0 ? getWindowTest().getRefreshAttempts() : 0; + setRefreshAttempts(refreshAttempts); + setUser(userCredentials); + navigateToUrl(url); + loginWithUser(userCredentials); + GeneralUIUtils.ultimateWait(); + } + + public User getUser(UserRoleEnum role) { + User user = new User(); + user.setUserId(role.getUserId()); + user.setFirstName(role.getFirstName()); + user.setLastName(role.getLastName()); + user.setRole(role.name()); + return user; + } + + protected void reloginWithNewRole(UserCredentials userCredentials) throws Exception { + System.out.println(String.format("Setup before relogin with the userId %s", userCredentials.getUserId())); + navigateAndLogin(userCredentials); + } + + public void addTrafficFileToReport(ITestResult result) { + try { + // Get the HAR data + Har har = MobProxy.getPoxyServer().getHar(); + String shortUUID = UUID.randomUUID().toString().split("-")[0]; + File harFile = new File(getHarFilesFolder() + result.getName() + shortUUID + ".har"); + new File(getHarFilesFolder()).mkdirs(); + + har.writeTo(harFile); + + String pathToFileFromReportDirectory = getReportFolder() + File.separator + harFile.getName(); + ExtentTestActions.addFileToReportAsLink(harFile, pathToFileFromReportDirectory, + "File with captured traffic"); + } catch (IOException ioe) { + ioe.printStackTrace(); + } + } + + /* + * * Start section of test in ExtentReport with DataProvider parameters, + * should be started from test method, see example in onboardVNFTest + */ + public void setLog(String fromDataProvider) { + + String suiteName = ExtentManager.getSuiteName(myContext); + if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) { + ExtentTestManager.startTest(RE_RUN + Thread.currentThread().getStackTrace()[2].getMethodName() + + " " + fromDataProvider); + } else { + ExtentTestManager.startTest(Thread.currentThread().getStackTrace()[2].getMethodName() + + " " + fromDataProvider); + } + + getWindowTest().setAddedValueFromDataProvider(fromDataProvider); + ExtentTestManager.assignCategory(this.getClass()); + setBrowserBeforeTest(getUserCredentials()); + } + + public static void main(String[] args) { + System.out.println("---------------------"); + System.out.println("running test from CLI"); + System.out.println("---------------------"); + + String testSuite = System.getProperty("testSuite"); + String[] testSuiteArr = {testSuite}; + StartTest.main(testSuiteArr); + } + +}
\ No newline at end of file diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/WebDriverThread.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/WebDriverThread.java new file mode 100644 index 000000000..501faa8de --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/WebDriverThread.java @@ -0,0 +1,177 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.execute.setup; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.UUID; +import net.lightbody.bmp.BrowserMobProxyServer; +import net.lightbody.bmp.client.ClientUtil; +import net.lightbody.bmp.proxy.CaptureType; +import org.onap.sdc.ci.tests.datatypes.Configuration; +import org.onap.sdc.ci.tests.utilities.FileHandling; +import org.openqa.selenium.Capabilities; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.Platform; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.firefox.FirefoxOptions; +import org.openqa.selenium.firefox.FirefoxProfile; +import org.openqa.selenium.remote.CapabilityType; +import org.openqa.selenium.remote.LocalFileDetector; +import org.openqa.selenium.remote.RemoteWebDriver; + +public class WebDriverThread { + + public static final String AUTOMATION_DOWNLOAD_DIR = "automationDownloadDir"; + private WebDriver webdriver; + private FirefoxProfile firefoxProfile; + public static final String SELENIUM_NODE_URL = "http://%s:%s/wd/hub"; + public static final String MARIONETTE_CAPABILITY= "marionette"; + + public WebDriverThread(Configuration config) { + initDriver(config); + if (isHeadless()) { + webdriver.manage().window().setSize(new Dimension(1920, 1080)); + } else { + webdriver.manage().window().maximize(); + } + } + + private boolean isHeadless() { + if (webdriver instanceof RemoteWebDriver) { + Capabilities capabilities = ((RemoteWebDriver) webdriver).getCapabilities(); + Object headless = capabilities.getCapability("moz:headless"); + return Boolean.TRUE == headless; + } else { + return false; + } + } + + public WebDriver getDriver() throws Exception { + return webdriver; + } + + public void quitDriver() { + if (webdriver != null) { + webdriver.quit(); + webdriver = null; + } + } + + + public void initDriver(Configuration config){ + try { + boolean remoteTesting = config.isRemoteTesting(); + if (!remoteTesting) { + boolean mobProxyStatus = config.isUseBrowserMobProxy(); + if (mobProxyStatus){ + setWebDriverWithMobProxy(); + } else { + System.out.println("Opening LOCAL browser"); + FirefoxOptions cap = new FirefoxOptions(); + + cap.setCapability("browserName","firefox"); + cap.setCapability(FirefoxDriver.PROFILE, initFirefoxProfile()); + cap.setCapability(MARIONETTE_CAPABILITY, true); + + firefoxProfile.setPreference("network.proxy.type", 2); + firefoxProfile.setPreference("network.proxy.autoconfig_url", "http://emea.onap.org:8001/"); + firefoxProfile.setPreference("network.proxy.no_proxies_on", "localhost"); + + webdriver = new FirefoxDriver(cap); + } + } else { + System.out.println("Opening REMOTE browser"); + String remoteEnvIP = config.getRemoteTestingMachineIP(); + int remoteEnvPort = config.getRemoteTestingMachinePort(); + + FirefoxOptions cap = new FirefoxOptions(); + cap.setCapability("platform",Platform.ANY); + cap.setCapability("browserName","firefox"); + cap.setCapability(MARIONETTE_CAPABILITY, true); + + String remoteNodeUrl = String.format(SELENIUM_NODE_URL, remoteEnvIP, remoteEnvPort); + RemoteWebDriver remoteWebDriver = new RemoteWebDriver(new URL(remoteNodeUrl), cap); + remoteWebDriver.setFileDetector(new LocalFileDetector()); + webdriver = remoteWebDriver; + } + + + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + } + + private FirefoxProfile initFirefoxProfile() { + firefoxProfile = new FirefoxProfile(); + firefoxProfile.setPreference("browser.download.folderList",2); + firefoxProfile.setPreference("browser.download.manager.showWhenStarting",false); + firefoxProfile.setPreference("browser.download.dir", getDownloadDirectory()); + firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/octet-stream, application/xml, text/plain, text/xml, image/jpeg"); + return firefoxProfile; + } + + private String getDownloadDirectory() { + String downloadDirectory = FileHandling.getBasePath() + File.separator + AUTOMATION_DOWNLOAD_DIR + UUID.randomUUID().toString().split("-")[0] + File.separator; + File dir = new File(downloadDirectory); + if(!dir.exists()) { + dir.mkdirs(); + } + return dir.getAbsolutePath(); + } + + public FirefoxProfile getFirefoxProfile() { + return firefoxProfile; + } + + private void setWebDriverWithMobProxy(){ + MobProxy.setProxyServer(); + BrowserMobProxyServer proxyServer = MobProxy.getPoxyServer(); + + firefoxProfile = new FirefoxProfile(); + firefoxProfile.setPreference("browser.download.folderList",2); + firefoxProfile.setPreference("browser.download.manager.showWhenStarting",false); + firefoxProfile.setPreference("browser.download.dir", getDownloadDirectory()); + firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/octet-stream, application/xml, text/plain, text/xml, image/jpeg"); + firefoxProfile.setAcceptUntrustedCertificates(true); + firefoxProfile.setAssumeUntrustedCertificateIssuer(true); +// firefoxProfile.setPreference("network.proxy.http", "localhost"); +// firefoxProfile.setPreference("network.proxy.http_port", proxyServer.getPort()); +// firefoxProfile.setPreference("network.proxy.ssl", "localhost"); +// firefoxProfile.setPreference("network.proxy.ssl_port", proxyServer.getPort()); +// firefoxProfile.setPreference("network.proxy.type", 1); +// firefoxProfile.setPreference("network.proxy.no_proxies_on", ""); + + FirefoxOptions capabilities = new FirefoxOptions(); + + capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile); + capabilities.setCapability(CapabilityType.PROXY, ClientUtil.createSeleniumProxy(proxyServer)); + capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); + capabilities.setCapability(MARIONETTE_CAPABILITY, true); + + webdriver = new FirefoxDriver(capabilities); + proxyServer.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT, CaptureType.REQUEST_COOKIES, CaptureType.REQUEST_BINARY_CONTENT, + CaptureType.REQUEST_HEADERS, CaptureType.RESPONSE_COOKIES, CaptureType.RESPONSE_HEADERS, CaptureType.RESPONSE_BINARY_CONTENT); + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/WindowTest.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/WindowTest.java new file mode 100644 index 000000000..1fb3b188b --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/WindowTest.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.execute.setup; + +import java.io.File; + +import org.onap.sdc.ci.tests.datatypes.User; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; + +public class WindowTest { + + + + public WindowTest(){ + refreshAttempts = 0; + previousUser = ""; + addedValueFromDataProvider = null; + try { + downloadDirectory = DriverFactory.getDriverFirefoxProfile().getStringPreference("browser.download.dir", null) + File.separator; + } catch (Exception e) { + e.printStackTrace(); + } + } + + private int refreshAttempts; + private String addedValueFromDataProvider; + private String downloadDirectory; + private UserCredentials userCredentials; + private String previousUser; + + public int getRefreshAttempts() { + return refreshAttempts; + } + public void setRefreshAttempts(int refreshAttempts) { + this.refreshAttempts = refreshAttempts; + } + public synchronized String getAddedValueFromDataProvider() { + return addedValueFromDataProvider; + } + public synchronized void setAddedValueFromDataProvider(String addedValueFromDataProvider) { + this.addedValueFromDataProvider = addedValueFromDataProvider; + } + public String getDownloadDirectory() { + return downloadDirectory; + } + public void setDownloadDirectory(String downloadDirectory) { + this.downloadDirectory = downloadDirectory; + } + public UserCredentials getUserCredentials() { + return userCredentials; + } + public void setUserCredentials(UserCredentials userCredentials) { + this.userCredentials = userCredentials; + } + + public void setUserCredentials(User user) { + this.userCredentials = new UserCredentials(user); + } + public String getPreviousUser() { + return previousUser; + } + public void setPreviousUser(String previousUser) { + this.previousUser = previousUser; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/WindowTestManager.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/WindowTestManager.java new file mode 100644 index 000000000..727876f27 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/WindowTestManager.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.execute.setup; + +import java.util.HashMap; + +import com.aventstack.extentreports.ExtentTest; + +public class WindowTestManager { + + private static HashMap<Long, WindowTest> windowMap = new HashMap<Long, WindowTest>(); + + public static synchronized WindowTest getWindowMap() { + Long currentThreadId = Thread.currentThread().getId(); + boolean containsKey = windowMap.containsKey(currentThreadId); + if (!containsKey){ + setWindowMap(currentThreadId); + } + return windowMap.get(currentThreadId); + } + + private static synchronized void setWindowMap(Long currentThreadId) { + WindowTestManager.windowMap.put(currentThreadId, new WindowTest()); + } + + public static synchronized void removeWindowTest(){ + windowMap.remove(Thread.currentThread().getId()); + } + + public static synchronized HashMap<Long, WindowTest> getWholeMap(){ + return windowMap; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/run/RunTest.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/run/RunTest.java new file mode 100644 index 000000000..a3f88e23b --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/run/RunTest.java @@ -0,0 +1,25 @@ +package org.onap.sdc.ci.tests.run; + +import java.util.ArrayList; +import java.util.List; + +import org.testng.TestNG; + +public class RunTest { + + public static void runTestSuite() { + TestNG testng = new TestNG(); + List<String> suites = new ArrayList<String>(); + + String testSuite = System.getProperty("testSuite"); + if (testSuite == null){ + System.out.println("No test suite file was found, please provide test suite."); + System.exit(1); + } + suites.add(testSuite); + testng.setTestSuites(suites); + testng.setUseDefaultListeners(true); + testng.setOutputDirectory("target/"); + testng.run(); + } +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/run/StartTest.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/run/StartTest.java new file mode 100644 index 000000000..b314c44bb --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/run/StartTest.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.run; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; +import org.testng.TestNG; + +public class StartTest { + + public static long timeOfTest = 0; + + public static boolean debug = false; + + public static AtomicBoolean loggerInitialized = new AtomicBoolean(false); + + protected static Logger logger = null; + + public static void main(String[] args) { + + String debugEnabled = System.getProperty("debug"); + if (debugEnabled != null && debugEnabled.equalsIgnoreCase("true")) { + debug = true; + } + System.out.println("Debug mode is " + (debug ? "enabled" : "disabled")); + + enableLogger(); + + TestNG testng = new TestNG(); + + List<String> suites = new ArrayList<String>(); + suites.add(args[0]); + testng.setTestSuites(suites); + testng.setUseDefaultListeners(true); + testng.setOutputDirectory("target/"); + + testng.run(); + + } + + public StartTest() { + logger = Logger.getLogger(StartTest.class.getName()); + } + + public static void enableLogger() { + + if (false == loggerInitialized.get()) { + + loggerInitialized.set(true); + + String log4jPropsFile = System.getProperty("log4j.configuration"); + if (System.getProperty("os.name").contains("Windows")) { + String logProps = "src/main/resources/ci/conf/log4j.properties"; + if (log4jPropsFile == null) { + System.setProperty("targetlog", "target/"); + log4jPropsFile = logProps; + } + + } + PropertyConfigurator.configureAndWatch(log4jPropsFile); + + } + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/AdditionalConditions.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/AdditionalConditions.java new file mode 100644 index 000000000..9a070e2b0 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/AdditionalConditions.java @@ -0,0 +1,133 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.utilities; + +import com.paulhammant.ngwebdriver.NgWebDriver; +import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedCondition; + +import java.util.List; + +public class AdditionalConditions { + + public static ExpectedCondition<WebElement> searchForOneElement(List<By> ByList){ + return new ExpectedCondition<WebElement>() { + @Override + public WebElement apply(WebDriver driver) { + for (By by : ByList){ + WebElement findElement = driver.findElement(by); + if (findElement != null){ + return findElement; + } + } + return null; + } + }; + } + + public static ExpectedCondition<Boolean> jQueryAJAXCallsHaveCompleted() { + return new ExpectedCondition<Boolean>() { + @Override + public Boolean apply(WebDriver driver) { + return (Boolean) ((JavascriptExecutor)driver). + executeScript("return (window.jQuery!= null) && (jQuery.active === 0);"); + } + }; + } + + public static ExpectedCondition <Boolean> angularHasFinishedProcessing() { + return new ExpectedCondition<Boolean>() { + @Override + public Boolean apply(WebDriver driver) { +// String scriptJS = "return (window.angular !==undefined) &&" +// + " (angular.element(document).injector() !==undefined) &&" +// + " (angular.element(document).injector().get('$http').pendingRequests.length === 0)"; +// return Boolean.valueOf(( (JavascriptExecutor) driver).executeScript(scriptJS).toString()); + new NgWebDriver((JavascriptExecutor) driver).waitForAngularRequestsToFinish(); + return true; + } + }; + } + + public static ExpectedCondition <Boolean> angular2HasFinishedProcessing() { + return driver -> { + new NgWebDriver((JavascriptExecutor) driver).waitForAngular2RequestsToFinish(); + return true; + }; + } + + public static ExpectedCondition <Boolean> pageLoadWait() { + return new ExpectedCondition<Boolean>() { + @Override + public Boolean apply(WebDriver driver) { + String scriptJS = + "try {\r\n" + + " if (document.readyState !== 'complete') {\r\n" + + " return false; // Page not loaded yet\r\n" + + " }\r\n" + + " if (window.jQuery) {\r\n" + + " if (window.jQuery.active) {\r\n" + + " return false;\r\n" + + " } else if (window.jQuery.ajax && window.jQuery.ajax.active) {\r\n" + + " return false;\r\n" + + " }\r\n" + + " }\r\n" + + " if (window.angular) {\r\n" + + " if (!window.qa) {\r\n" + + " // Used to track the render cycle finish after loading is complete\r\n" + + " window.qa = {\r\n" + + " doneRendering: false\r\n" + + " };\r\n" + + " }\r\n" + + " // Get the angular injector for this app (change element if necessary)\r\n" + + " var injector = window.angular.element(document).find('body').injector();\r\n" + + " // Store providers to use for these checks\r\n" + + " var $rootScope = injector.get('$rootScope');\r\n" + + " var $http = injector.get('$http');\r\n" + + " var $timeout = injector.get('$timeout');\r\n" + + " // Check if digest\r\n" + + " if ($rootScope.$$phase === '$apply' || $rootScope.$$phase === '$digest' || $http.pendingRequests.length !== 0) {\r\n" + + " window.qa.doneRendering = false;\r\n" + + " return false; // Angular digesting or loading data\r\n" + + " }\r\n" + + " if (!window.qa.doneRendering) {\r\n" + + " // Set timeout to mark angular rendering as finished\r\n" + + " $timeout(function() {\r\n" + + " window.qa.doneRendering = true;\r\n" + + " }, 0);\r\n" + + " return false;\r\n" + + " }\r\n" + + " }\r\n" + + " return true;\r\n" + + "} catch (ex) {\r\n" + + " return false;\r\n" + + "}"; + return Boolean.valueOf(( (JavascriptExecutor) driver).executeScript(scriptJS).toString()); + } + }; + } + + + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/CanvasElement.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/CanvasElement.java new file mode 100644 index 000000000..eb93a619e --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/CanvasElement.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.utilities; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.onap.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems; +import org.openqa.selenium.WebElement; + +public final class CanvasElement { + private final String uniqueId; + private ImmutablePair<Integer, Integer> location; + private WebElement elementType; + + CanvasElement(String name, ImmutablePair<Integer, Integer> location, WebElement canvasItem) { + super(); + this.uniqueId = name; + this.location = location; + elementType = canvasItem; + } + + public String getUniqueId() { + return uniqueId; + } + + public ImmutablePair<Integer, Integer> getLocation() { + return location; + } + + public void setLocation(ImmutablePair<Integer, Integer> location) { + this.location = location; + } + + public WebElement getElementType() { + return elementType; + } +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/CanvasManager.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/CanvasManager.java new file mode 100644 index 000000000..91011f333 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/CanvasManager.java @@ -0,0 +1,179 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.utilities; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.UUID; +import java.util.stream.Collectors; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.onap.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +public final class CanvasManager { + private Map<String, CanvasElement> canvasElements; + private Actions actions; + private WebElement canvas; + private int reduceCanvasWidthFactor; + // Offsets Are used to find upper right corner of canvas element in order to + // connect links + private static final int CANVAS_ELEMENT_Y_OFFSET = 40; + private static final int CANVAS_ELEMENT_X_OFFSET = 21; // 14 - 27 + + private CanvasManager() { + canvasElements = new HashMap<>(); + actions = new Actions(GeneralUIUtils.getDriver()); + canvas = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.CANVAS.getValue()); + try { + WebElement webElement = GeneralUIUtils + .getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.CANVAS_RIGHT_PANEL.getValue()); + reduceCanvasWidthFactor = webElement.getSize().width; + } catch (Exception e) { + reduceCanvasWidthFactor = 0; + } + } + + public static CanvasManager getCanvasManager() { + return new CanvasManager(); + } + + public List<CanvasElement> getCanvasElements() { + return canvasElements.values().stream().collect(Collectors.toList()); + } + + private void addCanvasElement(CanvasElement element) { + canvasElements.put(element.getUniqueId(), element); + } + + private void moveElementOnCanvas(CanvasElement canvasElement, ImmutablePair<Integer, Integer> newLocation) + throws Exception { + GeneralUIUtils.waitForLoader(); + Thread.sleep(500); + actions.moveToElement(canvas, canvasElement.getLocation().left, canvasElement.getLocation().right); + actions.clickAndHold(); + actions.moveToElement(canvas, newLocation.left, newLocation.right); + actions.release(); + actions.perform(); + canvasElement.setLocation(newLocation); + GeneralUIUtils.waitForLoader(); + + } + + public void moveElementOnCanvas(CanvasElement canvasElement) throws Exception { + moveElementOnCanvas(canvasElement, getFreePosition()); + } + + public void deleteElementFromCanvas(CanvasElement canvasElement) throws Exception { + GeneralUIUtils.waitForLoader(); + actions.moveToElement(canvas, canvasElement.getLocation().left, canvasElement.getLocation().right); + actions.click(); + actions.perform(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.DELETE_INSTANCE_BUTTON.getValue()) + .click(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.OK.getValue()).click(); + canvasElements.remove(canvasElement.getUniqueId()); + GeneralUIUtils.waitForLoader(); + } + + private String getItemName(WebElement canvasItem) { + String canvasItemName = canvasItem.getAttribute("data-tests-id"); + + return canvasItemName.substring(canvasItemName.lastIndexOf("-")); + } + + public CanvasElement createElementOnCanvas(WebElement canvasItem) throws Exception { + GeneralUIUtils.waitForLoader(); + ImmutablePair<Integer, Integer> freePosition = getFreePosition(); + actions.moveToElement(canvasItem, 0, 0); + actions.clickAndHold(); + actions.moveToElement(canvas, freePosition.left, freePosition.right); + actions.release(); + actions.perform(); + + String uniqueId = getItemName(canvasItem) + "_" + UUID.randomUUID().toString(); + CanvasElement canvasElement = new CanvasElement(uniqueId, freePosition, canvasItem); + addCanvasElement(canvasElement); + GeneralUIUtils.waitForLoader(); + return canvasElement; + } + + private ImmutablePair<Integer, Integer> getFreePosition() { + // TODO mshitrit use better method + ImmutablePair<Integer, Integer> randomPosition = null; + boolean freePosition = false; + int minSpace = 150; + while (!freePosition) { + ImmutablePair<Integer, Integer> tempRandomPosition = getRandomPosition(); + freePosition = !canvasElements.values().stream().map(e -> e.getLocation()) + .filter(e -> Math.abs(e.left - tempRandomPosition.left) < minSpace + && Math.abs(e.right - tempRandomPosition.right) < minSpace) + .findAny().isPresent(); + randomPosition = tempRandomPosition; + } + return randomPosition; + } + + private ImmutablePair<Integer, Integer> getRandomPosition() { + int edgeBuffer = 50; + Random random = new Random(); + int xElement = random.nextInt(canvas.getSize().width - 2 * edgeBuffer - reduceCanvasWidthFactor) + edgeBuffer; + int yElement = random.nextInt(canvas.getSize().height - 2 * edgeBuffer) + edgeBuffer; + return new ImmutablePair<Integer, Integer>(xElement, yElement); + } + + public void linkElements(CanvasElement firstElement, CanvasElement secondElement) throws Exception { + GeneralUIUtils.waitForLoader(); + drawSimpleLink(firstElement, secondElement); + + selectReqAndCapAndConnect(); + + GeneralUIUtils.waitForLoader(); + + } + + private void selectReqAndCapAndConnect() { + // Select First Cap + GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.LinkMenuItems.LINK_ITEM_CAP.getValue()).get(0).click(); + // Select First Req + GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.LinkMenuItems.LINK_ITEM_REQ.getValue()).get(0).click(); + // Connect + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.LinkMenuItems.CONNECT_BUTTON.getValue()).click(); + } + + private void drawSimpleLink(CanvasElement firstElement, CanvasElement secondElement) { + + int yOffset = CANVAS_ELEMENT_Y_OFFSET; + int xOffset = CANVAS_ELEMENT_X_OFFSET; + + actions.moveToElement(canvas, firstElement.getLocation().left + xOffset, + firstElement.getLocation().right - yOffset); + + actions.clickAndHold(); + actions.moveToElement(canvas, secondElement.getLocation().left + xOffset, + secondElement.getLocation().right - yOffset); + actions.release(); + actions.perform(); + } +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/Constants.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/Constants.java new file mode 100644 index 000000000..4be51fbfd --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/Constants.java @@ -0,0 +1,128 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.utilities; + +public interface Constants { + + public static final String APPLICATION_NAME = "application-name"; + public static final String APPLICATION_VERSION = "application-version"; + public static final String CONFIG_HOME = "config.home"; + public static final String LOG_HOME = "log.home"; + public static final String YAML_SUFFIX = ".yaml"; + public static final String CONFIGURATION_SOURCE_ATTR = "configuration-source"; + public static final String MDC_APP_NAME = "APP_NAME"; + public static final String CONFIGURATION_MANAGER_ATTR = "configuration-manager"; + public static final String HEALTH_CHECK_SERVICE_ATTR = "healthCheckService"; + public static final String REST_CLIENT_ATTR = "rest-client"; + public static final String ARTIFACT_DAO_ATTR = "artifact-dao"; + public static final String UPLOAD_VALIDATORR_ATTR = "upload-validator"; + public static final String THREAD_EXECUTOR_ATTR = "thread-executor"; + public static final String ERROR_LOG_FORMAT = "EVENT = ARTIFACT_UPLOAD USER_ID=%s USER_NAME=%s ACCESS_IP=%s ACCESS_TYPE=%s RURL=%s SC=%d"; + public static final String FIRST_NAME_HEADER = "HTTP_CSP_FIRSTNAME"; + public static final String LAST_NAME_HEADER = "HTTP_CSP_LASTNAME"; + public static final String USER_ID_HEADER = "USER_ID"; + public static final String MD5_HEADER = "Content-MD5"; + public static final String CONTENT_DISPOSITION_HEADER = "Content-Disposition"; + public static final String CONTENT_TYPE_HEADER = "Content-Type"; + public static final String ORIGIN_HEADER = "HTTP_IV_REMOTE_ADDRESS"; + public static final String ACCESS_HEADER = "HTTP_CSP_WSTYPE"; + public static final String X_ECOMP_REQUEST_ID_HEADER = "X-ECOMP-RequestID"; + public static final String X_ECOMP_INSTANCE_ID_HEADER = "X-ECOMP-InstanceID"; + public static final String X_ECOMP_SERVICE_ID_HEADER = "X-ECOMP-ServiceID"; + public static final String HTTP = "http"; + public static final String HTTPS = "https"; + public static final String HTTP_IV_USER = "HTTP_IV_USER"; + public static final String A4C_CSAR_CONTEXT = "/rest/csars/"; + public static final String WEB_APPLICATION_CONTEXT_WRAPPER_ATTR = "web-application-context-wrapper"; + public static final String CATALOG_BE = "catalog-be"; + public static final String HTTP_CSP_FIRSTNAME = "HTTP_CSP_FIRSTNAME"; + public static final String HTTP_CSP_LASTNAME = "HTTP_CSP_LASTNAME"; + public static final String HTTP_IV_REMOTE_ADDRESS = "HTTP_IV_REMOTE_ADDRESS"; + public static final String HTTP_CSP_TYPE = "HTTP_CSP_WSTYPE"; + public static final String RESOURCE_SUPPORTED_VERSION = "0.0.1"; + public static final String ARTIFACT_ID_FORMAT = "%s:%s:%s"; // resourceName:resourceVersion:artifactName + public static final String SERVICE_ARTIFACT_ID_FORMAT = "%s:%s:%s:%s"; // serviceName:serviceVersion:nodeTemplateName:artifactName + public static final String CONTENT_DISPOSITION = "content-disposition"; + public static final String DOWNLOAD_ARTIFACT_LOGIC_ATTR = "downloadArtifactLogic"; + public static final String ASDC_RELEASE_VERSION_ATTR = "ASDC-Version"; + // public static final String AUDITING_MANAGER = "auditingManager"; + // public static final String USER_ADMIN_MANAGER = "userAdminManager"; + public static final String YEAR = "year"; + public static final String MONTH = "month"; + public static final String DAY = "day"; + public static final String HOUR = "hour"; + public static final String MINUTE = "minute"; + public static final String NONE = "none"; + public static final String RESOURCE_OPERATION_MANAGER = "resourceOperationManager"; + public static final String PROPERTY_OPERATION_MANAGER = "propertyOperationManager"; + public static final String SERVICE_OPERATION_MANAGER = "serviceOperationManager"; + public static final String EMPTY_STRING = ""; + public static final String NULL_STRING = "null"; + public static final String DOUBLE_NULL_STRING = "null null"; + public static final String ECOMP_ERROR_MNGR_ATTR = "ecompErrorMngrAttr"; + public static final String AUTHORIZATION_HEADER = "Authorization"; + public static final String ACCEPT_HEADER = "Accept"; + public static final String STANDARD_INTERFACE_TYPE = "standard"; + public static final String MURANO_PKG_ARTIFACT_TYPE = "MURANO-PKG"; + public static final String ARTIFACT_GROUP_TYPE_FIELD = "artifactGroupType"; + + // TOSCA + public static final String TOSCA_META_PATH = "TOSCA-Metadata/TOSCA.meta"; + public static final String TOSCA_META_ENTRY_DEFINITIONS = "Entry-Definitions"; + public static final String USER_DEFINED_RESOURCE_NAMESPACE_PREFIX = "org.openecomp.resource."; + + public static final String IS_BASE = "isBase"; + public static final String HEAT_FILE_PROPS = "heat_file"; + public static final String MODULE_NAME_FORMAT = "%s..%s..module-%s"; + public static final String MODULE_DESC_PATTERN = "[\\_\\-\\.a-zA-Z0-9]+"; + public static final String MODULE_OLD_NAME_PATTERN = "([\\w\\_\\-\\.\\s]+)(::module-)(\\d+)"; + public static final String MODULE_NEW_NAME_PATTERN = "([\\w\\_\\-\\.\\s]+\\.\\.)([\\_\\-\\.a-zA-Z0-9]+)(..module-)(\\d+)"; + public static final String MODULE_NAME_DELIMITER = "module-"; + public static final String IMPORT_STRUCTURE = "importStructure"; + public static final String DEFAULT_GROUP_VF_MODULE = "org.openecomp.groups.VfModule"; + + public static final String ARTIFACT_GROUP_TYPE = "artifactGroupType"; + public static final String ARTIFACT_LABEL = "artifactLabel"; + public static final String ARTIFACT_PAYLOAD_DATA = "payloadData"; + public static final String ARTIFACT_DISPLAY_NAME = "artifactDisplayName"; + public static final String ARTIFACT_DESCRIPTION = "description"; + public static final String ARTIFACT_TYPE = "artifactType"; + public static final String ARTIFACT_NAME = "artifactName"; + public static final String ARTIFACT_ID = "uniqueId"; + public static final String REQUIRED_ARTIFACTS = "requiredArtifacts"; + + public static final String ABSTRACT = "abstract"; + public static final String GLOBAL_SUBSTITUTION_TYPES_SERVICE_TEMPLATE = "Definitions/GlobalSubstitutionTypesServiceTemplate.yaml"; + public static final String ABSTRACT_SUBSTITUTE_GLOBAL_TYPES_SERVICE_TEMPLATE = "Definitions/AbstractSubstituteGlobalTypesServiceTemplate.yaml"; + + public static final String VENDOR_LICENSE_MODEL = "vendor-license-model.xml"; + public static final String VENDOR_LICENSE_LABEL = "vendorlicense"; + public static final String VENDOR_LICENSE_DISPLAY_NAME = "Vendor License"; + public static final String VENDOR_LICENSE_DESCRIPTION = " Vendor license file"; + + public static final String VF_LICENSE_MODEL = "vf-license-model.xml"; + public static final String VF_LICENSE_LABEL = "vflicense"; + public static final String VF_LICENSE_DISPLAY_NAME = "VF License"; + public static final String VF_LICENSE_DESCRIPTION = "VF license file"; + public static final String GET_INPUT = "get_input"; + public static final String SERVICE_TEMPLATE_FILE_POSTFIX = "ServiceTemplate.yaml"; + public static final String UNBOUNDED = "unbounded"; +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/Decoder.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/Decoder.java new file mode 100644 index 000000000..049302e54 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/Decoder.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.utilities; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +import org.apache.commons.codec.binary.Base64; + +public class Decoder { + + public static String encode(byte[] byteArrayToEncode) { + + byte[] bytesEncoded = Base64.encodeBase64(byteArrayToEncode); + String strEncoded = new String(bytesEncoded); + return strEncoded; + } + + public static String decode(String strEncoded) throws IOException { + + byte[] byteDecoded = Base64.decodeBase64(strEncoded); + String decoded = new String(byteDecoded); + + return decoded; + + } + + public static String readFileToString(String file) throws IOException { + + BufferedReader reader = new BufferedReader(new FileReader(file)); + String line = null; + StringBuilder stringBuilder = new StringBuilder(); + String ls = System.getProperty("line.separator"); + + while ((line = reader.readLine()) != null) { + stringBuilder.append(line); + stringBuilder.append(ls); + } + reader.close(); + return stringBuilder.toString(); + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/EcompPortalUtilities.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/EcompPortalUtilities.java new file mode 100644 index 000000000..bded65be8 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/EcompPortalUtilities.java @@ -0,0 +1,17 @@ +package org.onap.sdc.ci.tests.utilities; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +public class EcompPortalUtilities { + + public static void swichFrames(By by){ + WebElement appImage = GeneralUIUtils.getClickableButtonBy(by, 3 * 60); + appImage.click(); + GeneralUIUtils.getDriver().switchTo().frame(1); + GeneralUIUtils.waitForBackLoader(); + GeneralUIUtils.waitForAngular(); + GeneralUIUtils.getWebElementByClassName("applicationWindow"); + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/FileHandling.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/FileHandling.java new file mode 100644 index 000000000..d5d5540a9 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/FileHandling.java @@ -0,0 +1,489 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.utilities; + +import static org.testng.AssertJUnit.assertTrue; + +import java.io.BufferedOutputStream; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.FilenameFilter; +import java.io.IOException; +import java.io.InputStream; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.zip.ZipEntry; +import java.util.zip.ZipException; +import java.util.zip.ZipFile; +import java.util.zip.ZipInputStream; + +import org.apache.commons.io.FileUtils; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.execute.setup.ExtentTestActions; +import org.onap.sdc.ci.tests.execute.setup.SetupCDTest; +import org.yaml.snakeyaml.Yaml; + +import com.aventstack.extentreports.Status; + +public class FileHandling { + +// ------------------yaml parser methods---------------------------- + public static Map<?, ?> parseYamlFile(String filePath) throws Exception { + Yaml yaml = new Yaml(); + File file = new File(filePath); + InputStream inputStream = new FileInputStream(file); + Map<?, ?> map = (Map<?, ?>) yaml.load(inputStream); + return map; + } + + /** + * The method return map fetched objects by pattern from yaml file + * @param yamlFile + * @param pattern + * @return + * @throws Exception + */ + public static Map<String, Object> parseYamlFileToMapByPattern(File yamlFile, String pattern) throws Exception { + Map<?, ?> yamlFileToMap = FileHandling.parseYamlFile(yamlFile.toString()); + Map<String, Object> objectMap = getObjectMapByPattern(yamlFileToMap, pattern); + return objectMap; + } + + @SuppressWarnings("unchecked") + public static Map<String, Object> getObjectMapByPattern(Map<?, ?> parseUpdetedEnvFile, String pattern) { + Map<String, Object> objectMap = null; + + Object objectUpdetedEnvFile = parseUpdetedEnvFile.get(pattern); + if(objectUpdetedEnvFile instanceof HashMap){ + objectMap = (Map<String, Object>) objectUpdetedEnvFile; + } + return objectMap; + } + +// ------------------------------------------------------------------------------------------------- + + public static String getFilePath(String folder) { + String filepath = System.getProperty("filepath"); + if (filepath == null && System.getProperty("os.name").contains("Windows")) { + filepath = FileHandling.getResourcesFilesPath() + folder + File.separator; + } + + else if(filepath.isEmpty() && !System.getProperty("os.name").contains("Windows")){ + filepath = FileHandling.getBasePath() + "Files" + File.separator + folder + File.separator; + } + + System.out.println(filepath); + + return filepath; + } + + public static String getBasePath() { + return System.getProperty("user.dir") + File.separator; + } + + public static String getDriversPath() { + return getBasePath() + "src" + File.separator + "main" + File.separator + "resources" + + File.separator + "ci" + File.separator + "drivers" + File.separator; + } + + public static String getResourcesFilesPath() { + return getBasePath() + "src" + File.separator + "main" + File.separator + "resources" + + File.separator + "Files" + File.separator; + } + + public static String getResourcesEnvFilesPath() { + return getBasePath() + File.separator + "src" + File.separator + "main" + File.separator + "resources" + + File.separator + "Files" + File.separator + "ResourcesEnvFiles" +File.separator; + } + + public static String getCiFilesPath() { + return getBasePath() + "src" + File.separator + "main" + File.separator + "resources" + + File.separator + "ci"; + } + + public static String getConfFilesPath() { + return getCiFilesPath() + File.separator + "conf" + File.separator; + } + + public static String getTestSuitesFilesPath() { + return getCiFilesPath() + File.separator + "testSuites" + File.separator; + } + + public static File getConfigFile(String configFileName) throws Exception { + File configFile = new File(FileHandling.getBasePath() + File.separator + "conf" + File.separator + configFileName); + if (!configFile.exists()) { + configFile = new File(FileHandling.getConfFilesPath() + configFileName); + } + return configFile; + } + + public static Object[] filterFileNamesFromFolder(String filepath, String extension) { + try { + File dir = new File(filepath); + List<String> filenames = new ArrayList<String>(); + + FilenameFilter extensionFilter = new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.endsWith(extension); + } + }; + + if (dir.isDirectory()) { + for (File file : dir.listFiles(extensionFilter)) { + filenames.add(file.getName()); + } + return filenames.toArray(); + } + + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static String[] getArtifactsFromZip(String filepath, String zipFilename){ + try{ + ZipFile zipFile = new ZipFile(filepath + File.separator + zipFilename); + Enumeration<? extends ZipEntry> entries = zipFile.entries(); + + String[] artifactNames = new String[zipFile.size() - 1]; + + int i = 0; + while(entries.hasMoreElements()){ + ZipEntry nextElement = entries.nextElement(); + if (!nextElement.isDirectory()){ + if (!nextElement.getName().equals("MANIFEST.json")){ + String name = nextElement.getName(); + artifactNames[i++] = name; + } + } + } + zipFile.close(); + return artifactNames; + } + catch(ZipException zipEx){ + System.err.println("Error in zip file named : " + zipFilename); + zipEx.printStackTrace(); + } catch (IOException e) { + System.err.println("Unhandled exception : "); + e.printStackTrace(); + } + + return null; + + } + + public static Object[] getZipFileNamesFromFolder(String filepath) { + return filterFileNamesFromFolder(filepath, ".zip"); + } + + public static int countFilesInZipFile(String[] artifactsArr, String reqExtension){ + int fileCounter = 0; + for (String artifact : artifactsArr){ + String extensionFile = artifact.substring(artifact.lastIndexOf(".") + 1 , artifact.length()); + if (extensionFile.equals(reqExtension)){ + fileCounter++; + } + } + return fileCounter; + } + + + public static synchronized File getLastModifiedFileFromDir() throws Exception{ + return getLastModifiedFileFromDir(SetupCDTest.getWindowTest().getDownloadDirectory()); + } + + public static synchronized File getLastModifiedFileFromDir(String dirPath){ + File dir = new File(dirPath); + File[] files = dir.listFiles(); + if (files == null) { + assertTrue("File not found under directory " + dirPath, false); + return null; + } + + File lastModifiedFile = files[0]; + for (int i = 1; i < files.length; i++) { + if(files[i].isDirectory()) { + continue; + } + if (lastModifiedFile.lastModified() < files[i].lastModified()) { + lastModifiedFile = files[i]; + } + } + return lastModifiedFile; + } + + public static void deleteDirectory(String directoryPath) { + File dir = new File(directoryPath); + try { + FileUtils.deleteDirectory(dir); + } catch (IOException e) { + System.out.println("Failed to delete " + dir); + SetupCDTest.getExtendTest().log(Status.INFO, "Failed to delete " + dir); + } + } + + public static void createDirectory(String directoryPath) { + File directory = new File(String.valueOf(directoryPath)); + if (! directory.exists()){ + directory.mkdir(); + } + } + + + /** + * The method append data to existing file, if file not exists - create it + * @param pathToFile + * @param text + * @param leftSpaceCount + * @throws IOException + */ + public static synchronized void writeToFile(File pathToFile, Object text, Integer leftSpaceCount) throws IOException{ + + BufferedWriter bw = null; + FileWriter fw = null; + if(!pathToFile.exists()){ + createEmptyFile(pathToFile); + } + try { + fw = new FileWriter(pathToFile, true); + bw = new BufferedWriter(fw); + StringBuilder sb = new StringBuilder(); + if(leftSpaceCount > 0 ){ + for(int i = 0; i < leftSpaceCount; i++){ + sb.append(" "); + } + } + bw.write(sb.toString() + text); + bw.newLine(); + bw.close(); + fw.close(); + } catch (Exception e) { + SetupCDTest.getExtendTest().log(Status.INFO, "Unable to write to flie " + pathToFile); + } + } + + + public static void cleanCurrentDownloadDir() throws IOException { + try{ + ExtentTestActions.log(Status.INFO, "Cleaning directory " + SetupCDTest.getWindowTest().getDownloadDirectory()); + System.gc(); + FileUtils.cleanDirectory(new File(SetupCDTest.getWindowTest().getDownloadDirectory())); + } + catch(Exception e){ + + } + } + + public static boolean isFileDownloaded(String downloadPath, String fileName) { + boolean flag = false; + File dir = new File(downloadPath); + File[] dir_contents = dir.listFiles(); + for (int i = 0; i < dir_contents.length; i++) { + if (dir_contents[i].getName().equals(fileName)) + return flag = true; + } + return flag; + } + + public static String getMD5OfFile(File file) throws IOException { + String content = FileUtils.readFileToString(file); + String md5 = GeneralUtility.calculateMD5ByString(content); + return md5; + } + + public static File createEmptyFile(String fileToCreate) { + File file= new File(fileToCreate); + try { + if(file.exists()){ + deleteFile(file); + } + file.createNewFile(); + SetupCDTest.getExtendTest().log(Status.INFO, "Create file " + fileToCreate); + } catch (IOException e) { + SetupCDTest.getExtendTest().log(Status.INFO, "Failed to create file " + fileToCreate); + e.printStackTrace(); + } + return file; + } + + public static File createEmptyFile(File fileToCreate) { + try { + if(fileToCreate.exists()){ + deleteFile(fileToCreate); + } + fileToCreate.createNewFile(); + SetupCDTest.getExtendTest().log(Status.INFO, "Create file " + fileToCreate); + } catch (IOException e) { + SetupCDTest.getExtendTest().log(Status.INFO, "Failed to create file " + fileToCreate); + e.printStackTrace(); + } + return fileToCreate; + } + + public static void deleteFile(File file){ + + try{ + if(file.exists()){ + file.deleteOnExit(); + SetupCDTest.getExtendTest().log(Status.INFO, "File " + file.getName() + "has been deleted"); + }else{ + SetupCDTest.getExtendTest().log(Status.INFO, "Failed to delete file " + file.getName()); + } + }catch(Exception e){ + e.printStackTrace(); + } + + } + + + /** + * get file list from directory by extension array + * @param directory + * @param okFileExtensions + * @return + */ + public static List<File> getHeatAndHeatEnvArtifactsFromZip(File directory, String[] okFileExtensions){ + + List<File> fileList = new ArrayList<>(); + File[] files = directory.listFiles(); + + for (String extension : okFileExtensions){ + for(File file : files){ + if (file.getName().toLowerCase().endsWith(extension)){ + fileList.add(file); + } + } + } + return fileList; + } + + private static final int BUFFER_SIZE = 4096; + public static void unzip(String zipFilePath, String destDirectory) throws IOException { + File destDir = new File(destDirectory); + if (!destDir.exists()) { + destDir.mkdir(); + } + ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath)); + ZipEntry entry = zipIn.getNextEntry(); +// iterates over entries in the zip file + while (entry != null) { + String entryName; + if(System.getProperty("os.name").contains("Windows")){ + entryName = entry.getName().replaceAll("/", "\\"+File.separator); + }else{ + entryName = entry.getName(); + } + String filePath = destDirectory + entryName; + String currPath = destDirectory; + String[] dirs = entryName.split("\\"+File.separator); + String currToken; + for(int i = 0; i<dirs.length;++i){ + currToken = dirs[i]; + if(!entry.isDirectory() && i==dirs.length-1){ + extractFile(zipIn, filePath); + } else { + if(currPath.endsWith(File.separator)){ + currPath = currPath + currToken; + }else{ + currPath = currPath + File.separator + currToken; + } +// if the entry is a directory, make the directory + File dir = new File(currPath); + dir.mkdir(); + } + } + zipIn.closeEntry(); + entry = zipIn.getNextEntry(); + } + zipIn.close(); + } + + private static void extractFile(ZipInputStream zipIn, String filePath) throws IOException { + BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath)); + byte[] bytesIn = new byte[BUFFER_SIZE]; + int read = 0; + while ((read = zipIn.read(bytesIn)) != -1) { + bos.write(bytesIn, 0, read); + } + bos.close(); + } + + public static int getFileCountFromDefaulDownloadDirectory(){ + return new File(SetupCDTest.getWindowTest().getDownloadDirectory()).listFiles().length; + } + + + public static String getKeyByValueFromPropertyFormatFile(String fullPath, String key) { + Properties prop = new Properties(); + InputStream input = null; + String value = null; + try { + input = new FileInputStream(fullPath); + prop.load(input); + value = (prop.getProperty(key)); + + } catch (IOException ex) { + ex.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + return value.replaceAll("\"",""); + } + + public static String getExecutionHostAddress() { + + String computerName = null; + try { + computerName = InetAddress.getLocalHost().getHostAddress().replaceAll("\\.", "·"); + System.out.println(computerName); + if (computerName.indexOf(".") > -1) + computerName = computerName.substring(0, + computerName.indexOf(".")).toUpperCase(); + } catch (UnknownHostException e) { + System.out.println("Uknown hostAddress"); + } + return computerName != null ? computerName : "Uknown hostAddress"; + } + + public static Map<?, ?> loadCredentialsFile(String path, String filename) throws Exception { + File credentialsFileRemote = new File(path + filename); + Map<?, ?> yamlFile = FileHandling.parseYamlFile(credentialsFileRemote.getAbsolutePath()); + return yamlFile; + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/FindUtils.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/FindUtils.java new file mode 100644 index 000000000..2b0ca66da --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/FindUtils.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.utilities; + +import org.onap.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.onap.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openqa.selenium.WebElement; +import org.testng.Assert; + +import com.aventstack.extentreports.Status; + +public final class FindUtils { + + + public static void findComponentAndClick(String componentName) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, "finding component " + componentName); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue()).sendKeys(componentName); + WebElement foundComp = null; + try { + foundComp = GeneralUIUtils.getWebElementByTestID(componentName); + foundComp.click(); + GeneralUIUtils.waitForLoader(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue()); + } catch (Exception e) { + String msg = String.format("DID NOT FIND A COMPONENT NAMED %s", componentName); + SetupCDTest.getExtendTest().log(Status.FAIL, msg); + System.out.println(msg); + Assert.fail(msg); + } + } + + + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/GeneralUIUtils.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/GeneralUIUtils.java new file mode 100644 index 000000000..8885e1c3f --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/GeneralUIUtils.java @@ -0,0 +1,803 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.utilities; + +import com.aventstack.extentreports.Status; +import org.apache.commons.io.FileUtils; +import org.junit.Assert; +import org.onap.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.onap.sdc.ci.tests.datatypes.DataTestIdEnum.DashboardCardEnum; +import org.onap.sdc.ci.tests.execute.setup.DriverFactory; +import org.onap.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openqa.selenium.*; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.support.ui.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.awt.*; +import java.awt.event.KeyEvent; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; + +import static org.hamcrest.Matchers.is; + + +public final class GeneralUIUtils { + + public static final String FILE_NAME = "Valid_tosca_Mycompute.yml"; + static final Logger logger = LoggerFactory.getLogger(GeneralUIUtils.class); + + private static int timeOut=90; + +// public static void setTimeOut(int time) { +// if (time>0) { +// timeOut=time; +// } +// else { +// timeOut=timeOut; +// } +// } + + /**************** DRIVER ****************/ + + public static WebDriver getDriver() { + try{ + return DriverFactory.getDriver(); + } + catch(Exception e){ + e.printStackTrace(); + } + return null; + } + /****************************************/ + + public static List<WebElement> getElemenetsFromTable(By by) { + return getDriver().findElements(by); + } + + public static File takeScreenshot(String screenshotFilename, String dir, String testName) throws IOException { + if (screenshotFilename == null) { + if (testName != null){ + screenshotFilename = testName; + } + else + { + screenshotFilename = UUID.randomUUID().toString(); + } + } + try { + File scrFile = ((TakesScreenshot) getDriver()).getScreenshotAs(OutputType.FILE); + File filePath = new File(String.format("%s/%s.png", dir, screenshotFilename)); + new File(dir).mkdirs(); + FileUtils.copyFile(scrFile, filePath); + return filePath; + } catch (IOException e1) { + e1.printStackTrace(); + } + return null; + } + + public static File takeScreenshot(String screenshotFilename, String dir) throws IOException{ + return takeScreenshot(screenshotFilename, dir, null); + } + + + public static void scrollDown() { + try{ + Robot robot = new Robot(); + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + GeneralUIUtils.waitForLoader(); + } + catch(Exception e){ + e.printStackTrace(); + } + } + + + public static WebElement getWebElementByTestID(String dataTestId) { + return getWebElementByTestID(dataTestId, timeOut); + } + + public static WebElement getWebElementByTestID(String dataTestId, int timeout) { + WebDriverWait wait = newWait(timeout); + return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@data-tests-id='" + dataTestId + "']"))); + } + + public static boolean isWebElementExistByTestId(String dataTestId) { + if(getDriver().findElements(By.xpath("//*[@data-tests-id='" + dataTestId + "']")).size() == 0) { + return false; + } + return true; + } + + public static WebElement getInputElement(String dataTestId) { + try{ + ultimateWait(); + return getDriver().findElement(By.xpath("//*[@data-tests-id='" + dataTestId + "']")); + } + catch(Exception e){ + return null; + } + } + + public static List<WebElement> getInputElements(String dataTestId) { + ultimateWait(); + return getDriver().findElements(By.xpath("//*[@data-tests-id='" + dataTestId + "']")); + + } + + public static WebElement getWebElementBy(By by) { + return getWebElementBy(by, timeOut); + } + + public static WebElement getWebElementBy(By by, int timeoutInSeconds) { + WebDriverWait wait = newWait(timeoutInSeconds); + return wait.until(ExpectedConditions.visibilityOfElementLocated(by)); + } + + public static List<String> getWebElementListText(List<WebElement>elements) { + List<String>Text=new ArrayList<>(); + for (WebElement webElement : elements) { + Text.add(webElement.getText()); + } + return Text; + } + + + public static List<WebElement> getWebElementsListBy(By by) { + return getWebElementsListBy(by, timeOut); + } + + public static List<WebElement> getWebElementsListBy(By by, int timeOut) { + WebDriverWait wait = newWait(timeOut); + return wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(by)); + } + + public static List<WebElement> getWebElementsListByContainTestID(String dataTestId) { + try{ + WebDriverWait wait = newWait(10); + return wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//*[contains(@data-tests-id, '"+dataTestId+"')]"))); + } + catch(Exception e){ + return new ArrayList<WebElement>(); + } + } + + public static List<WebElement> getWebElementsListByContainsClassName(String containedText) { + return getWebElementsListByContainsClassName(containedText, timeOut); + } + + public static List<WebElement> getWebElementsListByContainsClassName(String containedText, int timeoutInSeconds) { + WebDriverWait wait = newWait(timeoutInSeconds); + return wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//*[contains(@class, '"+containedText+"')]"))); + } + + public static WebElement getWebElementByContainsClassName(String containedText) { + return getWebElementByContainsClassName(containedText, timeOut); + } + + public static WebElement getWebElementByContainsClassName(String containedText, int timeoutInSeconds) { + return getWebElementBy(By.xpath("//*[contains(@class, '"+containedText+"')]"), timeoutInSeconds); + } + + public static WebElement getWebElementByClassName(String className) { + return getWebElementByClassName(className, timeOut); + } + + public static WebElement getWebElementByClassName(String className, int timeoutInSeconds) { + WebDriverWait wait = newWait(timeoutInSeconds); + return wait.until(ExpectedConditions.visibilityOfElementLocated(By.className(className))); + } + + public static List<WebElement> getWebElementsListByContainsClassNameAndText(String cssName, String text, int timeoutInSeconds) { + WebDriverWait wait = newWait(timeoutInSeconds); + String xpath = String.format("//*[contains(@class, '%s') and contains(text(),'%s')]", cssName, text); + return wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy( + By.xpath(xpath))); + } + + public static WebElement getWebElementByLinkText(String linkText) { + WebDriverWait wait = newWait(timeOut); + return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@text='" + linkText + "']"))); + } + + + public static List<WebElement> getWebElementsListByTestID(String dataTestId) { + WebDriverWait wait = newWait(timeOut); + return wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//*[@data-tests-id='" + dataTestId + "']"))); + } + + public static List<WebElement> getWebElementsListByClassName(String className) { + WebDriverWait wait = newWait(timeOut); + return wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.className(className))); + } + + + + + public static Boolean isElementInvisibleByTestId(String dataTestId) { + WebDriverWait wait = newWait(timeOut); + return wait.until( + ExpectedConditions.invisibilityOfElementLocated(By.xpath("//*[@data-tests-id='" + dataTestId + "']"))); + } + + public static Boolean isElementVisibleByTestId(String dataTestId) { + try{ + WebDriverWait wait = newWait(timeOut); + if(wait.until(ExpectedConditions.visibilityOfElementLocated((By.xpath("//*[@data-tests-id='" + dataTestId + "']")))).isDisplayed()){ + return true; + }else { + return false; + } + } + catch(Exception e){ + return false; + } + } + + public static void clickOnElementByTestId(String dataTestId) { + clickOnElementByTestIdWithoutWait(dataTestId); + ultimateWait(); + } + + public static void clickOnElementByTestIdWithoutWait(String dataTestId) { + WebDriverWait wait = newWait(timeOut); + wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@data-tests-id='" + dataTestId + "']"))).click(); + } + + public static void clickOnElementByTestId(String dataTestId, int customTimeout) { + WebDriverWait wait = newWait(customTimeout); + wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@data-tests-id='" + dataTestId + "']"))).click(); + } + + public static WebElement waitForElementVisibilityByTestId(String dataTestId) { + WebDriverWait wait = newWait(timeOut); + return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@data-tests-id='" + dataTestId + "']"))); + } + + public static Boolean waitForElementInVisibilityByTestId(String dataTestId) { + return waitForElementInVisibilityByTestId(dataTestId, timeOut); + } + + public static Boolean waitForElementInVisibilityByTestId(String dataTestId, int timeOut) { + WebDriverWait wait = newWait(timeOut); + boolean displayed = getDriver().findElements(By.xpath("//*[@data-tests-id='" + dataTestId + "']")).isEmpty(); + if (!displayed){ + Boolean until = wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//*[@data-tests-id='" + dataTestId + "'])"))); + ultimateWait(); + return until; + } + return false; + } + + public static Boolean waitForElementInVisibilityByTestId(By by) { + return waitForElementInVisibilityBy(by, timeOut); + } + + + public static Boolean waitForElementInVisibilityBy(By by, int timeOut) { + WebDriverWait wait = newWait(timeOut); + boolean displayed = getDriver().findElements(by).isEmpty(); + if (!displayed){ + Boolean until = wait.until(ExpectedConditions.invisibilityOfElementLocated(by)); + sleep(1); + return until; + } + return false; + } + + + public static void setWebElementByTestId(String elementID, String value) { + WebElement resourceDescriptionTextbox = GeneralUIUtils.getWebElementByTestID(elementID); + resourceDescriptionTextbox.clear(); + resourceDescriptionTextbox.sendKeys(value); + + } + + public static WebElement hoverOnAreaByTestId(String areaId) { + Actions actions = new Actions(getDriver()); + WebElement area = getWebElementByTestID(areaId); + actions.moveToElement(area).perform(); + ultimateWait(); + return area; + } + + public static WebElement hoverOnAreaByClassName(String className) { + Actions actions = new Actions(getDriver()); + WebElement area = getWebElementByClassName(className); + actions.moveToElement(area).perform(); + GeneralUIUtils.ultimateWait(); + return area; + } + + public static void clickElementUsingActions(WebElement element){ + Actions actions = new Actions(getDriver()); + + actions.moveToElement(element); + actions.perform(); + + actions.click(); + actions.perform(); + + ultimateWait(); + } + + public static void waitForLoader() { + waitForLoader(timeOut); + } + + public static void waitForLoader(int timeOut) { + sleep(1); + waitForElementInVisibilityBy(By.className("tlv-loader"), timeOut); + } + + public static void findComponentAndClick(String resourceName) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " in homepage"); + WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue()); + try{ + searchTextbox.clear(); + searchTextbox.sendKeys(resourceName); + ultimateWait(); + } + catch(Exception e){ + SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar"); + e.printStackTrace(); + } + + + try{ + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the %s component from home screen", resourceName)); + clickOnElementByTestId(resourceName); + GeneralUIUtils.ultimateWait(); + getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue()); + } + catch(Exception e){ + SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on component named " + resourceName); + e.printStackTrace(); + } + } + + + public static String getComponentVersion(String componentName) { + return GeneralUIUtils.getWebElementByTestID(componentName + "Version").getText(); + } + + public static void windowZoomOut() { + final int zoomOutFactor = 3; + for (int i = 0; i < zoomOutFactor; i++) { + if(getDriver() instanceof FirefoxDriver) { + getDriver().findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL, Keys.SUBTRACT)); + } + } + } + + public static void resetZoom(){ + getDriver().findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL, "0")); + } + + public static void windowZoomOutUltimate(){ + resetZoom(); + windowZoomOut(); +// JavascriptExecutor js = (JavascriptExecutor) driver; +// js.executeScript("document.body.style.zoom='90%'"); + } + + public static void clickASDCLogo() { + WebDriverWait wait = newWait(15); + wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("ASDC"))); + WebElement ClickASDCLogo = getDriver().findElement(By.linkText("ASDC")); + ClickASDCLogo.click(); + GeneralUIUtils.waitForLoader(); + } + + public static void sleep(int millis) { + try { + Thread.sleep(millis); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + + public static void moveToStep(DataTestIdEnum.StepsEnum Stepname) { + moveToStep(Stepname.getValue()); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Going to %s page ", Stepname.toString())); + } + + public static void moveToStep(String dataTestId) { + clickOnElementByTestId(dataTestId); + ultimateWait(); + } + + + public static Select getSelectList(String item, String datatestsid) { + Select selectlist = new Select(getWebElementByTestID(datatestsid)); + if (item != null) { + selectlist.selectByVisibleText(item); + Assert.assertThat(selectlist.getFirstSelectedOption().getText(), is(item)); + } + return selectlist; + } + + public static List<WebElement> waitForElementsListVisibilityTestMethod(DashboardCardEnum dataTestId) { + GeneralUIUtils.waitForLoader(); + return getDriver().findElements(By.xpath("//*[@data-tests-id='" + dataTestId.getValue() + "']")); + } + + public static List<WebElement> getElementsByCSS(String cssString) throws InterruptedException { + GeneralUIUtils.waitForLoader(); + List<WebElement> assets = getDriver().findElements(By.cssSelector(cssString)); + return assets; + } + + public static WebElement getElementfromElementByCSS(WebElement parentElement, String cssString){ + WebDriverWait wait = newWait(timeOut); + GeneralUIUtils.waitForLoader(); + return parentElement.findElement(By.cssSelector(cssString)); + } + + public static WebElement getElementfromElementByXPATH(WebElement parentElement, DashboardCardEnum dataTestId){ + WebDriverWait wait = newWait(timeOut); + GeneralUIUtils.waitForLoader(); + return HighlightMyElement( parentElement.findElement(By.xpath("//*[@data-tests-id='" + dataTestId.getValue() + "']"))); + } + + public static WebElement HighlightMyElement(WebElement element) { + JavascriptExecutor javascript = (JavascriptExecutor) getDriver(); + javascript.executeScript("arguments[0].setAttribute('style', arguments[1]);", element, "color: yellow; border: 4px solid yellow;"); + return element; + } + + public static WebElement getSelectedElementFromDropDown(String dataTestId){ + GeneralUIUtils.ultimateWait();; + WebElement selectedElement = new Select (getDriver().findElement(By.xpath("//*[@data-tests-id='" + dataTestId + "']"))).getFirstSelectedOption(); + return selectedElement; + } + + + public static void waitForPageLoadByReadyState() { + newWait(30).until((ExpectedCondition<Boolean>) wd -> + ((JavascriptExecutor) wd).executeScript("return document.readyState").equals("complete")); + } + + + public static boolean checkElementsCountInTable(int expectedElementsCount, Supplier<List<WebElement>> func) { + int maxWaitingPeriodMS = 10 * 1000; + int napPeriodMS = 100; + int sumOfWaiting = 0; + List<WebElement> elements = null; + boolean isKeepWaiting = false; + while (!isKeepWaiting) { + elements = func.get(); + isKeepWaiting = (expectedElementsCount == elements.size()); + sleep(isKeepWaiting ? napPeriodMS : 0); + sumOfWaiting += napPeriodMS; + if (sumOfWaiting > maxWaitingPeriodMS) + return false; + } + return true; + } + + public static String getActionDuration(Runnable func) throws Exception{ + long startTime = System.nanoTime(); + func.run(); + long estimateTime = System.nanoTime(); + long duration = TimeUnit.NANOSECONDS.toSeconds(estimateTime - startTime); + String durationString = String.format("%02d:%02d", duration / 60, duration % 60); + return durationString; + } + + public static WebElement clickOnAreaJS(String areaId) { + return clickOnAreaJS(areaId, timeOut); + } + + + public static WebElement clickOnAreaJS(String areaId, int timeout) { + try{ + ultimateWait(); + WebElement area = getWebElementByTestID(areaId); + JavascriptExecutor javascript = (JavascriptExecutor) getDriver(); + //HighlightMyElement(area); + Object executeScript = javascript.executeScript("arguments[0].click();", area, "color: yellow; border: 4px solid yellow;"); + waitForLoader(timeout); + return area; + } + catch (Exception e){ + e.printStackTrace(); + } + return null; + } + + + + public static WebElement clickOnAreaJS(WebElement areaId) throws InterruptedException { + JavascriptExecutor javascript = (JavascriptExecutor) getDriver(); + //HighlightMyElement(area); + javascript.executeScript("arguments[0].click();", areaId, "color: yellow; border: 4px solid yellow;"); + return areaId; + } + + + + public static void clickSomewhereOnPage() { + getDriver().findElement(By.cssSelector(".asdc-app-title")).click(); + } + + public static void findComponentAndClickInCatalog(String resourceName) throws Exception { + // This method will find element by element name, don't use data-tests-id argument + WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue()); + searchTextbox.clear(); + searchTextbox.sendKeys(resourceName); + ultimateWait(); + clickOnElementByText(resourceName); + ultimateWait(); + } + + public static void clickOnElementByText(String textInElement) { + logger.info("clickOnElementByText: {}", textInElement); + WebDriverWait wait = newWait(timeOut); + HighlightMyElement(wait.until( + ExpectedConditions.elementToBeClickable(findByText(textInElement)))).click(); + } + + public static void clickOnElementByText(String textInElement, int customTimeout) { + logger.info("clickOnElementByText: {}", textInElement); + WebDriverWait wait = newWait(customTimeout); + HighlightMyElement(wait.until(ExpectedConditions.elementToBeClickable(searchByTextContaining(textInElement)))).click(); + } + + private static WebDriverWait newWait(int timeoutInSeconds) { + final WebDriver driver = getDriver(); + driver.manage().timeouts().setScriptTimeout(timeoutInSeconds, TimeUnit.SECONDS); + return new WebDriverWait(driver, timeoutInSeconds, 120); + } + + public static void clickJSOnElementByText(String textInElement) throws Exception { + WebDriverWait wait = newWait(timeOut); + clickOnAreaJS(wait.until( + ExpectedConditions.elementToBeClickable(findByText(textInElement)))); + } + + public static void fluentWaitTestID(String dataTestId, String text) { + FluentWait<WebDriver> fluentWait = new FluentWait<WebDriver>(getDriver()) + .withTimeout(30, TimeUnit.SECONDS) + .pollingEvery(50, TimeUnit.MILLISECONDS) + .ignoring(NoSuchElementException.class); + + fluentWait.until(ExpectedConditions.refreshed( + ExpectedConditions.textToBePresentInElementValue(By.xpath("//*[@data-tests-id='" + dataTestId + "']"), text))); + } + + public static void regularWait(WebElement element, String text){ + WebDriverWait wait = newWait(timeOut); + + wait.until(ExpectedConditions.textToBePresentInElementValue(element, text)); + } + + public static void waitForAngular(){ + WebDriverWait wait = newWait(90); + wait.until(AdditionalConditions.pageLoadWait()); + wait.until(AdditionalConditions.angularHasFinishedProcessing()); + } + + public static void waitForAngular2(){ + WebDriverWait wait = newWait(90); + wait.until(AdditionalConditions.pageLoadWait()); + try { + WebDriverWait briefWait = newWait(2); + briefWait.until(AdditionalConditions.angular2HasFinishedProcessing()); + } catch (TimeoutException | org.openqa.selenium.ScriptTimeoutException e) { + logger.info("Ignoring TimeoutException while waiting for angular2: {}", e, e); + } + } + + public static Object getAllElementAttributes(WebElement element) { + return ((JavascriptExecutor)getDriver()).executeScript("var s = []; var attrs = arguments[0].attributes; for (var l = 0; l < attrs.length; ++l) { var a = attrs[l]; s.push(a.name + ':' + a.value); } ; return s;", element); + } + + public static boolean isElementReadOnly(WebElement element){ + try { + HighlightMyElement(element).clear(); + return false; + } catch (Exception e) { + return true; + } + } + + public static boolean isElementReadOnly(String dataTestId){ + return isElementReadOnly( + waitForElementVisibilityByTestId(dataTestId)); + } + + public static boolean isElementDisabled(WebElement element){ + return HighlightMyElement(element).getAttribute("class").contains("view-mode") || + element.getAttribute("class").contains("disabled"); + } + + public static boolean isElementDisabled(String dataTestId){ + return isElementDisabled( + waitForElementVisibilityByTestId(dataTestId)); + } + + public static void ultimateWait(){ + logger.info("ultimateWait: starting"); + long startTime = System.nanoTime(); + + GeneralUIUtils.waitForAngular(); + logger.info("ultimateWait: waited for angular: {} ms", TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime)); + + GeneralUIUtils.waitForAngular2(); + logger.info("ultimateWait: waited for angular2: {} ms", TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime)); + + long estimateTime = System.nanoTime(); + long duration = TimeUnit.NANOSECONDS.toSeconds(estimateTime - startTime); + if(duration > timeOut){ + SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Delays on page, %d seconds", duration)); + } + + logger.info("ultimateWait: done"); + } + + public static WebElement makeElementVisibleWithJS(WebElement element){ + String js = "arguments[0].style.height='auto'; arguments[0].style.visibility='visible';"; + ((JavascriptExecutor) getDriver()).executeScript(js, element); + return element; + } + + public static WebElement unhideElement(WebElement element, String attributeValue){ + String js = "arguments[0].setAttribute('class','" + attributeValue + "');"; + ((JavascriptExecutor) getDriver()).executeScript(js, element); + return element; + } + + public static WebElement findByText(String textInElement){ + return getDriver().findElement(searchByTextContaining(textInElement)); + } + + public static List<WebElement> findElementsByText(String textInElement){ + return getDriver().findElements(searchByTextContaining(textInElement)); + } + + public static By searchByTextContaining(String textInElement) { + return By.xpath("//*[contains(text(),'" + textInElement + "')]"); + } + + + public static boolean findAndWaitByText(String textInElement, int timeout){ + logger.info("findAndWaitByText: {}", textInElement); + try{ + WebDriverWait wait = newWait(timeout); + wait.until(ExpectedConditions.presenceOfElementLocated(searchByTextContaining(textInElement))); + return true; + } + catch(Exception e){ + return false; + } + } + + public static WebElement getClickableButtonBy(By by, int timout){ + try{ + WebDriverWait wait = newWait(timout); + WebElement element = wait.until(ExpectedConditions.elementToBeClickable(by)); + return element; + } + catch(Exception e){ + return null; + } + } + + + + public static WebElement getButtonWithText(String textInButton){ + try{ + return getDriver().findElement(By.xpath("//button[contains(text(),'" + textInButton + "')]")); + } + catch(Exception e) + { + return null; + } + } + + + public static List<WebElement> getElementsByDataTestsIdStartWith(String startWithString){ + ultimateWait(); + return getDriver().findElements(By.xpath("//*[starts-with(@data-tests-id,'" + startWithString + "')]")); + } + + public static void closeErrorMessage() { + WebElement okWebElement = getButtonWithText("OK"); + if (okWebElement != null){ + okWebElement.click(); + ultimateWait(); + } + } + + public static WebElement getElementByCSS(String cssString) throws InterruptedException { + ultimateWait(); + return getDriver().findElement(By.cssSelector(cssString)); + } + + public static String getDataTestIdAttributeValue(WebElement element) { + return element.getAttribute("data-tests-id"); + } + + public static String getTextContentAttributeValue(WebElement element) { + return element.getAttribute("textContent"); + } + + public static WebElement getElementInsideElementByDataTestsId(WebElement element, String dataTestId) { + try{ + return element.findElement(By.xpath("//*[@data-tests-id='" + dataTestId + "']")); + } + catch(Exception e){ + return null; + } + } + + public static void clickOnElementByCSS(String cssString) throws Exception { + WebDriverWait wait = newWait(timeOut); + wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(cssString))).click(); + ultimateWait(); + } + public static String getRandomComponentName(String prefix) { + return prefix + GeneralUIUtils.randomNumber(); + } + public static int randomNumber() { + Random r = new Random(); + return r.nextInt(10000); + } + + public static void waitForUINotification() { + List<WebElement> notificationElements = getDriver().findElements(By.className("ui-notification")); + if (!notificationElements.isEmpty()){ + notificationElements.forEach(WebElement::click); + } + } + + public static boolean checkForDisabledAttribute(String dataTestId){ + Object elementAttributes = getAllElementAttributes(waitForElementVisibilityByTestId(dataTestId)); + return elementAttributes.toString().contains("disabled"); + } + + public static void dragAndDropElementByY(WebElement area, int yOffset) { + Actions actions = new Actions(getDriver()); + actions.dragAndDropBy(area, 10, yOffset).perform(); + ultimateWait(); + } + + public static void waitForBackLoader() { + waitForBackLoader(timeOut); + } + + public static void waitForBackLoader(int timeOut) { + sleep(1); + waitForElementInVisibilityBy(By.className("tlv-loader-back"), timeOut); + } + +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/GeneralUtility.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/GeneralUtility.java new file mode 100644 index 000000000..f2e834e03 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/GeneralUtility.java @@ -0,0 +1,155 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.sdc.ci.tests.utilities; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.regex.Pattern; + +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.io.FileUtils; + +public class GeneralUtility { + + public static boolean generateTextFile(String fileName, String fileData) { + boolean isSuccessfull = true; + try { + FileUtils.writeStringToFile(new File(fileName), fileData); + } catch (IOException e) { + isSuccessfull = false; + } + return isSuccessfull; + } + + /** + * Use with care, usage is not advised!!! + * The method only checks if String does not contain special characters + length divided by 4 with no remainder. + * The methods contained in other common libraries do the same. + */ + public static boolean isBase64Encoded(byte[] data) { + return Base64.isBase64(data); + } + + /** + *Use with care, usage is not advised!!! + * The method only checks if String does not contain special characters + length divided by 4 with no remainder. + * The methods contained in other common libraries do the same. + */ + public static boolean isBase64Encoded(String str) { + boolean isEncoded = false; + try { + // checks if the string was properly padded to the + isEncoded = ((str.length() % 4 == 0) && (Pattern.matches("\\A[a-zA-Z0-9/+]+={0,2}\\z", str))); + if (isEncoded) { + // If no exception is caught, then it is possibly a base64 + // encoded string + byte[] data = Base64.decodeBase64(str); + } + + } catch (Exception e) { + // If exception is caught, then it is not a base64 encoded string + isEncoded = false; + } + return isEncoded; + } + + /** + * Checks whether the passed string exceeds a limit of number of characters. + * + * @param str + * @param limit + * @return the result of comparison, or false if str is null. + */ + public static boolean isExceedingLimit(String str, int limit) { + if (str == null) { + return false; + } + return str.length() > limit; + } + + /** + * Checks the passed string list whether the cumulative length of strings and delimiters between them exceeds a limit of number of characters. For example for list ("one","two","three") with delimiter "," the length of list is calculated + * 3+1+3+1+5=13 + * + * @param strList + * @param limit + * @param delimiterLength + * - 0 if there is no delimeter. + * @return the result of comparison, or false if strList is null. + */ + public static boolean isExceedingLimit(List<String> strList, int limit, int delimiterLength) { + if (strList == null || strList.isEmpty()) { + return false; + } + int sum = 0; + int size = strList.size(); + for (int i = 0; i < size - 1; i++) { + String str = strList.get(i); + if (str != null) { + sum += str.length(); + } + sum += delimiterLength; + } + String str = strList.get(size - 1); + if (str != null) { + sum += str.length(); + } + return sum > limit; + } + + /** + * Return the extension as the substring from the last dot. For input "kuku.txt", "txt" will be returned. If no dot is found or input is null, empty string is returned. + * + * @param fileName + * @return extension + */ + public static String getFilenameExtension(String fileName) { + String res = Constants.EMPTY_STRING; + if (fileName != null) { + int indexOf = fileName.lastIndexOf('.'); + if (indexOf != -1 && indexOf < (fileName.length() - 1)) { + res = fileName.substring(indexOf + 1); + } + } + return res; + } + + public static String calculateMD5ByByteArray(byte[] payload) { + String decodedMd5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(payload); + byte[] encodeMd5 = Base64.encodeBase64(decodedMd5.getBytes()); + return new String(encodeMd5); + + } + + /** + * + * @param data + * @return + */ + public static String calculateMD5ByString(String data) { + String calculatedMd5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(data); + + // encode base-64 result + byte[] encodeBase64 = Base64.encodeBase64(calculatedMd5.getBytes()); + return new String(encodeBase64); + } +} diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/LoginUtils.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/LoginUtils.java new file mode 100644 index 000000000..eca3599c6 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/utilities/LoginUtils.java @@ -0,0 +1,42 @@ +package org.onap.sdc.ci.tests.utilities; + +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.datatypes.UserRoleEnum; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +public class LoginUtils { + + private static final String WEB_SEAL_PASSWORD = "123123a"; + + public static void loginToLocalWebsealSimulator(UserRoleEnum role) { + WebDriver driver = GeneralUIUtils.getDriver(); + WebDriverWait wait = new WebDriverWait(driver, 30); + + wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//*[@method='" + "post" + "']")))); + + WebElement userIdTextbox = GeneralUIUtils.getWebElementBy(By.name("userId")); + userIdTextbox.sendKeys(role.getUserId()); + WebElement passwordTextbox = GeneralUIUtils.getWebElementBy(By.name("password")); + passwordTextbox.sendKeys(WEB_SEAL_PASSWORD); + + wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath("//*[@value='" + "Login" + "']")))).click(); + } + + public static void loginToLocalWebsealSimulator(UserCredentials user) { + WebDriver driver = GeneralUIUtils.getDriver(); + WebDriverWait wait = new WebDriverWait(driver, 30); + + wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//*[@method='" + "post" + "']")))); + + WebElement userIdTextbox = GeneralUIUtils.getWebElementBy(By.name("userId")); + userIdTextbox.sendKeys(user.getUserId()); + WebElement passwordTextbox = GeneralUIUtils.getWebElementBy(By.name("password")); + passwordTextbox.sendKeys(user.getPassword()); + + wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath("//*[@value='" + "Login" + "']")))).click(); + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseMSOPreset.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseMSOPreset.java index 8194d87ac..4f4779d8e 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseMSOPreset.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseMSOPreset.java @@ -1,5 +1,6 @@ package org.onap.simulator.presetGenerator.presets.BasePresets; +import java.util.Map; import vid.automation.test.infra.Features; /** @@ -7,13 +8,17 @@ import vid.automation.test.infra.Features; */ public abstract class BaseMSOPreset extends BasePreset { + public static final String DEFAULT_CLOUD_OWNER = "irma-aic"; + public static final String DEFAULT_INSTANCE_ID = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb"; + protected String cloudOwner = DEFAULT_CLOUD_OWNER; + public static String getRequestBodyWithTestApiOnly() { if (Features.FLAG_ADD_MSO_TESTAPI_FIELD.isActive()) { return "" + "{" + " \"requestDetails\": { " + " \"requestParameters\": { " + - " \"testApi\": \"GR_API\" " + + " \"testApi\": \"VNF_API\" " + " } " + " } " + "} " + @@ -23,8 +28,20 @@ public abstract class BaseMSOPreset extends BasePreset { } } + protected String addCloudOwnerIfNeeded() { + return Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST.isActive() ? + "\"cloudOwner\": \""+cloudOwner+"\"," : ""; + } + @Override protected String getRootPath() { return "/mso"; } + + @Override + public Map<String, String> getRequestHeaders() { + Map<String, String> map = super.getRequestHeaders(); + map.put("X-ONAP-PartnerName", "VID"); + return map; + } } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BasePreset.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BasePreset.java index 162367368..662677e83 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BasePreset.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BasePreset.java @@ -1,11 +1,10 @@ package org.onap.simulator.presetGenerator.presets.BasePresets; -import org.onap.simulator.presetGenerator.presets.model.RegistrationRequest; -import org.springframework.http.HttpMethod; - import java.util.HashMap; import java.util.List; import java.util.Map; +import org.onap.simulator.presetGenerator.presets.model.RegistrationRequest; +import org.springframework.http.HttpMethod; /** * Created by itzikliderman on 13/12/2017. @@ -13,12 +12,13 @@ import java.util.Map; public abstract class BasePreset { public RegistrationRequest generateScenario() { - Map<String, String> headers = new HashMap<>(); - headers.put("Content-Type", getContentType()); + Map<String, String> responseHeaders = new HashMap<>(); + responseHeaders.put("Content-Type", getContentType()); return new RegistrationRequest( - new RegistrationRequest.SimulatorRequest(getReqMethod(), getReqPath(), getQueryParams(), getRequestBody()), - new RegistrationRequest.SimulatorResponse(getResponseCode(), headers, getResponseBody(), getFile())); + new RegistrationRequest.SimulatorRequest(getReqMethod(), getReqPath(), getQueryParams(), getRequestBody(), isStrictMatch(), getRequestHeaders()), + new RegistrationRequest.SimulatorResponse(getResponseCode(), responseHeaders, getResponseBody(), getFile()), + new RegistrationRequest.Misc(getNumberOfTimes(), getReplace())); } public Object getResponseBody() { return null; }; @@ -41,7 +41,19 @@ public abstract class BasePreset { return null; } + public boolean isStrictMatch() { + return false; + } + public Map<String, List> getQueryParams() { return null; } protected abstract String getRootPath(); + + protected Integer getNumberOfTimes() {return null;} + + protected boolean getReplace() {return true;} + + public Map<String,String> getRequestHeaders() { + return new HashMap<>(); + } } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aaf/AAFGetBasicAuthPreset.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aaf/AAFGetBasicAuthPreset.java new file mode 100644 index 000000000..f7900d14b --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aaf/AAFGetBasicAuthPreset.java @@ -0,0 +1,31 @@ +package org.onap.simulator.presetGenerator.presets.aaf; + +import com.google.common.collect.ImmutableMap; +import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset; +import org.springframework.http.HttpMethod; + +import java.util.Map; + +public class AAFGetBasicAuthPreset extends BasePreset { + public static final String VALID_AUTH_VALUE = "bTEyMzRAYXR0LmNvbTphYWFh"; + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return "/authn/basicAuth"; + } + + @Override + protected String getRootPath() { + return ""; + } + + @Override + public Map<String, String> getRequestHeaders() { + return ImmutableMap.of("Authorization", "Basic " + VALID_AUTH_VALUE); + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aaf/AAFGetUrlServicePreset.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aaf/AAFGetUrlServicePreset.java new file mode 100644 index 000000000..b3376e61a --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aaf/AAFGetUrlServicePreset.java @@ -0,0 +1,26 @@ +package org.onap.simulator.presetGenerator.presets.aaf; + +import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset; +import org.springframework.http.HttpMethod; + +public class AAFGetUrlServicePreset extends BasePreset { + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return "/locate/com.att.aaf.service:2.0"; + } + + @Override + protected String getRootPath() { + return ""; + } + + @Override + public Object getResponseBody() { + return "{\"endpoint\":[{\"name\":\"com.att.aaf.service\",\"major\": 2,\"minor\": 0,\"patch\": 19,\"pkg\": 21,\"latitude\": 38.627346,\"longitude\": -90.19377,\"protocol\": \"http\",\"subprotocol\": [],\"hostname\": \"127.0.0.1\",\"port\": 1080}]}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/BasePresetAAIGetVersion.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/BasePresetAAIGetVersion.java deleted file mode 100644 index 2452a24f7..000000000 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/BasePresetAAIGetVersion.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.onap.simulator.presetGenerator.presets.aai; - -import com.google.common.collect.ImmutableMap; -import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; -import org.springframework.http.HttpMethod; - -import java.util.Collections; -import java.util.List; -import java.util.Map; - -public class BasePresetAAIGetVersion extends BaseAAIPreset { - public String modelVersionId1; - public String modelInvariantId; - - public BasePresetAAIGetVersion(String modelVersionId1, String modelInvariantId) { - this.modelVersionId1 = modelVersionId1; - this.modelInvariantId = modelInvariantId; - } - @Override - public HttpMethod getReqMethod() { - return HttpMethod.PUT; - } - - @Override - public String getReqPath() { - return getRootPath() + "/query"; - } - - @Override - public Map<String, List> getQueryParams() { - return ImmutableMap.of("format", Collections.singletonList("resource")); - } - - @Override - public Object getRequestBody() { - return "{\"start\" : \"service-design-and-creation/models/\", \"query\" : \"query/serviceModels-byDistributionStatus?distributionStatus=DISTRIBUTION_COMPLETE_OK\"}"; - } - - public String getModelVersionId1() { - return modelVersionId1; - } - - public String getModelInvariantId() { - return modelInvariantId; - } - - -} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAICloudRegionAndSourceFromConfigurationPut.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAICloudRegionAndSourceFromConfigurationPut.java index c74cc0b14..66562ed63 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAICloudRegionAndSourceFromConfigurationPut.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAICloudRegionAndSourceFromConfigurationPut.java @@ -2,12 +2,11 @@ package org.onap.simulator.presetGenerator.presets.aai; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; -import org.springframework.http.HttpMethod; - import java.util.Collections; import java.util.List; import java.util.Map; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; public class PresetAAICloudRegionAndSourceFromConfigurationPut extends BaseAAIPreset { @@ -64,9 +63,9 @@ public class PresetAAICloudRegionAndSourceFromConfigurationPut extends BaseAAIPr " \"results\": [{" + " \"id\": \"2979590232\"," + " \"node-type\": \"cloud-region\"," + - " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/SDNO-S-BcloudReg-E1802\"," + + " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/SDNO-S-BcloudReg-E1802\"," + " \"properties\": {" + - " \"cloud-owner\": \"att-aic\"," + + " \"cloud-owner\": \"irma-aic\"," + " \"cloud-region-id\": \"" + getCloudRegionId() + "\"," + " \"sriov-automation\": false," + " \"resource-version\": \"1513631040564\"" + diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIFilterServiceInstanceById.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIFilterServiceInstanceById.java new file mode 100644 index 000000000..5fca9f392 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIFilterServiceInstanceById.java @@ -0,0 +1,39 @@ +package org.onap.simulator.presetGenerator.presets.aai; + +import com.google.common.collect.ImmutableMap; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public class PresetAAIFilterServiceInstanceById extends PresetAAIBaseSearchNodeQuery { + + private String subscriberId; + private String serviceType; + private String serviceInstanceId; + + public PresetAAIFilterServiceInstanceById(String subscriberId, String serviceType, String serviceInstanceId) { + this.subscriberId = subscriberId; + this.serviceType = serviceType; + this.serviceInstanceId = serviceInstanceId; + } + + @Override + public Map<String, List> getQueryParams() { + return ImmutableMap.of("search-node-type", Collections.singletonList("service-instance"), + "filter", Collections.singletonList("service-instance-id:EQUALS:" + this.serviceInstanceId)); + } + + @Override + public Object getResponseBody() { + return "" + + "{" + + "\"result-data\": [\n" + + " {\n" + + " \"resource-type\": \"service-instance\",\n" + + " \"resource-link\": \"/aai/v11/business/customers/customer/" + this.subscriberId + "/service-subscriptions/service-subscription/" + this.serviceType + "/service-instances/service-instance/" + this.serviceInstanceId + "\"\n" + + " }\n" + + " ]" + + "}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetCloudOwnersByCloudRegionId.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetCloudOwnersByCloudRegionId.java new file mode 100644 index 000000000..be075b481 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetCloudOwnersByCloudRegionId.java @@ -0,0 +1,130 @@ +package org.onap.simulator.presetGenerator.presets.aai; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; + +import com.google.common.collect.ImmutableMap; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; + +public class PresetAAIGetCloudOwnersByCloudRegionId extends BaseAAIPreset { + public static final String SOME_LEGACY_REGION = "some legacy region"; + public static final String JUST_ANOTHER_REGION = "just another region"; + public static final String MY_REGION = "my region"; + public static final String LCP_REGION_TEXT = "lcpRegionText"; + public static final String ATT_AIC = "irma-aic"; + public static final String MDT_1 = "mdt1"; + public static final String ATT_NC = "att-nc"; + public static final String hvf3 = "hvf3"; + public static final String olson3 = "olson3"; + public static final String olson5B = "olson5b"; + public static final String ATT_SABABA = "att-sababa"; + public static final String AAIAIC_25 = "JANET25"; + public static final String ONE = "One"; + public static final String hvf6 = "hvf6"; + private final String cloudRegionId; + private final String cloudOwner; + + //Since there is a cache of cloudRegionToCloudOwner, we can't have 2 preset of same cloud region that return different cloud owner. + //So all the preset instance must be declared here, for conflicts prevention. + public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_SOME_LEGACY_REGION_TO_ATT_AIC = + new PresetAAIGetCloudOwnersByCloudRegionId(SOME_LEGACY_REGION, ATT_AIC); + + public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_JUST_ANOTHER_REGION_TO_ATT_AIC = + new PresetAAIGetCloudOwnersByCloudRegionId(JUST_ANOTHER_REGION, ATT_AIC); + + public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_MDT1_TO_ATT_NC = + new PresetAAIGetCloudOwnersByCloudRegionId(MDT_1, ATT_NC); + + public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_RDM3_TO_ATT_NC = + new PresetAAIGetCloudOwnersByCloudRegionId(olson3, ATT_NC); + + public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_MTN3_TO_ATT_SABABA = + new PresetAAIGetCloudOwnersByCloudRegionId(hvf3, ATT_SABABA); + + public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_AAIAIC25_TO_ATT_AIC = + new PresetAAIGetCloudOwnersByCloudRegionId(AAIAIC_25, ATT_AIC); + + public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_ONE_TO_ATT_AIC = + new PresetAAIGetCloudOwnersByCloudRegionId(ONE, ATT_AIC); + + public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_MTN6_TO_ATT_AIC = + new PresetAAIGetCloudOwnersByCloudRegionId(hvf6, ATT_AIC); + + public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_MY_REGION_TO_ATT_AIC = + new PresetAAIGetCloudOwnersByCloudRegionId(MY_REGION, ATT_AIC); + + public static final PresetAAIGetCloudOwnersByCloudRegionId PRESET_LCP_REGION_TEXT_TO_ATT_AIC = + new PresetAAIGetCloudOwnersByCloudRegionId(LCP_REGION_TEXT, ATT_AIC); + + private PresetAAIGetCloudOwnersByCloudRegionId(String cloudRegionId, String cloudOwnerResult) { + this.cloudRegionId = cloudRegionId; + this.cloudOwner = cloudOwnerResult; + } + + @Override + public Object getResponseBody() { + return "" + + "{" + + " \"cloud-region\": [{" + + " \"cloud-owner\": \"" + cloudOwner + "\"," + + " \"cloud-region-id\": \"" + cloudRegionId + "\"," + + " \"cloud-region-version\": \"2.5\"," + + " \"identity-url\": \"http://" + randomAlphabetic(5) + ":5000/v2.0\"," + + " \"complex-name\": \"" + cloudRegionId + "\"," + + " \"resource-version\": \"" + randomNumeric(5) + "\"," + + " \"relationship-list\": {" + + " \"relationship\": [{" + + " \"related-to\": \"pserver\"," + + " \"relationship-label\": \"org.onap.relationships.inventory.LocatedIn\"," + + " \"related-link\": \"/aai/v12/cloud-infrastructure/pservers/pserver/" + randomAlphabetic(5) + "\"," + + " \"relationship-data\": [{" + + " \"relationship-key\": \"pserver.hostname\"," + + " \"relationship-value\": \"" + randomAlphabetic(5) + "\"" + + " }" + + " ]," + + " \"related-to-property\": [{" + + " \"property-key\": \"pserver.pserver-name2\"" + + " }" + + " ]" + + " }, {" + + " \"related-to\": \"l3-network\"," + + " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," + + " \"related-link\": \"/aai/v12/network/l3-networks/l3-network/" + UUID.randomUUID() + "\"," + + " \"relationship-data\": [{" + + " \"relationship-key\": \"l3-network.network-id\"," + + " \"relationship-value\": \"" + UUID.randomUUID() + "\"" + + " }" + + " ]," + + " \"related-to-property\": [{" + + " \"property-key\": \"l3-network.network-name\"," + + " \"property-value\": \"" + randomAlphabetic(5) + "\"" + + " }" + + " ]" + + " }" + + " ]" + + " }" + + " }" + + " ]" + + "}"; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return getRootPath() + "/cloud-infrastructure/cloud-regions"; + } + + @Override + public Map<String, List> getQueryParams() { + return ImmutableMap.of("cloud-region-id", Collections.singletonList(cloudRegionId)); + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetCloudRegionFromVnf.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetCloudRegionFromVnf.java new file mode 100644 index 000000000..976228bf0 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetCloudRegionFromVnf.java @@ -0,0 +1,130 @@ +package org.onap.simulator.presetGenerator.presets.aai; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; + +public class PresetAAIGetCloudRegionFromVnf extends BaseAAIPreset { + + private String vnfInstanceId; + + public PresetAAIGetCloudRegionFromVnf(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.PUT; + } + + @Override + public String getReqPath() { + return getRootPath() + "/query"; + } + + @Override + public Map<String, List> getQueryParams() { + return ImmutableMap.of( + "format", Collections.singletonList("simple") + ); + } + + @Override + public Object getRequestBody() { + return ImmutableMap.of( + "start", ImmutableList.of("/network/generic-vnfs/generic-vnf/" + getVnfInstanceId()), + "query", "/query/cloud-region-fromVnf" + ); + } + + @Override + public Object getResponseBody() { + return "{" + + " \"results\": [" + + " {" + + " \"id\": \"363687968\"," + + " \"node-type\": \"generic-vnf\"," + + " \"url\": \"/aai/v14/network/generic-vnfs/generic-vnf/" + getVnfInstanceId() + "\"," + + " \"properties\": {" + + " \"vnf-id\": \"" + getVnfInstanceId() + "\"," + + " \"vnf-name\": \"zhvf23bmogx05_oam_01_rk\"," + + " \"vnf-type\": \"vMOG_SVC_UPDATED_FLAV_OAM/vMOG_VSP_UPDATED_FLAV 0\"," + + " \"service-id\": \"db171b8f-115c-4992-a2e3-ee04cae357e0\"," + + " \"prov-status\": \"NVTPROV\"," + + " \"orchestration-status\": \"Created\"," + + " \"in-maint\": false," + + " \"is-closed-loop-disabled\": false," + + " \"resource-version\": \"1522780608709\"," + + " \"model-invariant-id\": \"5108d7e4-f32a-44cd-8835-433a70915b8c\"," + + " \"model-version-id\": \"bae37933-b694-4b4e-a734-db63416f9cfe\"," + + " \"model-customization-id\": \"732305c6-d36a-47ee-a701-6f28f87b90cd\"," + + " \"nf-type\": \"POLICY\"," + + " \"nf-function\": \"Emanuel Orchestration Gateway (MOG)\"," + + " \"nf-role\": \"vMOG\"," + + " \"nf-naming-code\": \"\"" + + " }," + + " \"related-to\": [" + + " {" + + " \"id\": \"193753168\"," + + " \"relationship-label\": \"org.onap.relationships.inventory.ComposedOf\"," + + " \"node-type\": \"service-instance\"," + + " \"url\": \"/aai/v14/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vMOG/service-instances/service-instance/7f10ffe2-548f-4168-8722-b782d05675b7\"" + + " }" + + " ]" + + " }," + + " {" + + " \"id\": \"8757432\"," + + " \"node-type\": \"tenant\"," + + " \"url\": \"/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/hvf23b/tenants/tenant/3e9a20a3e89e45f884e09df0cc2d2d2a\"," + + " \"properties\": {" + + " \"tenant-id\": \"3e9a20a3e89e45f884e09df0cc2d2d2a\"," + + " \"tenant-name\": \"APPC-24595-T-IST-02C\"," + + " \"resource-version\": \"1539855222745\"" + + " }," + + " \"related-to\": [" + + " {" + + " \"id\": \"264798392\"," + + " \"relationship-label\": \"org.onap.relationships.inventory.BelongsTo\"," + + " \"node-type\": \"vserver\"," + + " \"url\": \"/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/hvf23b/tenants/tenant/3e9a20a3e89e45f884e09df0cc2d2d2a/vservers/vserver/088c2bf0-80e2-4bdf-93ae-b2469fbeba84\"" + + " }" + + " ]" + + " }," + + " {" + + " \"id\": \"302227536\"," + + " \"node-type\": \"cloud-region\"," + + " \"url\": \"/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/hvf23b\"," + + " \"properties\": {" + + " \"cloud-owner\": \"irma-aic\"," + + " \"cloud-region-id\": \"hvf23b\"," + + " \"cloud-type\": \"openstack\"," + + " \"owner-defined-type\": \"lcp\"," + + " \"cloud-region-version\": \"3.0\"," + + " \"identity-url\": \"https://iden.onap.org:5000/v2.0\"," + + " \"cloud-zone\": \"z1\"," + + " \"complex-name\": \"c1\"," + + " \"sriov-automation\": \"false\"," + + " \"resource-version\": \"1539855222969\"" + + " }," + + " \"related-to\": [" + + " {" + + " \"id\": \"2744328\"," + + " \"relationship-label\": \"org.onap.relationships.inventory.BelongsTo\"," + + " \"node-type\": \"tenant\"," + + " \"url\": \"/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/hvf23b/tenants/tenant/5452d6bd0cb34e99a3553d349456c642\"" + + " }" + + " ]" + + " }" + + " ]" + + "}"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetHomingForVfModule.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetHomingForVfModule.java new file mode 100644 index 000000000..6b07f5293 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetHomingForVfModule.java @@ -0,0 +1,150 @@ +package org.onap.simulator.presetGenerator.presets.aai; + +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; + +public class PresetAAIGetHomingForVfModule extends BaseAAIPreset { + private final String vnfInstanceId; + private final String vfModuleId; + private final String tenantId; + private final String lcpRegionId; + + public PresetAAIGetHomingForVfModule(String vnfInstanceId, String vfModuleId, String tenantId, String lcpRegionId) { + this.vnfInstanceId = vnfInstanceId; + this.vfModuleId = vfModuleId; + this.tenantId = tenantId; + this.lcpRegionId = lcpRegionId; + } + + public PresetAAIGetHomingForVfModule(String vnfInstanceId, String vfModuleId) { + this( + vnfInstanceId, + vfModuleId, + "db1818f7f2e34862b378bfb2cc520f91", + "olson5b" + ); + } + + public PresetAAIGetHomingForVfModule() { + this( + "0846287b-65bf-45a6-88f6-6a1af4149fac", + "a9b70ac0-5917-4203-a308-0e6920e6d09b", + "db1818f7f2e34862b378bfb2cc520f91", + "olson5b" + ); + } + + @Override + public Object getResponseBody() { + return "{" + + " \"vf-module-id\": \""+vfModuleId+"\"," + + " \"vf-module-name\": \"apndns_az_02_module_1\"," + + " \"heat-stack-id\": \"apndns_az_02_module_1/97a319f3-b095-4fff-befa-c657508ecaf8\"," + + " \"orchestration-status\": \"active\"," + + " \"is-base-vf-module\": false," + + " \"resource-version\": \"1530559380383\"," + + " \"model-invariant-id\": \"74450b48-0aa0-4743-8314-9163e92b7862\"," + + " \"model-version-id\": \"6bc01a2b-bc48-4991-b9fe-e22c2215d801\"," + + " \"model-customization-id\": \"74f638c2-0368-4212-8f73-e961005af17c\"," + + " \"module-index\": 0," + + " \"relationship-list\": {" + + " \"relationship\": [" + + " {" + + " \"related-to\": \"l3-network\"," + + " \"relationship-label\": \"org.onap.relationships.inventory.DependsOn\"," + + " \"related-link\": \"/aai/v12/network/l3-networks/l3-network/335e62be-73a3-41e8-930b-1a677bcafea5\"," + + " \"relationship-data\": [" + + " {" + + " \"relationship-key\": \"l3-network.network-id\"," + + " \"relationship-value\": \"335e62be-73a3-41e8-930b-1a677bcafea5\"" + + " }" + + " ]," + + " \"related-to-property\": [" + + " {" + + " \"property-key\": \"l3-network.network-name\"," + + " \"property-value\": \"MNS-FN-25180-T-02Shared_oam_protected_net_1\"" + + " }" + + " ]" + + " }," + + " {" + + " \"related-to\": \"l3-network\"," + + " \"relationship-label\": \"org.onap.relationships.inventory.DependsOn\"," + + " \"related-link\": \"/aai/v12/network/l3-networks/l3-network/2db4ee3e-2ac7-4fc3-8739-ecf53416459e\"," + + " \"relationship-data\": [" + + " {" + + " \"relationship-key\": \"l3-network.network-id\"," + + " \"relationship-value\": \"2db4ee3e-2ac7-4fc3-8739-ecf53416459e\"" + + " }" + + " ]," + + " \"related-to-property\": [" + + " {" + + " \"property-key\": \"l3-network.network-name\"," + + " \"property-value\": \"Mobisupport-FN-27099-T-02_int_apn_dns_net_1\"" + + " }" + + " ]" + + " }," + + " {" + + " \"related-to\": \"volume-group\"," + + " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," + + " \"related-link\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/" + lcpRegionId + "/volume-groups/volume-group/66013ebe-0c81-44b9-a24f-7c6acba73a39\"," + + " \"relationship-data\": [" + + " {" + + " \"relationship-key\": \"cloud-region.cloud-owner\"," + + " \"relationship-value\": \"irma-aic\"" + + " }," + + " {" + + " \"relationship-key\": \"cloud-region.cloud-region-id\"," + + " \"relationship-value\": \"" + lcpRegionId + "\"" + + " }," + + " {" + + " \"relationship-key\": \"volume-group.volume-group-id\"," + + " \"relationship-value\": \"66013ebe-0c81-44b9-a24f-7c6acba73a39\"" + + " }" + + " ]" + + " }," + + " {" + + " \"related-to\": \"vserver\"," + + " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," + + " \"related-link\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/" + lcpRegionId + "/tenants/tenant/" + tenantId+ "/vservers/vserver/5eef9f6d-9933-4bc6-9a1a-862d61309437\"," + + " \"relationship-data\": [" + + " {" + + " \"relationship-key\": \"cloud-region.cloud-owner\"," + + " \"relationship-value\": \"irma-aic\"" + + " }," + + " {" + + " \"relationship-key\": \"cloud-region.cloud-region-id\"," + + " \"relationship-value\": \"" + lcpRegionId + "\"" + + " }," + + " {" + + " \"relationship-key\": \"tenant.tenant-id\"," + + " \"relationship-value\": \"" + tenantId + "\"" + + " }," + + " {" + + " \"relationship-key\": \"vserver.vserver-id\"," + + " \"relationship-value\": \"5eef9f6d-9933-4bc6-9a1a-862d61309437\"" + + " }" + + " ]," + + " \"related-to-property\": [" + + " {" + + " \"property-key\": \"vserver.vserver-name\"," + + " \"property-value\": \"zolson5bfapn01dns002\"" + + " }" + + " ]" + + " }" + + " ]" + + " }" + + "}"; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return getRootPath() + "/network/generic-vnfs/generic-vnf/" + this.vnfInstanceId + "/vf-modules/vf-module/" + this.vfModuleId; + } + + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetInstanceGroupsByCloudRegion.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetInstanceGroupsByCloudRegion.java index a50462a3d..9435dcd2b 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetInstanceGroupsByCloudRegion.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetInstanceGroupsByCloudRegion.java @@ -44,7 +44,7 @@ public class PresetAAIGetInstanceGroupsByCloudRegion extends BaseAAIPreset { public Object getRequestBody() { return ImmutableMap.of( "start", ImmutableList.of("cloud-infrastructure/cloud-regions/cloud-region/" + getCloudOwner() + "/" + getCloudRegionId()), - "query", "query/instance-group-byCloudRegion?type=" + type + "&role=" + role + "&function=" + getNetworkFunction() + "query", "query/instance-groups-byCloudRegion?type=" + type + "&role=" + role + "&function=" + getNetworkFunction() ); } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest.java index 9dae89be5..b20ef5a6e 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest.java @@ -44,7 +44,7 @@ public class PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest extends BaseA public Object getRequestBody() { return ImmutableMap.of( "start", ImmutableList.of("cloud-infrastructure/cloud-regions/cloud-region/" + getCloudOwner() + "/" + getCloudRegionId()), - "query", "query/instance-group-byCloudRegion?type=" + type + "&role=" + role + "&function=" + getNetworkFunction() + "query", "query/instance-groups-byCloudRegion?type=" + type + "&role=" + role + "&function=" + getNetworkFunction() ); } @@ -62,124 +62,124 @@ public class PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest extends BaseA @Override public Object getResponseBody() { - return "{\n" + - " \"results\": [\n" + - " {\n" + - " \"instance-group\": {\n" + - " \"instance-group-role\": \"JZmha7QSS4tJ\",\n" + - " \"some-filed\": \"some-data\",\n" + //extra field - " \"model-invariant-id\": \"model-id3\",\n" + - " \"model-version-id\": \"a0efd5fc-f7be-4502-936a-a6c6392b958f\",\n" + - " \"id\": \"AAI-12002-test3-vm230w\",\n" + - " \"description\": \"a9DEa0kpY\",\n" + - " \"instance-group-type\": \"type\",\n" + - " \"resource-version\": \"1520888659539\",\n" + - " \"instance-group-name\": \"wKmBXiO1xm8bK\",\n" + - " \"instance-group-function\": \"testfunction2\",\n" + - " \"relationship-list\": {\n" + - " \"relationship\": [\n" + - " {\n" + - " \"related-to\": \"cloud-region\",\n" + - " \"some-filed\": \"some-data\",\n" + //extra field - " \"relationship-label\": \"org.onap.relationships.inventory.Uses\",\n" + - " \"related-link\": \"/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/AAI-12002-vm230w/AAI-region-vm230w\",\n" + - " \"relationship-data\": [\n" + - " {\n" + - " \"relationship-key\": \"cloud-region.cloud-owner\",\n" + - " \"relationship-value\": \"AAI-12002-vm230w\"\n" + - " },\n" + - " {\n" + - " \"relationship-key\": \"cloud-region.cloud-region-id\",\n" + - " \"relationship-value\": \"AAI-region-vm230w\"\n" + - " }\n" + - " ],\n" + - " \"related-to-property\": [\n" + - " {\n" + - " \"property-key\": \"cloud-region.owner-defined-type\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - " }\n" + - " }\n" + - " },\n" + - " {\n" + - " \"instance-group\": {\n" + - " \"instance-group-role\": \"JZmha7QSS4tJ\",\n" + - " \"model-invariant-id\": \"model-id1\",\n" + - " \"model-version-id\": \"a0efd5fc-f7be-4502-936a-a6c6392b958f\",\n" + - " \"id\": \"AAI-12002-test1-vm230w\",\n" + - " \"description\": \"a9DEa0kpY\",\n" + - " \"instance-group-type\": \"type\",\n" + - " \"resource-version\": \"1520886467989\",\n" + - " \"instance-group-name\": \"wKmBXiO1xm8bK\",\n" + - " \"instance-group-function\": \"testfunction2\",\n" + - " \"relationship-list\": {\n" + - " \"relationship\": [\n" + - " {\n" + - " \"related-to\": \"cloud-region\",\n" + - " \"relationship-label\": \"org.onap.relationships.inventory.Uses\",\n" + - " \"related-link\": \"/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/AAI-12002-vm230w/AAI-region-vm230w\",\n" + - " \"relationship-data\": [\n" + - " {\n" + - " \"relationship-key\": \"cloud-region.cloud-owner\",\n" + - " \"some-filed\": \"some-data\",\n" + //extra field - " \"relationship-value\": \"AAI-12002-vm230w\"\n" + - " },\n" + - " {\n" + - " \"relationship-key\": \"cloud-region.cloud-region-id\",\n" + - " \"relationship-value\": \"AAI-region-vm230w\"\n" + - " }\n" + - " ],\n" + - " \"related-to-property\": [\n" + - " {\n" + - " \"property-key\": \"cloud-region.owner-defined-type\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - " }\n" + - " }\n" + - " },\n" + - " {\n" + - " \"instance-group\": {\n" + - " \"instance-group-role\": \"JZmha7QSS4tJ\",\n" + - " \"model-invariant-id\": \"model-id2\",\n" + - " \"model-version-id\": \"version2\",\n" + - " \"id\": \"AAI-12002-test2-vm230w\",\n" + - " \"description\": \"a9DEa0kpY\",\n" + - " \"instance-group-type\": \"type\",\n" + - " \"resource-version\": \"1520888629970\",\n" + - " \"instance-group-name\": \"wKmBXiO1xm8bK\",\n" + - " \"instance-group-function\": \"testfunction2\",\n" + - " \"relationship-list\": {\n" + - " \"relationship\": [\n" + - " {\n" + - " \"related-to\": \"cloud-region\",\n" + - " \"relationship-label\": \"org.onap.relationships.inventory.Uses\",\n" + - " \"related-link\": \"/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/AAI-12002-vm230w/AAI-region-vm230w\",\n" + - " \"relationship-data\": [\n" + - " {\n" + - " \"relationship-key\": \"cloud-region.cloud-owner\",\n" + - " \"relationship-value\": \"AAI-12002-vm230w\"\n" + - " },\n" + - " {\n" + - " \"relationship-key\": \"cloud-region.cloud-region-id\",\n" + - " \"relationship-value\": \"AAI-region-vm230w\"\n" + - " }\n" + - " ],\n" + - " \"related-to-property\": [\n" + - " {\n" + - " \"property-key\": \"cloud-region.owner-defined-type\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - " }\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n"; + return "{" + + " \"results\": [" + + " {" + + " \"instance-group\": {" + + " \"instance-group-role\": \"JZmha7QSS4tJ\"," + + " \"some-filed\": \"some-data\"," + //extra field + " \"model-invariant-id\": \"model-id3\"," + + " \"model-version-id\": \"a0efd5fc-f7be-4502-936a-a6c6392b958f\"," + + " \"id\": \"AAI-12002-test3-vm230w\"," + + " \"description\": \"a9DEa0kpY\"," + + " \"instance-group-type\": \"type\"," + + " \"resource-version\": \"1520888659539\"," + + " \"instance-group-name\": \"wKmBXiO1xm8bK\"," + + " \"instance-group-function\": \"testfunction2\"," + + " \"relationship-list\": {" + + " \"relationship\": [" + + " {" + + " \"related-to\": \"cloud-region\"," + + " \"some-filed\": \"some-data\"," + //extra field + " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," + + " \"related-link\": \"/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/AAI-12002-vm230w/AAI-region-vm230w\"," + + " \"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\"" + + " }" + + " ]" + + " }" + + " ]" + + " }" + + " }" + + " }," + + " {" + + " \"instance-group\": {" + + " \"instance-group-role\": \"JZmha7QSS4tJ\"," + + " \"model-invariant-id\": \"model-id1\"," + + " \"model-version-id\": \"a0efd5fc-f7be-4502-936a-a6c6392b958f\"," + + " \"id\": \"AAI-12002-test1-vm230w\"," + + " \"description\": \"a9DEa0kpY\"," + + " \"instance-group-type\": \"type\"," + + " \"resource-version\": \"1520886467989\"," + + " \"instance-group-name\": \"wKmBXiO1xm8bK\"," + + " \"instance-group-function\": \"testfunction2\"," + + " \"relationship-list\": {" + + " \"relationship\": [" + + " {" + + " \"related-to\": \"cloud-region\"," + + " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," + + " \"related-link\": \"/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/AAI-12002-vm230w/AAI-region-vm230w\"," + + " \"relationship-data\": [" + + " {" + + " \"relationship-key\": \"cloud-region.cloud-owner\"," + + " \"some-filed\": \"some-data\"," + //extra field + " \"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\"" + + " }" + + " ]" + + " }" + + " ]" + + " }" + + " }" + + " }," + + " {" + + " \"instance-group\": {" + + " \"instance-group-role\": \"JZmha7QSS4tJ\"," + + " \"model-invariant-id\": \"model-id2\"," + + " \"model-version-id\": \"version2\"," + + " \"id\": \"AAI-12002-test2-vm230w\"," + + " \"description\": \"a9DEa0kpY\"," + + " \"instance-group-type\": \"type\"," + + " \"resource-version\": \"1520888629970\"," + + " \"instance-group-name\": \"wKmBXiO1xm8bK\"," + + " \"instance-group-function\": \"testfunction2\"," + + " \"relationship-list\": {" + + " \"relationship\": [" + + " {" + + " \"related-to\": \"cloud-region\"," + + " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," + + " \"related-link\": \"/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/AAI-12002-vm230w/AAI-region-vm230w\"," + + " \"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\"" + + " }" + + " ]" + + " }" + + " ]" + + " }" + + " }" + + " }" + + " ]" + + "}"; } } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetInstanceGroupsByCloudRegionRequiredMissing.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetInstanceGroupsByCloudRegionRequiredMissing.java index 4d596e527..eb4a22889 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetInstanceGroupsByCloudRegionRequiredMissing.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetInstanceGroupsByCloudRegionRequiredMissing.java @@ -44,7 +44,7 @@ public class PresetAAIGetInstanceGroupsByCloudRegionRequiredMissing extends Base public Object getRequestBody() { return ImmutableMap.of( "start", ImmutableList.of("cloud-infrastructure/cloud-regions/cloud-region/" + getCloudOwner() + "/" + getCloudRegionId()), - "query", "query/instance-group-byCloudRegion?type=" + type + "&role=" + role + "&function=" + getNetworkFunction() + "query", "query/instance-groups-byCloudRegion?type=" + type + "&role=" + role + "&function=" + getNetworkFunction() ); } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetModelsByOwningEntity.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetModelsByOwningEntity.java index 610ab6b48..41c35b8a5 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetModelsByOwningEntity.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetModelsByOwningEntity.java @@ -1,12 +1,11 @@ package org.onap.simulator.presetGenerator.presets.aai; import com.google.common.collect.ImmutableMap; -import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; -import org.springframework.http.HttpMethod; - import java.util.Collections; import java.util.List; import java.util.Map; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; public class PresetAAIGetModelsByOwningEntity extends BaseAAIPreset { String oeName; @@ -45,11 +44,11 @@ public class PresetAAIGetModelsByOwningEntity extends BaseAAIPreset { " {" + " \"related-to\": \"service-instance\"," + " \"relationship-label\": \"org.onap.relationships.inventory.BelongsTo\"," + - " \"related-link\": \"/aai/v12/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/af9d52f9-13b2-4657-a198-463677f82dc0\"," + + " \"related-link\": \"/aai/v12/business/customers/customer/CAR_2020_ER/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/af9d52f9-13b2-4657-a198-463677f82dc0\"," + " \"relationship-data\": [" + " {" + " \"relationship-key\": \"customer.global-customer-id\"," + - " \"relationship-value\": \"MSO_1610_ST\"" + + " \"relationship-value\": \"CAR_2020_ER\"" + " }," + " {" + " \"relationship-key\": \"service-subscription.service-type\"," + @@ -70,11 +69,11 @@ public class PresetAAIGetModelsByOwningEntity extends BaseAAIPreset { " {" + " \"related-to\": \"service-instance\"," + " \"relationship-label\": \"org.onap.relationships.inventory.BelongsTo\"," + - " \"related-link\": \"/aai/v12/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/49769492-5def-4c89-8e73-b236f958fa40\"," + + " \"related-link\": \"/aai/v12/business/customers/customer/CAR_2020_ER/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/49769492-5def-4c89-8e73-b236f958fa40\"," + " \"relationship-data\": [" + " {" + " \"relationship-key\": \"customer.global-customer-id\"," + - " \"relationship-value\": \"MSO_1610_ST\"" + + " \"relationship-value\": \"CAR_2020_ER\"" + " }," + " {" + " \"relationship-key\": \"service-subscription.service-type\"," + @@ -120,7 +119,7 @@ public class PresetAAIGetModelsByOwningEntity extends BaseAAIPreset { " {" + " \"related-to\": \"service-instance\"," + " \"relationship-label\": \"org.onap.relationships.inventory.BelongsTo\"," + - " \"related-link\": \"/aai/v12/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/Mobility/service-instances/service-instance/7e4f8130-5dee-47c4-8770-1abc5f5ded83\"," + + " \"related-link\": \"/aai/v12/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/Emanuel/service-instances/service-instance/7e4f8130-5dee-47c4-8770-1abc5f5ded83\"," + " \"relationship-data\": [" + " {" + " \"relationship-key\": \"customer.global-customer-id\"," + @@ -128,7 +127,7 @@ public class PresetAAIGetModelsByOwningEntity extends BaseAAIPreset { " }," + " {" + " \"relationship-key\": \"service-subscription.service-type\"," + - " \"relationship-value\": \"Mobility\"" + + " \"relationship-value\": \"Emanuel\"" + " }," + " {" + " \"relationship-key\": \"service-instance.service-instance-id\"," + @@ -145,7 +144,7 @@ public class PresetAAIGetModelsByOwningEntity extends BaseAAIPreset { " {" + " \"related-to\": \"service-instance\"," + " \"relationship-label\": \"org.onap.relationships.inventory.BelongsTo\"," + - " \"related-link\": \"/aai/v12/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/Mobility/service-instances/service-instance/d849b312-03f6-4fa3-a923-a469b850ec73\"," + + " \"related-link\": \"/aai/v12/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/Emanuel/service-instances/service-instance/d849b312-03f6-4fa3-a923-a469b850ec73\"," + " \"relationship-data\": [" + " {" + " \"relationship-key\": \"customer.global-customer-id\"," + @@ -153,7 +152,7 @@ public class PresetAAIGetModelsByOwningEntity extends BaseAAIPreset { " }," + " {" + " \"relationship-key\": \"service-subscription.service-type\"," + - " \"relationship-value\": \"Mobility\"" + + " \"relationship-value\": \"Emanuel\"" + " }," + " {" + " \"relationship-key\": \"service-instance.service-instance-id\"," + diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetModelsByProject.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetModelsByProject.java index 96372abb4..cb80fd6ce 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetModelsByProject.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetModelsByProject.java @@ -1,13 +1,12 @@ package org.onap.simulator.presetGenerator.presets.aai; import com.google.common.collect.ImmutableMap; -import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; -import org.springframework.http.HttpMethod; - import java.util.Collections; import java.util.List; import java.util.Map; import java.util.UUID; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; public class PresetAAIGetModelsByProject extends BaseAAIPreset { private String projectName; @@ -49,7 +48,7 @@ public class PresetAAIGetModelsByProject extends BaseAAIPreset { " {" + " \"related-to\": \"service-instance\"," + " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," + - " \"related-link\": \"/aai/v12/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/Mobility/service-instances/service-instance/3f826016-3ac9-4928-9561-beee75fd91d5\"," + + " \"related-link\": \"/aai/v12/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/Emanuel/service-instances/service-instance/3f826016-3ac9-4928-9561-beee75fd91d5\"," + " \"relationship-data\": [" + " {" + " \"relationship-key\": \"customer.global-customer-id\"," + @@ -57,7 +56,7 @@ public class PresetAAIGetModelsByProject extends BaseAAIPreset { " }," + " {" + " \"relationship-key\": \"service-subscription.service-type\"," + - " \"relationship-value\": \"Mobility\"" + + " \"relationship-value\": \"Emanuel\"" + " }," + " {" + " \"relationship-key\": \"service-instance.service-instance-id\"," + @@ -124,7 +123,7 @@ public class PresetAAIGetModelsByProject extends BaseAAIPreset { " {" + " \"related-to\": \"service-instance\"," + " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," + - " \"related-link\": \"/aai/v12/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/Mobility/service-instances/service-instance/ff2d9326-1ef5-4760-aba0-0eaf372ae675\"," + + " \"related-link\": \"/aai/v12/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/Emanuel/service-instances/service-instance/ff2d9326-1ef5-4760-aba0-0eaf372ae675\"," + " \"relationship-data\": [" + " {" + " \"relationship-key\": \"customer.global-customer-id\"," + @@ -132,7 +131,7 @@ public class PresetAAIGetModelsByProject extends BaseAAIPreset { " }," + " {" + " \"relationship-key\": \"service-subscription.service-type\"," + - " \"relationship-value\": \"Mobility\"" + + " \"relationship-value\": \"Emanuel\"" + " }," + " {" + " \"relationship-key\": \"service-instance.service-instance-id\"," + diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetMultipleVersion.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetMultipleVersion.java deleted file mode 100644 index a9c63196a..000000000 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetMultipleVersion.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.onap.simulator.presetGenerator.presets.aai; - -public class PresetAAIGetMultipleVersion extends BasePresetAAIGetVersion { - public String modelVersionId2; - public String modelVersionId3; - public PresetAAIGetMultipleVersion(String modelVersionId1, - String modelVersionId2, - String modelVersionId3, - String modelInvariantId) { - super( modelVersionId1, modelInvariantId); - this.modelVersionId2 = modelVersionId2; - this.modelVersionId3 = modelVersionId3; - } - public String getModelVersionId2() { - return modelVersionId2; - } - public String getModelVersionId3() { - return modelVersionId3; - } - - @Override - public Object getResponseBody() { - return "{\"results\": [" + - " {" + - " \"model\": {" + - " \"model-invariant-id\": \"" + getModelInvariantId() + "\"," + - " \"model-type\": \"resource\"," + - " \"resource-version\": \"1500138206526\"," + - " \"model-vers\": {" + - " \"model-ver\": [" + - " {" + - " \"model-version-id\": \"" + getModelVersionId1() + "\"," + - " \"model-name\": \"action-data\"," + - " \"model-version\": \"1.0\"," + - " \"model-description\": \"decontamination arm circus ammonia hump edge\"," + - " \"resource-version\": \"1500137463984\"" + - " }," + - " {" + - " \"model-version-id\": \"" + getModelVersionId3() + "\"," + - " \"model-name\": \"action-data\"," + - " \"model-version\": \"3.0\"," + - " \"model-description\": \"Non decontamination arm circus ammonia hump edge\"," + - " \"resource-version\": \"1500137463986\"" + - " }," + - " {" + - " \"model-version-id\": \"" + getModelVersionId2() + "\"," + - " \"model-name\": \"action-data\"," + - " \"model-version\": \"2.0\"," + - " \"model-description\": \"The oldest one\"," + - " \"resource-version\": \"1500137463980\"" + - " }" + - " ]" + - " }" + - " }" + - " }" + - " ]}"; - } - - }
\ No newline at end of file diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetNetworkCollectionDetails.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetNetworkCollectionDetails.java index e1fa74ec8..b99f58bda 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetNetworkCollectionDetails.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetNetworkCollectionDetails.java @@ -2,12 +2,11 @@ package org.onap.simulator.presetGenerator.presets.aai; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; -import org.springframework.http.HttpMethod; - import java.util.Collections; import java.util.List; import java.util.Map; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; public class PresetAAIGetNetworkCollectionDetails extends BaseAAIPreset { @@ -219,10 +218,11 @@ public class PresetAAIGetNetworkCollectionDetails extends BaseAAIPreset { " \"network-id\": \"l3network-id-rs804s\",\n" + " \"network-name\": \"oam-net\",\n" + " \"network-type\": \"Tenant_Layer_3\",\n" + - " \"network-role\": \"HngwProtectedOam.OAM\",\n" + + " \"network-role\": \"RosemaProtectedOam.OAM\",\n" + " \"network-technology\": \"Contrail\",\n" + " \"is-bound-to-vpn\": false,\n" + " \"resource-version\": \"1521662814627\",\n" + + " \"orchestration-status\": \"Created\",\n" + " \"is-provider-network\": false,\n" + " \"is-shared-network\": false,\n" + " \"is-external-network\": false,\n" + @@ -258,10 +258,11 @@ public class PresetAAIGetNetworkCollectionDetails extends BaseAAIPreset { " \"network-id\": \"l3network-id-3-rs804s\",\n" + " \"network-name\": \"oam-net\",\n" + " \"network-type\": \"Tenant_Layer_3\",\n" + - " \"network-role\": \"HngwProtectedOam.OAM\",\n" + + " \"network-role\": \"RosemaProtectedOam.OAM\",\n" + " \"network-technology\": \"Contrail\",\n" + " \"is-bound-to-vpn\": false,\n" + " \"resource-version\": \"1521662816043\",\n" + + " \"orchestration-status\": \"Created\",\n" + " \"is-provider-network\": false,\n" + " \"is-shared-network\": false,\n" + " \"is-external-network\": false,\n" + @@ -297,10 +298,11 @@ public class PresetAAIGetNetworkCollectionDetails extends BaseAAIPreset { " \"network-id\": \"l3network-id-2-rs804s\",\n" + " \"network-name\": \"oam-net\",\n" + " \"network-type\": \"Tenant_Layer_3\",\n" + - " \"network-role\": \"HngwProtectedOam.OAM\",\n" + + " \"network-role\": \"RosemaProtectedOam.OAM\",\n" + " \"network-technology\": \"Contrail\",\n" + " \"is-bound-to-vpn\": false,\n" + " \"resource-version\": \"1521662815304\",\n" + + " \"orchestration-status\": \"Created\",\n" + " \"is-provider-network\": false,\n" + " \"is-shared-network\": false,\n" + " \"is-external-network\": false,\n" + diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetNetworkCollectionDetailsInvalidRequest.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetNetworkCollectionDetailsInvalidRequest.java index d0e4baf60..0d447c2c2 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetNetworkCollectionDetailsInvalidRequest.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetNetworkCollectionDetailsInvalidRequest.java @@ -2,12 +2,11 @@ package org.onap.simulator.presetGenerator.presets.aai; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; -import org.springframework.http.HttpMethod; - import java.util.Collections; import java.util.List; import java.util.Map; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; public class PresetAAIGetNetworkCollectionDetailsInvalidRequest extends BaseAAIPreset { @@ -221,11 +220,12 @@ public class PresetAAIGetNetworkCollectionDetailsInvalidRequest extends BaseAAIP " \"network-id\": \"l3network-id-rs804s\",\n" + " \"network-name\": \"oam-net\",\n" + " \"network-type\": \"Tenant_Layer_3\",\n" + - " \"network-role\": \"HngwProtectedOam.OAM\",\n" + - " \"network-roles\": \"HngwProtectedOam.OAM\",\n" +//extra field + " \"network-role\": \"RosemaProtectedOam.OAM\",\n" + + " \"network-roles\": \"RosemaProtectedOam.OAM\",\n" +//extra field " \"network-technology\": \"Contrail\",\n" + " \"is-bound-to-vpn\": false,\n" + " \"resource-version\": \"1521662814627\",\n" + + " \"orchestration-status\": \"Created\",\n" + " \"is-provider-network\": false,\n" + " \"is-shared-network\": false,\n" + " \"is-external-network\": false,\n" + @@ -261,10 +261,11 @@ public class PresetAAIGetNetworkCollectionDetailsInvalidRequest extends BaseAAIP " \"network-id\": \"l3network-id-3-rs804s\",\n" + " \"network-name\": \"oam-net\",\n" + " \"network-type\": \"Tenant_Layer_3\",\n" + - " \"network-role\": \"HngwProtectedOam.OAM\",\n" + + " \"network-role\": \"RosemaProtectedOam.OAM\",\n" + " \"network-technology\": \"Contrail\",\n" + " \"is-bound-to-vpn\": false,\n" + " \"resource-version\": \"1521662816043\",\n" + + " \"orchestration-status\": \"Created\",\n" + " \"is-provider-network\": false,\n" + " \"is-shared-network\": false,\n" + " \"is-external-network\": false,\n" + @@ -300,10 +301,11 @@ public class PresetAAIGetNetworkCollectionDetailsInvalidRequest extends BaseAAIP " \"network-id\": \"l3network-id-2-rs804s\",\n" + " \"network-name\": \"oam-net\",\n" + " \"network-type\": \"Tenant_Layer_3\",\n" + - " \"network-role\": \"HngwProtectedOam.OAM\",\n" + + " \"network-role\": \"RosemaProtectedOam.OAM\",\n" + " \"network-technology\": \"Contrail\",\n" + " \"is-bound-to-vpn\": false,\n" + " \"resource-version\": \"1521662815304\",\n" + + " \"orchestration-status\": \"Created\",\n" + " \"is-provider-network\": false,\n" + " \"is-shared-network\": false,\n" + " \"is-external-network\": false,\n" + diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetNetworkCollectionDetailsRequiredMissing.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetNetworkCollectionDetailsRequiredMissing.java index c32a3b563..23b35d204 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetNetworkCollectionDetailsRequiredMissing.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetNetworkCollectionDetailsRequiredMissing.java @@ -2,12 +2,11 @@ package org.onap.simulator.presetGenerator.presets.aai; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; -import org.springframework.http.HttpMethod; - import java.util.Collections; import java.util.List; import java.util.Map; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; public class PresetAAIGetNetworkCollectionDetailsRequiredMissing extends BaseAAIPreset { @@ -218,7 +217,7 @@ public class PresetAAIGetNetworkCollectionDetailsRequiredMissing extends BaseAAI " \"network-id\": \"l3network-id-rs804s\",\n" + " \"network-name\": \"oam-net\",\n" + " \"network-type\": \"Tenant_Layer_3\",\n" + - " \"network-role\": \"HngwProtectedOam.OAM\",\n" + + " \"network-role\": \"RosemaProtectedOam.OAM\",\n" + " \"network-technology\": \"Contrail\",\n" + " \"is-bound-to-vpn\": false,\n" + " \"resource-version\": \"1521662814627\",\n" + @@ -257,7 +256,7 @@ public class PresetAAIGetNetworkCollectionDetailsRequiredMissing extends BaseAAI " \"network-id\": \"l3network-id-3-rs804s\",\n" + " \"network-name\": \"oam-net\",\n" + " \"network-type\": \"Tenant_Layer_3\",\n" + - " \"network-role\": \"HngwProtectedOam.OAM\",\n" + + " \"network-role\": \"RosemaProtectedOam.OAM\",\n" + " \"network-technology\": \"Contrail\",\n" + " \"is-bound-to-vpn\": false,\n" + " \"resource-version\": \"1521662816043\",\n" + @@ -296,7 +295,7 @@ public class PresetAAIGetNetworkCollectionDetailsRequiredMissing extends BaseAAI " \"network-id\": \"l3network-id-2-rs804s\",\n" + " \"network-name\": \"oam-net\",\n" + " \"network-type\": \"Tenant_Layer_3\",\n" + - " \"network-role\": \"HngwProtectedOam.OAM\",\n" + + " \"network-role\": \"RosemaProtectedOam.OAM\",\n" + " \"network-technology\": \"Contrail\",\n" + " \"is-bound-to-vpn\": false,\n" + " \"resource-version\": \"1521662815304\",\n" + diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetNetworkZones.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetNetworkZones.java index e8449b320..93f8ad8ab 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetNetworkZones.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetNetworkZones.java @@ -721,8 +721,8 @@ public class PresetAAIGetNetworkZones extends BaseAAIPreset { " \"zone-name\": \"QWERTYUI-NUM1\"" + " }," + " {" + - " \"zone-id\": \"MTN32\"," + - " \"zone-name\": \"MDTWNJ21-MTN32\"" + + " \"zone-id\": \"hvf32\"," + + " \"zone-name\": \"MDTWNJ21-hvf32\"" + " }," + " {" + " \"zone-id\": \"RTZ4\"," + @@ -773,8 +773,8 @@ public class PresetAAIGetNetworkZones extends BaseAAIPreset { " \"zone-name\": \"ATLSECIA-ABC12\"" + " }," + " {" + - " \"zone-id\": \"MTN20\"," + - " \"zone-name\": \"MDTWNJ21-MTN20\"" + + " \"zone-id\": \"hvf20\"," + + " \"zone-name\": \"MDTWNJ21-hvf20\"" + " }," + " {" + " \"zone-id\": \"ABC15\"," + diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetOneVersion.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetOneVersion.java deleted file mode 100644 index 74e2102f1..000000000 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetOneVersion.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.onap.simulator.presetGenerator.presets.aai; - -public class PresetAAIGetOneVersion extends BasePresetAAIGetVersion { - - public PresetAAIGetOneVersion(String modelVersionId1, - String modelInvariantId) { - super(modelVersionId1, modelInvariantId); - } - - @Override - public Object getResponseBody() { - return "{\"results\": [" + - " {" + - " \"model\": {" + - " \"model-invariant-id\": \"" + getModelInvariantId() + "\"," + - " \"model-type\": \"resource\"," + - " \"resource-version\": \"1500138206526\"," + - " \"model-vers\": {" + - " \"model-ver\": [" + - " {" + - " \"model-version-id\": \"" + getModelVersionId1() + "\"," + - " \"model-name\": \"action-data\"," + - " \"model-version\": \"1.0\"," + - " \"model-description\": \"decontamination arm circus ammonia hump edge\"," + - " \"resource-version\": \"1500137463984\"" + - " }" + - " ]" + - " }" + - " }" + - " }" + - " ]}"; - } -} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetPNFByRegionErrorPut.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetPNFByRegionErrorPut.java index d363619e5..0676217a1 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetPNFByRegionErrorPut.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetPNFByRegionErrorPut.java @@ -12,7 +12,7 @@ public class PresetAAIGetPNFByRegionErrorPut extends BaseAAIPreset { public Object getResponseBody() { return "{" + " \"start\": \"/business/customers/customer/e433710f-9217-458d-a79d-1c7aff376d89/service-subscriptions/service-subscription/VIRTUAL%20USP/service-instances?model-version-id=8a84e59b-45fe-4851-8ff1-34225a0b32c3&model-invariant-id=83b458fd-5dd3-419b-a9e3-7335814a0911\"," + - " \"query\": \"query/pnf-fromModel-byRegion?cloudRegionId=AAIAIC25&equipVendor=Cisco&equipModel=Nexus%203048-TP\"" + + " \"query\": \"query/pnf-fromModel-byRegion?cloudRegionId=JANET25&equipVendor=Cisco&equipModel=Nexus%203048-TP\"" + " }"; } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetPortMirroringSourcePorts.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetPortMirroringSourcePorts.java index a95df4592..fdb387d71 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetPortMirroringSourcePorts.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetPortMirroringSourcePorts.java @@ -1,12 +1,11 @@ package org.onap.simulator.presetGenerator.presets.aai; import com.google.common.collect.ImmutableMap; -import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; -import org.springframework.http.HttpMethod; - import java.util.Collections; import java.util.List; import java.util.Map; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; public class PresetAAIGetPortMirroringSourcePorts extends BaseAAIPreset { public PresetAAIGetPortMirroringSourcePorts(String configurationId, String interfaceId, String interfaceName, boolean isPortMirrored) { @@ -64,10 +63,10 @@ public class PresetAAIGetPortMirroringSourcePorts extends BaseAAIPreset { " {\n" + " \"id\": \"4876980240\",\n" + " \"node-type\": \"l-interface\",\n" + - " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\",\n" + + " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zolson5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\",\n" + " \"properties\": {\n" + " \"interface-name\": " + doubleQuoteIfNotNull(getInterfaceName()) + ",\n" + - " \"selflink\": \"https://network-aic.rdm5b.cci.att.com:9696/v2.0/ports/6de7bf87-6faa-4984-9492-18d1188b3d4a\",\n" + + " \"selflink\": \"https://netw.onap.org:9696/v2.0/ports/6de7bf87-6faa-4984-9492-18d1188b3d4a\",\n" + " \"interface-id\": " + doubleQuoteIfNotNull(getInterfaceId()) + ",\n" + " \"macaddr\": \"02:6d:e7:bf:87:6f\",\n" + " \"network-name\": \"APP-C-24595-D-T001-vprobe_int_pktmirror_net_1\",\n" + @@ -81,7 +80,7 @@ public class PresetAAIGetPortMirroringSourcePorts extends BaseAAIPreset { " \"id\": \"4999893128\",\n" + " \"relationship-label\": \"org.onap.relationships.inventory.BelongsTo\",\n" + " \"node-type\": \"l3-interface-ipv4-address-list\",\n" + - " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib/l3-interface-ipv4-address-list/107.244.46.254\"\n" + + " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zolson5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib/l3-interface-ipv4-address-list/107.244.46.254\"\n" + " },\n" + " {\n" + " \"id\": \"6150074384\",\n" + @@ -111,7 +110,7 @@ public class PresetAAIGetPortMirroringSourcePorts extends BaseAAIPreset { " \"id\": \"5491453960\",\n" + " \"relationship-label\": \"tosca.relationships.network.BindsTo\",\n" + " \"node-type\": \"vserver\",\n" + - " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a\"\n" + + " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a\"\n" + " }\n" + " ]\n" + " }\n" + diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetRelatedInstanceGroupsByVnfId.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetRelatedInstanceGroupsByVnfId.java index 97186c9da..da1a120b4 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetRelatedInstanceGroupsByVnfId.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetRelatedInstanceGroupsByVnfId.java @@ -1,12 +1,11 @@ package org.onap.simulator.presetGenerator.presets.aai; import com.google.common.collect.ImmutableMap; -import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; -import org.springframework.http.HttpMethod; - import java.util.Collections; import java.util.List; import java.util.Map; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; public class PresetAAIGetRelatedInstanceGroupsByVnfId extends BaseAAIPreset { @@ -47,7 +46,7 @@ public class PresetAAIGetRelatedInstanceGroupsByVnfId extends BaseAAIPreset { public Object getResponseBody() { return "{\n" + " \"vnf-id\": \"vnf-id-3\",\n" + - " \"vnf-name\": \"zmtn6nf-code-110\",\n" + + " \"vnf-name\": \"zhvf6nf-code-110\",\n" + " \"vnf-type\": \"vnf-type\",\n" + " \"prov-status\": \"NVTPROV\",\n" + " \"operational-status\": \"out-of-service-path\",\n" + @@ -106,15 +105,15 @@ public class PresetAAIGetRelatedInstanceGroupsByVnfId extends BaseAAIPreset { " {\n" + " \"related-to\": \"availability-zone\",\n" + " \"relationship-label\": \"org.onap.relationships.inventory.Uses\",\n" + - " \"related-link\": \"/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn6/availability-zones/availability-zone/AZ-MN02\",\n" + + " \"related-link\": \"/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/hvf6/availability-zones/availability-zone/AZ-MN02\",\n" + " \"relationship-data\": [\n" + " {\n" + " \"relationship-key\": \"cloud-region.cloud-owner\",\n" + - " \"relationship-value\": \"att-aic\"\n" + + " \"relationship-value\": \"irma-aic\"\n" + " },\n" + " {\n" + " \"relationship-key\": \"cloud-region.cloud-region-id\",\n" + - " \"relationship-value\": \"mtn6\"\n" + + " \"relationship-value\": \"hvf6\"\n" + " },\n" + " {\n" + " \"relationship-key\": \"availability-zone.availability-zone-name\",\n" + diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServiceInstancesByInvariantId.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServiceInstancesByInvariantId.java new file mode 100644 index 000000000..8f7b6d0fb --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServiceInstancesByInvariantId.java @@ -0,0 +1,90 @@ +package org.onap.simulator.presetGenerator.presets.aai; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Multimap; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class PresetAAIGetServiceInstancesByInvariantId extends BaseAAIPreset { + + private String globalCustomerId; + private String serviceType; + private String invariantId; + private Map<String, Multimap<String, String>> servicesWithRelationships; + + public PresetAAIGetServiceInstancesByInvariantId(String globalCustomerId, String serviceType, String invariantId, + Map<String, Multimap<String, String>> servicesWithRelationships) { + this.globalCustomerId = globalCustomerId; + this.serviceType = serviceType; + this.invariantId = invariantId; + this.servicesWithRelationships = servicesWithRelationships; + } + + @Override + public String getResponseBody() { + return "{" + + " \"service-instance\":[" + + servicesWithRelationships.entrySet().stream().map( + entry -> buildServiceInstance(entry.getKey(), entry.getValue()) + ).collect(Collectors.joining(",")) + + " ]" + + "}"; + } + + private String buildServiceInstance(String serviceInstanceId, Multimap<String, String> relationships) { + return " {" + + " \"service-instance-id\":\"" + serviceInstanceId + "\"," + + " \"service-instance-name\":\"service-instance-name\"," + + " \"service-instance-type\":\"service-instance-type\"," + + " \"service-instance-role\":\"service-instance-role\"," + + " \"model-invariant-id\":\"" + invariantId + "\"," + + " \"model-version-id\":\"7a6ee536-f052-46fa-aa7e-2fca9d674c44\"," + + " \"resource-version\":\"GARBAGE DATA\"," + + " \"orchestration-status\":\"GARBAGE DATA\"," + + " \"relationship-list\":{" + + " \"relationship\":[" + + relationships.entries().stream().map( + entry -> buildRelationship(entry.getKey(), entry.getValue()) + ).collect(Collectors.joining(",")) + + " ]" + + " }" + + " }"; + } + + private String buildRelationship(String relatedTo, final String relatedLink) { + return "" + + "{ " + + " \"related-to\": \"" + relatedTo + "\", " + + " \"relationship-label\": \"org.onap.relationships.inventory.ComposedOf\", " + + " \"related-link\": \"" + relatedLink + "\", " + + " \"relationship-data\": [" + + " { " + + " \"relationship-key\": \"GARBAGE DATA\", " + + " \"relationship-value\": \"GARBAGE DATA\" " + + " } " + + " ] " + + "}"; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return getRootPath() + "/business/customers/customer/" + + globalCustomerId + "/service-subscriptions/service-subscription/" + + serviceType + "/service-instances"; + } + + @Override + public Map<String, List> getQueryParams() { + return ImmutableMap.of("model-invariant-id", ImmutableList.of(invariantId)); + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServiceModelList.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServiceModelList.java deleted file mode 100644 index e99630639..000000000 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServiceModelList.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.onap.simulator.presetGenerator.presets.aai; - -public class PresetAAIGetServiceModelList extends BasePresetAAIGetVersion { - - public String modelInvariant2; - public String modelInvariant3; - public PresetAAIGetServiceModelList(String modelVersionId1, - String modelInvariantId1, String modelInvariant2, String modelInvariant3) { - super(modelVersionId1, modelInvariantId1); - this.modelInvariant2 = modelInvariant2; - this.modelInvariant3 = modelInvariant3; - } - - public String getModelInvariant2() { - return modelInvariant2; - } - - public void setModelInvariant2(String modelInvariant2) { - this.modelInvariant2 = modelInvariant2; - } - - public String getModelInvariant3() { - return modelInvariant3; - } - - public void setModelInvariant3(String modelInvariant3) { - this.modelInvariant3 = modelInvariant3; - } - - @Override - public Object getResponseBody() { - return "{\n" + - "\"results\": [\n" + - " {\"model\": { \n" + - " \"model-invariant-id\": \"" + getModelInvariantId() + "\"," + - " \"model-type\": \"service\",\n" + - " \"resource-version\": \"1515103312329\",\n" + - " \"model-vers\": {\"model-ver\": [\n" + - " {\n" + - " \"model-version-id\": \"" + getModelVersionId1() + "\"," + - " \"model-name\": \"AAAvIRC_mm779p_Service\",\n" + - " \"model-version\": \"1.0\",\n" + - " \"distribution-status\": \"DISTRIBUTION_COMPLETE_OK\",\n" + - " \"model-description\": \"tbd\",\n" + - " \"resource-version\": \"1516206395612\"\n" + - " }\n" + - " ]}\n" + - " }},\n" + - " {\"model\": { \n" + - " \"model-invariant-id\": \"" + getModelInvariant2() + "\"," + - " \"model-type\": \"service\",\n" + - " \"resource-version\": \"1515103312329\",\n" + - " \"model-vers\": {\"model-ver\": [\n" + - " {\n" + - " \"model-version-id\": \"1dae721c-a1ef-435f-b811-760c23f467bf\",\n" + - " \"model-name\": \"BBBvIRC_mm779p_Service\",\n" + - " \"model-version\": \"3.0\",\n" + - " \"model-description\": \"tbd\",\n" + - " \"resource-version\": \"1516025197086\"\n" + - " }\n" + - " ]}\n" + - " }},\n" + - " {\"model\": { \n" + - " \"model-invariant-id\": \"" + getModelInvariant3() + "\"," + - " \"model-type\": \"service\",\n" + - " \"resource-version\": \"1515103312329\",\n" + - " \"model-vers\": {\"model-ver\": [\n" + - "{\n" + - " \"model-version-id\": \"29236d45-e790-4c17-a115-1533cc09b7b1\",\n" + - " \"model-name\": \"CCCvIRC_mm779p_Service\",\n" + - " \"model-version\": \"4.0\",\n" + - " \"distribution-status\": \"DISTRIBUTION_COMPLETE_ERROR\",\n" + - " \"model-description\": \"tbd\",\n" + - " \"resource-version\": \"1517319724440\"\n" + - " }\n" + - " ]}\n" + - " }}\n" + - "]}\n"; - } -} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServicesGet.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServicesGet.java index 04cef06ad..615879e18 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServicesGet.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServicesGet.java @@ -29,18 +29,18 @@ public class PresetAAIGetServicesGet extends PresetAAIBaseGetServicesGet { " \"resource-version\":\"1494001980153\"" + " }," + " {" + - " \"service-id\":\"vRRaaS\"," + - " \"service-description\":\"vRRaaS\"," + + " \"service-id\":\"vTerrance\"," + + " \"service-description\":\"vTerrance\"," + " \"resource-version\":\"1484865266\"" + " }," + " {" + " \"service-id\":\"323d69d9-2efe-4r45-ay0a-89ea7ard4e6f\"," + - " \"service-description\":\"vSCP\"," + + " \"service-description\":\"vEsmeralda\"," + " \"resource-version\":\"1494001903012\"" + " }," + " {" + " \"service-id\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"," + - " \"service-description\":\"Mobility\"," + + " \"service-description\":\"Emanuel\"," + " \"resource-version\":\"1503954056794\"" + " }," + " {" + @@ -59,18 +59,18 @@ public class PresetAAIGetServicesGet extends PresetAAIBaseGetServicesGet { " \"resource-version\":\"1494001863930\"" + " }," + " {" + - " \"service-id\":\"vHNGWaas\"," + + " \"service-id\":\"vRosemarie\"," + " \"service-description\":\"HNGATEWAY\"," + " \"resource-version\":\"1501192849249\"" + " }," + " {" + " \"service-id\":\"vHNPaas\"," + - " \"service-description\":\"HNPORTAL\"," + + " \"service-description\":\"WILKINS\"," + " \"resource-version\":\"1501192982895\"" + " }," + " {" + " \"service-id\":\"e433710f-9217-458d-a79d-1c7aff376d89\"," + - " \"service-description\":\"VIRTUAL USP\"," + + " \"service-description\":\"TYLER SILVIA\"," + " \"resource-version\":\"1494001802638\"" + " }," + " {" + @@ -79,8 +79,8 @@ public class PresetAAIGetServicesGet extends PresetAAIBaseGetServicesGet { " \"resource-version\":\"1492533254036\"" + " }," + " {" + - " \"service-id\":\"VIPRaaS\"," + - " \"service-description\":\"vIPRaaS\"," + + " \"service-id\":\"vMuriel\"," + + " \"service-description\":\"vMuriel\"," + " \"resource-version\":\"1490910058887\"" + " }," + " {" + @@ -99,8 +99,8 @@ public class PresetAAIGetServicesGet extends PresetAAIBaseGetServicesGet { " \"resource-version\":\"1506361785997\"" + " }," + " {" + - " \"service-id\":\"vVIGaaS\"," + - " \"service-description\":\"vVIGaaS\"," + + " \"service-id\":\"vSalvatore\"," + + " \"service-description\":\"vSalvatore\"," + " \"resource-version\":\"1494001900545\"" + " }," + " {" + @@ -109,8 +109,8 @@ public class PresetAAIGetServicesGet extends PresetAAIBaseGetServicesGet { " \"resource-version\":\"1494001941772\"" + " }," + " {" + - " \"service-id\":\"vPEaaS\"," + - " \"service-description\":\"vPEaaS\"," + + " \"service-id\":\"vHubbard\"," + + " \"service-description\":\"vHubbard\"," + " \"resource-version\":\"1494001988229\"" + " }," + " {" + diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetSubDetailsGet.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetSubDetailsGet.java index 3033c027f..db41b9518 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetSubDetailsGet.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetSubDetailsGet.java @@ -1,13 +1,13 @@ package org.onap.simulator.presetGenerator.presets.aai; -import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; -import org.springframework.http.HttpMethod; +import static vid.automation.test.utils.ReadFile.loadResourceAsString; +import com.google.common.collect.ImmutableMap; import java.util.Collections; import java.util.List; import java.util.Map; - -import static vid.automation.test.utils.ReadFile.loadResourceAsString; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; public class PresetAAIGetSubDetailsGet extends BaseAAIPreset { private String subscriberId; @@ -15,14 +15,23 @@ public class PresetAAIGetSubDetailsGet extends BaseAAIPreset { private static final String baseResponseBody = loadResourceAsString("presets_templates/PresetAAIGetSubDetailsGet.json"); private static final String GLOBAL_CUSTOMER_ID = "GLOBAL_CUSTOMER_ID"; + private static final String ORCH_STATUS = "<ORCH_STATUS>"; public PresetAAIGetSubDetailsGet(String subscriberId) { this.subscriberId = subscriberId == null ? "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" : subscriberId; this.responseBody = baseResponseBody.replace(GLOBAL_CUSTOMER_ID, this.subscriberId); } - public void mapQueryParams(Map<String, List> map) { - map.put("depth", Collections.singletonList("2")); + public PresetAAIGetSubDetailsGet(String subscriberId, String orchStatus) { + this.subscriberId = subscriberId == null ? "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" : subscriberId; + this.responseBody = baseResponseBody.replace(GLOBAL_CUSTOMER_ID, this.subscriberId); + this.responseBody = this.responseBody.replace("\"subscriber-name\":\"Emanuel\"", "\"subscriber-name\":\"SILVIA ROBBINS\""); + this.responseBody = this.responseBody.replaceAll(ORCH_STATUS, orchStatus); + } + + @Override + public Map<String, List> getQueryParams() { + return ImmutableMap.of("depth", Collections.singletonList("2")); } @Override diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetSubDetailsGetSpecificService.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetSubDetailsGetSpecificService.java new file mode 100644 index 000000000..615c196a9 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetSubDetailsGetSpecificService.java @@ -0,0 +1,114 @@ +package org.onap.simulator.presetGenerator.presets.aai; + +import static vid.automation.test.infra.ModelInfo.serviceFabricSriovService; + +import com.google.common.collect.ImmutableMap; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; +import vid.automation.test.infra.ModelInfo; + +public class PresetAAIGetSubDetailsGetSpecificService extends BaseAAIPreset { + private String subscriberId; + private String subscriberName = "Emanuel"; + private String orchStatus; + + private String serviceInstanceId = "c187e9fe-40c3-4862-b73e-84ff056205f61234"; + private String serviceInstanceName = "test_fabric_config"; + private ModelInfo modelInfo = serviceFabricSriovService; + + public PresetAAIGetSubDetailsGetSpecificService(String subscriberId) { + this.subscriberId = subscriberId == null ? "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" : subscriberId; + } + + public PresetAAIGetSubDetailsGetSpecificService(String subscriberId, String subscriberName, String orchStatus, ModelInfo modelInfo, String serviceInstanceId) { + this(subscriberId); + this.subscriberName = subscriberName; + this.orchStatus = orchStatus; + this.modelInfo = modelInfo; + this.serviceInstanceId = serviceInstanceId; + } + + @Override + public Map<String, List> getQueryParams() { + return ImmutableMap.of("depth", Collections.singletonList("2")); + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return getRootPath() + "/business/customers/customer/" + getSubscriberId(); + } + + public String getSubscriberId() { + return subscriberId; + } + + @Override + public Object getResponseBody() { + return "{" + + " \"global-customer-id\":\""+this.subscriberId+"\"," + + " \"subscriber-name\":\""+this.subscriberName+"\"," + + " \"subscriber-type\":\"INFRA\"," + + " \"resource-version\":\"1494255056308\"," + + " \"service-subscriptions\":{" + + " \"service-subscription\":[" + + " {" + + " \"service-type\":\"vFlowLogic\"," + + " \"resource-version\":\"1501700976809\"," + + " \"service-instances\":{" + + " \"service-instance\":[" + + " {" + + " \"service-instance-id\":\"414db2d4-18d0-415e-aac2-f255b586cfb5\"," + + " \"service-instance-name\":\"vFlowLogic-vflf_080117\"," + + " \"persona-model-id\":null," + + " \"persona-model-version\":null," + + " \"resource-version\":\"1502391806301\"," + + " \"orchestration-status\":\"Active\"," + + " \"model-invariant-id\":\"64dbe153-48c6-4d6f-95e7-12ff4cce9871\"," + + " \"model-version-id\":\"4e8b6372-dea3-4028-81d0-16eba59c94fb\"" + + " }," + + " {" + + " \"service-instance-id\":\"769be44e-981a-4da8-af3b-ca5fa76b7fb1\"," + + " \"service-instance-name\":\"vFlowLogic-vflp_080117\"," + + " \"persona-model-id\":null," + + " \"persona-model-version\":null," + + " \"resource-version\":\"1501712783617\"," + + " \"orchestration-status\":\"Active\"," + + " \"model-invariant-id\":\"14a99b56-dfb6-4300-97e1-ef10198ec936\"," + + " \"model-version-id\":\"9c6eee3b-8bd6-4a01-8afc-39441b63ecc9\"" + + " }" + + " ]" + + " }," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"TYLER SILVIA\"," + + " \"resource-version\":\"1501700976809\"," + + " \"service-instances\":{" + + " \"service-instance\":[" + + " {" + + " \"service-instance-id\": \""+this.serviceInstanceId+"\"," + + " \"service-instance-name\": \""+this.serviceInstanceName+"\"," + + " \"model-invariant-id\": \""+this.modelInfo.modelInvariantId+"\"," + + " \"model-version-id\": \""+this.modelInfo.modelVersionId+"\"," + + " \"resource-version\": \"1500789244674\"," + + " \"orchestration-status\": \""+this.orchStatus+"\"" + + " }" + + " ]" + + " }," + + " \"is-permitted\":false" + + " }" + + " ]" + + " }" + + "}"; + } + +} + diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetSubDetailsWithoutInstancesGet.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetSubDetailsWithoutInstancesGet.java new file mode 100644 index 000000000..f6ce3e86d --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetSubDetailsWithoutInstancesGet.java @@ -0,0 +1,153 @@ +package org.onap.simulator.presetGenerator.presets.aai; + +import com.google.common.collect.ImmutableMap; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; + +public class PresetAAIGetSubDetailsWithoutInstancesGet extends BaseAAIPreset { + private String subscriberId; + private String subscriberName = "Emanuel"; + + + public PresetAAIGetSubDetailsWithoutInstancesGet(String subscriberId) { + this.subscriberId = subscriberId == null ? "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" : subscriberId; + } + + public PresetAAIGetSubDetailsWithoutInstancesGet(String subscriberId, boolean isSubscriberUspVoice) { + this(subscriberId); + if (isSubscriberUspVoice) { + this.subscriberName = "SILVIA ROBBINS"; + } + } + + @Override + public Map<String, List> getQueryParams() { + return ImmutableMap.of("depth", Collections.singletonList("1")); + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return getRootPath() + "/business/customers/customer/" + getSubscriberId(); + } + + public String getSubscriberId() { + return subscriberId; + } + + @Override + public Object getResponseBody() { + return "{" + + " \"global-customer-id\":\"" + subscriberId + "\"," + + " \"subscriber-name\":\" " + subscriberName + "\"," + + " \"subscriber-type\":\"INFRA\"," + + " \"resource-version\":\"1494255056308\"," + + " \"service-subscriptions\":{" + + " \"service-subscription\":[" + + " {" + + " \"service-type\":\"vFlowLogic\"," + + " \"resource-version\":\"1501700976809\"," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"TYLER SILVIA\"," + + " \"resource-version\":\"1501700976809\"," + + " \"is-permitted\":true" + + " }," + + " {" + + " \"service-type\":\"Emanuel\"," + + " \"resource-version\":\"1505402148533\"," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"vBNG\"," + + " \"resource-version\":\"1498068165053\"," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"vVoiceMail\"," + + " \"resource-version\":\"1494254889686\"," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"Kennedy\"," + + " \"resource-version\":\"1509369877126\"," + + " \"is-permitted\":true" + + " }," + + " {" + + " \"service-type\":\"vSEGW\"," + + " \"resource-version\":\"1494254851983\"," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"vVM\"," + + " \"resource-version\":\"1494255049530\"," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"vOTA\"," + + " \"resource-version\":\"1501692006937\"," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"vMME\"," + + " \"resource-version\":\"1497729820723\"," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"vMNS\"," + + " \"resource-version\":\"1509391084129\"," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"vEsmeralda\"," + + " \"resource-version\":\"1501532104695\"," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"VPMS\"," + + " \"resource-version\":\"1509738154248\"," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"vWINIFRED\"," + + " \"resource-version\":\"1498752217386\"," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"SSD\"," + + " \"resource-version\":\"1494254866295\"," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"vMOG\"," + + " \"resource-version\":\"1500675745252\"," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"FIRSTNET\"," + + " \"resource-version\":\"1509387060781\"," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"ACTIVE_CHARGE\"," + + " \"resource-version\":\"1494255101364\"," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"vHSS\"," + + " \"resource-version\":\"1494254877333\"," + + " \"is-permitted\":false" + + " }" + + " ]" + + " }" + + "}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetSubDetailsWithoutInstancesGetSpecificService.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetSubDetailsWithoutInstancesGetSpecificService.java new file mode 100644 index 000000000..62a587001 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetSubDetailsWithoutInstancesGetSpecificService.java @@ -0,0 +1,67 @@ +package org.onap.simulator.presetGenerator.presets.aai; + +import com.google.common.collect.ImmutableMap; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; + +public class PresetAAIGetSubDetailsWithoutInstancesGetSpecificService extends BaseAAIPreset { + private String subscriberId; + private String subscriberName = "Emanuel"; + + public PresetAAIGetSubDetailsWithoutInstancesGetSpecificService(String subscriberId) { + this.subscriberId = subscriberId == null ? "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" : subscriberId; + } + + public PresetAAIGetSubDetailsWithoutInstancesGetSpecificService(String subscriberId, String subscriberName) { + this(subscriberId); + this.subscriberName = subscriberName; + } + + @Override + public Map<String, List> getQueryParams() { + return ImmutableMap.of("depth", Collections.singletonList("1")); + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return getRootPath() + "/business/customers/customer/" + getSubscriberId(); + } + + public String getSubscriberId() { + return subscriberId; + } + + @Override + public Object getResponseBody() { + return "{" + + " \"global-customer-id\":\""+this.subscriberId+"\"," + + " \"subscriber-name\":\""+this.subscriberName+"\"," + + " \"subscriber-type\":\"INFRA\"," + + " \"resource-version\":\"1494255056308\"," + + " \"service-subscriptions\":{" + + " \"service-subscription\":[" + + " {" + + " \"service-type\":\"vFlowLogic\"," + + " \"resource-version\":\"1501700976809\"," + + " \"is-permitted\":false" + + " }," + + " {" + + " \"service-type\":\"TYLER SILVIA\"," + + " \"resource-version\":\"1501700976809\"," + + " \"is-permitted\":false" + + " }" + + " ]" + + " }" + + "}"; + } + +} + diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetSubscribersGet.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetSubscribersGet.java index b21e9de27..0517fd788 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetSubscribersGet.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetSubscribersGet.java @@ -3,14 +3,13 @@ package org.onap.simulator.presetGenerator.presets.aai; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; -import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; -import org.onap.simulator.presetGenerator.presets.model.Subscriber; -import org.springframework.http.HttpMethod; - import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.Map; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.onap.simulator.presetGenerator.presets.model.Subscriber; +import org.springframework.http.HttpMethod; public class PresetAAIGetSubscribersGet extends BaseAAIPreset { @@ -29,26 +28,26 @@ public class PresetAAIGetSubscribersGet extends BaseAAIPreset { String subscribersString = "" + "[ " + " { " + - " \"global-customer-id\":\"MSO_1610_ST\", " + - " \"subscriber-name\":\"MSO_1610_ST\", " + + " \"global-customer-id\":\"CAR_2020_ER\", " + + " \"subscriber-name\":\"CAR_2020_ER\", " + " \"subscriber-type\":\"INFRA\", " + " \"resource-version\":\"1494001902987\" " + " }, " + " { " + " \"global-customer-id\":\"21014aa2-526b-11e6-beb8-9e71128cae77\", " + - " \"subscriber-name\":\"PACKET CORE\", " + + " \"subscriber-name\":\"JULIO ERICKSON\", " + " \"subscriber-type\":\"INFRA\", " + " \"resource-version\":\"1494001776295\" " + " }, " + " { " + " \"global-customer-id\":\"DHV1707-TestSubscriber-2\", " + - " \"subscriber-name\":\"ICORE CORE\", " + + " \"subscriber-name\":\"DALE BRIDGES\", " + " \"subscriber-type\":\"INFRA\", " + " \"resource-version\":\"1498751754450\" " + " }, " + " { " + " \"global-customer-id\":\"DHV1707-TestSubscriber-1\", " + - " \"subscriber-name\":\"PACKET1 CORE\", " + + " \"subscriber-name\":\"LLOYD BRIDGES\", " + " \"subscriber-type\":\"INFRA\", " + " \"resource-version\":\"1498595633607\" " + " }, " + @@ -65,59 +64,90 @@ public class PresetAAIGetSubscribersGet extends BaseAAIPreset { " \"resource-version\":\"1494001970225\" " + " }, " + " { " + - " \"global-customer-id\":\"DHV1802-TestSub-PWT-102\", " + - " \"subscriber-name\":\"DHV1802-TestSub-PWT-102\", " + + " \"global-customer-id\":\"ERICA5779-TestSub-PWT-102\", " + + " \"subscriber-name\":\"ERICA5779-TestSub-PWT-102\", " + " \"subscriber-type\":\"INFRA\", " + " \"resource-version\":\"1508852495058\" " + " }, " + " { " + - " \"global-customer-id\":\"DHV1802-TestSub-PWT-101\", " + - " \"subscriber-name\":\"DHV1802-TestSub-PWT-101\", " + + " \"global-customer-id\":\"ERICA5779-TestSub-PWT-101\", " + + " \"subscriber-name\":\"ERICA5779-TestSub-PWT-101\", " + " \"subscriber-type\":\"INFRA\", " + " \"resource-version\":\"1508179953733\" " + " }, " + " { " + " \"global-customer-id\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\", " + - " \"subscriber-name\":\"Mobility\", " + + " \"subscriber-name\":\"Emanuel\", " + " \"subscriber-type\":\"INFRA\", " + " \"resource-version\":\"1494001894192\" " + " }, " + " { " + - " \"global-customer-id\":\"DHV1802-Subscriber-4\", " + - " \"subscriber-name\":\"DHV1802-Subscriber-5\", " + + " \"global-customer-id\":\"ERICA5779-Subscriber-4\", " + + " \"subscriber-name\":\"ERICA5779-Subscriber-5\", " + " \"subscriber-type\":\"INFRA\", " + " \"resource-version\":\"1509134064531\" " + " }, " + " { " + - " \"global-customer-id\":\"DHV1802-TestSub-PWT-103\", " + - " \"subscriber-name\":\"DHV1802-TestSub-PWT-103\", " + + " \"global-customer-id\":\"ERICA5779-TestSub-PWT-103\", " + + " \"subscriber-name\":\"ERICA5779-TestSub-PWT-103\", " + " \"subscriber-type\":\"INFRA\", " + " \"resource-version\":\"1509045503736\" " + " }, " + " { " + - " \"global-customer-id\":\"DHV1802-Subscriber-2\", " + - " \"subscriber-name\":\"DHV1802-Subscriber-2\", " + + " \"global-customer-id\":\"ERICA5779-Subscriber-2\", " + + " \"subscriber-name\":\"ERICA5779-Subscriber-2\", " + " \"subscriber-type\":\"INFRA\", " + " \"resource-version\":\"1509122065439\" " + " }, " + " { " + " \"global-customer-id\":\"e433710f-9217-458d-a79d-1c7aff376d89\", " + - " \"subscriber-name\":\"USP VOICE\", " + + " \"subscriber-name\":\"SILVIA ROBBINS\", " + " \"subscriber-type\":\"INFRA\", " + " \"resource-version\":\"1494001938080\" " + " }, " + " { " + - " \"global-customer-id\":\"DHV1802-Subscriber-3\", " + - " \"subscriber-name\":\"DHV1802-Subscriber-3\", " + + " \"global-customer-id\":\"ERICA5779-Subscriber-3\", " + + " \"subscriber-name\":\"ERICA5779-Subscriber-3\", " + " \"subscriber-type\":\"INFRA\", " + " \"resource-version\":\"1509122759407\" " + " }, " + " { " + " \"global-customer-id\":\"31739f3e-526b-11e6-beb8-9e71128cae77\", " + - " \"subscriber-name\":\"FIREWALL/MISC\", " + + " \"subscriber-name\":\"CRAIG/ROBERTS\", " + " \"subscriber-type\":\"INFRA\", " + " \"resource-version\":\"1494001772223\" " + - " } " + + " }, " + + " { " + + " \"global-customer-id\":\"global-customer-id\", " + + " \"subscriber-name\":\"global-customer-id\", " + + " \"subscriber-type\":\"INFRA\", " + + " \"resource-version\":\"1494001772226\", " + + " \"relationship-list\":{ " + + " \"relationship\":[ " + + " { " + + " \"related-to\":\"vpn-binding\", " + + " \"relationship-label\":\"org.onap.relationships.inventory.Uses\", " + + " \"related-link\":\"/aai/v14/network/vpn-bindings/vpn-binding/3e7834fb-a8e0-4243-a837-5352ccab4602\", " + + " \"relationship-data\":[ " + + " { " + + " \"relationship-key\":\"vpn-binding.vpn-id\", " + + " \"relationship-value\":\"3e7834fb-a8e0-4243-a837-5352ccab4602\" " + + " } " + + " ], " + + " \"related-to-property\":[ " + + " { " + + " \"property-key\":\"vpn-binding.vpn-name\", " + + " \"property-value\":\"LPPVPN\" " + + " }, " + + " { " + + " \"property-key\":\"vpn-binding.vpn-type\", " + + " \"property-value\":\"CUSTOMER\" " + + " } " + + " ] " + + " } " + + " ] " + + " } " + + " }" + " ] "; try { this.subscriberList = objectMapper.readValue(subscribersString, typeRef); diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetTenants.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetTenants.java index ed370cf15..638cc3911 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetTenants.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetTenants.java @@ -1,11 +1,28 @@ package org.onap.simulator.presetGenerator.presets.aai; +import static vid.automation.test.utils.ReadFile.loadResourceAsString; + import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; import org.springframework.http.HttpMethod; -import static vid.automation.test.utils.ReadFile.loadResourceAsString; - public class PresetAAIGetTenants extends BaseAAIPreset { + private final String subscriberId; + private final String serviceType; + private String responseBody; + + public PresetAAIGetTenants(String subscriberId, String serviceType, String responseBodyResource) { + this.subscriberId = subscriberId; + this.serviceType = serviceType; + this.responseBody = loadResourceAsString(responseBodyResource); + } + + public PresetAAIGetTenants() { + this( + "e433710f-9217-458d-a79d-1c7aff376d89", + "TYLER SILVIA", + "presets_templates/PresetAAIGetTenants.json" + ); + } @Override public Object getResponseBody() { @@ -19,9 +36,8 @@ public class PresetAAIGetTenants extends BaseAAIPreset { @Override public String getReqPath() { - return getRootPath() + "/business/customers/customer/e433710f-9217-458d-a79d-1c7aff376d89/service-subscriptions/service-subscription/VIRTUAL USP"; + return getRootPath() + "/business/customers/customer/" + this.subscriberId + "/service-subscriptions/service-subscription/" + this.serviceType; } - private String responseBody = loadResourceAsString("presets_templates/PresetAAIGetTenants.json"); } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetVfModulesByVnf.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetVfModulesByVnf.java new file mode 100644 index 000000000..798a02642 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetVfModulesByVnf.java @@ -0,0 +1,83 @@ +package org.onap.simulator.presetGenerator.presets.aai; + +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; + +public class PresetAAIGetVfModulesByVnf extends BaseAAIPreset { + private final String vnfInstanceId; + + public PresetAAIGetVfModulesByVnf(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return getRootPath() + "/network/generic-vnfs/generic-vnf/" + this.vnfInstanceId + "/vf-modules"; + } + + @Override + public Object getResponseBody() { + return "" + + "{" + + " \"vf-module\": [{" + + " \"vf-module-id\": \"2c1ca484-cbc2-408b-ab86-25a2c15ce280\"," + + " \"vf-module-name\": \"ss820f_0918_db\"," + + " \"orchestration-status\": \"deleted\"," + + " \"is-base-vf-module\": false," + + " \"in-maint\": true," + + " \"automated-assignment\": false," + + " \"resource-version\": \"1537396469591\"," + + " \"model-invariant-id\": \"09edc9ef-85d0-4b26-80de-1f569d49e750\"," + + " \"model-version-id\": \"522159d5-d6e0-4c2a-aa44-5a542a12a830\"," + + " \"model-customization-id\": \"55b1be94-671a-403e-a26c-667e9c47d091\"," + + " \"module-index\": 0," + + " \"relationship-list\": {" + + " \"relationship\": [{" + + " \"related-to\": \"vnfc\"," + + " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," + + " \"related-link\": \"/aai/v13/network/vnfcs/vnfc/ss820f_0918_refvnf_vnfinstancem002mmb001\"," + + " \"relationship-data\": [{" + + " \"relationship-key\": \"vnfc.vnfc-name\"," + + " \"relationship-value\": \"ss820f_0918_refvnf_vnfinstancem002mmb001\"" + + " }" + + " ]" + + " }" + + " ]" + + " }" + + " }, {" + + " \"vf-module-id\": \"3ef042c4-259f-45e0-9aba-0989bd8d1cc5\"," + + " \"vf-module-name\": \"ss820f_0918_base\"," + + " \"heat-stack-id\": \"\"," + + " \"orchestration-status\": \"Assigned\"," + + " \"is-base-vf-module\": true," + + " \"automated-assignment\": false," + + " \"resource-version\": \"1537310272044\"," + + " \"model-invariant-id\": \"1e463c9c-404d-4056-ba56-28fd102608de\"," + + " \"model-version-id\": \"dc229cd8-c132-4455-8517-5c1787c18b14\"," + + " \"model-customization-id\": \"8ad8670b-0541-4499-8101-275bbd0e8b6a\"," + + " \"module-index\": 0," + + " \"relationship-list\": {" + + " \"relationship\": [{" + + " \"related-to\": \"vnfc\"," + + " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," + + " \"related-link\": \"/aai/v13/network/vnfcs/vnfc/ss820f_0918_refvnf_vnfinstancem001mmb001\"," + + " \"relationship-data\": [{" + + " \"relationship-key\": \"vnfc.vnfc-name\"," + + " \"relationship-value\": \"ss820f_0918_refvnf_vnfinstancem001mmb001\"" + + " }" + + " ]" + + " }" + + " ]" + + " }" + + " }" + + " ]" + + "}"; + } + + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIModelsByInvariantIdGet.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIModelsByInvariantIdGet.java new file mode 100644 index 000000000..429d17647 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIModelsByInvariantIdGet.java @@ -0,0 +1,394 @@ +package org.onap.simulator.presetGenerator.presets.aai; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; + +import java.util.List; +import java.util.Map; + +import static java.util.stream.Collectors.joining; + +public class PresetAAIModelsByInvariantIdGet extends BaseAAIPreset { + private final ImmutableList<String> modelInvariantIds; + + public PresetAAIModelsByInvariantIdGet(ImmutableList<String> modelInvariantIds) { + this.modelInvariantIds = modelInvariantIds; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return getRootPath() + "/service-design-and-creation/models"; + } + + @Override + public Map<String, List> getQueryParams() { + return ImmutableMap.<String, List>builder() + .put("depth", ImmutableList.of("2")) + .put("model-invariant-id", modelInvariantIds) + .build(); + } + + @Override + public Object getResponseBody() { + // based on aai_get_model_by_2_invariant_ids.json + // should be refined to match input + return "" + + "{" + + " \"model\": [" + + modelInvariantIds.stream().map(modelInvariantId -> + " {" + + " \"model-invariant-id\": \""+modelInvariantId+"\"," + + " \"model-type\": \"resource\"," + + " \"resource-version\": \"1507472057666\"," + + " \"model-vers\": {" + + " \"model-ver\": [" + + " {" + + " \"model-version-id\": \"7a6ee536-f052-46fa-aa7e-2fca9d674c44\"," + + " \"model-name\": \"vf_vEPDG\"," + + " \"model-version\": \"2.0\"," + + " \"model-description\": \"vEPDG\"," + + " \"distribution-status\": \"DISTRIBUTION_COMPLETE_ERROR\"," + + " \"resource-version\": \"1507649620979\"," + + " \"model-elements\": {" + + " \"model-element\": [" + + " {" + + " \"model-element-uuid\": \"ccbc6dc9-58ad-4082-a81f-630114d99a70\"," + + " \"new-data-del-flag\": \"T\"," + + " \"cardinality\": \"unbounded\"," + + " \"resource-version\": \"1507649620982\"," + + " \"relationship-list\": {" + + " \"relationship\": [" + + " {" + + " \"related-to\": \"model-ver\"," + + " \"related-link\": \"/aai/v11/service-design-and-creation/models/model/acc6edd8-a8d4-4b93-afaa-0994068be14c/model-vers/model-ver/93a6166f-b3d5-4f06-b4ba-aed48d009ad9\"," + + " \"relationship-data\": [" + + " {" + + " \"relationship-key\": \"model.model-invariant-id\"," + + " \"relationship-value\": \"acc6edd8-a8d4-4b93-afaa-0994068be14c\"" + + " }," + + " {" + + " \"relationship-key\": \"model-ver.model-version-id\"," + + " \"relationship-value\": \"93a6166f-b3d5-4f06-b4ba-aed48d009ad9\"" + + " }" + + " ]," + + " \"related-to-property\": [" + + " {" + + " \"property-key\": \"model-ver.model-name\"," + + " \"property-value\": \"generic-vnf\"" + + " }" + + " ]" + + " }" + + " ]" + + " }" + + " }" + + " ]" + + " }," + + " \"relationship-list\": {" + + " \"relationship\": [" + + " {" + + " \"related-to\": \"model-element\"," + + " \"related-link\": \"/aai/v11/service-design-and-creation/models/model/d661b5fd-e0be-457e-a5ca-e345621af761/model-vers/model-ver/6019af4d-1902-47b1-a7ee-4609c198bf37/model-elements/model-element/8cf71918-6cce-4e01-8049-3f980f8f2b00/model-elements/model-element/4703eeb3-7200-4546-aff2-6e942ac0c0e1\"," + + " \"relationship-data\": [" + + " {" + + " \"relationship-key\": \"model.model-invariant-id\"," + + " \"relationship-value\": \"d661b5fd-e0be-457e-a5ca-e345621af761\"" + + " }," + + " {" + + " \"relationship-key\": \"model-ver.model-version-id\"," + + " \"relationship-value\": \"6019af4d-1902-47b1-a7ee-4609c198bf37\"" + + " }," + + " {" + + " \"relationship-key\": \"model-element.model-element-uuid\"," + + " \"relationship-value\": \"8cf71918-6cce-4e01-8049-3f980f8f2b00\"" + + " }," + + " {" + + " \"relationship-key\": \"model-element.model-element-uuid\"," + + " \"relationship-value\": \"4703eeb3-7200-4546-aff2-6e942ac0c0e1\"" + + " }" + + " ]" + + " }" + + " ]" + + " }" + + " }," + + " {" + + " \"model-version-id\": \"eb5f56bf-5855-4e61-bd00-3e19a953bf02\"," + + " \"model-name\": \"vf_vEPDG\"," + + " \"model-version\": \"1.0\"," + + " \"model-description\": \"vEPDG\"," + + " \"resource-version\": \"1507472057702\"," + + " \"model-elements\": {" + + " \"model-element\": [" + + " {" + + " \"model-element-uuid\": \"18881687-8dab-4ec8-ab65-ebf8f95a6599\"," + + " \"new-data-del-flag\": \"T\"," + + " \"cardinality\": \"unbounded\"," + + " \"resource-version\": \"1507472057707\"," + + " \"relationship-list\": {" + + " \"relationship\": [" + + " {" + + " \"related-to\": \"model-ver\"," + + " \"related-link\": \"/aai/v11/service-design-and-creation/models/model/acc6edd8-a8d4-4b93-afaa-0994068be14c/model-vers/model-ver/93a6166f-b3d5-4f06-b4ba-aed48d009ad9\"," + + " \"relationship-data\": [" + + " {" + + " \"relationship-key\": \"model.model-invariant-id\"," + + " \"relationship-value\": \"acc6edd8-a8d4-4b93-afaa-0994068be14c\"" + + " }," + + " {" + + " \"relationship-key\": \"model-ver.model-version-id\"," + + " \"relationship-value\": \"93a6166f-b3d5-4f06-b4ba-aed48d009ad9\"" + + " }" + + " ]," + + " \"related-to-property\": [" + + " {" + + " \"property-key\": \"model-ver.model-name\"," + + " \"property-value\": \"generic-vnf\"" + + " }" + + " ]" + + " }" + + " ]" + + " }" + + " }" + + " ]" + + " }," + + " \"relationship-list\": {" + + " \"relationship\": [" + + " {" + + " \"related-to\": \"model-element\"," + + " \"related-link\": \"/aai/v11/service-design-and-creation/models/model/d661b5fd-e0be-457e-a5ca-e345621af761/model-vers/model-ver/de6f879b-37a9-44a5-97ed-cd52cc14bc47/model-elements/model-element/7a074be4-fcf1-46a5-88ee-41a7c7a6faab/model-elements/model-element/72f0adb5-5294-46f7-8085-a8aee9cb5f49\"," + + " \"relationship-data\": [" + + " {" + + " \"relationship-key\": \"model.model-invariant-id\"," + + " \"relationship-value\": \"d661b5fd-e0be-457e-a5ca-e345621af761\"" + + " }," + + " {" + + " \"relationship-key\": \"model-ver.model-version-id\"," + + " \"relationship-value\": \"de6f879b-37a9-44a5-97ed-cd52cc14bc47\"" + + " }," + + " {" + + " \"relationship-key\": \"model-element.model-element-uuid\"," + + " \"relationship-value\": \"7a074be4-fcf1-46a5-88ee-41a7c7a6faab\"" + + " }," + + " {" + + " \"relationship-key\": \"model-element.model-element-uuid\"," + + " \"relationship-value\": \"72f0adb5-5294-46f7-8085-a8aee9cb5f49\"" + + " }" + + " ]" + + " }" + + " ]" + + " }" + + " }," + + " {" + + " \"model-version-id\": \"b7f2e8fb-ac71-4ea0-a801-06ef1479ea84\"," + + " \"model-name\": \"vf_vEPDG\"," + + " \"model-version\": \"4.0\"," + + " \"model-description\": \"vEPDG_Up\"," + + " \"resource-version\": \"1508954433176\"," + + " \"model-elements\": {" + + " \"model-element\": [" + + " {" + + " \"model-element-uuid\": \"4ed7025a-d37b-444f-8008-5c7c41d76d47\"," + + " \"new-data-del-flag\": \"T\"," + + " \"cardinality\": \"unbounded\"," + + " \"resource-version\": \"1508954433179\"," + + " \"relationship-list\": {" + + " \"relationship\": [" + + " {" + + " \"related-to\": \"model-ver\"," + + " \"related-link\": \"/aai/v11/service-design-and-creation/models/model/acc6edd8-a8d4-4b93-afaa-0994068be14c/model-vers/model-ver/93a6166f-b3d5-4f06-b4ba-aed48d009ad9\"," + + " \"relationship-data\": [" + + " {" + + " \"relationship-key\": \"model.model-invariant-id\"," + + " \"relationship-value\": \"acc6edd8-a8d4-4b93-afaa-0994068be14c\"" + + " }," + + " {" + + " \"relationship-key\": \"model-ver.model-version-id\"," + + " \"relationship-value\": \"93a6166f-b3d5-4f06-b4ba-aed48d009ad9\"" + + " }" + + " ]," + + " \"related-to-property\": [" + + " {" + + " \"property-key\": \"model-ver.model-name\"," + + " \"property-value\": \"generic-vnf\"" + + " }" + + " ]" + + " }" + + " ]" + + " }" + + " }" + + " ]" + + " }," + + " \"relationship-list\": {" + + " \"relationship\": [" + + " {" + + " \"related-to\": \"model-element\"," + + " \"related-link\": \"/aai/v11/service-design-and-creation/models/model/d661b5fd-e0be-457e-a5ca-e345621af761/model-vers/model-ver/0e3f3390-48dd-4640-aed7-0eb873d40a97/model-elements/model-element/106d11a5-2b8c-4586-a56d-ee387e822757/model-elements/model-element/3d7e724a-6f05-4111-8b22-78d024c53081\"," + + " \"relationship-data\": [" + + " {" + + " \"relationship-key\": \"model.model-invariant-id\"," + + " \"relationship-value\": \"d661b5fd-e0be-457e-a5ca-e345621af761\"" + + " }," + + " {" + + " \"relationship-key\": \"model-ver.model-version-id\"," + + " \"relationship-value\": \"0e3f3390-48dd-4640-aed7-0eb873d40a97\"" + + " }," + + " {" + + " \"relationship-key\": \"model-element.model-element-uuid\"," + + " \"relationship-value\": \"106d11a5-2b8c-4586-a56d-ee387e822757\"" + + " }," + + " {" + + " \"relationship-key\": \"model-element.model-element-uuid\"," + + " \"relationship-value\": \"3d7e724a-6f05-4111-8b22-78d024c53081\"" + + " }" + + " ]" + + " }" + + " ]" + + " }" + + " }," + + " {" + + " \"model-version-id\": \"4117a0b6-e234-467d-b5b9-fe2f68c8b0fc\"," + + " \"model-name\": \"Grouping Service for Test\"," + + " \"model-version\": \"1.0\"," + + " \"model-description\": \"vEPDG_Up\"," + + " \"resource-version\": \"1508954433176\"," + + " \"model-elements\": {" + + " \"model-element\": [" + + " {" + + " \"model-element-uuid\": \"4ed7025a-d37b-444f-8008-5c7c41d76d47\"," + + " \"new-data-del-flag\": \"T\"," + + " \"cardinality\": \"unbounded\"," + + " \"resource-version\": \"1508954433179\"," + + " \"relationship-list\": {" + + " \"relationship\": [" + + " {" + + " \"related-to\": \"model-ver\"," + + " \"related-link\": \"/aai/v11/service-design-and-creation/models/model/acc6edd8-a8d4-4b93-afaa-0994068be14c/model-vers/model-ver/93a6166f-b3d5-4f06-b4ba-aed48d009ad9\"," + + " \"relationship-data\": [" + + " {" + + " \"relationship-key\": \"model.model-invariant-id\"," + + " \"relationship-value\": \"acc6edd8-a8d4-4b93-afaa-0994068be14c\"" + + " }," + + " {" + + " \"relationship-key\": \"model-ver.model-version-id\"," + + " \"relationship-value\": \"93a6166f-b3d5-4f06-b4ba-aed48d009ad9\"" + + " }" + + " ]," + + " \"related-to-property\": [" + + " {" + + " \"property-key\": \"model-ver.model-name\"," + + " \"property-value\": \"generic-vnf\"" + + " }" + + " ]" + + " }" + + " ]" + + " }" + + " }" + + " ]" + + " }," + + " \"relationship-list\": {" + + " \"relationship\": [" + + " {" + + " \"related-to\": \"model-element\"," + + " \"related-link\": \"/aai/v11/service-design-and-creation/models/model/d661b5fd-e0be-457e-a5ca-e345621af761/model-vers/model-ver/0e3f3390-48dd-4640-aed7-0eb873d40a97/model-elements/model-element/106d11a5-2b8c-4586-a56d-ee387e822757/model-elements/model-element/3d7e724a-6f05-4111-8b22-78d024c53081\"," + + " \"relationship-data\": [" + + " {" + + " \"relationship-key\": \"model.model-invariant-id\"," + + " \"relationship-value\": \"d661b5fd-e0be-457e-a5ca-e345621af761\"" + + " }," + + " {" + + " \"relationship-key\": \"model-ver.model-version-id\"," + + " \"relationship-value\": \"0e3f3390-48dd-4640-aed7-0eb873d40a97\"" + + " }," + + " {" + + " \"relationship-key\": \"model-element.model-element-uuid\"," + + " \"relationship-value\": \"106d11a5-2b8c-4586-a56d-ee387e822757\"" + + " }," + + " {" + + " \"relationship-key\": \"model-element.model-element-uuid\"," + + " \"relationship-value\": \"3d7e724a-6f05-4111-8b22-78d024c53081\"" + + " }" + + " ]" + + " }" + + " ]" + + " }" + + " }," + + " {" + + " \"model-version-id\": \"6e59c5de-f052-46fa-aa7e-2fca9d674c44\"," + + " \"model-name\": \"vf_vEPDG\"," + + " \"model-version\": \"5.0\"," + + " \"model-description\": \"vEPDG_Up\"," + + " \"resource-version\": \"1509570916147\"," + + " \"model-elements\": {" + + " \"model-element\": [" + + " {" + + " \"model-element-uuid\": \"49899999-076d-456b-915c-078d1b2a05b3\"," + + " \"new-data-del-flag\": \"T\"," + + " \"cardinality\": \"unbounded\"," + + " \"resource-version\": \"1509570916150\"," + + " \"relationship-list\": {" + + " \"relationship\": [" + + " {" + + " \"related-to\": \"model-ver\"," + + " \"related-link\": \"/aai/v11/service-design-and-creation/models/model/acc6edd8-a8d4-4b93-afaa-0994068be14c/model-vers/model-ver/93a6166f-b3d5-4f06-b4ba-aed48d009ad9\"," + + " \"relationship-data\": [" + + " {" + + " \"relationship-key\": \"model.model-invariant-id\"," + + " \"relationship-value\": \"acc6edd8-a8d4-4b93-afaa-0994068be14c\"" + + " }," + + " {" + + " \"relationship-key\": \"model-ver.model-version-id\"," + + " \"relationship-value\": \"93a6166f-b3d5-4f06-b4ba-aed48d009ad9\"" + + " }" + + " ]," + + " \"related-to-property\": [" + + " {" + + " \"property-key\": \"model-ver.model-name\"," + + " \"property-value\": \"generic-vnf\"" + + " }" + + " ]" + + " }" + + " ]" + + " }" + + " }" + + " ]" + + " }," + + " \"relationship-list\": {" + + " \"relationship\": [" + + " {" + + " \"related-to\": \"model-element\"," + + " \"related-link\": \"/aai/v11/service-design-and-creation/models/model/d661b5fd-e0be-457e-a5ca-e345621af761/model-vers/model-ver/03655348-0148-4482-b0b7-a5de71ab6264/model-elements/model-element/e97f008f-fc19-4b6e-8842-e54ec6eafb6e/model-elements/model-element/cfc574f2-6869-41d3-bfae-42b54b711568\"," + + " \"relationship-data\": [" + + " {" + + " \"relationship-key\": \"model.model-invariant-id\"," + + " \"relationship-value\": \"d661b5fd-e0be-457e-a5ca-e345621af761\"" + + " }," + + " {" + + " \"relationship-key\": \"model-ver.model-version-id\"," + + " \"relationship-value\": \"03655348-0148-4482-b0b7-a5de71ab6264\"" + + " }," + + " {" + + " \"relationship-key\": \"model-element.model-element-uuid\"," + + " \"relationship-value\": \"e97f008f-fc19-4b6e-8842-e54ec6eafb6e\"" + + " }," + + " {" + + " \"relationship-key\": \"model-element.model-element-uuid\"," + + " \"relationship-value\": \"cfc574f2-6869-41d3-bfae-42b54b711568\"" + + " }" + + " ]" + + " }" + + " ]" + + " }" + + " }" + + " ]" + + " }" + + " }").collect(joining(", ")) + + " ]" + + " }"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIPostNamedQueryForViewEdit.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIPostNamedQueryForViewEdit.java index e098a576d..0d143b50c 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIPostNamedQueryForViewEdit.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIPostNamedQueryForViewEdit.java @@ -6,15 +6,20 @@ import org.springframework.http.HttpMethod; public class PresetAAIPostNamedQueryForViewEdit extends BaseAAIPreset { private final String serviceInstanceId; - private final boolean hasConfigurationInstance; + private final boolean hasProxyConfigurationInstance; + private final boolean hasFabricConfigurationInstance; + private String serviceInstanceName; + public static final String DEFAULT_SERVICE_INSTANCE_NAME = "test_sssdad"; - public PresetAAIPostNamedQueryForViewEdit(String serviceInstanceId) { - this(serviceInstanceId, true); + public PresetAAIPostNamedQueryForViewEdit(String serviceInstanceId, boolean hasProxyConfigurationInstance, boolean hasFabricConfigurationInstance) { + this(serviceInstanceId, DEFAULT_SERVICE_INSTANCE_NAME, hasProxyConfigurationInstance, hasFabricConfigurationInstance); } - public PresetAAIPostNamedQueryForViewEdit(String serviceInstanceId, boolean hasConfigurationInstance) { + public PresetAAIPostNamedQueryForViewEdit(String serviceInstanceId, String serviceInstanceName, boolean hasProxyConfigurationInstance, boolean hasFabricConfigurationInstance) { this.serviceInstanceId = serviceInstanceId; - this.hasConfigurationInstance = hasConfigurationInstance; + this.serviceInstanceName = serviceInstanceName; + this.hasProxyConfigurationInstance = hasProxyConfigurationInstance; + this.hasFabricConfigurationInstance = hasFabricConfigurationInstance; } // inspired by @@ -44,7 +49,7 @@ public class PresetAAIPostNamedQueryForViewEdit extends BaseAAIPreset { " \"service-instance-id\": \"" + serviceInstanceId + "\"" + " }," + " \"service-subscription\": {" + - " \"service-type\": \"VIRTUAL USP\"" + + " \"service-type\": \"TYLER SILVIA\"" + " }" + " }" + " ]" + @@ -65,10 +70,10 @@ public class PresetAAIPostNamedQueryForViewEdit extends BaseAAIPreset { " \"model-name\": \"0eOHz2Yh8WJcBYzKy079\"," + " \"service-instance\": {" + " \"service-instance-id\": \"" + serviceInstanceId + "\"," + - " \"service-instance-name\": \"test_sssdad\"" + + " \"service-instance-name\": \"" + serviceInstanceName + "\"" + " }," + " \"extra-properties\": {}"; - if(hasConfigurationInstance) { + if(hasProxyConfigurationInstance) { response += "," + " \"inventory-response-items\": {" + " \"inventory-response-item\": [{" + @@ -92,6 +97,29 @@ public class PresetAAIPostNamedQueryForViewEdit extends BaseAAIPreset { " ]" + " }"; } + else if(hasFabricConfigurationInstance) { + response += "," + + " \"inventory-response-items\": {" + + " \"inventory-response-item\": [{" + + " \"model-name\": \"Fabric-Configuration-Instance\"," + + " \"configuration\": {" + + " \"configuration-id\": \"1234-fabric-config-LB1113\"," + + " \"configuration-name\": \"dummy_instance\"," + + " \"configuration-type\": \"fabric-configuration-type-1234\"," + + " \"configuration-sub-type\": \"fabric-configuration-sub-type-1234\"," + + " \"model-invariant-id\": \"model-invariant-id-1234\"," + + " \"model-version-id\": \"model-version-id-1234\"," + + " \"orchestration-status\": \"Assigned\"," + + " \"operational-status\": \"\"," + + " \"configuration-selflink\": \"\"," + + " \"model-customization-id\": \"model-customization-id-1234\"," + + " \"resource-version\": \"1504038855716\"" + + " }," + + " \"extra-properties\": {}" + + " }" + + " ]" + + " }"; + } response += " }" + " ]" + "}"; diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAISearchNodeQueryEmptyResult.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAISearchNodeQueryEmptyResult.java deleted file mode 100644 index f5ab2d1f7..000000000 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAISearchNodeQueryEmptyResult.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.onap.simulator.presetGenerator.presets.aai; - -public class PresetAAISearchNodeQueryEmptyResult extends PresetAAIBaseSearchNodeQuery { - - @Override - public Object getResponseBody() { - return "{}"; - } - - @Override - public int getResponseCode() { - return 200; - } -} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAISearchNodeQueryNonEmptyResult.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAISearchNodeQueryNonEmptyResult.java new file mode 100644 index 000000000..29e7d5092 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAISearchNodeQueryNonEmptyResult.java @@ -0,0 +1,46 @@ +package org.onap.simulator.presetGenerator.presets.aai; + +import com.google.common.collect.ImmutableMap; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public class PresetAAISearchNodeQueryNonEmptyResult extends PresetAAIBaseSearchNodeQuery { + + private final String type; + private final String name; + + public PresetAAISearchNodeQueryNonEmptyResult(String type, String name) { + this.type = type; + this.name = name; + } + + @Override + public Object getResponseBody() { + return "{ \"something\": [] }"; + } + + @Override + public int getResponseCode() { + return 200; + } + + @Override + public String getReqPath() { + return getRootPath() + "/nodes/" + searchPath(); + } + + @Override + public Map<String, List> getQueryParams() { + return ImmutableMap.of(searchKey(), Collections.singletonList(name)); + } + + private String searchPath() { + return type + "s"; + } + + private String searchKey() { + return type + "-name"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIServiceDesignAndCreationPut.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIServiceDesignAndCreationPut.java index 6a97e1159..180685282 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIServiceDesignAndCreationPut.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIServiceDesignAndCreationPut.java @@ -4,40 +4,34 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; import org.springframework.http.HttpMethod; +import vid.automation.test.infra.ModelInfo; +import vid.automation.test.test.BrowseASDCTest; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import static vid.automation.test.infra.ModelInfo.ModelInfoWithMultipleVersions.modelInfoWithMultipleVersions; + public class PresetAAIServiceDesignAndCreationPut extends BaseAAIPreset { public PresetAAIServiceDesignAndCreationPut(boolean emptyList) { - serviceModelIdentifiers = ImmutableList.of(); + modelInfos = ImmutableList.of(); this.emptyList = emptyList; } - public PresetAAIServiceDesignAndCreationPut(String modelVersionId, String modelInvariantId) { - serviceModelIdentifiers = ImmutableList.of(new ServiceModelIdentifiers(modelVersionId, modelInvariantId)); - } - public PresetAAIServiceDesignAndCreationPut(List<ServiceModelIdentifiers> serviceModelIdentifiers) { - this.serviceModelIdentifiers = serviceModelIdentifiers; - } + private List<ModelInfo> modelInfos; + boolean emptyList; - public static class ServiceModelIdentifiers { - public final String modelVersionId; - public final String modelInvariantId; - public ServiceModelIdentifiers(String modelVersionId, String modelInvariantId) { - this.modelVersionId = modelVersionId; - this.modelInvariantId = modelInvariantId; - } + //Constructor that use the super set of model infos as response + //all test should be migrated to use this constructor + public PresetAAIServiceDesignAndCreationPut() { + this.modelInfos = ModelInfo.superSetOfModelInfos; } - private List<ServiceModelIdentifiers> serviceModelIdentifiers; - boolean emptyList; - @Override public HttpMethod getReqMethod() { return HttpMethod.PUT; @@ -62,16 +56,16 @@ public class PresetAAIServiceDesignAndCreationPut extends BaseAAIPreset { private String presetModels() { return - serviceModelIdentifiers.stream().map(identifiers -> + modelInfos.stream().map(modelInfo -> " {" + " \"model\": {" + - " \"model-invariant-id\": \"" + identifiers.modelInvariantId + "\"," + + " \"model-invariant-id\": \"" + modelInfo.modelInvariantId + "\"," + " \"model-type\": \"resource\"," + " \"resource-version\": \"1500138206526\"," + " \"model-vers\": {" + " \"model-ver\": [" + " {" + - " \"model-version-id\": \"" + identifiers.modelVersionId + "\"," + + " \"model-version-id\": \"" + modelInfo.modelVersionId + "\"," + " \"model-name\": \"action-data\"," + " \"model-version\": \"1.0\"," + " \"model-description\": \"lustre settler sideways volcanic eight cellular\"," + @@ -112,6 +106,89 @@ public class PresetAAIServiceDesignAndCreationPut extends BaseAAIPreset { } + private String serviceWithMultipleVersions() { + return + " {" + + " \"model\": {" + + " \"model-invariant-id\": \"" + modelInfoWithMultipleVersions.modelInvariantId + "\"," + + " \"model-type\": \"resource\"," + + " \"resource-version\": \"1500138206526\"," + + " \"model-vers\": {" + + " \"model-ver\": [" + + " {" + + " \"model-version-id\": \"" + modelInfoWithMultipleVersions.modelVersionId1 + "\"," + + " \"model-name\": \""+modelInfoWithMultipleVersions.modelName+"\"," + + " \"model-version\": \"1.0\"," + + " \"model-description\": \"decontamination arm circus ammonia hump edge\"," + + " \"resource-version\": \"1500137463984\"" + + " }," + + " {" + + " \"model-version-id\": \"" + modelInfoWithMultipleVersions.modelVersionId3 + "\"," + + " \"model-name\": \""+modelInfoWithMultipleVersions.modelName+"\"," + + " \"model-version\": \"3.0\"," + + " \"model-description\": \"Non decontamination arm circus ammonia hump edge\"," + + " \"resource-version\": \"1500137463986\"" + + " }," + + " {" + + " \"model-version-id\": \"" + modelInfoWithMultipleVersions.modelVersionId2 + "\"," + + " \"model-name\": \""+modelInfoWithMultipleVersions.modelName+"\"," + + " \"model-version\": \"2.0\"," + + " \"model-description\": \"The oldest one\"," + + " \"resource-version\": \"1500137463980\"" + + " }" + + " ]" + + " }" + + " }" + + " }," ; + } + + public String modelsForBrowseSDCServiceModelListCheckAAIResponse() { + return " {\"model\": { " + + " \"model-invariant-id\": \"" + BrowseASDCTest.modelInvariantUUID1 + "\"," + + " \"model-type\": \"service\"," + + " \"resource-version\": \"1515103312329\"," + + " \"model-vers\": {\"model-ver\": [" + + " {" + + " \"model-version-id\": \"" + BrowseASDCTest.modelUuid + "\"," + + " \"model-name\": \"CheckAAIResponse_AAAvIRC_mm779p_Service\"," + + " \"model-version\": \"1.0\"," + + " \"distribution-status\": \"DISTRIBUTION_COMPLETE_OK\"," + + " \"model-description\": \"tbd\"," + + " \"resource-version\": \"1516206395612\"" + + " }" + + " ]}" + + " }}," + + " {\"model\": { " + + " \"model-invariant-id\": \"" + BrowseASDCTest.modelInvariantUUID2 + "\"," + + " \"model-type\": \"service\"," + + " \"resource-version\": \"1515103312329\"," + + " \"model-vers\": {\"model-ver\": [" + + " {" + + " \"model-version-id\": \"1dae721c-a1ef-435f-b811-760c23f467bf\"," + + " \"model-name\": \"CheckAAIResponse_BBBvIRC_mm779p_Service\"," + + " \"model-version\": \"3.0\"," + + " \"model-description\": \"tbd\"," + + " \"resource-version\": \"1516025197086\"" + + " }" + + " ]}" + + " }}," + + " {\"model\": { " + + " \"model-invariant-id\": \"" + BrowseASDCTest.modelInvariantUUID3 + "\"," + + " \"model-type\": \"service\"," + + " \"resource-version\": \"1515103312329\"," + + " \"model-vers\": {\"model-ver\": [" + + " {" + + " \"model-version-id\": \"29236d45-e790-4c17-a115-1533cc09b7b1\"," + + " \"model-name\": \"CheckAAIResponse_CCCvIRC_mm779p_Service\"," + + " \"model-version\": \"4.0\"," + + " \"distribution-status\": \"DISTRIBUTION_COMPLETE_ERROR\"," + + " \"model-description\": \"tbd\"," + + " \"resource-version\": \"1517319724440\"" + + " }" + + " ]}" + + " }},"; + } + @Override public Object getResponseBody() { if(emptyList) { @@ -119,6 +196,8 @@ public class PresetAAIServiceDesignAndCreationPut extends BaseAAIPreset { } return "{\"results\": [" + presetModels()+ + serviceWithMultipleVersions() + + modelsForBrowseSDCServiceModelListCheckAAIResponse() + " {" + " \"model\": {" + " \"model-invariant-id\": \"00beb8f9-6d39-452f-816d-c709b9cbb87d\"," + diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIStandardQueryGet.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIStandardQueryGet.java new file mode 100644 index 000000000..13ee91e2b --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIStandardQueryGet.java @@ -0,0 +1,239 @@ +package org.onap.simulator.presetGenerator.presets.aai; + +import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; +import static org.apache.commons.text.StringEscapeUtils.escapeJson; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.Multimap; +import java.util.UUID; +import java.util.stream.Collectors; +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.text.StrSubstitutor; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; + +public class PresetAAIStandardQueryGet extends BaseAAIPreset { + private final String instanceId; + private final String instanceName; + private final String instanceType; + private final String instanceRole; + private final String additionalProperties; + private final String uri; + private final String typeInResponse; + private final Multimap<String, String> relationshipsUris; + + private PresetAAIStandardQueryGet(String typeInResponse, String instanceId, String instanceName, String instanceType, String instanceRole, String uri, Multimap<String, String> relationshipsUris, String additionalProperties) { + this.instanceId = defaultIfNull(instanceId, randomUUID()); + this.instanceName = defaultIfNull(instanceName, randomAlphanumeric()); + this.instanceType = defaultIfNull(instanceType, randomAlphanumeric()); + this.instanceRole = defaultIfNull(instanceRole, randomAlphanumeric()); + this.uri = uri; + this.typeInResponse = typeInResponse; + this.additionalProperties = additionalProperties; + this.relationshipsUris = relationshipsUris; + } + + private PresetAAIStandardQueryGet(String typeInResponse, String instanceId, String uri, Multimap<String, String> relationshipsUris, String additionalProperties) { + this(typeInResponse, instanceId, randomAlphanumeric(), randomAlphanumeric(), randomAlphanumeric(), uri, relationshipsUris, additionalProperties); + } + + public static PresetAAIStandardQueryGet ofServiceInstance(String instanceId, final String modelVersionId, final String modelInvariantId, String subscriberId, String serviceType, Multimap<String, String> relationshipsUris) { + return new PresetAAIStandardQueryGet( + "service-instance", instanceId, + new StrSubstitutor(ImmutableMap.of( + "global-customer-id", subscriberId, + "service-type", serviceType, + "service-instance-id", instanceId + )).replace("" + + "/business/customers/customer/${global-customer-id}" + + "/service-subscriptions/service-subscription/${service-type}" + + "/service-instances/service-instance/${service-instance-id}"), + relationshipsUris, "" + + "\"model-invariant-id\": \"" + modelInvariantId + "\", " + + "\"model-version-id\": \"" + modelVersionId + "\", " + + "\"resource-version\": \"GARBAGE DATA\", " + + "\"orchestration-status\": \"GARBAGE DATA\", " + ); + } + + public static PresetAAIStandardQueryGet ofInstanceGroup(String groupType, String groupRole, Multimap<String, String> relationshipsUris) { + final String instanceId = randomUUID(); + return new PresetAAIStandardQueryGet( + "instance-group", instanceId, randomAlphanumeric(), groupType, groupRole, + "/network/instance-groups/instance-group/" + instanceId, + relationshipsUris, "" + + " \"id\": \"" + instanceId + "\"," + + " \"model-invariant-id\": \"4bb2e27e-ddab-4790-9c6d-1f731bc14a45\"," + + " \"model-version-id\": \"daeb6568-cef8-417f-9075-ed259ce59f48\"," + + " \"description\": \"vTSBC Customer Landing Network Collection Desc\"," + + " \"resource-version\": \"1536169790853\"," + + " \"instance-group-function\": \"vTSBC Customer Landing Network Collection\"," + ); + } + + public static PresetAAIStandardQueryGet ofVnf(String instanceId, Multimap<String, String> relationshipsUris) { + return ofVnf(instanceId, "vnf-instance-model-version-id", "vnf-instance-model-customization-id", "", relationshipsUris); + } + + public static PresetAAIStandardQueryGet ofVnf(String instanceId, String modelVersionId,String modelCustomizationId, String additionalProperties, Multimap<String, String> relationshipsUris) { + return new PresetAAIStandardQueryGet( + "vnf", instanceId, + "/network/generic-vnfs/generic-vnf/" + instanceId, + relationshipsUris, additionalProperties + + "\"model-invariant-id\": \"vnf-instance-model-invariant-id\", " + + "\"model-customization-id\": \"" + modelCustomizationId + "\", "+ + "\"model-version-id\": \"" + modelVersionId + "\", " + ); + } + + public static PresetAAIStandardQueryGet ofRelatedVnf(String instanceId, String modelVersionId, String additionalProperties, Multimap<String, String> relationshipsUris) { + return new PresetAAIStandardQueryGet( + "vnf", instanceId, + "/network/generic-vnfs/generic-vnf/" + instanceId, + relationshipsUris, additionalProperties + + "\"model-invariant-id\": \"vnf-instance-model-invariant-id\", " + + "\"model-version-id\": \"" + modelVersionId + "\", " + ); + } + + private static String randomAlphanumeric() { + return RandomStringUtils.randomAlphanumeric(17); + } + + private static String randomUUID() { + return UUID.randomUUID().toString(); + } + + public static PresetAAIStandardQueryGet ofL3Network(String instanceType, String orchStatus, Multimap<String, String> relationshipsUris) { + return ofL3Network(randomUUID(), randomAlphanumeric(), instanceType, relationshipsUris, orchStatus, "prov", "network-instance-model-version-id", "network-instance-model-customization-id"); + } + + public static PresetAAIStandardQueryGet ofL3Network(String instanceType, String orchStatus, String provStatus, String modelVersionId, String modelCustomizationId,Multimap<String, String> relationshipsUris) { + return ofL3Network(randomUUID(), randomAlphanumeric(), instanceType, relationshipsUris, orchStatus, provStatus, modelVersionId, modelCustomizationId); + } + + public static PresetAAIStandardQueryGet ofL3Network(String instanceId, String instanceName, String instanceType, Multimap<String, String> relationshipsUris, String orchStatus) { + return ofL3Network(instanceId, instanceName, instanceType, relationshipsUris, orchStatus, "prov", "network-instance-model-version-id", "94fdd893-4a36-4d70-b16a-ec29c54c184f"); + } + + public static PresetAAIStandardQueryGet ofL3Network(String instanceId, String instanceName, String instanceType, Multimap<String, String> relationshipsUris, String orchStatus, String provStatus, String modelVersionId, String modelCustomizationId) { + return new PresetAAIStandardQueryGet( + "network", instanceId, instanceName, instanceType, randomAlphanumeric(), + "/network/l3-networks/l3-network/" + instanceId, + relationshipsUris, "" + + "\"orchestration-status\": \"" + orchStatus + "\"," + + "\"prov-status\": \"" + provStatus + "\"," + + "\"network-technology\": \"contrail\", " + + "\"neutron-network-id\": \"66ee6123-1c45-4e71-b6c0-a748ae0fee88\", " + + "\"is-bound-to-vpn\": true, " + + "\"is-external-network\": true, " + + "\"model-invariant-id\": \"network-instance-model-invariant-id\", " + + "\"model-customization-id\": \"" + modelCustomizationId + "\", " + + "\"model-version-id\": \"" + modelVersionId + "\", " + ); + } + + public static PresetAAIStandardQueryGet ofVolumeGroup(String instanceType, Multimap<String, String> relationshipsUris) { + final String instanceId = randomUUID(); + return new PresetAAIStandardQueryGet( + "volume-group", instanceId, randomAlphanumeric(), instanceType, randomAlphanumeric(), + "/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson5b/volume-groups/volume-group/" + instanceId, + relationshipsUris, "" + + " \"vnf-type\": \"vSON_test_ap7145/vSON_test_ap7145 0\"," + + " \"orchestration-status\": \"Active\"," + + " \"model-customization-id\": \"bc3bbdcc-42f3-4682-b151-99c308d15255\"," + + " \"vf-module-model-customization-id\": \"bc3bbdcc-42f3-4682-b151-99c308d15255\"," + + " \"resource-version\": \"1533679899735\"," + ); + } + + public static PresetAAIStandardQueryGet ofCollectionResource(String orchStatus, Multimap<String, String> relationshipsUris) { + final String instanceId = randomUUID(); + return new PresetAAIStandardQueryGet( + "collection", instanceId, randomAlphanumeric(), "L3-NETWORK", randomAlphanumeric(), + "/network/collections/collection/" + instanceId, + relationshipsUris, "" + + "\"orchestration-status\": \"" + orchStatus + "\", " + + "\"model-invariant-id\": \"081ceb56-eb71-4566-a72d-3e7cbee5cdf1\", " + + "\"model-version-id\": \"ce8c98bc-4691-44fb-8ff0-7a47487c11c4\", " + ); + } + + public static PresetAAIStandardQueryGet ofVlanTag(int vlanIdOuter) { + final String instanceId = randomUUID(); + return new PresetAAIStandardQueryGet( + "vlan-tag", instanceId, + "/this is an invented link/tag/vlan-tags/vlan-tag/" + instanceId, + ImmutableMultimap.of(), "" + + "\"vlan-interface\": \"US-10688-genvnf-vlan-interface1\", " + + "\"vlan-id-inner\": " + 123456789 + ", " + + "\"vlan-id-outer\": " + vlanIdOuter + ", " + + "\"resource-version\": \"1518934744675\", " + + "\"in-maint\": false, " + + "\"is-ip-unnumbered\": false, " + ); + } + + public String getInstanceId() { + return instanceId; + } + + public String getInstanceName() { + return instanceName; + } + + public String getInstanceType() { + return instanceType; + } + + public String getInstanceRole() { + return instanceRole; + } + + @Override + public Object getResponseBody() { + return "" + + "{ " + + " \"" + typeInResponse + "-id\": \"" + getInstanceId() + "\", " + + " \"" + typeInResponse + "-name\": \"" + escapeJson(getInstanceName()) + "\", " + + " \"" + typeInResponse + "-type\": \"" + escapeJson(getInstanceType()) + "\", " + + " \"" + typeInResponse + "-role\": \"" + escapeJson(getInstanceRole()) + "\", " + + additionalProperties + + " \"relationship-list\": { " + + " \"relationship\": [ " + + relationshipsUris.entries().stream().map( + entry -> buildRelationship(entry.getKey(), entry.getValue()) + ).collect(Collectors.joining(",")) + + " ] " + + " } " + + "} "; + } + + private String buildRelationship(String relatedTo, final String relatedLink) { + return "" + + "{ " + + " \"related-to\": \"" + relatedTo + "\", " + + " \"relationship-label\": \"org.onap.relationships.inventory.ComposedOf\", " + + " \"related-link\": \"" + relatedLink + "\", " + + " \"relationship-data\": [" + + " { " + + " \"relationship-key\": \"GARBAGE DATA\", " + + " \"relationship-value\": \"GARBAGE DATA\" " + + " } " + + " ] " + + "}"; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return getRootPath() + uri; + } + + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/ecompportal_att/PresetGetSessionSlotCheckIntervalGet.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/ecompportal_att/PresetGetSessionSlotCheckIntervalGet.java index 55cc3dbc6..02ff1c159 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/ecompportal_att/PresetGetSessionSlotCheckIntervalGet.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/ecompportal_att/PresetGetSessionSlotCheckIntervalGet.java @@ -13,6 +13,6 @@ public class PresetGetSessionSlotCheckIntervalGet extends BaseEcompPortalPreset } public String getReqPath() { - return getRootPath() + "//getSessionSlotCheckInterval"; + return getRootPath() + "/v3/getSessionSlotCheckInterval"; } } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/model/RegistrationRequest.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/model/RegistrationRequest.java index 680dabe92..56fd1c9a7 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/model/RegistrationRequest.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/model/RegistrationRequest.java @@ -11,6 +11,8 @@ public class RegistrationRequest { public static class SimulatorRequest { public final HttpMethod method; public final String path; + public final boolean strict; + public final Map<String,String> headers; @JsonInclude(JsonInclude.Include.NON_NULL) public final Map<String,List> queryParams; @@ -18,11 +20,13 @@ public class RegistrationRequest { @JsonInclude(JsonInclude.Include.NON_NULL) public final Object body; - public SimulatorRequest(HttpMethod method, String path, Map<String, List> queryParams, Object body) { + public SimulatorRequest(HttpMethod method, String path, Map<String, List> queryParams, Object body, boolean strictMatch, Map<String, String> headers) { this.method = method; this.path = path; this.queryParams = queryParams; this.body = body; + this.strict = strictMatch; + this.headers = headers; } } @@ -44,11 +48,27 @@ public class RegistrationRequest { } } + public static class Misc { + + @JsonInclude(JsonInclude.Include.NON_NULL) + public Integer numberOfTimes; + + public boolean replace; + + public Misc(Integer numberOfTimes, boolean replace) { + this.numberOfTimes = numberOfTimes; + this.replace = replace; + } + } + public SimulatorRequest simulatorRequest; public SimulatorResponse simulatorResponse; + public Misc misc; - public RegistrationRequest(SimulatorRequest simulatorRequest, SimulatorResponse simulatorResponse) { + public RegistrationRequest(SimulatorRequest simulatorRequest, SimulatorResponse simulatorResponse, Misc misc) { this.simulatorRequest = simulatorRequest; this.simulatorResponse = simulatorResponse; + this.misc = misc; } + } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/model/Subscriber.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/model/Subscriber.java index 27f3f9bba..2f1d83f19 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/model/Subscriber.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/model/Subscriber.java @@ -3,6 +3,8 @@ package org.onap.simulator.presetGenerator.presets.model; import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + public class Subscriber { @JsonProperty("global-customer-id") @@ -16,4 +18,7 @@ public class Subscriber { @JsonProperty("resource-version") public String resourceVersion; + + @JsonProperty("relationship-list") + public Map relationshipList; } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOActivateFabricConfiguration.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOActivateFabricConfiguration.java new file mode 100644 index 000000000..51aaaf5a3 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOActivateFabricConfiguration.java @@ -0,0 +1,61 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset; +import org.springframework.http.HttpMethod; + +public class PresetMSOActivateFabricConfiguration extends BaseMSOPreset { + private final String serviceInstanceId; + private final String requestId; + public static final String DEFAULT_SERVICE_INSTANCE_ID = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d"; + public static final String DEFAULT_REQUEST_ID = "318cc766-b673-4a50-b9c5-471f68914584"; + + public PresetMSOActivateFabricConfiguration() { + this(null, null); + } + + public PresetMSOActivateFabricConfiguration(String serviceInstanceId) { + this(serviceInstanceId, null); + } + + public PresetMSOActivateFabricConfiguration(String serviceInstanceId, String requestId) { + this.serviceInstanceId = serviceInstanceId != null ? serviceInstanceId : DEFAULT_SERVICE_INSTANCE_ID; + this.requestId = requestId != null ? requestId : DEFAULT_REQUEST_ID; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.POST; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/activateFabricConfiguration"; + } + + @Override + public String getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"modelInfo\": {" + + " \"modelType\": \"service\"" + + " }," + + " \"requestInfo\": {" + + " \"source\": \"VID\"" + + " }," + + " \"requestParameters\": {" + + " \"aLaCarte\": false" + + " }" + + " }" + + "}"; + } + + @Override + public Object getResponseBody() { + return "{\"requestReferences\":{\"instanceId\":\"" + serviceInstanceId + "\",\"requestId\":\"" + requestId + "\"}}"; + } + + @Override + public int getResponseCode() { + return 202; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOActivateFabricConfigurationErrorResponse.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOActivateFabricConfigurationErrorResponse.java new file mode 100644 index 000000000..92d45bf5b --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOActivateFabricConfigurationErrorResponse.java @@ -0,0 +1,62 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset; +import org.springframework.http.HttpMethod; + +public class PresetMSOActivateFabricConfigurationErrorResponse extends BaseMSOPreset { + private final String serviceInstanceId; + private final int errorCode; + public static final String DEFAULT_SERVICE_INSTANCE_ID = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d"; + + public PresetMSOActivateFabricConfigurationErrorResponse() { + this(null, 0); + } + + public PresetMSOActivateFabricConfigurationErrorResponse(String serviceInstanceId) { + this(serviceInstanceId, 0); + } + + public PresetMSOActivateFabricConfigurationErrorResponse(String serviceInstanceId, int errorCode) { + this.serviceInstanceId = serviceInstanceId != null ? serviceInstanceId : DEFAULT_SERVICE_INSTANCE_ID; + this.errorCode = errorCode > 0 ? errorCode : 500; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.POST; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/activateFabricConfiguration"; + } + + @Override + public String getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"modelInfo\": {" + + " \"modelType\": \"service\"" + + " }," + + " \"cloudConfiguration\": {" + + " }," + + " \"requestInfo\": {" + + " \"source\": \"VID\"" + + " }," + + " \"requestParameters\": {" + + " \"aLaCarte\": false" + + " }" + + " }" + + "}"; + } + + @Override + public Object getResponseBody() { + return "{\"error\":\"222\",\"message\":\"error message\"}"; + } + + @Override + public int getResponseCode() { + return errorCode; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOAddOrRemoveOneInstanceGroupMember.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOAddOrRemoveOneInstanceGroupMember.java new file mode 100644 index 000000000..eba6be256 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOAddOrRemoveOneInstanceGroupMember.java @@ -0,0 +1,60 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSOAddOrRemoveOneInstanceGroupMember extends PresetMSOBaseCreateInstancePost { + + public enum InstanceGroupMemberAction { + Add("/addMembers"), + Remove("/removeMembers"); + + private final String actionPath; + + InstanceGroupMemberAction(String actionPath) { + this.actionPath = actionPath; + } + + public String getActionPAth() { + return actionPath; + } + } + + + private final String memberInstanceId; + private final String userId; + private final InstanceGroupMemberAction action; + + public PresetMSOAddOrRemoveOneInstanceGroupMember(String vnfGroupInstanceId, String memberInstanceId, String userId, String requestId, InstanceGroupMemberAction action) { + super(requestId, vnfGroupInstanceId); + this.memberInstanceId = memberInstanceId; + this.userId = userId; + this.action = action; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./instanceGroups/" + responseInstanceId + action.getActionPAth(); + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"requestInfo\": {" + + " \"source\": \"VID\"," + + " \"requestorId\": \"" + userId + "\"" + + " }," + + " \"relatedInstanceList\": [" + + " {" + + " \"relatedInstance\": {" + + " \"instanceId\": \"" + memberInstanceId + "\"," + + " \"modelInfo\": {" + + " \"modelType\": \"vnf\"" + + " }" + + " }" + + " }" + + " ]" + + " }" + + "}" + + ""; + } + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOAssignServiceInstanceGen2WithNames.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOAssignServiceInstanceGen2WithNames.java index 4d7b85027..6fc2182db 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOAssignServiceInstanceGen2WithNames.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOAssignServiceInstanceGen2WithNames.java @@ -1,5 +1,7 @@ package org.onap.simulator.presetGenerator.presets.mso; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId; + import java.util.Map; public class PresetMSOAssignServiceInstanceGen2WithNames extends PresetMSOServiceInstanceGen2WithNames { @@ -7,10 +9,11 @@ public class PresetMSOAssignServiceInstanceGen2WithNames extends PresetMSOServic public PresetMSOAssignServiceInstanceGen2WithNames(Map<Keys, String> names, int suffix) { super(names, suffix); + this.cloudOwner = PresetAAIGetCloudOwnersByCloudRegionId.ATT_SABABA; } @Override public String getReqPath() { - return getRootPath() + "/serviceInstantiation/v7/serviceInstances/assign"; + return getRootPath() + "/serviceInstantiation/v./serviceInstances/assign"; } } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseCreateInstancePost.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseCreateInstancePost.java new file mode 100644 index 000000000..05b8c8bec --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseCreateInstancePost.java @@ -0,0 +1,68 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import org.apache.commons.lang3.StringUtils; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset; +import org.springframework.http.HttpMethod; + +public abstract class PresetMSOBaseCreateInstancePost extends BaseMSOPreset { + + private final String requestId; + protected String responseInstanceId; + public static final String DEFAULT_REQUEST_ID = "c0011670-0e1a-4b74-945d-8bf5aede1d9c"; + protected String msoTestApi; + protected boolean withTestApi; + + public PresetMSOBaseCreateInstancePost() { + this(null); + } + + public PresetMSOBaseCreateInstancePost(String requestId) { + this.requestId = requestId != null ? requestId : DEFAULT_REQUEST_ID; + this.responseInstanceId = DEFAULT_INSTANCE_ID; + } + + public PresetMSOBaseCreateInstancePost(String requestId, String responseInstanceId) { + this.requestId = requestId != null ? requestId : DEFAULT_REQUEST_ID; + this.responseInstanceId = responseInstanceId; + } + + public PresetMSOBaseCreateInstancePost(String requestId, String responseInstanceId, String msoTestApi) { + this(requestId, responseInstanceId, msoTestApi, true); + } + + public PresetMSOBaseCreateInstancePost(String requestId, String responseInstanceId, String msoTestApi, boolean withTestApi) { + this(requestId, responseInstanceId); + this.msoTestApi = msoTestApi; + this.withTestApi= withTestApi; + } + + public String addTestApi() { + if(this.withTestApi) { + return "\"testApi\": \"" + msoTestApi + "\","; + } + return ""; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.POST; + } + + @Override + public int getResponseCode() { + return 202; + } + + public String getRequestId() { + return requestId; + } + + @Override + public Object getResponseBody() { + return "{\"requestReferences\":{\"instanceId\":\"" + responseInstanceId + "\",\"requestId\":\"" + requestId + "\"}}"; + } + + protected String formatSuffix(int suffix) { + return (suffix==0) ? StringUtils.EMPTY : "_" + String.format("%03d", suffix); + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseCreateServiceInstancePost.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseCreateServiceInstancePost.java deleted file mode 100644 index 703829213..000000000 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseCreateServiceInstancePost.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.onap.simulator.presetGenerator.presets.mso; - -import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset; -import org.springframework.http.HttpMethod; - -public abstract class PresetMSOBaseCreateServiceInstancePost extends BaseMSOPreset { - private final String requestId; - public static final String DEFAULT_REQUEST_ID = "c0011670-0e1a-4b74-945d-8bf5aede1d9c"; - - public PresetMSOBaseCreateServiceInstancePost() { - this(null); - } - - public PresetMSOBaseCreateServiceInstancePost(String requestId) { - this.requestId = requestId != null ? requestId : DEFAULT_REQUEST_ID; - } - - @Override - public HttpMethod getReqMethod() { - return HttpMethod.POST; - } - - @Override - public int getResponseCode() { - return 202; - } - - - - @Override - public Object getResponseBody() { - return "{\"requestReferences\":{\"instanceId\":\"f8791436-8d55-4fde-b4d5-72dd2cf13cfb\",\"requestId\":\"" + requestId + "\"}}"; - } -} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseDelete.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseDelete.java index 99433e0a2..e8ef7b51b 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseDelete.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseDelete.java @@ -4,20 +4,25 @@ import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset; import org.springframework.http.HttpMethod; public abstract class PresetMSOBaseDelete extends BaseMSOPreset { - private final String requestId; - public static final String DEFAULT_REQUEST_ID = "c0011670-0e1a-4b74-945d-8bf5aede1d9c"; + protected final String requestId; + protected final String instanceId; - public PresetMSOBaseDelete() { - this(null ); - } + public static final String DEFAULT_REQUEST_ID = "c0011670-0e1a-4b74-945d-8bf5aede1d9c"; public PresetMSOBaseDelete(String requestId) { this.requestId = requestId != null ? requestId : DEFAULT_REQUEST_ID; + this.instanceId = DEFAULT_INSTANCE_ID; } + public PresetMSOBaseDelete(String requestId, String instanceId) { + this.requestId = requestId; + this.instanceId = instanceId; + } + + @Override protected String getRootPath() { - return super.getRootPath() + "/serviceInstances/v./"; + return super.getRootPath() + "/serviceInstantiation/v./serviceInstances/"; } @Override @@ -32,6 +37,6 @@ public abstract class PresetMSOBaseDelete extends BaseMSOPreset { @Override public Object getResponseBody() { - return "{\"requestReferences\":{\"instanceId\":\"f8791436-8d55-4fde-b4d5-72dd2cf13cfb\",\"requestId\":\"" + requestId + "\"}}"; + return "{\"requestReferences\":{\"instanceId\":\""+instanceId+"\",\"requestId\":\"" + requestId + "\"}}"; } } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseDeleteWithCloudConfiguration.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseDeleteWithCloudConfiguration.java new file mode 100644 index 000000000..0c813641d --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseDeleteWithCloudConfiguration.java @@ -0,0 +1,36 @@ +package org.onap.simulator.presetGenerator.presets.mso; + + +public abstract class PresetMSOBaseDeleteWithCloudConfiguration extends PresetMSOBaseDelete { + + private final String modelType; + + public PresetMSOBaseDeleteWithCloudConfiguration(String requestId, String modelType) { + super(requestId); + this.modelType = modelType; + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"modelInfo\": {" + + " \"modelType\": \""+modelType+"\"" + + //" \"modelName\": \"\", //required for VfModule" + + " }," + + " \"requestInfo\": {" + + " \"source\": \"VID\"," + + " \"requestorId\": \"us16807000\"" + + " }," + + " \"requestParameters\": {" + + " \"testApi\": \"VNF_API\"" + + " }," + + " \"cloudConfiguration\": {" + + " \"lcpCloudRegionId\": \"hvf6\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"bae71557c5bb4d5aac6743a4e5f1d054\"" + + " }" + + " }" + + "}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateMacroPre1806Post.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateMacroPre1806Post.java new file mode 100644 index 000000000..ed92767fa --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateMacroPre1806Post.java @@ -0,0 +1,63 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.ATT_NC; + +public class PresetMSOCreateMacroPre1806Post extends PresetMSOBaseCreateInstancePost { + + public PresetMSOCreateMacroPre1806Post() { + this.cloudOwner = ATT_NC; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstances/v."; + } + + @Override + public Object getRequestBody() { + return "" + + "{" + + " \"requestDetails\": {" + + " \"requestInfo\": {" + + " \"instanceName\": \"New Instance Name\"," + + " \"source\": \"VID\"," + + " \"suppressRollback\": false," + + " \"requestorId\": \"fi5777000\"," + + " \"productFamilyId\": \"e30755dc-5673-4b6b-9dcf-9abdd96b93d1\"" + + " }," + + " \"modelInfo\": {" + + " \"modelType\": \"service\"," + + " \"modelInvariantId\": \"d27e42cf-087e-4d31-88ac-6c4b7585f800\"," + + " \"modelVersionId\": \"4d71990b-d8ad-4510-ac61-496288d9078e\"," + + " \"modelName\": \"vidmacrofalsenaming\"," + + " \"modelVersion\": \"1.0\"" + + " }," + + " \"requestParameters\": {" + + " \"userParams\": [" + + " {" + + " \"name\": \"aic_zone\"," + + " \"value\": \"NFT1\"" + + " }" + + " ]," + + " \"subscriptionServiceType\": \"AIM Transport\"," + + " \"aLaCarte\": false" + + " }," + + " \"cloudConfiguration\": {" + + " \"lcpCloudRegionId\": \"olson3\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"bae71557c5bb4d5aac6743a4e5f1d054\"" + + " }," + + " \"subscriberInfo\": {" + + " \"globalSubscriberId\": \"31739f3e-526b-11e6-beb8-9e71128cae77\"" + + " }," + + " \"project\": {" + + " \"projectName\": \"yyy1\"" + + " }," + + " \"owningEntity\": {" + + " \"owningEntityId\": \"aaa1\"," + + " \"owningEntityName\": \"aaa1\"" + + " }" + + " }" + + "}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateNetworkALaCarte5G.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateNetworkALaCarte5G.java new file mode 100644 index 000000000..42b1578f4 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateNetworkALaCarte5G.java @@ -0,0 +1,79 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId; + +public class PresetMSOCreateNetworkALaCarte5G extends PresetMSOBaseCreateInstancePost { + private String serviceInstanceId; + private String networkName; + private final String requestorId; + + + public PresetMSOCreateNetworkALaCarte5G(String overrideRequestId, String serviceInstanceId, String networkName, String requestorId) { + super(overrideRequestId); + this.serviceInstanceId = serviceInstanceId; + this.networkName = networkName; + this.requestorId = requestorId; + this.cloudOwner = PresetAAIGetCloudOwnersByCloudRegionId.ATT_AIC; + } + + @Override + public boolean isStrictMatch() { + return true; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/networks"; + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"modelInfo\": {" + + " \"modelCustomizationName\": \"SR-IOV Provider-1\"," + + " \"modelCustomizationId\": \"0a0287b1-74a3-4c40-9bbb-9f56601e4fc4\"," + + " \"modelInvariantId\": \"379f816b-a7aa-422f-be30-17114ff50b7c\"," + + " \"modelVersionId\": \"840ffc47-e4cf-46de-8e23-525fd8c6fdc3\"," + + " \"modelName\": \"ExtVL\"," + + " \"modelType\": \"network\"," + + " \"modelVersion\": \"49.0\"" + + " }," + + " \"cloudConfiguration\": {" + + " \"lcpCloudRegionId\": \""+PresetAAIGetCloudOwnersByCloudRegionId.SOME_LEGACY_REGION+"\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"092eb9e8e4b7412e8787dd091bc58e86\"," + + " }," + + " \"requestInfo\": {" + + " \"instanceName\": \""+networkName+"\"," + + " \"source\": \"VID\"," + + " \"suppressRollback\": false," + + " \"requestorId\": \""+requestorId+"\"" + + " }," + + " \"platform\": {" + + " \"platformName\": \"platform\"" + + " }," + + " \"lineOfBusiness\": {" + + " \"lineOfBusinessName\": \"ECOMP\"" + + " }," + + " \"relatedInstanceList\": [{" + + " \"relatedInstance\": {" + + " \"modelInfo\": {" + + " \"modelInvariantId\": \"16e56d12-40b3-4db1-a40e-d48c36679e2e\"," + + " \"modelVersionId\": \"4659e8bd-0920-4eed-8ec5-550b4c8dceeb\"," + + " \"modelName\": \"SR-IOV Provider-1\"," + + " \"modelType\": \"service\"," + + " \"modelVersion\": \"1.0\"" + + " }," + + " \"instanceId\": \""+serviceInstanceId+"\"" + + " }" + + " }" + + " ]," + + " \"requestParameters\": {" + + " \"testApi\": \"VNF_API\"," + + " \"userParams\": []" + + " }" + + " }" + + "}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateNetworkALaCarteCypress.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateNetworkALaCarteCypress.java new file mode 100644 index 000000000..273fc255f --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateNetworkALaCarteCypress.java @@ -0,0 +1,68 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSOCreateNetworkALaCarteCypress extends PresetMSOBaseCreateInstancePost { + private final String networkInstanceName; + private final String serviceInstanceId; + + + public PresetMSOCreateNetworkALaCarteCypress(String overrideRequestId, String serviceInstanceId, String responseInstanceId, String networkInstanceName, String msoTestApi, boolean withTestApi) { + super(overrideRequestId, responseInstanceId, msoTestApi, withTestApi); + this.serviceInstanceId = serviceInstanceId; + this.networkInstanceName = networkInstanceName; + } + + @Override + public boolean isStrictMatch() { + return true; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/networks"; + } + + @Override + public Object getRequestBody() { + return "{\"requestDetails\": {" + + + "\"modelInfo\":{" + + "\"modelCustomizationId\":\"94fdd893-4a36-4d70-b16a-ec29c54c184f\"," + + "\"modelCustomizationName\":\"ExtVL 0\"," + + "\"modelInvariantId\":\"379f816b-a7aa-422f-be30-17114ff50b7c\"," + + "\"modelName\":\"ExtVL\"," + + "\"modelVersion\":\"37.0\"," + + "\"modelVersionId\":\"ddc3f20c-08b5-40fd-af72-c6d14636b986\"," + + "\"modelType\":\"network\"" + + "}," + + "\"cloudConfiguration\":" + + "{\"lcpCloudRegionId\":\"lcpRegionText\"," + + addCloudOwnerIfNeeded() + + "\"tenantId\":\"092eb9e8e4b7412e8787dd091bc58e86\"}," + + "\"requestInfo\":" + + "{\"instanceName\":\""+ networkInstanceName +"\"," + + "\"productFamilyId\":\"ebc3bc3d-62fd-4a3f-a037-f619df4ff034\"," + + "\"source\":\"VID\"," + + "\"suppressRollback\":false," + + "\"requestorId\":\"us16807000\"}," + + //not sure it should be here + "\"platform\":{\"platformName\":\"xxx1\"}," + + //not sure it should be here + "\"lineOfBusiness\":{\"lineOfBusinessName\":\"zzz1\"}," + + + "\"relatedInstanceList\":[" + + "{\"relatedInstance\":{" + + "\"instanceId\":\""+serviceInstanceId+"\"," + + "\"modelInfo\":{" + + "\"modelVersionId\":\"2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd\"," + + "\"modelName\":\"action-data\"," + + "\"modelInvariantId\":\"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0\"," + + "\"modelType\":\"service\"," + + "\"modelVersion\":\"1.0\"" + + "}}}]," + + + "\"requestParameters\":{" + + this.addTestApi() + + "\"userParams\":[]}" + + "}}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateNetworkALaCarteOldViewEdit.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateNetworkALaCarteOldViewEdit.java new file mode 100644 index 000000000..bccb07251 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateNetworkALaCarteOldViewEdit.java @@ -0,0 +1,65 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSOCreateNetworkALaCarteOldViewEdit extends PresetMSOBaseCreateInstancePost { + private final String networkInstanceName; + private final String serviceInstanceId; + + public PresetMSOCreateNetworkALaCarteOldViewEdit(String overrideRequestId, String serviceInstanceId, String responseInstanceId, String networkInstanceName) { + super(overrideRequestId, responseInstanceId); + this.serviceInstanceId = serviceInstanceId; + this.networkInstanceName = networkInstanceName; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/networks"; + } + + @Override + public Object getRequestBody() { + return "{\"requestDetails\": {" + + " \"requestInfo\": {" + + " \"instanceName\": \""+networkInstanceName+"\"," + + " \"source\": \"VID\"," + + " \"suppressRollback\": false," + + " \"requestorId\": \"mo57174000\"," + + " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"" + + " }," + + " \"modelInfo\": {" + + " \"modelType\": \"network\"," + + " \"modelInvariantId\": \"de01afb5-532b-451d-aac4-ff9ff0644060\"," + + " \"modelVersionId\": \"ac815c68-35b7-4ea4-9d04-92d2f844b27c\"," + + " \"modelName\": \"AIC30_CONTRAIL_BASIC\"," + + " \"modelVersion\": \"3.0\"," + + " \"modelCustomizationId\": \"e94d61f7-b4b2-489a-a4a7-30b1a1a80daf\"," + + " \"modelCustomizationName\": \"AIC30_CONTRAIL_BASIC 0\"" + + " }," + + " \"requestParameters\": {" + + " \"testApi\": \"VNF_API\"," + + " \"userParams\": []" + + " }," + + " \"cloudConfiguration\": {" + + " \"lcpCloudRegionId\": \"One\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"c630e297a3ae486497d63eacec1d7c14\"" + + " }," + + " \"platform\": {" + + " \"platformName\": \"xxx1\"" + + " }," + + " \"relatedInstanceList\": [" + + " {" + + " \"relatedInstance\": {" + + " \"instanceId\": \""+serviceInstanceId+"\"," + + " \"modelInfo\": {" + + " \"modelType\": \"service\"," + + " \"modelName\": \"Using VID for VoIP Network Instantiations Shani\"," + + " \"modelInvariantId\": \"5b9c0f33-eec1-484a-bf77-736a6644d7a8\"," + + " \"modelVersion\": \"1.0\"," + + " \"modelVersionId\": \"b75e0d22-05ff-4448-9266-5f0d4e1dbbd6\"" + + " }" + + " }" + + " }" + + " ]" + + " }}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateNetworkALaCarteServiceCypress2.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateNetworkALaCarteServiceCypress2.java new file mode 100644 index 000000000..356b59d9f --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateNetworkALaCarteServiceCypress2.java @@ -0,0 +1,68 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSOCreateNetworkALaCarteServiceCypress2 extends PresetMSOBaseCreateInstancePost { + private String serviceInstanceId; + private String networkName; + private String serviceModelName; + private String serviceModelVersionId; + + + public PresetMSOCreateNetworkALaCarteServiceCypress2(String overrideRequestId, String serviceInstanceId, String networkName) { + this(overrideRequestId, serviceInstanceId, networkName, "ComplexService", "6e59c5de-f052-46fa-aa7e-2fca9d674c44"); + } + + public PresetMSOCreateNetworkALaCarteServiceCypress2(String overrideRequestId, String serviceInstanceId, String networkName, String serviceModelName, String serviceModelVersionId) { + super(overrideRequestId); + this.serviceInstanceId = serviceInstanceId; + this.networkName = networkName; + this.serviceModelName = serviceModelName; + this.serviceModelVersionId = serviceModelVersionId; + } + + @Override + public boolean isStrictMatch() { + return true; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/networks"; + } + + @Override + public Object getRequestBody() { + return "{\"requestDetails\":" + + "{\"requestInfo\":" + + "{\"instanceName\":\"" + networkName + "\"," + + "\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"," + + "\"source\":\"VID\"," + + "\"suppressRollback\":false," + + "\"requestorId\":\"us16807000\"}," + + "\"lineOfBusiness\":{\"lineOfBusinessName\":\"zzz1\"}," + + "\"cloudConfiguration\":" + + "{\"lcpCloudRegionId\":\"hvf6\"," + + addCloudOwnerIfNeeded() + + "\"tenantId\":\"229bcdc6eaeb4ca59d55221141d01f8e\"}," + + "\"platform\":{\"platformName\":\"xxx1\"}," + + "\"modelInfo\":" + + "{\"modelCustomizationId\":\"94fdd893-4a36-4d70-b16a-ec29c54c184f\"," + + "\"modelCustomizationName\":\"ExtVL 0\"," + + "\"modelVersionId\":\"ddc3f20c-08b5-40fd-af72-c6d14636b986\"," + + "\"modelName\":\"ExtVL\"," + + "\"modelInvariantId\":\"379f816b-a7aa-422f-be30-17114ff50b7c\"," + + "\"modelType\":\"network\"," + + "\"modelVersion\":\"37.0\"}," + + "\"requestParameters\":{" + + "\"testApi\": \"GR_API\", " + + "\"userParams\":[]}," + + "\"relatedInstanceList\":[" + + "{\"relatedInstance\":{" + + "\"instanceId\":\"" + serviceInstanceId + "\"," + + "\"modelInfo\":{" + + "\"modelVersionId\":\"" + serviceModelVersionId + "\"," + + "\"modelName\":\"" + serviceModelName + "\"," + + "\"modelInvariantId\":\"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0\"," + + "\"modelType\":\"service\"," + + "\"modelVersion\":\"1.0\"}}}]}}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceAlacarte5GServiceWithNetwork.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceAlacarte5GServiceWithNetwork.java new file mode 100644 index 000000000..afd96a46f --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceAlacarte5GServiceWithNetwork.java @@ -0,0 +1,59 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.SERVICE_NAME; + +import java.util.Map; + +public class PresetMSOCreateServiceInstanceAlacarte5GServiceWithNetwork extends PresetMSOCreateServiceInstanceGen2WithNames { + + private final String requestorId; + + public PresetMSOCreateServiceInstanceAlacarte5GServiceWithNetwork(Map<Keys, String> names, String requestId, String requestorId) { + super(names, 0, requestId); + this.requestorId = requestorId; + } + + @Override + public boolean isStrictMatch() { + return true; + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"modelInfo\": {" + + " \"modelInvariantId\": \"16e56d12-40b3-4db1-a40e-d48c36679e2e\"," + + " \"modelVersionId\": \"4659e8bd-0920-4eed-8ec5-550b4c8dceeb\"," + + " \"modelName\": \"SR-IOV Provider-1\"," + + " \"modelType\": \"service\"," + + " \"modelVersion\": \"1.0\"" + + " }," + + " \"owningEntity\": {" + + " \"owningEntityId\": \"d61e6f2d-12fa-4cc2-91df-7c244011d6fc\"," + + " \"owningEntityName\": \"MetroPacketCore\"" + + " }," + + " \"subscriberInfo\": {" + + " \"globalSubscriberId\": \"e433710f-9217-458d-a79d-1c7aff376d89\"" + + " }," + + " \"project\": {" + + " \"projectName\": \"DFW\"" + + " }," + + " \"requestInfo\": {" + + " \"instanceName\": \""+names.get(SERVICE_NAME)+"\"," + + " \"source\": \"VID\"," + + " \"suppressRollback\": false," + + " \"requestorId\": \""+this.requestorId+"\"" + + " }," + + " \"requestParameters\": {" + + " \"testApi\": \"VNF_API\"," + + " \"subscriptionServiceType\": \"TYLER SILVIA\"," + + " \"aLaCarte\": true," + + " \"userParams\": []" + + " }" + + " }" + + "}"; + + } + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2.java index 3dbebd5e5..3a7b09b43 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2.java @@ -1,17 +1,15 @@ package org.onap.simulator.presetGenerator.presets.mso; -public class PresetMSOCreateServiceInstanceGen2 extends PresetMSOBaseCreateServiceInstancePost{ +public class PresetMSOCreateServiceInstanceGen2 extends PresetMSOBaseCreateInstancePost { - public PresetMSOCreateServiceInstanceGen2() { - } - - public PresetMSOCreateServiceInstanceGen2(String requestId) { - super(requestId); + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./serviceInstances"; } @Override - public String getReqPath() { - return getRootPath() + "/serviceInstantiation/v7/serviceInstances"; + public boolean isStrictMatch() { + return true; } @Override @@ -44,7 +42,7 @@ public class PresetMSOCreateServiceInstanceGen2 extends PresetMSOBaseCreateServi " \"requestorId\": \"us16807000\" " + " }, " + " \"requestParameters\": { " + - " \"subscriptionServiceType\": \"VIRTUAL USP\", " + + " \"subscriptionServiceType\": \"TYLER SILVIA\", " + " \"aLaCarte\": false, " + " \"userParams\": [{ " + " \"service\": { " + @@ -58,16 +56,17 @@ public class PresetMSOCreateServiceInstanceGen2 extends PresetMSOBaseCreateServi " \"resources\": { " + " \"vnfs\": [{ " + " \"modelInfo\": { " + - " \"modelCustomizationName\": \"2017-488_ADIOD-vPE 0\", " + + " \"modelCustomizationName\": \"2017-488_PASQUALE-vPE 0\", " + " \"modelCustomizationId\": \"1da7b585-5e61-4993-b95e-8e6606c81e45\", " + " \"modelInvariantId\": \"72e465fe-71b1-4e7b-b5ed-9496118ff7a8\", " + " \"modelVersionId\": \"69e09f68-8b63-4cc9-b9ff-860960b5db09\", " + - " \"modelName\": \"2017-488_ADIOD-vPE\", " + + " \"modelName\": \"2017-488_PASQUALE-vPE\", " + " \"modelType\": \"vnf\", " + " \"modelVersion\": \"5.0\" " + " }, " + " \"cloudConfiguration\": { " + - " \"lcpCloudRegionId\": \"mtn6\", " + + " \"lcpCloudRegionId\": \"hvf6\", " + + addCloudOwnerIfNeeded() + " \"tenantId\": \"bae71557c5bb4d5aac6743a4e5f1d054\" " + " }, " + " \"platform\": { " + @@ -78,19 +77,20 @@ public class PresetMSOCreateServiceInstanceGen2 extends PresetMSOBaseCreateServi " }, " + " \"productFamilyId\": \"e433710f-9217-458d-a79d-1c7aff376d89\", " + " \"instanceParams\": [], " + - " \"vfModules\": [{ " + + " \"vfModules\": [" + + " { " + " \"modelInfo\": { " + " \"modelInvariantId\": \"7253ff5c-97f0-4b8b-937c-77aeb4d79aa1\", " + " \"modelVersionId\": \"25284168-24bb-4698-8cb4-3f509146eca5\", " + - " \"modelName\": \"2017488AdiodVpe..ADIOD_vRE_BV..module-1\", " + + " \"modelName\": \"2017488PASQUALEVpe..PASQUALE_vRE_BV..module-1\", " + " \"modelType\": \"vfModule\", " + " \"modelVersion\": \"6\" " + " }, " + -// " \"instanceName\": \"VFinstancename_00" + suffix + "\", " + +// \"instanceName\": \"VFinstancename_00" + suffix + "\", " + " \"instanceParams\": [] " + - " } " + + " }" + " ] " + -// " \"instanceName\": \"2017488_ADIODvPEVNFinstancename_00" + suffix + "\" " + +// " \"instanceName\": \"2017488_PASQUALEvPEVNFinstancename_00" + suffix + "\" " + " } " + " ] " + " } " + diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2AlacarteService.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2AlacarteService.java new file mode 100644 index 000000000..f76293f1d --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2AlacarteService.java @@ -0,0 +1,55 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import java.util.Map; + +public class PresetMSOCreateServiceInstanceGen2AlacarteService extends PresetMSOCreateServiceInstanceGen2WithNames { + + public PresetMSOCreateServiceInstanceGen2AlacarteService(Map<Keys, String> names, int suffix, String requestId) { + super(names, suffix, requestId); + } + + @Override + public boolean isStrictMatch() { + return true; + } + + @Override + public Object getRequestBody() { + return "" + + "{ " + + " \"requestDetails\": { " + + " \"modelInfo\": { " + + " \"modelType\": \"service\", " + + " \"modelInvariantId\": \"16e56d12-40b3-4db1-a40e-d48c36679e2e\", " + + " \"modelVersionId\": \"4659e8bd-0920-4eed-8ec5-550b4c8dceeb\", " + + " \"modelName\": \"SR-IOV Provider-1\", " + + " \"modelVersion\": \"1.0\" " + + " }, " + + " \"owningEntity\": { " + + " \"owningEntityName\": \"MetroPacketCore\", " + + " \"owningEntityId\": \"d61e6f2d-12fa-4cc2-91df-7c244011d6fc\" " + + " }, " + + " \"project\": { " + + " \"projectName\": \"DFW\" " + + " }, " + + " \"subscriberInfo\": { " + + " \"globalSubscriberId\": \"e433710f-9217-458d-a79d-1c7aff376d89\" " + + " }, " + + " \"requestInfo\": { " + + " \"source\": \"VID\", " + + " \"suppressRollback\": false, " + + " \"instanceName\": \"" + names.get(Keys.SERVICE_NAME) + suffix + "\", " + + " \"requestorId\": \"us16807000\" " + + " }, " + + " \"requestParameters\": { " + + " \"testApi\": \"VNF_API\", " + + " \"subscriptionServiceType\": \"TYLER SILVIA\", " + + " \"aLaCarte\": true, " + + " \"userParams\": [] " + + " } " + + " } " + + "} "; + + } + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2ErrorResponse.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2ErrorResponse.java new file mode 100644 index 000000000..a8b4d9aa5 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2ErrorResponse.java @@ -0,0 +1,24 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSOCreateServiceInstanceGen2ErrorResponse extends PresetMSOBaseCreateInstancePost { + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./serviceInstances"; + } + + @Override + public int getResponseCode() { + return 500; + } + + @Override + public Object getResponseBody() { + return "{" + + " \"serviceException\": {" + + " \"messageId\": \"SVC0002\"," + + " \"text\": \"JSON Object Mapping Request\"" + + " }" + + "}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2WithNames.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2WithNames.java index 89008b99b..f9124cc75 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2WithNames.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2WithNames.java @@ -1,15 +1,27 @@ package org.onap.simulator.presetGenerator.presets.mso; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId; + import java.util.Map; public class PresetMSOCreateServiceInstanceGen2WithNames extends PresetMSOServiceInstanceGen2WithNames { public PresetMSOCreateServiceInstanceGen2WithNames(Map<Keys, String> names, int suffix) { super(names, suffix); + this.cloudOwner = PresetAAIGetCloudOwnersByCloudRegionId.ATT_SABABA; + } + + public PresetMSOCreateServiceInstanceGen2WithNames(Map<Keys, String> names, int suffix, String requestId) { + super(names, suffix, requestId); } + public PresetMSOCreateServiceInstanceGen2WithNames(Map<Keys, String> names, int suffix, String requestId, String responseInstanceId) { + super(names, suffix, requestId, responseInstanceId); + } + + @Override public String getReqPath() { - return getRootPath() + "/serviceInstantiation/v7/serviceInstances"; + return getRootPath() + "/serviceInstantiation/v./serviceInstances"; } } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2WithNamesAlacarteGroupingService.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2WithNamesAlacarteGroupingService.java new file mode 100644 index 000000000..8f0b14115 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2WithNamesAlacarteGroupingService.java @@ -0,0 +1,63 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import java.util.Map; + +public class PresetMSOCreateServiceInstanceGen2WithNamesAlacarteGroupingService extends PresetMSOCreateServiceInstanceGen2WithNames { + + private String userId = "us16807000"; + + public PresetMSOCreateServiceInstanceGen2WithNamesAlacarteGroupingService(Map<Keys, String> names, int suffix, String requestId) { + super(names, suffix, requestId); + } + + public PresetMSOCreateServiceInstanceGen2WithNamesAlacarteGroupingService(Map<Keys, String> names, int suffix, String requestId, String responseInstanceId, String userId) { + super(names, suffix, requestId); + this.responseInstanceId = responseInstanceId; + this.userId = userId; + } + + @Override + public boolean isStrictMatch() { + return true; + } + + @Override + public Object getRequestBody() { + return "" + + "{ " + + " \"requestDetails\": { " + + " \"modelInfo\": { " + + " \"modelType\": \"service\", " + + " \"modelInvariantId\": \"7ee41ce4-4827-44b0-a48e-2707a59905d2\", " + + " \"modelVersionId\": \"4117a0b6-e234-467d-b5b9-fe2f68c8b0fc\", " + + " \"modelName\": \"Grouping Service for Test\", " + + " \"modelVersion\": \"1.0\" " + + " }, " + + " \"owningEntity\": { " + + " \"owningEntityId\": \"d61e6f2d-12fa-4cc2-91df-7c244011d6fc\", " + + " \"owningEntityName\": \"MetroPacketCore\" " + + " }, " + + " \"project\": { " + + " \"projectName\": \"DFW\" " + + " }, " + + " \"subscriberInfo\": { " + + " \"globalSubscriberId\": \"e433710f-9217-458d-a79d-1c7aff376d89\" " + + " }, " + + " \"requestInfo\": { " + + " \"source\": \"VID\", " + + " \"suppressRollback\": false, " + + " \"instanceName\": \"" + names.get(Keys.SERVICE_NAME) + suffix + "\", " + + " \"requestorId\": \"" + userId + "\" " + + " }, " + + " \"requestParameters\": { " + + " \"testApi\": \"VNF_API\", " + + " \"subscriptionServiceType\": \"TYLER SILVIA\", " + + " \"aLaCarte\": true, " + + " \"userParams\": [] " + + " } " + + " } " + + "} "; + + } + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2WithNamesAlacarteService.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2WithNamesAlacarteService.java new file mode 100644 index 000000000..cc33a3b14 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2WithNamesAlacarteService.java @@ -0,0 +1,60 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import java.util.Map; + +public class PresetMSOCreateServiceInstanceGen2WithNamesAlacarteService extends PresetMSOCreateServiceInstanceGen2WithNames { + + public PresetMSOCreateServiceInstanceGen2WithNamesAlacarteService(Map<Keys, String> names, int suffix, String requestId) { + super(names, suffix, requestId); + } + + public PresetMSOCreateServiceInstanceGen2WithNamesAlacarteService(Map<Keys, String> names, int suffix, String requestId, String responseInstanceId) { + super(names, suffix, requestId, responseInstanceId); + } + + @Override + public boolean isStrictMatch() { + return true; + } + + @Override + public Object getRequestBody() { + return "" + + "{ " + + " \"requestDetails\": { " + + " \"modelInfo\": { " + + " \"modelType\": \"service\", " + + " \"modelInvariantId\": \"0367689e-d41e-483f-b200-eab17e4a7f8d\", " + + " \"modelVersionId\": \"e3c34d88-a216-4f1d-a782-9af9f9588705\", " + + " \"modelName\": \"gayawabawe\", " + + " \"modelVersion\": \"5.1\" " + + " }, " + + " \"owningEntity\": { " + + " \"owningEntityId\": \"038d99af-0427-42c2-9d15-971b99b9b489\", " + + " \"owningEntityName\": \"Lucine Sarika\" " + + " }, " + + " \"project\": { " + + " \"projectName\": \"zasaki\" " + + " }, " + + " \"subscriberInfo\": { " + + " \"globalSubscriberId\": \"e433710f-9217-458d-a79d-1c7aff376d89\" " + + " }, " + + " \"requestInfo\": { " + + " \"source\": \"VID\", " + + " \"suppressRollback\": true, " + + " \"instanceName\": \"" + names.get(Keys.SERVICE_NAME) + suffix + "\", " + + " \"productFamilyId\": \"ddf9cc0f-6331-4d35-bed0-a37f2d5e9cb3\", " + + " \"requestorId\": \"us16807000\" " + + " }, " + + " \"requestParameters\": { " + + " \"testApi\": \"VNF_API\", " + + " \"subscriptionServiceType\": \"TYLER SILVIA\", " + + " \"aLaCarte\": true, " + + " \"userParams\": [] " + + " } " + + " } " + + "} "; + + } + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2WithNamesAlacarteServiceCypress.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2WithNamesAlacarteServiceCypress.java new file mode 100644 index 000000000..a864b0d10 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2WithNamesAlacarteServiceCypress.java @@ -0,0 +1,58 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import java.util.Map; + +public class PresetMSOCreateServiceInstanceGen2WithNamesAlacarteServiceCypress extends PresetMSOCreateServiceInstanceGen2WithNames { + + public PresetMSOCreateServiceInstanceGen2WithNamesAlacarteServiceCypress(Map<Keys, String> names, int suffix, String requestId, String testApi, boolean withTestApi) { + super(names, suffix, requestId); + this.msoTestApi = testApi; + this.withTestApi = withTestApi; + } + + @Override + public boolean isStrictMatch() { + return true; + } + + @Override + public Object getRequestBody() { + return "" + + "{ " + + " \"requestDetails\": { " + + " \"modelInfo\": { " + + " \"modelType\": \"service\", " + + " \"modelInvariantId\": \"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0\", " + + " \"modelVersionId\": \"2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd\", " + + " \"modelName\": \"action-data\", " + + " \"modelVersion\": \"1.0\" " + + " }, " + + " \"owningEntity\": { " + + " \"owningEntityName\": \"MetroPacketCore\", " + + " \"owningEntityId\": \"d61e6f2d-12fa-4cc2-91df-7c244011d6fc\" " + + " }, " + + " \"project\": { " + + " \"projectName\": \"DFW\" " + + " }, " + + " \"subscriberInfo\": { " + + " \"globalSubscriberId\": \"e433710f-9217-458d-a79d-1c7aff376d89\" " + + " }, " + + " \"requestInfo\": { " + + " \"source\": \"VID\", " + + " \"suppressRollback\": false, " + + " \"productFamilyId\": \"ebc3bc3d-62fd-4a3f-a037-f619df4ff034\", " + + " \"instanceName\": \"" + names.get(Keys.SERVICE_NAME) + suffix + "\", " + + " \"requestorId\": \"us16807000\" " + + " }, " + + " \"requestParameters\": { " + + addTestApi()+ + " \"subscriptionServiceType\": \"TYLER SILVIA\", " + + " \"aLaCarte\": true, " + + " \"userParams\": [] " + + " } " + + " } " + + "} "; + + } + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2WithNamesEcompNamingFalse.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2WithNamesEcompNamingFalse.java new file mode 100644 index 000000000..2a8d7586e --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceGen2WithNamesEcompNamingFalse.java @@ -0,0 +1,327 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.SERVICE_NAME; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.VFM_NAME1; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.VFM_NAME2; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.VG_NAME; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.VNF_NAME; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.VNF_NAME2; + +import java.util.Map; +import vid.automation.test.infra.Features; + +public class PresetMSOCreateServiceInstanceGen2WithNamesEcompNamingFalse extends PresetMSOCreateServiceInstanceGen2WithNames { + + protected static final String INSTANCE_PARAMS_VNF = "{ " + + " \"bandwidth\": \"10\", " + + " \"vnf_instance_name\": \"mtnj309me6\", " + + " \"vnf_config_template_version\": \"17.2\", " + + " \"AIC_CLLI\": \"ATLMY8GA\", " + + " \"ASN\": \"AV_vPE\", " + + " \"bandwidth_units\": \"Gbps\" " + + " }"; + + protected static final String INSTANCE_PARAMS_WITH_SUPP_FILE_VNF = "{ " + + " \"vnf_config_template_version\": \"17.2\", " + + " \"AIC_CLLI\": \"ATLMY8GA\", " + + " \"bandwidth\": \"10\", " + + " \"bandwidth_units\": \"Gbps\", " + + " \"ASN\": \"AV_vPE\", " + + " \"param\": \"ABCD\", " + + " \"vnf_instance_name\": \"sample\" " + + " }"; + + protected static final String INSTANCE_PARAMS_VF_MODULE = "{ " + + " \"bandwidth\": \"10\", " + + " \"vnf_instance_name\": \"mtnj309me6\", " + + " \"vnf_config_template_version\": \"17.2\", " + + " \"AIC_CLLI\": \"ATLMY8GA\", " + + " \"bandwidth_units\": \"Gbps\" " + + " }"; + + protected static final String INSTANCE_PARAMS_WITH_SUPP_FILE_VF_MODULE = "{ " + + " \"vnf_config_template_version\": \"17.2\", " + + " \"AIC_CLLI\": \"ATLMY8GA\", " + + " \"bandwidth\": \"10\", " + + " \"bandwidth_units\": \"Gbps\", " + + " \"param\": \"ABCD\", " + + " \"vnf_instance_name\": \"sample\" " + + " }"; + + + + public PresetMSOCreateServiceInstanceGen2WithNamesEcompNamingFalse(Map<Keys, String> names, int suffix, String requestId) { + super(names, suffix, requestId); + } + + @Override + public boolean isStrictMatch() { + return false; + } + + protected String getVnfInstanceParams() { + if (!Features.FLAG_SHIFT_VFMODULE_PARAMS_TO_VNF.isActive()) { + return ""; + } + + if (Features.FLAG_SUPPLEMENTARY_FILE.isActive()) { + return INSTANCE_PARAMS_WITH_SUPP_FILE_VNF; + } + return INSTANCE_PARAMS_VNF; + } + + protected String getVFModuleInstanceParams() { + if (Features.FLAG_SUPPLEMENTARY_FILE.isActive()) { + return INSTANCE_PARAMS_WITH_SUPP_FILE_VF_MODULE; + } + return INSTANCE_PARAMS_VF_MODULE; + } + + @Override + public Object getRequestBody() { + return "" + + "{ " + + " \"requestDetails\": { " + + " \"modelInfo\": { " + + " \"modelInvariantId\": \"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0\", " + + " \"modelVersionId\": \"6b528779-44a3-4472-bdff-9cd15ec93450\", " + + " \"modelName\": \"action-data\", " + + " \"modelType\": \"service\", " + + " \"modelVersion\": \"1.0\" " + + " }, " + + " \"owningEntity\": { " + + " \"owningEntityId\": \"d61e6f2d-12fa-4cc2-91df-7c244011d6fc\", " + + " \"owningEntityName\": \"MetroPacketCore\" " + + " }, " + + " \"subscriberInfo\": { " + + " \"globalSubscriberId\": \"e433710f-9217-458d-a79d-1c7aff376d89\" " + + " }, " + + " \"project\": { " + + " \"projectName\": \"DFW\" " + + " }, " + + " \"requestInfo\": { " + + " \"instanceName\": \"" + names.get(SERVICE_NAME) + suffix + "\", " + + " \"productFamilyId\": \"e433710f-9217-458d-a79d-1c7aff376d89\", " + + " \"source\": \"VID\", " + + " \"suppressRollback\": false, " + + " \"requestorId\": \"us16807000\" " + + " }, " + + " \"requestParameters\": { " + + " \"subscriptionServiceType\": \"TYLER SILVIA\", " + + " \"aLaCarte\": false, " + + " \"userParams\": [{ " + + " \"service\": { " + + " \"instanceName\": \"" + names.get(SERVICE_NAME) + suffix + "\", " + + " \"modelInfo\": { " + + " \"modelVersionId\": \"6b528779-44a3-4472-bdff-9cd15ec93450\", " + + " \"modelName\": \"action-data\", " + + " \"modelType\": \"service\" " + + " }, " + + " \"instanceParams\": [{ " + + " \"2017488_PASQUALEvpe0_ASN\": \"AV_vPE\"" + + " }" + + " ], " + + " \"resources\": { " + + " \"vnfs\": [{ " + + " \"instanceName\": \"" + names.get(VNF_NAME2) + suffix + "\", " + + " \"modelInfo\": { " + + " \"modelCustomizationName\": \"2017-388_PASQUALE-vPE 0\", " + + " \"modelCustomizationId\": \"b3c76f73-eeb5-4fb6-9d31-72a889f1811c\", " + + " \"modelInvariantId\": \"72e465fe-71b1-4e7b-b5ed-9496118ff7a8\", " + + " \"modelVersionId\": \"afacccf6-397d-45d6-b5ae-94c39734b168\", " + + " \"modelName\": \"2017-388_PASQUALE-vPE\", " + + " \"modelType\": \"vnf\", " + + " \"modelVersion\": \"4.0\" " + + " }, " + + " \"cloudConfiguration\": { " + + " \"lcpCloudRegionId\": \"hvf6\", " + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"bae71557c5bb4d5aac6743a4e5f1d054\" " + + " }, " + + " \"platform\": { " + + " \"platformName\": \"platform\" " + + " }, " + + " \"lineOfBusiness\": { " + + " \"lineOfBusinessName\": \"ECOMP\" " + + " }, " + + " \"productFamilyId\": \"e433710f-9217-458d-a79d-1c7aff376d89\", " + + " \"instanceParams\": [" + INSTANCE_PARAMS_VNF + "] " + + " }," + + " { " + //start of vnf + " \"instanceName\": \"" + names.get(VNF_NAME) + suffix + "\", " + + " \"modelInfo\": { " + + " \"modelCustomizationName\": \"2017-488_PASQUALE-vPE 0\", " + + " \"modelCustomizationId\": \"1da7b585-5e61-4993-b95e-8e6606c81e45\", " + + " \"modelInvariantId\": \"72e465fe-71b1-4e7b-b5ed-9496118ff7a8\", " + + " \"modelVersionId\": \"69e09f68-8b63-4cc9-b9ff-860960b5db09\", " + + " \"modelName\": \"2017-488_PASQUALE-vPE\", " + + " \"modelType\": \"vnf\", " + + " \"modelVersion\": \"5.0\" " + + " }, " + + " \"cloudConfiguration\": { " + + " \"lcpCloudRegionId\": \"hvf6\", " + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"bae71557c5bb4d5aac6743a4e5f1d054\" " + + " }, " + + " \"platform\": { " + + " \"platformName\": \"platform\" " + + " }, " + + " \"lineOfBusiness\": { " + + " \"lineOfBusinessName\": \"ECOMP\" " + + " }, " + + " \"productFamilyId\": \"e433710f-9217-458d-a79d-1c7aff376d89\", " + + " \"instanceParams\": [" + getVnfInstanceParams() + "], " + + " \"vfModules\": [{ " + + " \"instanceName\": \"" + names.get(VFM_NAME1) + suffix + "\", " + + " \"modelInfo\": { " + + " \"modelCustomizationName\": \"2017488PASQUALEVpe..PASQUALE_base_vPE_BV..module-0\", " + + " \"modelCustomizationId\": \"a55961b2-2065-4ab0-a5b7-2fcee1c227e3\", " + + " \"modelInvariantId\": \"b34833bb-6aa9-4ad6-a831-70b06367a091\", " + + " \"modelVersionId\": \"f8360508-3f17-4414-a2ed-6bc71161e8db\", " + + " \"modelName\": \"2017488PASQUALEVpe..PASQUALE_base_vPE_BV..module-0\", " + + " \"modelType\": \"vfModule\", " + + " \"modelVersion\": \"5\" " + + " }, " + + " \"instanceParams\": [] " + + " }, { " + + " \"instanceName\": \"" + names.get(VFM_NAME2) + suffix + "\", " + + " \"volumeGroupInstanceName\": \"" + names.get(VG_NAME) + suffix + "\", " + + " \"modelInfo\": { " + + " \"modelCustomizationName\": \"2017488PASQUALEVpe..PASQUALE_vRE_BV..module-1\", " + + " \"modelCustomizationId\": \"f7e7c365-60cf-49a9-9ebf-a1aa11b9d401\", " + + " \"modelInvariantId\": \"7253ff5c-97f0-4b8b-937c-77aeb4d79aa1\", " + + " \"modelVersionId\": \"25284168-24bb-4698-8cb4-3f509146eca5\", " + + " \"modelName\": \"2017488PASQUALEVpe..PASQUALE_vRE_BV..module-1\", " + + " \"modelType\": \"vfModule\", " + + " \"modelVersion\": \"6\" " + + " }, " + + " \"instanceParams\": [" + getVFModuleInstanceParams() + "] " + + " }" + //end of vfModule + " ] " + //end of vfModules list + " }" + //end of vnf + addDuplicatedVnfIfFeatureOn() + + " ] " + //end of vnf list + " } " + + " } " + + " } " + + " ] " + + " } " + + " } " + + "}"; + + } + + private String addDuplicatedVnfIfFeatureOn() { + if (!Features.FLAG_DUPLICATE_VNF.isActive()) { + return ""; + } + + return + " ,{ " + //start of vnf + " \"instanceName\": \"" + names.get(VNF_NAME)+ "_001" + suffix + "\", " + + " \"modelInfo\": { " + + " \"modelCustomizationName\": \"2017-488_PASQUALE-vPE 0\", " + + " \"modelCustomizationId\": \"1da7b585-5e61-4993-b95e-8e6606c81e45\", " + + " \"modelInvariantId\": \"72e465fe-71b1-4e7b-b5ed-9496118ff7a8\", " + + " \"modelVersionId\": \"69e09f68-8b63-4cc9-b9ff-860960b5db09\", " + + " \"modelName\": \"2017-488_PASQUALE-vPE\", " + + " \"modelType\": \"vnf\", " + + " \"modelVersion\": \"5.0\" " + + " }, " + + " \"cloudConfiguration\": { " + + " \"lcpCloudRegionId\": \"hvf6\", " + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"bae71557c5bb4d5aac6743a4e5f1d054\" " + + " }, " + + " \"platform\": { " + + " \"platformName\": \"platform\" " + + " }, " + + " \"lineOfBusiness\": { " + + " \"lineOfBusinessName\": \"ECOMP\" " + + " }, " + + " \"productFamilyId\": \"e433710f-9217-458d-a79d-1c7aff376d89\", " + + " \"instanceParams\": [" + getVnfInstanceParams() + "], " + + " \"vfModules\": [{ " + + " \"instanceName\": \"" + names.get(VFM_NAME1) + "_001" + suffix + "\", " + + " \"modelInfo\": { " + + " \"modelCustomizationName\": \"2017488PASQUALEVpe..PASQUALE_base_vPE_BV..module-0\", " + + " \"modelCustomizationId\": \"a55961b2-2065-4ab0-a5b7-2fcee1c227e3\", " + + " \"modelInvariantId\": \"b34833bb-6aa9-4ad6-a831-70b06367a091\", " + + " \"modelVersionId\": \"f8360508-3f17-4414-a2ed-6bc71161e8db\", " + + " \"modelName\": \"2017488PASQUALEVpe..PASQUALE_base_vPE_BV..module-0\", " + + " \"modelType\": \"vfModule\", " + + " \"modelVersion\": \"5\" " + + " }, " + + " \"instanceParams\": [] " + + " }, { " + + " \"instanceName\": \"" + names.get(VFM_NAME2) + "_001" + suffix + "\", " + + " \"volumeGroupInstanceName\": \"" + names.get(VG_NAME) + "_001" + suffix + "\", " + + " \"modelInfo\": { " + + " \"modelCustomizationName\": \"2017488PASQUALEVpe..PASQUALE_vRE_BV..module-1\", " + + " \"modelCustomizationId\": \"f7e7c365-60cf-49a9-9ebf-a1aa11b9d401\", " + + " \"modelInvariantId\": \"7253ff5c-97f0-4b8b-937c-77aeb4d79aa1\", " + + " \"modelVersionId\": \"25284168-24bb-4698-8cb4-3f509146eca5\", " + + " \"modelName\": \"2017488PASQUALEVpe..PASQUALE_vRE_BV..module-1\", " + + " \"modelType\": \"vfModule\", " + + " \"modelVersion\": \"6\" " + + " }, " + + " \"instanceParams\": [" + getVFModuleInstanceParams() + "] " + + " }" + //end of vfModule + " ] " + //end of vfModules list + " }" + //end of vnf + " ,{ " + //start of vnf + " \"instanceName\": \"" + names.get(VNF_NAME)+ "_002" + suffix + "\", " + + " \"modelInfo\": { " + + " \"modelCustomizationName\": \"2017-488_PASQUALE-vPE 0\", " + + " \"modelCustomizationId\": \"1da7b585-5e61-4993-b95e-8e6606c81e45\", " + + " \"modelInvariantId\": \"72e465fe-71b1-4e7b-b5ed-9496118ff7a8\", " + + " \"modelVersionId\": \"69e09f68-8b63-4cc9-b9ff-860960b5db09\", " + + " \"modelName\": \"2017-488_PASQUALE-vPE\", " + + " \"modelType\": \"vnf\", " + + " \"modelVersion\": \"5.0\" " + + " }, " + + " \"cloudConfiguration\": { " + + " \"lcpCloudRegionId\": \"hvf6\", " + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"bae71557c5bb4d5aac6743a4e5f1d054\" " + + " }, " + + " \"platform\": { " + + " \"platformName\": \"platform\" " + + " }, " + + " \"lineOfBusiness\": { " + + " \"lineOfBusinessName\": \"ECOMP\" " + + " }, " + + " \"productFamilyId\": \"e433710f-9217-458d-a79d-1c7aff376d89\", " + + " \"instanceParams\": [" + getVnfInstanceParams() + "], " + + " \"vfModules\": [{ " + + " \"instanceName\": \"" + names.get(VFM_NAME1) + "_002" + suffix + "\", " + + " \"modelInfo\": { " + + " \"modelCustomizationName\": \"2017488PASQUALEVpe..PASQUALE_base_vPE_BV..module-0\", " + + " \"modelCustomizationId\": \"a55961b2-2065-4ab0-a5b7-2fcee1c227e3\", " + + " \"modelInvariantId\": \"b34833bb-6aa9-4ad6-a831-70b06367a091\", " + + " \"modelVersionId\": \"f8360508-3f17-4414-a2ed-6bc71161e8db\", " + + " \"modelName\": \"2017488PASQUALEVpe..PASQUALE_base_vPE_BV..module-0\", " + + " \"modelType\": \"vfModule\", " + + " \"modelVersion\": \"5\" " + + " }, " + + " \"instanceParams\": [] " + + " }, { " + + " \"instanceName\": \"" + names.get(VFM_NAME2) + "_002" + suffix + "\", " + + " \"volumeGroupInstanceName\": \"" + names.get(VG_NAME) + "_002" + suffix + "\", " + + " \"modelInfo\": { " + + " \"modelCustomizationName\": \"2017488PASQUALEVpe..PASQUALE_vRE_BV..module-1\", " + + " \"modelCustomizationId\": \"f7e7c365-60cf-49a9-9ebf-a1aa11b9d401\", " + + " \"modelInvariantId\": \"7253ff5c-97f0-4b8b-937c-77aeb4d79aa1\", " + + " \"modelVersionId\": \"25284168-24bb-4698-8cb4-3f509146eca5\", " + + " \"modelName\": \"2017488PASQUALEVpe..PASQUALE_vRE_BV..module-1\", " + + " \"modelType\": \"vfModule\", " + + " \"modelVersion\": \"6\" " + + " }, " + + " \"instanceParams\": [" + getVFModuleInstanceParams() + "] " + + " }" + //end of vfModule + " ] " + //end of vfModules list + " }" ; //end of vnf + } + + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceMultipleVnfsServiceCypress.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceMultipleVnfsServiceCypress.java new file mode 100644 index 000000000..065050a63 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstanceMultipleVnfsServiceCypress.java @@ -0,0 +1,56 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import java.util.Map; + +public class PresetMSOCreateServiceInstanceMultipleVnfsServiceCypress extends PresetMSOCreateServiceInstanceGen2WithNames { + + public PresetMSOCreateServiceInstanceMultipleVnfsServiceCypress(Map<Keys, String> names, int suffix, String requestId) { + super(names, suffix, requestId); + } + + @Override + public boolean isStrictMatch() { + return true; + } + + @Override + public Object getRequestBody() { + return "" + + "{ " + + " \"requestDetails\": { " + + " \"modelInfo\": { " + + " \"modelType\": \"service\", " + + " \"modelInvariantId\": \"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0\", " + + " \"modelVersionId\": \"6e59c5de-f052-46fa-aa7e-2fca9d674c44\", " + + " \"modelName\": \"ComplexService\", " + + " \"modelVersion\": \"1.0\" " + + " }, " + + " \"owningEntity\": { " + + " \"owningEntityName\": \"aaa1\", " + + " \"owningEntityId\": \"aaa1\" " + + " }, " + + " \"project\": { " + + " \"projectName\": \"yyy1\" " + + " }, " + + " \"subscriberInfo\": { " + + " \"globalSubscriberId\": \"e433710f-9217-458d-a79d-1c7aff376d89\" " + + " }, " + + " \"requestInfo\": { " + + " \"source\": \"VID\", " + + " \"suppressRollback\": false, " + + " \"productFamilyId\": \"36b4733a-53f4-4cc8-8ff0-9172e5fc4b8e\", " + + " \"instanceName\": \"" + names.get(Keys.SERVICE_NAME) + suffix + "\", " + + " \"requestorId\": \"us16807000\" " + + " }, " + + " \"requestParameters\": { " + + " \"testApi\": \"GR_API\", " + + " \"subscriptionServiceType\": \"TYLER SILVIA\", " + + " \"aLaCarte\": true, " + + " \"userParams\": [] " + + " } " + + " } " + + "} "; + + } + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstancePost.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstancePost.java index 931fe59e3..39b415fa2 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstancePost.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateServiceInstancePost.java @@ -3,10 +3,10 @@ package org.onap.simulator.presetGenerator.presets.mso; /** * Created by itzikliderman on 13/12/2017. */ -public class PresetMSOCreateServiceInstancePost extends PresetMSOBaseCreateServiceInstancePost { +public class PresetMSOCreateServiceInstancePost extends PresetMSOBaseCreateInstancePost { public String getReqPath() { - return getRootPath() + "/serviceInstances/v6"; + return getRootPath() + "/serviceInstances/v."; } } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVNFInstanceOnlyRelatedServiceInstance.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVNFInstanceOnlyRelatedServiceInstance.java new file mode 100644 index 000000000..f203a7df6 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVNFInstanceOnlyRelatedServiceInstance.java @@ -0,0 +1,74 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId; + +public class PresetMSOCreateVNFInstanceOnlyRelatedServiceInstance extends PresetMSOBaseCreateInstancePost { + private final String suffix; + private String serviceInstanceId; + private String vnfInstanceName; + + public PresetMSOCreateVNFInstanceOnlyRelatedServiceInstance(String vnfInstanceName, String vnfRequestId, String serviceInstanceId, String vnfInstanceId, int suffix) { + super(vnfRequestId, vnfInstanceId); + this.vnfInstanceName = vnfInstanceName; + this.serviceInstanceId = serviceInstanceId; + this.cloudOwner = PresetAAIGetCloudOwnersByCloudRegionId.ATT_NC; + this.suffix = formatSuffix(suffix); + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/vnfs"; + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"modelInfo\": {" + + " \"modelType\": \"vnf\"," + + " \"modelInvariantId\": \"ff5256d1-5a33-55df-13ab-12abad84e7ff\"," + + " \"modelVersionId\": \"fe042c22-ba82-43c6-b2f6-8f1fc4164091\"," + + " \"modelName\": \"vSAMP12\"," + + " \"modelVersion\": \"1.0\"," + + " \"modelCustomizationName\": \"vSAMP12 1\"," + + " \"modelCustomizationId\": \"a7f1d08e-b02d-11e6-80f5-76304dec7eb7\"" + + " }," + + " \"cloudConfiguration\": {" + + " \"lcpCloudRegionId\": \"mdt1\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\"" + + " }," + + " \"requestInfo\": {" + + " \"instanceName\": \"" + vnfInstanceName+suffix + "\"," + + " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"," + + " \"source\": \"VID\"," + + " \"suppressRollback\": true," + + " \"requestorId\": \"us16807000\"" + + " }," + + " \"platform\": {" + + " \"platformName\": \"vnf_platformName\"" + + " }," + + " \"lineOfBusiness\": {" + + " \"lineOfBusinessName\": \"vnf_lineOfBusinessName\"" + + " }," + + " \"relatedInstanceList\": [" + + " {" + + " \"relatedInstance\": {" + + " \"instanceId\": \"" + serviceInstanceId + "\"," + + " \"modelInfo\": {" + + " \"modelInvariantId\": \"0367689e-d41e-483f-b200-eab17e4a7f8d\"," + + " \"modelVersionId\": \"e3c34d88-a216-4f1d-a782-9af9f9588705\"," + + " \"modelName\": \"gayawabawe\"," + + " \"modelVersion\": \"5.1\"" + + " }" + + " }" + + " }" + + " ]," + + " \"requestParameters\": {" + + " \"userParams\": []," + + " \"testApi\": \"VNF_API\"" + + " }" + + " }" + + "}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVNFInstancePost.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVNFInstancePost.java deleted file mode 100644 index 443d78e81..000000000 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVNFInstancePost.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.onap.simulator.presetGenerator.presets.mso; - -public class PresetMSOCreateVNFInstancePost extends PresetMSOBaseCreateServiceInstancePost { - private String serviceInstanceId; - private String serviceModelVersionId; - - public PresetMSOCreateVNFInstancePost(String serviceInstanceId, String serviceModelVersionId) { - this.serviceInstanceId = serviceInstanceId; - this.serviceModelVersionId = serviceModelVersionId; - } - - @Override - public String getReqPath() { - return getRootPath() + "/serviceInstances/v./" + serviceInstanceId + "/vnfs"; - } - - @Override - public Object getRequestBody() { - return "{\"requestDetails\":{\"requestInfo\":{\"productFamilyId\":\"e433710f-9217-458d-a79d-1c7aff376d89\",\"source\":\"VID\",\"suppressRollback\":false,\"requestorId\":\"us16807000\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"ecomp\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"AAIAIC25\",\"tenantId\":\"092eb9e8e4b7412e8787dd091bc58e86\"},\"platform\":{\"platformName\":\"plat1\"},\"modelInfo\":{\"modelCustomizationId\":\"882e5dcb-ba9f-4766-8cde-e326638107db\",\"modelCustomizationName\":\"vDBE 0\",\"modelVersionId\":\"61535073-2e50-4141-9000-f66fea69b433\",\"modelName\":\"vDBE\",\"modelInvariantId\":\"fcdf49ce-6f0b-4ca2-b676-a484e650e734\",\"modelType\":\"vnf\",\"modelVersion\":\"0.2\"},\"requestParameters\":{\"userParams\":[],\"testApi\":\"GR_API\"},\"relatedInstanceList\":[{\"relatedInstance\":{\"instanceId\":\"" + serviceInstanceId + "\",\"modelInfo\":{\"modelVersionId\":\"" + serviceModelVersionId + "\",\"modelName\":\"vDBE_srv\",\"modelInvariantId\":\"9aa04749-c02c-432d-a90c-18caa361c833\",\"modelType\":\"service\",\"modelVersion\":\"1.0\"}}},{\"relatedInstance\":{\"instanceId\":\"AAI-12002-test3-vm230w\",\"modelInfo\":{\"modelName\":\"oam_group\",\"modelType\":\"networkCollection\",\"modelVersion\":\"1\",\"modelVersionId\":\"a0efd5fc-f7be-4502-936a-a6c6392b958f\",\"modelInvariantId\":\"9384abf9-1231-4da4-bd8d-89e4d2f8a749\"}}},{\"relatedInstance\":{\"instanceId\":\"AAI-12002-test3-vm230w\",\"modelInfo\":{\"modelName\":\"oam_group\",\"modelType\":\"networkCollection\",\"modelVersion\":\"1\",\"modelVersionId\":\"a0efd5fc-f7be-4502-936a-a6c6392b958f\",\"modelInvariantId\":\"9384abf9-1231-4da4-bd8d-89e4d2f8a749\"}}}]}}"; - } -} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVfModuleInstancePost.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVfModule.java index 4f662ee87..72538fc11 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVfModuleInstancePost.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVfModule.java @@ -1,17 +1,32 @@ package org.onap.simulator.presetGenerator.presets.mso; -public class PresetMSOCreateVfModuleInstancePost extends PresetMSOBaseCreateServiceInstancePost{ +public class PresetMSOCreateVfModule extends PresetMSOBaseCreateInstancePost { private String serviceInstanceId; private String vnfInstanceId; + private String instanceName; + private String modelVersionId; + private String modelInvariantId; + private String serviceName; - public PresetMSOCreateVfModuleInstancePost(String serviceInstanceId, String vnfInstanceId) { + public PresetMSOCreateVfModule(String serviceInstanceId, String vnfInstanceId, String cloudOwner) { + this(serviceInstanceId, vnfInstanceId, cloudOwner, "aa", "240376de-870e-48df-915a-31f140eedd2c", + "709d1be4-9a3f-4a29-8c4d-a20465e808a3", "Demo Service 1"); + } + + public PresetMSOCreateVfModule(String serviceInstanceId, String vnfInstanceId, + String cloudOwner, String instanceName, String modelVersionId, String modelInvariantId, String serviceName) { this.serviceInstanceId = serviceInstanceId; this.vnfInstanceId = vnfInstanceId; + this.cloudOwner = cloudOwner; + this.instanceName = instanceName; + this.modelVersionId = modelVersionId; + this.modelInvariantId = modelInvariantId; + this.serviceName = serviceName; } @Override public String getReqPath() { - return getRootPath() + "/serviceInstances/v./" + serviceInstanceId + "/vnfs/"+vnfInstanceId+"/vfModules"; + return getRootPath() + "/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/vnfs/"+vnfInstanceId+"/vfModules"; } @Override @@ -19,7 +34,7 @@ public class PresetMSOCreateVfModuleInstancePost extends PresetMSOBaseCreateServ return "{" + "\"requestDetails\":{" + "\"requestInfo\":{" + - "\"instanceName\":\"aa\"," + + "\"instanceName\":\"" + instanceName + "\"," + "\"source\":\"VID\"," + "\"suppressRollback\":false," + "\"requestorId\":\"us16807000\"" + @@ -40,6 +55,7 @@ public class PresetMSOCreateVfModuleInstancePost extends PresetMSOBaseCreateServ "}," + "\"cloudConfiguration\":{" + "\"lcpCloudRegionId\":\"mdt1\"," + + addCloudOwnerIfNeeded() + "\"tenantId\":\"092eb9e8e4b7412e8787dd091bc58e86\"" + "}," + "\"relatedInstanceList\":[" + @@ -48,10 +64,10 @@ public class PresetMSOCreateVfModuleInstancePost extends PresetMSOBaseCreateServ "\"instanceId\":\"" + serviceInstanceId + "\","+ "\"modelInfo\":{" + "\"modelType\":\"service\"," + - "\"modelName\":\"Demo Service 1\"," + - "\"modelInvariantId\":\"709d1be4-9a3f-4a29-8c4d-a20465e808a3\"," + + "\"modelName\":\"" + serviceName + "\","+ + "\"modelInvariantId\":\"" + modelInvariantId + "\","+ "\"modelVersion\":\"1.0\"," + - "\"modelVersionId\":\"240376de-870e-48df-915a-31f140eedd2c\"" + + "\"modelVersionId\":\"" + modelVersionId + "\"" + "}" + "}" + "}" + diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVfModuleALaCarteCypress.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVfModuleALaCarteCypress.java new file mode 100644 index 000000000..dabc526c7 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVfModuleALaCarteCypress.java @@ -0,0 +1,115 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import com.google.common.collect.ImmutableMap; +import java.util.Map; + +public class PresetMSOCreateVfModuleALaCarteCypress extends PresetMSOBaseCreateInstancePost { + private String serviceInstanceId; + private String vnfInstanceId; + protected final Map<Keys, String> names; + + public enum Keys { + modelVersionId, modelName, modelVersion, modelCustomizationId, modelCustomizationName, instanceName, modelInvariantId + } + + public static final Map<Keys, String> module0Names = ImmutableMap.<Keys, String>builder() + .put(Keys.instanceName, "mimazepubi") + .put(Keys.modelInvariantId, "b34833bb-6aa9-4ad6-a831-70b06367a091") + .put(Keys.modelVersionId, "f8360508-3f17-4414-a2ed-6bc71161e8db") + .put(Keys.modelName, "2017488PASQUALEVpe..PASQUALE_base_vPE_BV..module-0") + .put(Keys.modelVersion, "5") + .put(Keys.modelCustomizationId, "a55961b2-2065-4ab0-a5b7-2fcee1c227e3") + .put(Keys.modelCustomizationName, "2017488PASQUALEVpe..PASQUALE_base_vPE_BV..module-0") + .build(); + + public static final Map<Keys, String> module2Names = ImmutableMap.<Keys, String>builder() + .put(Keys.instanceName, "bnmgtrx") + .put(Keys.modelInvariantId, "eff8cc59-53a1-4101-aed7-8cf24ecf8339") + .put(Keys.modelVersionId, "0a0dd9d4-31d3-4c3a-ae89-a02f383e6a9a") + .put(Keys.modelName, "2017488PASQUALEVpe..PASQUALE_vPFE_BV..module-2") + .put(Keys.modelVersion, "6") + .put(Keys.modelCustomizationId, "3cd946bb-50e0-40d8-96d3-c9023520b557") + .put(Keys.modelCustomizationName, "2017488PASQUALEVpe..PASQUALE_vPFE_BV..module-2") + .build(); + + public PresetMSOCreateVfModuleALaCarteCypress(String overrideRequestId, String serviceInstanceId, String vnfInstanceId, Map<Keys, String> names, String testApi, boolean withTestApi) { + super(overrideRequestId); + this.vnfInstanceId = vnfInstanceId; + this.serviceInstanceId = serviceInstanceId; + this.names = names; + this.msoTestApi = testApi; + this.withTestApi = withTestApi; + } + + @Override + public boolean isStrictMatch() { + return true; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/vnfs/" + vnfInstanceId + "/vfModules"; + } + + @Override + public Object getRequestBody() { + return "" + + "{" + + " \"requestDetails\":{" + + " \"modelInfo\":{" + + " \"modelType\":\"vfModule\"," + + " \"modelInvariantId\":\"" + names.get(Keys.modelInvariantId) + "\"," + + " \"modelVersionId\":\"" + names.get(Keys.modelVersionId) + "\"," + + " \"modelName\":\"" + names.get(Keys.modelName) + "\"," + + " \"modelVersion\":\"" + names.get(Keys.modelVersion) + "\"," + + " \"modelCustomizationId\":\"" + names.get(Keys.modelCustomizationId) + "\"," + + " \"modelCustomizationName\":\"" + names.get(Keys.modelCustomizationName) + "\"" + + " }," + + " \"cloudConfiguration\":{" + + " \"lcpCloudRegionId\":\"hvf6\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\":\"624eb554b0d147c19ff8885341760481\"" + + + " }," + + " \"requestInfo\":{" + + " \"instanceName\":\"" + names.get(Keys.instanceName) + "\"," + + " \"source\":\"VID\"," + + " \"suppressRollback\":true," + + " \"requestorId\":\"us16807000\"" + + " }," + + " \"relatedInstanceList\":[{" + + " \"relatedInstance\":{" + + " \"instanceId\":\"" + serviceInstanceId + "\"," + + " \"modelInfo\":{" + + " \"modelType\":\"service\"," + + " \"modelName\":\"action-data\"," + + " \"modelInvariantId\":\"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0\"," + + " \"modelVersion\":\"1.0\"," + + " \"modelVersionId\":\"2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd\"" + + " }" + + " }" + + " }, {" + + " \"relatedInstance\":{" + + " \"instanceId\":\"" + vnfInstanceId + "\"," + + " \"modelInfo\":{" + + " \"modelType\":\"vnf\"," + + " \"modelName\":\"2017-488_PASQUALE-vPE\"," + + " \"modelInvariantId\":\"72e465fe-71b1-4e7b-b5ed-9496118ff7a8\"," + + " \"modelVersion\":\"5.0\"," + + " \"modelVersionId\":\"69e09f68-8b63-4cc9-b9ff-860960b5db09\"," + + " \"modelCustomizationId\":\"1da7b585-5e61-4993-b95e-8e6606c81e45\"," + + " \"modelCustomizationName\":\"2017-488_PASQUALE-vPE 0\"" + + " }" + + " }" + + " }" + + " ]," + + " \"requestParameters\":{" + + addTestApi()+ + " \"userParams\":[" + + " ]," + + " \"usePreload\":false" + + " }" + + " }" + + "}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVfModuleOldViewEdit.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVfModuleOldViewEdit.java new file mode 100644 index 000000000..bf085cae5 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVfModuleOldViewEdit.java @@ -0,0 +1,81 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSOCreateVfModuleOldViewEdit extends PresetMSOBaseCreateInstancePost { + private final String serviceInstanceId; + private final String vnfInstanceId; + private final String instanceName; + + public PresetMSOCreateVfModuleOldViewEdit(String overrideRequestId, String responseInstanceId , + String serviceInstanceId, String vnfInstanceId, + String instanceName, String msoTestApi, + String cloudOwner) { + super(overrideRequestId, responseInstanceId, msoTestApi); + this.serviceInstanceId = serviceInstanceId; + this.vnfInstanceId = vnfInstanceId; + this.instanceName = instanceName; + this.cloudOwner = cloudOwner; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/vnfs/"+vnfInstanceId+"/vfModules"; + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"requestInfo\": {" + + " \"instanceName\": \""+instanceName+"\"," + + " \"source\": \"VID\"," + + " \"suppressRollback\": false," + + " \"requestorId\": \"mo37915000\"" + + " }," + + " \"modelInfo\": {" + + " \"modelType\": \"vfModule\"," + + " \"modelInvariantId\": \"d9f9c851-9543-476e-b3c2-a2e5284a26aa\"," + + " \"modelVersionId\": \"d205e01d-e5da-4e68-8c52-f95cb0607959\"," + + " \"modelName\": \"Vsp1710pid298109Vmmsc..mmsc_mod1_ltm..module-8\"," + + " \"modelVersion\": \"1\"," + + " \"modelCustomizationId\": \"e81b58ce-ae9b-4bde-9f81-9962a5007756\"," + + " \"modelCustomizationName\": \"Vsp1710pid298109Vmmsc..mmsc_mod1_ltm..module-8\"" + + " }," + + " \"requestParameters\": {" + + addTestApi() + + " \"usePreload\": false" + + " }," + + " \"cloudConfiguration\": {" + + " \"lcpCloudRegionId\": \"mdt1\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"092eb9e8e4b7412e8787dd091bc58e86\"" + + " }," + + " \"relatedInstanceList\": [{" + + " \"relatedInstance\": {" + + " \"instanceId\": \""+serviceInstanceId+"\"," + + " \"modelInfo\": {" + + " \"modelType\": \"service\"," + + " \"modelName\": \"ServicevWINIFREDPID298109\"," + + " \"modelInvariantId\": \"a8dcd72d-d44d-44f2-aa85-53aa9ca0c657\"," + + " \"modelVersion\": \"1.0\"," + + " \"modelVersionId\": \"aa2f8e9c-9e47-4b15-a95c-4a93855ac61b\"" + + " }" + + " }" + + " }, {" + + " \"relatedInstance\": {" + + " \"instanceId\": \""+vnfInstanceId+"\"," + + " \"modelInfo\": {" + + " \"modelType\": \"vnf\"," + + " \"modelName\": \"VSP1710PID298109_vWINIFRED\"," + + " \"modelInvariantId\": \"e7961100-cde6-4b5a-bcda-b8945086950a\"," + + " \"modelVersion\": \"1.0\"," + + " \"modelVersionId\": \"959a7ba0-89ee-4984-9af6-65d5bdda4b0e\"," + + " \"modelCustomizationId\": \"6b8fc7dc-2db1-4283-a222-b07d10595495\"," + + " \"modelCustomizationName\": \"VSP1710PID298109_vWINIFRED 0\"" + + " }" + + " }" + + " }" + + " ]" + + " }" + + "}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVfModuleWithVolumeGroupALaCarteCypress.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVfModuleWithVolumeGroupALaCarteCypress.java new file mode 100644 index 000000000..c8fb7fcf9 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVfModuleWithVolumeGroupALaCarteCypress.java @@ -0,0 +1,116 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSOCreateVfModuleWithVolumeGroupALaCarteCypress extends PresetMSOBaseCreateInstancePost { + private final String serviceInstanceId; + private final String vnfInstanceId; + private final String volumeGroupInstanceId; + private final boolean isVolumeGroupPreset; + private PresetMSOCreateVfModuleWithVolumeGroupALaCarteCypress(Boolean isVolumeGroupPreset, String requestId, String serviceInstanceId, String vnfInstanceId, String volumeGroupInstanceId, String testApi, boolean withTestApi) { + super(requestId, isVolumeGroupPreset ? volumeGroupInstanceId : DEFAULT_INSTANCE_ID, testApi, withTestApi); + this.serviceInstanceId = serviceInstanceId; + this.vnfInstanceId = vnfInstanceId; + this.isVolumeGroupPreset = isVolumeGroupPreset; + this.volumeGroupInstanceId = volumeGroupInstanceId; + } + + public static PresetMSOCreateVfModuleWithVolumeGroupALaCarteCypress forVfModule(String requestId, String serviceInstanceId, String vnfInstanceId, String volumeGroupInstanceId, String testApi, boolean withTestApi) { + return new PresetMSOCreateVfModuleWithVolumeGroupALaCarteCypress(false, requestId, serviceInstanceId, vnfInstanceId, volumeGroupInstanceId, testApi, withTestApi); + } + + public static PresetMSOCreateVfModuleWithVolumeGroupALaCarteCypress forVolumeGroup(String requestId, String serviceInstanceId, String vnfInstanceId, String testApi, boolean withTestApi) { + return new PresetMSOCreateVfModuleWithVolumeGroupALaCarteCypress(true, requestId, serviceInstanceId, vnfInstanceId, requestId,testApi, withTestApi); + } + + @Override + public boolean isStrictMatch() { + return true; + } + + @Override + public String getReqPath() { + if (isVolumeGroupPreset) { + return getRootPath() + "/serviceInstances/v./" + serviceInstanceId + "/vnfs/" + vnfInstanceId + "/volumeGroups"; + } else { + return getRootPath() + "/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/vnfs/" + vnfInstanceId + "/vfModules"; + } + } + + @Override + public Object getRequestBody() { + return "" + + "{" + + " \"requestDetails\":{" + + " \"modelInfo\":{" + + " \"modelType\":\"" + select("volumeGroup", "vfModule") + "\"," + + " \"modelInvariantId\":\"7253ff5c-97f0-4b8b-937c-77aeb4d79aa1\"," + + " \"modelVersionId\":\"25284168-24bb-4698-8cb4-3f509146eca5\"," + + " \"modelName\":\"2017488PASQUALEVpe..PASQUALE_vRE_BV..module-1\"," + + " \"modelVersion\":\"6\"," + + " \"modelCustomizationId\":\"f7e7c365-60cf-49a9-9ebf-a1aa11b9d401\"," + + " \"modelCustomizationName\":\"2017488PASQUALEVpe..PASQUALE_vRE_BV..module-1\"" + + " }," + + " \"cloudConfiguration\":{" + + " \"lcpCloudRegionId\":\"my region\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\":\"092eb9e8e4b7412e8787dd091bc58e86\"" + + " }," + + " \"requestInfo\":{" + + " \"instanceName\":\"" + select("puwesovabe_vol", "puwesovabe") + "\"," + + " \"source\":\"VID\"," + + " \"suppressRollback\":false," + + " \"requestorId\":\"us16807000\"" + + " }," + + " \"relatedInstanceList\":[{" + + " \"relatedInstance\":{" + + " \"instanceId\":\"" + serviceInstanceId + "\"," + + " \"modelInfo\":{" + + " \"modelType\":\"service\"," + + " \"modelName\":\"action-data\"," + + " \"modelInvariantId\":\"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0\"," + + " \"modelVersion\":\"1.0\"," + + " \"modelVersionId\":\"2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd\"" + + " }" + + " }" + + " }, {" + + " \"relatedInstance\":{" + + " \"instanceId\":\"" + vnfInstanceId + "\"," + + " \"modelInfo\":{" + + " \"modelType\":\"vnf\"," + + " \"modelName\":\"2017-488_PASQUALE-vPE\"," + + " \"modelInvariantId\":\"72e465fe-71b1-4e7b-b5ed-9496118ff7a8\"," + + " \"modelVersion\":\"5.0\"," + + " \"modelVersionId\":\"69e09f68-8b63-4cc9-b9ff-860960b5db09\"," + + " \"modelCustomizationId\":\"1da7b585-5e61-4993-b95e-8e6606c81e45\"," + + " \"modelCustomizationName\":\"2017-488_PASQUALE-vPE 0\"" + + " }" + + " }" + + select("", " }, {" + + " \"relatedInstance\":{" + + " \"modelInfo\":{" + + " \"modelType\":\"volumeGroup\"" + + " }," + + " \"instanceId\":\"" + volumeGroupInstanceId + "\"," + + " \"instanceName\":\"puwesovabe_vol\"" + + " } ") + + " }" + + " ]," + + " \"requestParameters\":{" + + addTestApi()+ + " \"userParams\":[{" + + " \"2017488_PASQUALEvpe0_vnf_instance_name\":\"mtnj309me6\"," + + " \"2017488_PASQUALEvpe0_vnf_config_template_version\":\"17.2\"," + + " \"PASQUALEvpe0_bandwidth\":\"10\"," + + " \"2017488_PASQUALEvpe0_AIC_CLLI\":\"ATLMY8GA\"," + + " \"PASQUALEvpe0_bandwidth_units\":\"Gbps\"" + + " }" + + " ]," + + " \"usePreload\":true" + + " }" + + " }" + + "}"; + } + + private String select(String ofVolumeGroup, String ofVfModule) { + return isVolumeGroupPreset ? ofVolumeGroup : ofVfModule; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfALaCarteCypress2.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfALaCarteCypress2.java new file mode 100644 index 000000000..96424e803 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfALaCarteCypress2.java @@ -0,0 +1,51 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSOCreateVnfALaCarteCypress2 extends PresetMSOCreateVnfBase { + private String vnfInstanceName; + + public PresetMSOCreateVnfALaCarteCypress2(String overrideRequestId, String serviceInstanceId, String responseInstanceId, String vnfInstanceName, String testApi, boolean withTestApi) { + super(overrideRequestId, serviceInstanceId, responseInstanceId); + this.vnfInstanceName = vnfInstanceName; + this.msoTestApi = testApi; + this.withTestApi = withTestApi; + } + + @Override + public Object getRequestBody() { + return "{\"requestDetails\":" + + "{\"requestInfo\":" + + "{\"instanceName\":\""+vnfInstanceName+"\"," + + "\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"," + + "\"source\":\"VID\"," + + "\"suppressRollback\":false," + + "\"requestorId\":\"us16807000\"}," + + "\"lineOfBusiness\":{\"lineOfBusinessName\":\"zzz1\"}," + + "\"cloudConfiguration\":" + + "{\"lcpCloudRegionId\":\"just another region\"," + + addCloudOwnerIfNeeded() + + "\"tenantId\":\"092eb9e8e4b7412e8787dd091bc58e86\"}," + + "\"platform\":{\"platformName\":\"xxx1\"}," + + "\"modelInfo\":" + + "{\"modelCustomizationId\":\"1da7b585-5e61-4993-b95e-8e6606c81e45\"," + + "\"modelCustomizationName\":\"2017-488_PASQUALE-vPE 0\"," + + "\"modelVersionId\":\"69e09f68-8b63-4cc9-b9ff-860960b5db09\"," + + "\"modelName\":\"2017-488_PASQUALE-vPE\"," + + "\"modelInvariantId\":\"72e465fe-71b1-4e7b-b5ed-9496118ff7a8\"," + + "\"modelType\":\"vnf\"," + + "\"modelVersion\":\"5.0\"}," + + "\"requestParameters\":{" + + addTestApi()+ + "\"userParams\":[]}, " + + "\"relatedInstanceList\":[" + + "{\"relatedInstance\":{" + + "\"instanceId\":\""+serviceInstanceId+"\"," + + "\"modelInfo\":{" + + "\"modelVersionId\":\"2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd\"," + + "\"modelName\":\"action-data\"," + + "\"modelInvariantId\":\"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0\"," + + "\"modelType\":\"service\"," + + "\"modelVersion\":\"1.0\"" + + "}}}]" + + "}}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfALaCarteOldViewEdit.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfALaCarteOldViewEdit.java new file mode 100644 index 000000000..7947c5b83 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfALaCarteOldViewEdit.java @@ -0,0 +1,69 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSOCreateVnfALaCarteOldViewEdit extends PresetMSOCreateVnfBase { + private String vnfInstanceName; + private boolean haveLOB; + + public PresetMSOCreateVnfALaCarteOldViewEdit(String overrideRequestId, String serviceInstanceId, + String vnfInstanceName, boolean haveLOB, String msoTestApi) { + super(overrideRequestId, serviceInstanceId); + this.vnfInstanceName = vnfInstanceName; + this.haveLOB = haveLOB; + this.msoTestApi = msoTestApi; + this.withTestApi = true; + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"requestInfo\": {" + + " \"instanceName\": \""+vnfInstanceName+"\"," + + " \"source\": \"VID\"," + + " \"suppressRollback\": false," + + " \"requestorId\": \"mo37915000\"," + + " \"productFamilyId\": \"ebc3bc3d-62fd-4a3f-a037-f619df4ff034\"" + + " }," + + " \"modelInfo\": {" + + " \"modelType\": \"vnf\"," + + " \"modelInvariantId\": \"e7961100-cde6-4b5a-bcda-b8945086950a\"," + + " \"modelVersionId\": \"959a7ba0-89ee-4984-9af6-65d5bdda4b0e\"," + + " \"modelName\": \"VSP1710PID298109_vWINIFRED\"," + + " \"modelVersion\": \"1.0\"," + + " \"modelCustomizationId\": \"6b8fc7dc-2db1-4283-a222-b07d10595495\"," + + " \"modelCustomizationName\": \"VSP1710PID298109_vWINIFRED 0\"" + + " }," + + " \"requestParameters\": {" + + addTestApi() + + " \"userParams\": []" + + " }," + + " \"cloudConfiguration\": {" + + " \"lcpCloudRegionId\": \"some legacy region\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"092eb9e8e4b7412e8787dd091bc58e86\"" + + " }," + + selectLob("\"lineOfBusiness\": {\"lineOfBusinessName\": \"ECOMP\"},", "") + + " \"platform\": {" + + " \"platformName\": \"platform\"" + + " }," + + " \"relatedInstanceList\": [{" + + " \"relatedInstance\": {" + + " \"instanceId\": \""+serviceInstanceId+"\"," + + " \"modelInfo\": {" + + " \"modelType\": \"service\"," + + " \"modelName\": \"ServicevWINIFREDPID298109\"," + + " \"modelInvariantId\": \"a8dcd72d-d44d-44f2-aa85-53aa9ca0c657\"," + + " \"modelVersion\": \"1.0\"," + + " \"modelVersionId\": \"aa2f8e9c-9e47-4b15-a95c-4a93855ac61b\"" + + " }" + + " }" + + " }" + + " ]" + + " }"+ + "}"; + } + + private String selectLob(String lob, String noLob) { + return haveLOB ? lob : noLob; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfALaCarteServiceCypress.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfALaCarteServiceCypress.java new file mode 100644 index 000000000..2be8c639b --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfALaCarteServiceCypress.java @@ -0,0 +1,51 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSOCreateVnfALaCarteServiceCypress extends PresetMSOCreateVnfBase { + protected String vnfInstanceName; + protected String lineOfBusinessName; + + public PresetMSOCreateVnfALaCarteServiceCypress(String overrideRequestId, String serviceInstanceId, String vnfInstanceName, String lineOfBusinessName) { + super(overrideRequestId, serviceInstanceId); + this.vnfInstanceName = vnfInstanceName; + this.lineOfBusinessName = lineOfBusinessName; + } + + @Override + public Object getRequestBody() { + return "{\"requestDetails\":" + + "{\"requestInfo\":" + + "{\"instanceName\":\""+vnfInstanceName+"\"," + + "\"productFamilyId\":\"36b4733a-53f4-4cc8-8ff0-9172e5fc4b8e\"," + + "\"source\":\"VID\"," + + "\"suppressRollback\":false," + + "\"requestorId\":\"us16807000\"}," + + "\"lineOfBusiness\":{\"lineOfBusinessName\":\""+lineOfBusinessName+"\"}," + + "\"cloudConfiguration\":" + + "{\"lcpCloudRegionId\":\"hvf6\"," + + addCloudOwnerIfNeeded() + + "\"tenantId\":\"bae71557c5bb4d5aac6743a4e5f1d054\"}," + + "\"platform\":{\"platformName\":\"platform\"}," + + "\"modelInfo\":" + + "{\"modelCustomizationId\":\"91415b44-753d-494c-926a-456a9172bbb9\"," + + "\"modelCustomizationName\":\"VF_vGeraldine 0\"," + + "\"modelVersionId\":\"d6557200-ecf2-4641-8094-5393ae3aae60\"," + + "\"modelName\":\"VF_vGeraldine\"," + + "\"modelInvariantId\":\"4160458e-f648-4b30-a176-43881ffffe9e\"," + + "\"modelType\":\"vnf\"," + + "\"modelVersion\":\"2.0\"}," + + "\"requestParameters\":{" + + "\"testApi\": \"GR_API\", " + + "\"userParams\":[]" + + "}," + + "\"relatedInstanceList\":[" + + "{\"relatedInstance\":{" + + "\"instanceId\":\"f8791436-8d55-4fde-b4d5-72dd2cf13cfb\"," + + "\"modelInfo\":{" + + "\"modelVersionId\":\"6e59c5de-f052-46fa-aa7e-2fca9d674c44\"," + + "\"modelName\":\"ComplexService\"," + + "\"modelInvariantId\":\"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0\"," + + "\"modelType\":\"service\"," + + "\"modelVersion\":\"1.0\"" + + "}}}]}}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfALaCarteServiceCypress2.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfALaCarteServiceCypress2.java new file mode 100644 index 000000000..afdb3f49b --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfALaCarteServiceCypress2.java @@ -0,0 +1,47 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSOCreateVnfALaCarteServiceCypress2 extends PresetMSOCreateVnfALaCarteServiceCypress { + + public PresetMSOCreateVnfALaCarteServiceCypress2(String overrideRequestId, String serviceInstanceId, String vnfInstanceName, String lineOfBusinessName) { + super(overrideRequestId, serviceInstanceId, vnfInstanceName, lineOfBusinessName); + } + + @Override + public Object getRequestBody() { + return "{\"requestDetails\":" + + "{\"requestInfo\":" + + "{\"instanceName\":\""+vnfInstanceName+"\"," + + "\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"," + + "\"source\":\"VID\"," + + "\"suppressRollback\":false," + + "\"requestorId\":\"us16807000\"}," + + "\"lineOfBusiness\":{\"lineOfBusinessName\":\""+lineOfBusinessName+"\"}," + + "\"cloudConfiguration\":" + + "{\"lcpCloudRegionId\":\"hvf6\"," + + addCloudOwnerIfNeeded() + + "\"tenantId\":\"229bcdc6eaeb4ca59d55221141d01f8e\"}," + + "\"platform\":{\"platformName\":\"xxx1\"}," + + "\"modelInfo\":" + + "{\"modelCustomizationId\":\"b3c76f73-eeb5-4fb6-9d31-72a889f1811c\"," + + "\"modelCustomizationName\":\"2017-388_PASQUALE-vPE 0\"," + + "\"modelVersionId\":\"afacccf6-397d-45d6-b5ae-94c39734b168\"," + + "\"modelName\":\"2017-388_PASQUALE-vPE\"," + + "\"modelInvariantId\":\"72e465fe-71b1-4e7b-b5ed-9496118ff7a8\"," + + "\"modelType\":\"vnf\"," + + "\"modelVersion\":\"4.0\"}," + + "\"requestParameters\":{" + + "\"testApi\": \"VNF_API\", " + + "\"userParams\":[]" + + "}," + + "\"relatedInstanceList\":[" + + "{\"relatedInstance\":{" + + "\"instanceId\":\"f8791436-8d55-4fde-b4d5-72dd2cf13cfb\"," + + "\"modelInfo\":{" + + "\"modelVersionId\":\"6b528779-44a3-4472-bdff-9cd15ec93450\"," + + "\"modelName\":\"action-data\"," + + "\"modelInvariantId\":\"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0\"," + + "\"modelType\":\"service\"," + + "\"modelVersion\":\"1.0\"" + + "}}}]}}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfBase.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfBase.java new file mode 100644 index 000000000..0fcbb3fe0 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfBase.java @@ -0,0 +1,25 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSOCreateVnfBase extends PresetMSOBaseCreateInstancePost { + protected String serviceInstanceId; + + public PresetMSOCreateVnfBase(String requestId, String serviceInstanceId) { + super(requestId); + this.serviceInstanceId = serviceInstanceId; + } + + public PresetMSOCreateVnfBase(String requestId, String serviceInstanceId, String responseInstanceId) { + super(requestId, responseInstanceId); + this.serviceInstanceId = serviceInstanceId; + } + + @Override + public boolean isStrictMatch() { + return true; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/vnfs"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfGroup.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfGroup.java new file mode 100644 index 000000000..ac2d6f4b9 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfGroup.java @@ -0,0 +1,68 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSOCreateVnfGroup extends PresetMSOBaseCreateInstancePost { + private String serviceInstanceId; + private String modelInfo; + private String instanceName; + private boolean suppressRollback; + + public PresetMSOCreateVnfGroup(String instanceName, String vnfGroupRequestId, String groupModelInfo, String serviceInstanceId,boolean suppressRollback ) { + super(vnfGroupRequestId); + this.serviceInstanceId = serviceInstanceId; + this.modelInfo = groupModelInfo; + this.instanceName = instanceName; + this.suppressRollback = suppressRollback; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./instanceGroups"; + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\": {" + + modelInfo + + " \"requestInfo\": {" + + " \"instanceName\": \"" + instanceName + "\"," + + " \"source\": \"VID\"," + + " \"suppressRollback\": "+suppressRollback+"," + + " \"requestorId\": \"us16807000\"" + + " }," + + " \"relatedInstanceList\": [" + + " {" + + " \"relatedInstance\": {" + + " \"instanceId\": \"" + serviceInstanceId + "\"," + + " \"modelInfo\": {" + + " \"modelType\": \"service\"," + + " \"modelInvariantId\": \"7ee41ce4-4827-44b0-a48e-2707a59905d2\"," + + " \"modelVersionId\": \"4117a0b6-e234-467d-b5b9-fe2f68c8b0fc\"," + + " \"modelName\": \"Grouping Service for Test\"," + + " \"modelVersion\": \"1.0\"" + + " }" + + " }" + + " }" + + " ]," + + " \"requestParameters\": {" + + " \"testApi\": \"VNF_API\", " + + " \"userParams\": []" + + " }" + + " }" + + "}"; + } + + //only modelType and modelVersionId are required by MSO fro create instance group + public static final String MODEL_INFO_0 = "" + + " \"modelInfo\": {" + + " \"modelType\": \"instanceGroup\"," + + " \"modelVersionId\": \"daeb6568-cef8-417f-9075-ed259ce59f48\"" + + " },"; + + public static final String MODEL_INFO_1 = "" + + " \"modelInfo\": {" + + " \"modelType\": \"instanceGroup\"," + + " \"modelVersionId\": \"c2b300e6-45de-4e5e-abda-3032bee2de56\"" + + " },"; + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfVlanTagging.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfVlanTagging.java new file mode 100644 index 000000000..9fd0a678f --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVnfVlanTagging.java @@ -0,0 +1,94 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSOCreateVnfVlanTagging extends PresetMSOBaseCreateInstancePost { + private final boolean ecompNamingEnabled; + private String serviceInstanceId; + private String serviceModelVersionId; + + public PresetMSOCreateVnfVlanTagging(String serviceInstanceId, String serviceModelVersionId, boolean ecompNamingEnabled) { + this.serviceInstanceId = serviceInstanceId; + this.serviceModelVersionId = serviceModelVersionId; + this.ecompNamingEnabled = ecompNamingEnabled; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/vnfs"; + } + + @Override + public boolean isStrictMatch() { + return true; + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"requestInfo\": {" + + " \"productFamilyId\": \"e433710f-9217-458d-a79d-1c7aff376d89\"," + + " \"source\": \"VID\"," + + " \"suppressRollback\": false," + + " \"instanceName\" : \"NewName\"," + +// addInstanceNameIfNeeded()+ + " \"requestorId\": \"us16807000\"" + + " }," + + " \"lineOfBusiness\": {" + + " \"lineOfBusinessName\": \"ECOMP\"" + + " }," + + " \"cloudConfiguration\": {" + + " \"lcpCloudRegionId\": \"JANET25\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"092eb9e8e4b7412e8787dd091bc58e86\"" + + " }," + + " \"platform\": {" + + " \"platformName\": \"xxx1\"" + + " }," + + " \"modelInfo\": {" + + " \"modelCustomizationId\": \"882e5dcb-ba9f-4766-8cde-e326638107db\"," + + " \"modelCustomizationName\": \"vDOROTHEA 0\"," + + " \"modelVersionId\": \"61535073-2e50-4141-9000-f66fea69b433\"," + + " \"modelName\": \"vDOROTHEA\"," + + " \"modelInvariantId\": \"fcdf49ce-6f0b-4ca2-b676-a484e650e734\"," + + " \"modelType\": \"vnf\"," + + " \"modelVersion\": \"0.2\"" + + " }," + + " \"requestParameters\": {" + + " \"userParams\": []," + + " \"testApi\": \"VNF_API\"" + + " }," + + " \"relatedInstanceList\": [{" + + " \"relatedInstance\": {" + + " \"instanceId\": \""+ serviceInstanceId +"\"," + + " \"modelInfo\": {" + + " \"modelVersionId\": \""+ serviceModelVersionId +"\"," + + " \"modelName\": \"vDOROTHEA_srv\"," + + " \"modelInvariantId\": \"9aa04749-c02c-432d-a90c-18caa361c833\"," + + " \"modelType\": \"service\"," + + " \"modelVersion\": \"1.0\"" + + " }" + + " }" + + " }, {" + + " \"relatedInstance\": {" + + " \"instanceId\": \"AAI-12002-test3-vm230w\"," + + " \"modelInfo\": {" + + " \"modelType\": \"networkInstanceGroup\"" + + " }" + + " }" + + " }, {" + + " \"relatedInstance\": {" + + " \"instanceId\": \"AAI-12002-test3-vm230w\"," + + " \"modelInfo\": {" + + " \"modelType\": \"networkInstanceGroup\"" + + " }" + + " }" + + " }" + + " ]" + + " }" + + "}"; + } + + private String addInstanceNameIfNeeded() { + return ecompNamingEnabled ? "": "\"instanceName\" : \"NewName\","; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVolumeGroupOldViewEdit.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVolumeGroupOldViewEdit.java new file mode 100644 index 000000000..ed5bee788 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOCreateVolumeGroupOldViewEdit.java @@ -0,0 +1,78 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSOCreateVolumeGroupOldViewEdit extends PresetMSOBaseCreateInstancePost { + private final String serviceInstanceId; + private final String vnfInstanceId; + private final String instanceName; + + public PresetMSOCreateVolumeGroupOldViewEdit(String overrideRequestId, String responseInstanceId , + String serviceInstanceId, String vnfInstanceId, + String instanceName, String msoTestApi) { + super(overrideRequestId, responseInstanceId, msoTestApi); + this.serviceInstanceId = serviceInstanceId; + this.vnfInstanceId = vnfInstanceId; + this.instanceName = instanceName; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstances/v./" + serviceInstanceId + "/vnfs/"+vnfInstanceId+"/volumeGroups"; + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"requestInfo\": {" + + " \"instanceName\": \""+instanceName+"\"," + + " \"source\": \"VID\"," + + " \"suppressRollback\": false," + + " \"requestorId\": \"mo37915000\"" + + " }," + + " \"modelInfo\": {" + + " \"modelType\": \"volumeGroup\"," + + " \"modelInvariantId\": \"6931e88a-fbcc-4ca9-8583-876b669c3106\"," + + " \"modelVersionId\": \"13f022c4-651e-4326-b8e1-61e9a8c7a7ad\"," + + " \"modelName\": \"Vsp1710pid298109Vmmsc..mmsc_mod6_eca_oam..module-3\"," + + " \"modelVersion\": \"1\"," + + " \"modelCustomizationId\": \"020af091-cc66-46db-876c-02f14b4a795f\"," + + " \"modelCustomizationName\": \"Vsp1710pid298109Vmmsc..mmsc_mod6_eca_oam..module-3\"" + + " }," + + " \"requestParameters\": {" + + addTestApi() + + " }," + + " \"cloudConfiguration\": {" + + " \"lcpCloudRegionId\": \"some legacy region\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"092eb9e8e4b7412e8787dd091bc58e86\"" + + " }," + + " \"relatedInstanceList\": [{" + + " \"relatedInstance\": {" + + " \"instanceId\": \""+serviceInstanceId+"\"," + + " \"modelInfo\": {" + + " \"modelType\": \"service\"," + + " \"modelName\": \"ServicevWINIFREDPID298109\"," + + " \"modelInvariantId\": \"a8dcd72d-d44d-44f2-aa85-53aa9ca0c657\"," + + " \"modelVersion\": \"1.0\"," + + " \"modelVersionId\": \"aa2f8e9c-9e47-4b15-a95c-4a93855ac61b\"" + + " }" + + " }" + + " }, {" + + " \"relatedInstance\": {" + + " \"instanceId\": \""+vnfInstanceId+"\"," + + " \"modelInfo\": {" + + " \"modelType\": \"vnf\"," + + " \"modelName\": \"VSP1710PID298109_vWINIFRED\"," + + " \"modelInvariantId\": \"e7961100-cde6-4b5a-bcda-b8945086950a\"," + + " \"modelVersion\": \"1.0\"," + + " \"modelVersionId\": \"959a7ba0-89ee-4984-9af6-65d5bdda4b0e\"," + + " \"modelCustomizationId\": \"6b8fc7dc-2db1-4283-a222-b07d10595495\"," + + " \"modelCustomizationName\": \"VSP1710PID298109_vWINIFRED 0\"" + + " }" + + " }" + + " }" + + " ]" + + " }" + + "}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeactivateAndCloudDelete.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeactivateAndCloudDelete.java new file mode 100644 index 000000000..04d7522a3 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeactivateAndCloudDelete.java @@ -0,0 +1,70 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset; +import org.springframework.http.HttpMethod; + +public class PresetMSODeactivateAndCloudDelete extends BaseMSOPreset { + private final String serviceInstanceId; + private final String vnfInstanceId; + private final String vfModuleInstanceId; + private final String requestId; + public static final String DEFAULT_SERVICE_INSTANCE_ID = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d"; + public static final String DEFAULT_REQUEST_ID = "318cc766-b673-4a50-b9c5-471f68914584"; + + public PresetMSODeactivateAndCloudDelete(String serviceInstanceId, String vnfInstanceId, String vfModuleInstanceId, String requestId, String cloudOwner) { + this.serviceInstanceId = serviceInstanceId != null ? serviceInstanceId : DEFAULT_SERVICE_INSTANCE_ID; + this.vnfInstanceId = vnfInstanceId; + this.vfModuleInstanceId = vfModuleInstanceId; + this.requestId = requestId != null ? requestId : DEFAULT_REQUEST_ID; + this.cloudOwner = cloudOwner; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.POST; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/vnfs/" + vnfInstanceId + "/vfModules/" + vfModuleInstanceId + "/deactivateAndCloudDelete"; + } + + @Override + public String getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"modelInfo\": {" + + " \"modelType\": \"vfModule\"" + + " }," + + " \"cloudConfiguration\": {" + + " \"lcpCloudRegionId\": \"hvf6\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"bae71557c5bb4d5aac6743a4e5f1d054\"" + + " }," + + " \"requestInfo\": {" + + " \"source\": \"VID\"," + + " \"requestorId\": \"us16807000\"" + + " }," + + " \"requestParameters\": { " + + " \"testApi\": \"GR_API\", " + + " \"userParams\": [] " + + " } " + + " }" + + "}"; + } + + @Override + public Object getResponseBody() { + return "{\"requestReferences\":{\"instanceId\":\"" + serviceInstanceId + "\",\"requestId\":\"" + requestId + "\"}}"; + } + + @Override + public int getResponseCode() { + return 202; + } + + @Override + public boolean isStrictMatch() { + return true; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeactivateAndCloudDeleteErrorResponse.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeactivateAndCloudDeleteErrorResponse.java new file mode 100644 index 000000000..fc19aed9d --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeactivateAndCloudDeleteErrorResponse.java @@ -0,0 +1,70 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset; +import org.springframework.http.HttpMethod; + +public class PresetMSODeactivateAndCloudDeleteErrorResponse extends BaseMSOPreset { + private final String serviceInstanceId; + private final String vnfInstanceId; + private final String vfModuleInstanceId; + private final int errorCode; + public static final String DEFAULT_SERVICE_INSTANCE_ID = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d"; + public static final String DEFAULT_REQUEST_ID = "318cc766-b673-4a50-b9c5-471f68914584"; + + public PresetMSODeactivateAndCloudDeleteErrorResponse(String serviceInstanceId, String vnfInstanceId, String vfModuleInstanceId, int errorCode, String cloudOwner) { + this.serviceInstanceId = serviceInstanceId != null ? serviceInstanceId : DEFAULT_SERVICE_INSTANCE_ID; + this.vnfInstanceId = vnfInstanceId; + this.vfModuleInstanceId = vfModuleInstanceId; + this.errorCode = errorCode > 0 ? errorCode : 500; + this.cloudOwner = cloudOwner; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.POST; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/vnfs/" + vnfInstanceId + "/vfModules/" + vfModuleInstanceId + "/deactivateAndCloudDelete"; + } + + @Override + public String getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"modelInfo\": {" + + " \"modelType\": \"vfModule\"" + + " }," + + " \"cloudConfiguration\": {" + + " \"lcpCloudRegionId\": \"hvf6\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"bae71557c5bb4d5aac6743a4e5f1d054\"" + + " }," + + " \"requestInfo\": {" + + " \"source\": \"VID\"," + + " \"requestorId\": \"us16807000\"" + + " }," + + " \"requestParameters\": { " + + " \"testApi\": \"GR_API\", " + + " \"userParams\": [] " + + " } " + + " }" + + "}"; + } + + @Override + public Object getResponseBody() { + return "{\"error\":\"222\",\"message\":\"error message\"}"; + } + + @Override + public int getResponseCode() { + return errorCode; + } + + @Override + public boolean isStrictMatch() { + return true; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteALaCarteService.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteALaCarteService.java new file mode 100644 index 000000000..b20d462e6 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteALaCarteService.java @@ -0,0 +1,58 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import org.springframework.http.HttpMethod; + +public class PresetMSODeleteALaCarteService extends PresetMSODeleteService { + + private final int responseCode; + + public PresetMSODeleteALaCarteService(String requestId, String serviceInstanceId) { + super(requestId, serviceInstanceId); + responseCode = 202; + } + + public PresetMSODeleteALaCarteService(String requestId, String serviceInstanceId, int responseCode) { + super(requestId, serviceInstanceId); + this.responseCode = responseCode; + } + + @Override + public int getResponseCode() { + return responseCode; + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"modelInfo\": {" + + " \"modelInvariantId\": \"7ee41ce4-4827-44b0-a48e-2707a59905d2\"," + + " \"modelVersionId\": \"4117a0b6-e234-467d-b5b9-fe2f68c8b0fc\"," + + " \"modelName\": \"Grouping Service for Test\"," + + " \"modelType\": \"service\"," + + " \"modelVersion\": \"1.0\"" + + " }," + + " \"requestInfo\": {" + + " \"source\": \"VID\"," + + " \"requestorId\": \"us16807000\"" + + " }," + + " \"requestParameters\": {" + + " \"testApi\": \"VNF_API\","+ + " \"aLaCarte\": true" + + " }" + + " }" + + "}"; + + } + + @Override + protected String getRootPath() { + return "/mso/serviceInstantiation/v./serviceInstances/"; + + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.DELETE; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteBaseVfModuleCypress.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteBaseVfModuleCypress.java new file mode 100644 index 000000000..fc9cc3c5c --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteBaseVfModuleCypress.java @@ -0,0 +1,38 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSODeleteBaseVfModuleCypress extends PresetMSODeleteVfModule { + + public PresetMSODeleteBaseVfModuleCypress() { + super(null, null, null, null); + } + + public PresetMSODeleteBaseVfModuleCypress(String requestId, String serviceInstanceId, String vnfInstanceId, String vfModuleInstanceId) { + super(requestId, serviceInstanceId, vnfInstanceId, vfModuleInstanceId); + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\":{" + + " \"modelInfo\":{" + + " \"modelCustomizationName\":\"2017488PASQUALEVpe..PASQUALE_base_vPE_BV..module-0\"," + + " \"modelCustomizationId\":\"a55961b2-2065-4ab0-a5b7-2fcee1c227e3\"," + + " \"modelInvariantId\":\"b34833bb-6aa9-4ad6-a831-70b06367a091\"," + + " \"modelVersionId\":\"f8360508-3f17-4414-a2ed-6bc71161e8db\"," + + " \"modelName\":\"2017488PASQUALEVpe..PASQUALE_base_vPE_BV..module-0\"," + + " \"modelType\":\"vfModule\"," + + " \"modelVersion\":\"5\"" + + " }," + + " \"cloudConfiguration\":{" + + " \"lcpCloudRegionId\":\"JANET25\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\":\"092eb9e8e4b7412e8787dd091bc58e86\"," + + " }," + + " \"requestInfo\":{" + + " \"source\":\"VID\"," + + " \"requestorId\":\"us16807000\"" + + " }" + + " }" + + "}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteGroupMembers.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteGroupMembers.java new file mode 100644 index 000000000..670e9a5e8 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteGroupMembers.java @@ -0,0 +1,51 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import com.google.common.collect.ImmutableList; +import org.springframework.http.HttpMethod; + +import static java.util.stream.Collectors.joining; + +public class PresetMSODeleteGroupMembers extends PresetMSOBaseCreateInstancePost { + + + private final ImmutableList<String> groupMembersInstanceIds; + + public PresetMSODeleteGroupMembers(String vnfGroupInstanceId, ImmutableList<String> groupMembersInstanceIds, String requestId) { + super(requestId, vnfGroupInstanceId); + this.groupMembersInstanceIds = groupMembersInstanceIds; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.POST; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./instanceGroups/" + responseInstanceId + "/removeMembers"; + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"requestInfo\": {" + + " \"source\": \"VID\"," + + " \"requestorId\": \"us16807000\"" + + " }," + + " \"relatedInstanceList\": [" + + groupMembersInstanceIds.stream().map(groupMemberInstanceId -> + " { " + + " \"relatedInstance\": { " + + " \"instanceId\": \""+ groupMemberInstanceId +"\"," + + " \"modelInfo\": {" + + " \"modelType\": \"vnf\"" + + " }" + + " }" + + " }").collect(joining(", ")) + + " ]" + + " }" + + "}" ; + } + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteInstanceGroup.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteInstanceGroup.java new file mode 100644 index 000000000..9174cd2bb --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteInstanceGroup.java @@ -0,0 +1,28 @@ +package org.onap.simulator.presetGenerator.presets.mso; + + +import java.util.Map; + +public class PresetMSODeleteInstanceGroup extends PresetMSOBaseDelete { + + private final String userId; + + public PresetMSODeleteInstanceGroup(String requestId, String instanceId, String userId) { + super(requestId, instanceId); + this.userId = userId; + } + + @Override + public String getReqPath() { + return "/mso/serviceInstantiation/v./instanceGroups/"+instanceId; + } + + @Override + public Map<String, String> getRequestHeaders() { + Map<String, String> map = super.getRequestHeaders(); + map.put("X-RequestorID", userId); + return map; + + } + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteInstanceOrchestrationRequestGet.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteInstanceOrchestrationRequestGet.java index bfe3a24c5..3d6770518 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteInstanceOrchestrationRequestGet.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteInstanceOrchestrationRequestGet.java @@ -30,7 +30,7 @@ public class PresetMSODeleteInstanceOrchestrationRequestGet extends BaseMSOPrese } public String getReqPath() { - return getRootPath() + "/orchestrationRequests/v5/" + requestId; + return getRootPath() + "/orchestrationRequests/v./" + requestId; } @Override diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteNetwork.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteNetwork.java index 426dec3d9..f45569448 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteNetwork.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteNetwork.java @@ -1,6 +1,6 @@ package org.onap.simulator.presetGenerator.presets.mso; -public class PresetMSODeleteNetwork extends PresetMSOBaseDelete { +public class PresetMSODeleteNetwork extends PresetMSOBaseDeleteWithCloudConfiguration { private final String serviceInstanceId; private final String networkInstanceId; public static final String DEFAULT_SERVICE_INSTANCE_ID = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d"; @@ -11,13 +11,13 @@ public class PresetMSODeleteNetwork extends PresetMSOBaseDelete { } public PresetMSODeleteNetwork(String requestId, String serviceInstanceId, String networkInstanceId) { - super(requestId); + super(requestId, "network"); this.serviceInstanceId = serviceInstanceId != null ? serviceInstanceId : DEFAULT_SERVICE_INSTANCE_ID; this.networkInstanceId = networkInstanceId != null ? networkInstanceId : DEFAULT_NETWORK_INSTANCE_ID; } @Override public String getReqPath() { - return getRootPath() + serviceInstanceId + "/networks/" + networkInstanceId; + return "/mso/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/networks/" + networkInstanceId; } } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteNetworkAlaCarteCypress.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteNetworkAlaCarteCypress.java new file mode 100644 index 000000000..23710f19a --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteNetworkAlaCarteCypress.java @@ -0,0 +1,56 @@ +package org.onap.simulator.presetGenerator.presets.mso; + + +public class PresetMSODeleteNetworkAlaCarteCypress extends PresetMSOBaseDelete { + + private final String userId; + private final String serviceInstanceId; + private final String networkInstanceId; + + public PresetMSODeleteNetworkAlaCarteCypress(String requestId, String serviceInstanceId, String networkInstanceId, String userId) { + super(requestId, networkInstanceId); + this.userId = userId; + this.serviceInstanceId = serviceInstanceId; + this.networkInstanceId = networkInstanceId; + } + + @Override + public String getReqPath() { + return "/mso/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/networks/" + networkInstanceId; + } +// +// @Override +// public Map<String, String> getRequestHeaders() { +// Map<String, String> map = super.getRequestHeaders(); +// map.put("X-RequestorID", userId); +// return map; +// +// } + + @Override + public String getRequestBody() { + return "{" + + " \"requestDetails\":{" + + " \"modelInfo\":{" + + " \"modelInvariantId\":\"379f816b-a7aa-422f-be30-17114ff50b7c\",\n" + + " \"modelVersionId\":\"ddc3f20c-08b5-40fd-af72-c6d14636b986\",\n" + + " \"modelName\":\"ExtVL\",\n" + + " \"modelVersion\":\"37.0\",\n" + + " \"modelType\":\"network\",\n" + + " \"modelCustomizationId\":\"94fdd893-4a36-4d70-b16a-ec29c54c184f\",\n" + + " \"modelCustomizationName\":\"ExtVL 0\"" + + " }," + + " \"cloudConfiguration\":{" + + " \"lcpCloudRegionId\":\"hvf6\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\":\"229bcdc6eaeb4ca59d55221141d01f8e\"" + + " }," + + " \"requestInfo\":{" + + " \"source\":\"VID\"," + + " \"requestorId\":\"" + userId + "\"" + + " }" + + " }" + + "}"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVfModule.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVfModule.java index 76487edf5..85ee1a8be 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVfModule.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVfModule.java @@ -1,6 +1,6 @@ package org.onap.simulator.presetGenerator.presets.mso; -public class PresetMSODeleteVfModule extends PresetMSOBaseDelete { +public class PresetMSODeleteVfModule extends PresetMSOBaseDeleteWithCloudConfiguration { private final String serviceInstanceId; private final String vnfInstanceId; private final String vfModuleInstanceId; @@ -13,7 +13,7 @@ public class PresetMSODeleteVfModule extends PresetMSOBaseDelete { } public PresetMSODeleteVfModule(String requestId, String serviceInstanceId, String vnfInstanceId, String vfModuleInstanceId) { - super(requestId); + super(requestId, "vfModule"); this.serviceInstanceId = serviceInstanceId != null ? serviceInstanceId : DEFAULT_SERVICE_INSTANCE_ID; this.vnfInstanceId = vnfInstanceId != null ? vnfInstanceId : DEFAULT_VNF_INSTANCE_ID; this.vfModuleInstanceId = vfModuleInstanceId != null ? vfModuleInstanceId : DEFAULT_VFMODULE_INSTANCE_ID; diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVfModuleCypress.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVfModuleCypress.java new file mode 100644 index 000000000..d4a21cc36 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVfModuleCypress.java @@ -0,0 +1,38 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSODeleteVfModuleCypress extends PresetMSODeleteVfModule { + + public PresetMSODeleteVfModuleCypress() { + super(null, null, null, null); + } + + public PresetMSODeleteVfModuleCypress(String requestId, String serviceInstanceId, String vnfInstanceId, String vfModuleInstanceId) { + super(requestId, serviceInstanceId, vnfInstanceId, vfModuleInstanceId); + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\":{" + + " \"modelInfo\":{" + + " \"modelCustomizationName\":\"2017488PASQUALEVpe..PASQUALE_vRE_BV..module-1\"," + + " \"modelCustomizationId\":\"f7e7c365-60cf-49a9-9ebf-a1aa11b9d401\"," + + " \"modelInvariantId\":\"7253ff5c-97f0-4b8b-937c-77aeb4d79aa1\"," + + " \"modelVersionId\":\"25284168-24bb-4698-8cb4-3f509146eca5\"," + + " \"modelName\":\"2017488PASQUALEVpe..PASQUALE_vRE_BV..module-1\"," + + " \"modelType\":\"vfModule\"," + + " \"modelVersion\":\"6\"" + + " }," + + " \"cloudConfiguration\":{" + + " \"lcpCloudRegionId\":\"JANET25\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\":\"092eb9e8e4b7412e8787dd091bc58e86\"," + + " }," + + " \"requestInfo\":{" + + " \"source\":\"VID\"," + + " \"requestorId\":\"us16807000\"" + + " }" + + " }" + + "}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVnf.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVnf.java index 83c9883f8..f1142523d 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVnf.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVnf.java @@ -1,6 +1,6 @@ package org.onap.simulator.presetGenerator.presets.mso; -public class PresetMSODeleteVnf extends PresetMSOBaseDelete { +public class PresetMSODeleteVnf extends PresetMSOBaseDeleteWithCloudConfiguration { private final String serviceInstanceId; private final String vnfInstanceId; public static final String DEFAULT_SERVICE_INSTANCE_ID = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d"; @@ -11,7 +11,7 @@ public class PresetMSODeleteVnf extends PresetMSOBaseDelete { } public PresetMSODeleteVnf(String requestId, String serviceInstanceId, String vnfInstanceId) { - super(requestId); + super(requestId, "vnf"); this.serviceInstanceId = serviceInstanceId != null ? serviceInstanceId : DEFAULT_SERVICE_INSTANCE_ID; this.vnfInstanceId = vnfInstanceId != null ? vnfInstanceId : DEFAULT_VNF_INSTANCE_ID; } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVnfAlaCarteCypress.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVnfAlaCarteCypress.java new file mode 100644 index 000000000..bb33bbe2a --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVnfAlaCarteCypress.java @@ -0,0 +1,48 @@ +package org.onap.simulator.presetGenerator.presets.mso; + + +public class PresetMSODeleteVnfAlaCarteCypress extends PresetMSOBaseDelete { + + private final String userId; + private final String serviceInstanceId; + private final String vnfInstanceId; + + public PresetMSODeleteVnfAlaCarteCypress(String requestId, String serviceInstanceId, String vnfInstanceId, String userId) { + super(requestId, vnfInstanceId); + this.userId = userId; + this.serviceInstanceId = serviceInstanceId; + this.vnfInstanceId = vnfInstanceId; + } + + @Override + public String getReqPath() { + return "/mso/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/vnfs/" + vnfInstanceId; + } + + @Override + public String getRequestBody() { + return "{" + + " \"requestDetails\":{" + + " \"modelInfo\":{" + + " \"modelInvariantId\":\"72e465fe-71b1-4e7b-b5ed-9496118ff7a8\",\n" + + " \"modelVersionId\":\"69e09f68-8b63-4cc9-b9ff-860960b5db09\",\n" + + " \"modelName\":\"2017-488_PASQUALE-vPE\",\n" + + " \"modelVersion\":\"5.0\",\n" + + " \"modelType\":\"vnf\",\n" + + " \"modelCustomizationId\":\"1da7b585-5e61-4993-b95e-8e6606c81e45\",\n" + + " \"modelCustomizationName\":\"2017-488_PASQUALE-vPE 0\"" + + " }," + + " \"cloudConfiguration\":{" + + " \"lcpCloudRegionId\":\"some legacy region\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\":\"092eb9e8e4b7412e8787dd091bc58e86\"" + + " }," + + " \"requestInfo\":{" + + " \"source\":\"VID\"," + + " \"requestorId\":\"" + userId + "\"" + + " }" + + " }" + + "}"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVolumeGroup.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVolumeGroup.java index d9598b20d..964d37e84 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVolumeGroup.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSODeleteVolumeGroup.java @@ -1,6 +1,6 @@ package org.onap.simulator.presetGenerator.presets.mso; -public class PresetMSODeleteVolumeGroup extends PresetMSOBaseDelete { +public class PresetMSODeleteVolumeGroup extends PresetMSOBaseDeleteWithCloudConfiguration { private final String serviceInstanceId; private final String vnfInstanceId; private final String volumeGroupInstanceId; @@ -13,7 +13,7 @@ public class PresetMSODeleteVolumeGroup extends PresetMSOBaseDelete { } public PresetMSODeleteVolumeGroup(String requestId, String serviceInstanceId, String vnfInstanceId, String volumeGroupInstanceId) { - super(requestId); + super(requestId, "volumeGroup"); this.serviceInstanceId = serviceInstanceId != null ? serviceInstanceId : DEFAULT_SERVICE_INSTANCE_ID; this.vnfInstanceId = vnfInstanceId != null ? vnfInstanceId : DEFAULT_VNF_INSTANCE_ID; this.volumeGroupInstanceId = volumeGroupInstanceId != null ? volumeGroupInstanceId : DEFAULT_VG_INSTANCE_ID; @@ -23,4 +23,10 @@ public class PresetMSODeleteVolumeGroup extends PresetMSOBaseDelete { public String getReqPath() { return getRootPath() + serviceInstanceId + "/vnfs/" + vnfInstanceId + "/volumeGroups/" + volumeGroupInstanceId; } + + //remove this method once VfModule path starts with /serviceInstantiation/v7/ + @Override + protected String getRootPath() { + return "/mso/serviceInstances/v7/"; + } } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestGet.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestGet.java index dcf1a054d..381ac856b 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestGet.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestGet.java @@ -1,21 +1,35 @@ package org.onap.simulator.presetGenerator.presets.mso; 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.BaseMSOPreset; import org.springframework.http.HttpMethod; +import java.time.Instant; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; + /** * Created by itzikliderman on 13/12/2017. */ public class PresetMSOOrchestrationRequestGet extends BaseMSOPreset { + private static final Logger logger = LogManager.getLogger(PresetMSOOrchestrationRequestGet.class); + + public static final String COMPLETE = "COMPLETE"; + public static final String DEFAULT_REQUEST_ID = "c0011670-0e1a-4b74-945d-8bf5aede1d9c"; + public static final String DEFAULT_SERVICE_INSTANCE_ID = BaseMSOPreset.DEFAULT_INSTANCE_ID; - private final String DEFAULT_REQUEST_ID = "c0011670-0e1a-4b74-945d-8bf5aede1d9c"; private final String requestId; private String statusMessage; - String requestState; + private String requestState; + private int startedHoursAgo = 1; + public PresetMSOOrchestrationRequestGet() { - requestState = "COMPLETE"; + requestState = COMPLETE; this.requestId = DEFAULT_REQUEST_ID; } @@ -35,25 +49,38 @@ public class PresetMSOOrchestrationRequestGet extends BaseMSOPreset { this.statusMessage = statusMessage; } + public PresetMSOOrchestrationRequestGet(String requestState, String overrideRequestId, String statusMessage, int startedHoursAgo) { + this.requestState = requestState; + this.requestId = overrideRequestId; + this.statusMessage = statusMessage; + this.startedHoursAgo = startedHoursAgo; + } + + public PresetMSOOrchestrationRequestGet(String requestState, int startedHoursAgo) { + this.requestState = requestState; + this.requestId = DEFAULT_REQUEST_ID; + this.startedHoursAgo = startedHoursAgo; + } + @Override public HttpMethod getReqMethod() { return HttpMethod.GET; } public String getReqPath() { - return getRootPath() + "/orchestrationRequests/v5/" + requestId; + return getRootPath() + "/orchestrationRequests/v./" + requestId; } @Override public Object getResponseBody() { - return "{" + + String body = "{" + " \"request\": {" + " \"requestId\": \"" + requestId + "\"," + - " \"startTime\": \"Mon, 11 Dec 2017 07:27:49 GMT\"," + + " \"startTime\": \"" + getTimeHoursAgo(startedHoursAgo) + "\"," + " \"requestScope\": \"service\"," + " \"requestType\": \"createInstance\"," + " \"instanceReferences\": {" + - " \"serviceInstanceId\": \"f8791436-8d55-4fde-b4d5-72dd2cf13cfb\"," + + " \"serviceInstanceId\": \"" + DEFAULT_SERVICE_INSTANCE_ID + "\"," + " \"serviceInstanceName\": \"asdfasdf234234asdf\"," + " \"requestorId\": \"il883e\"" + " }," + @@ -61,17 +88,30 @@ public class PresetMSOOrchestrationRequestGet extends BaseMSOPreset { " \"requestState\": \"" + requestState + "\"," + " \"statusMessage\": \"" + getStatusMessage() + "\"," + " \"percentProgress\": 100," + - " \"finishTime\": \"Mon, 11 Dec 2017 07:27:53 GMT\"" + + " \"timestamp\": \"" + getTimeNow() + "\"" + " }" + " }" + "}"; + logger.info(body); + return body; } private String getStatusMessage() { - if (!StringUtils.isEmpty(statusMessage)) - return statusMessage; - return "COMPLETE".equals(requestState) ? - "Service Instance was created successfully." : - ("Service Instance was " + requestState.toLowerCase() + " successfully."); + return StringUtils.defaultIfEmpty(statusMessage, + "COMPLETE".equals(requestState) ? + "Service Instance was created successfully." : + ("Service Instance was " + requestState.toLowerCase() + " successfully.")); + } + + private String getTimeNow() { + return getTimeHoursAgo(0); + } + + private String getTimeHoursAgo(int delta) { + Instant instant = Instant.now(); + Instant instantMinus = instant.minus(delta, ChronoUnit.HOURS); + ZonedDateTime dateDayAgo = ZonedDateTime.ofInstant(instantMinus, ZoneOffset.UTC); + DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME; + return formatter.format(dateDayAgo); } } diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsGet5GServiceInstanceAndNetwork.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsGet5GServiceInstanceAndNetwork.java new file mode 100644 index 000000000..3d83ca55d --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsGet5GServiceInstanceAndNetwork.java @@ -0,0 +1,179 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import static java.util.Collections.singletonList; + +import com.google.common.collect.ImmutableMap; +import java.util.List; +import java.util.Map; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset; +import org.springframework.http.HttpMethod; + +public class PresetMSOOrchestrationRequestsGet5GServiceInstanceAndNetwork extends BaseMSOPreset { + + public PresetMSOOrchestrationRequestsGet5GServiceInstanceAndNetwork(ResponseDetails parentDetails, ResponseDetails childDetails, String parentInstanceId) { + this.parentDetails = parentDetails; + this.childDetails = childDetails; + this.parentInstanceId = parentInstanceId; + } + + public static class ResponseDetails { + public final String instanceName; + public final String requestId; + public final String status; + public final String type; + + public ResponseDetails(String instanceName, String requestId, String status, String type) { + this.instanceName = instanceName; + this.requestId = requestId; + this.status = status; + this.type = type; + } + } + + protected final ResponseDetails parentDetails; + protected final ResponseDetails childDetails; + protected final String parentInstanceId; + + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return getRootPath() + "/orchestrationRequests/v."; + } + + @Override + public Map<String, List> getQueryParams() { + return ImmutableMap.of("filter", singletonList("serviceInstanceId:EQUALS:"+ parentInstanceId)); + } + + @Override + public Object getResponseBody() { + return "{" + + " \"requestList\": [{" + + " \"request\": {" + + " \"requestId\": \""+ parentDetails.requestId+"\"," + + " \"startTime\": \"Mon, 05 Nov 2018 09:22:23 GMT\"," + + " \"requestScope\": \""+ parentDetails.type+"\"," + + " \"requestType\": \"createInstance\"," + + " \"requestDetails\": {" + + " \"modelInfo\": {" + + " \"modelInvariantId\": \"1469946d-d566-467e-867b-88b29f6cb6c7\"," + + " \"modelType\": \""+ parentDetails.type+"\"," + + " \"modelName\": \"FCGI_5G_NC\"," + + " \"modelVersion\": \"1.0\"," + + " \"modelVersionId\": \"ed2a3691-c3f3-4ac3-98b3-b0b12acfd1b1\"," + + " \"modelUuid\": \"ed2a3691-c3f3-4ac3-98b3-b0b12acfd1b1\"," + + " \"modelInvariantUuid\": \"1469946d-d566-467e-867b-88b29f6cb6c7\"" + + " }," + + " \"requestInfo\": {" + + " \"source\": \"VID\"," + + " \"instanceName\": \""+ parentDetails.instanceName+"\"," + + " \"suppressRollback\": false," + + " \"requestorId\": \"us16807000\"" + + " }," + + " \"subscriberInfo\": {" + + " \"globalSubscriberId\": \"e433710f-9217-458d-a79d-1c7aff376d89\"" + + " }," + + " \"requestParameters\": {" + + " \"subscriptionServiceType\": \"TYLER SILVIA\"," + + " \"aLaCarte\": true," + + " \"testApi\": \"VNF_API\"" + + " }," + + " \"project\": {" + + " \"projectName\": \"DFW\"" + + " }," + + " \"owningEntity\": {" + + " \"owningEntityId\": \"3f592a6f-459b-435e-b0d4-59959ab1d385\"," + + " \"owningEntityName\": \"own1\"" + + " }" + + " }," + + " \"instanceReferences\": {" + + " \""+parentDetails.type+"InstanceId\": \"f4c4d4f7-311b-4ecb-bb86-eb3138aac0fb\"," + + " \""+parentDetails.type+"InstanceName\": \""+parentDetails.instanceName+"\"," + + " \"requestorId\": \"us16807000\"" + + " }," + + " \"requestStatus\": {" + + " \"requestState\": \""+ parentDetails.status+"\"," + + " \"statusMessage\": \"STATUS: "+parentDetails.type+" Instance was created successfully.\"," + + " \"percentProgress\": 100," + + " \"finishTime\": \"Wed, 07 Nov 2018 09:22:35 GMT\"" + + " }" + + " }" + + " }, {" + + " \"request\": {" + + " \"requestId\": \""+childDetails.requestId+"\"," + + " \"startTime\": \"Mon, 05 Nov 2018 09:22:41 GMT\"," + + " \"requestScope\": \""+childDetails.type+"\"," + + " \"requestType\": \"createInstance\"," + + " \"requestDetails\": {" + + " \"modelInfo\": {" + + " \"modelCustomizationName\": \"FCGI 0\"," + + " \"modelInvariantId\": \"ba2ee320-23ce-4d2e-94dd-1ec450cec62c\"," + + " \"modelType\": \""+childDetails.type+"\"," + + " \"modelName\": \"FCGI\"," + + " \"modelVersion\": \"1.0\"," + + " \"modelCustomizationUuid\": \"de9b7aea-9727-4a7c-8e72-292263fb61a9\"," + + " \"modelVersionId\": \"0d23f7bc-eee4-4151-9fb9-37f5bea834c2\"," + + " \"modelCustomizationId\": \"de9b7aea-9727-4a7c-8e72-292263fb61a9\"," + + " \"modelUuid\": \"0d23f7bc-eee4-4151-9fb9-37f5bea834c2\"," + + " \"modelInvariantUuid\": \"ba2ee320-23ce-4d2e-94dd-1ec450cec62c\"," + + " \"modelInstanceName\": \"FCGI 0\"" + + " }," + + " \"requestInfo\": {" + + " \"productFamilyId\": \"e433710f-9217-458d-a79d-1c7aff376d89\"," + + " \"source\": \"VID\"," + + " \"instanceName\": \""+childDetails.instanceName+"\"," + + " \"suppressRollback\": false," + + " \"requestorId\": \"us16807000\"" + + " }," + + " \"relatedInstanceList\": [{" + + " \"relatedInstance\": {" + + " \"instanceId\": \"f4c4d4f7-311b-4ecb-bb86-eb3138aac0fb\"," + + " \"modelInfo\": {" + + " \"modelInvariantId\": \"1469946d-d566-467e-867b-88b29f6cb6c7\"," + + " \"modelType\": \"service\"," + + " \"modelName\": \"FCGI_5G_NC\"," + + " \"modelVersion\": \"1.0\"," + + " \"modelVersionId\": \"ed2a3691-c3f3-4ac3-98b3-b0b12acfd1b1\"," + + " \"modelUuid\": \"ed2a3691-c3f3-4ac3-98b3-b0b12acfd1b1\"," + + " \"modelInvariantUuid\": \"1469946d-d566-467e-867b-88b29f6cb6c7\"" + + " }" + + " }" + + " }" + + " ]," + + " \"cloudConfiguration\": {" + + " \"tenantId\": \"460f35aeb53542dc9f77105066483e83\"," + + " \"cloudOwner\": \"irma-aic\"," + + " \"lcpCloudRegionId\": \"olson5b\"" + + " }," + + " \"requestParameters\": {}," + + " \"platform\": {" + + " \"platformName\": \"plat1\"" + + " }," + + " \"lineOfBusiness\": {" + + " \"lineOfBusinessName\": \"ECOMP\"" + + " }" + + " }," + + " \"instanceReferences\": {" + + " \""+parentDetails.type+"InstanceId\": \"f4c4d4f7-311b-4ecb-bb86-eb3138aac0fb\"," + + " \""+childDetails.type+"InstanceId\": \"2f668980-7dbc-4231-a67c-8b69cd266b3a\"," + + " \""+childDetails.type+"InstanceName\": \""+childDetails.instanceName+"\"," + + " \"requestorId\": \"us16807000\"" + + " }," + + " \"requestStatus\": {" + + " \"requestState\": \""+childDetails.status+"\"," + + " \"statusMessage\": \"STATUS: "+childDetails.type+" has been created successfully.\"," + + " \"percentProgress\": 100," + + " \"finishTime\": \"Wed, 07 Nov 2018 09:22:45 GMT\"" + + " }" + + " }" + + " }" + + " ]" + + "}"; + + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsGetByRequestId.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsGetByRequestId.java new file mode 100644 index 000000000..69780d0aa --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsGetByRequestId.java @@ -0,0 +1,85 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import static java.util.Collections.singletonList; + +import com.google.common.collect.ImmutableMap; +import java.util.List; +import java.util.Map; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset; +import org.springframework.http.HttpMethod; + +public class PresetMSOOrchestrationRequestsGetByRequestId extends BaseMSOPreset { + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return getRootPath() + "/orchestrationRequests/v."; + } + + @Override + public Map<String, List> getQueryParams() { + return ImmutableMap.of("filter", singletonList("requestId:EQUALS:405652f4-ceb3-4a75-9474-8aea71480a77")); + } + + @Override + public Object getResponseBody() { + return "" + + "{ " + + " \"requestList\": [{ " + + " \"request\": {" + + " \"requestId\": \"405652f4-ceb3-4a75-9474-8aea71480a77\"," + + " \"startTime\": \"Mon, 13 Aug 2018 18:13:28 GMT\"," + + " \"requestScope\": \"service\"," + + " \"requestType\": \"createInstance\"," + + " \"requestDetails\": {" + + " \"modelInfo\": {" + + " \"modelInvariantId\": \"c42c7d13-435e-4a38-84e5-158972673ff2\"," + + " \"modelType\": \"service\"," + + " \"modelName\": \"CGWY27-SVC\"," + + " \"modelVersion\": \"1.0\"," + + " \"modelVersionId\": \"c0e6858a-e467-412c-9766-3872f03ac0ab\"," + + " \"modelUuid\": \"c0e6858a-e467-412c-9766-3872f03ac0ab\"," + + " \"modelInvariantUuid\": \"c42c7d13-435e-4a38-84e5-158972673ff2\"" + + " }," + + " \"requestInfo\": {" + + " \"source\": \"VID\"," + + " \"suppressRollback\": false," + + " \"requestorId\": \"cb4449\"" + + " }," + + " \"subscriberInfo\": {" + + " \"globalSubscriberId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"" + + " }," + + " \"requestParameters\": {" + + " \"subscriptionServiceType\": \"Kennedy\"," + + " \"aLaCarte\": true," + + " \"testApi\": \"VNF_API\"" + + " }," + + " \"project\": {" + + " \"projectName\": \"Kennedy\"" + + " }," + + " \"owningEntity\": {" + + " \"owningEntityId\": \"10c645f5-9924-4b89-bec0-b17cf49d3cad\"," + + " \"owningEntityName\": \"EMANUEL-CORE\"" + + " }" + + " }," + + " \"instanceReferences\": {" + + " \"requestorId\": \"cb4449\"" + + " }," + + " \"requestStatus\": {" + + " \"requestState\": \"FAILED\"," + + " \"statusMessage\": \"Service Instance was failed.\"," + + " \"percentProgress\": 100," + + " \"finishTime\": \"Mon, 13 Aug 2018 18:13:39 GMT\"" + + " }" + + " }" + + "}" + + " ] " + + "} "; + + + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsGetByServiceInstanceId.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsGetByServiceInstanceId.java new file mode 100644 index 000000000..58686f26b --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsGetByServiceInstanceId.java @@ -0,0 +1,158 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import static java.util.Collections.singletonList; + +import com.google.common.collect.ImmutableMap; +import java.util.List; +import java.util.Map; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset; +import org.springframework.http.HttpMethod; + +public class PresetMSOOrchestrationRequestsGetByServiceInstanceId extends BaseMSOPreset { + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return getRootPath() + "/orchestrationRequests/v."; + } + + @Override + public Map<String, List> getQueryParams() { + return ImmutableMap.of("filter", singletonList("serviceInstanceId:EQUALS:bc305d54-75b4-431b-adb2-eb6b9e546014")); + } + + @Override + public Object getResponseBody() { + return "" + + "{ " + + " \"requestList\": [{ " + + " \"request\": {" + + " \"requestId\": \"405652f4-ceb3-4a75-9474-8aea71480a77\"," + + " \"startTime\": \"Mon, 13 Aug 2018 18:13:28 GMT\"," + + " \"requestScope\": \"service\"," + + " \"requestType\": \"createInstance\"," + + " \"requestDetails\": {" + + " \"modelInfo\": {" + + " \"modelInvariantId\": \"c42c7d13-435e-4a38-84e5-158972673ff2\"," + + " \"modelType\": \"service\"," + + " \"modelName\": \"CGWY27-SVC\"," + + " \"modelVersion\": \"1.0\"," + + " \"modelVersionId\": \"c0e6858a-e467-412c-9766-3872f03ac0ab\"," + + " \"modelUuid\": \"c0e6858a-e467-412c-9766-3872f03ac0ab\"," + + " \"modelInvariantUuid\": \"c42c7d13-435e-4a38-84e5-158972673ff2\"" + + " }," + + " \"requestInfo\": {" + + " \"source\": \"VID\"," + + " \"instanceName\": \"instance name 1\"," + + " \"suppressRollback\": false," + + " \"requestorId\": \"cb4449\"" + + " }," + + " \"subscriberInfo\": {" + + " \"globalSubscriberId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"" + + " }," + + " \"requestParameters\": {" + + " \"subscriptionServiceType\": \"Kennedy\"," + + " \"aLaCarte\": true," + + " \"testApi\": \"VNF_API\"" + + " }," + + " \"project\": {" + + " \"projectName\": \"Kennedy\"" + + " }," + + " \"owningEntity\": {" + + " \"owningEntityId\": \"10c645f5-9924-4b89-bec0-b17cf49d3cad\"," + + " \"owningEntityName\": \"EMANUEL-CORE\"" + + " }" + + " }," + + " \"instanceReferences\": {" + + " \"serviceInstanceId\": \"64f3123a-f9a8-4591-b481-d662134bcb52\"," + + " \"serviceInstanceName\": \"CGWY27-SVC-olson5b\"," + + " \"requestorId\": \"cb4449\"" + + " }," + + " \"requestStatus\": {" + + " \"requestState\": \"COMPLETE\"," + + " \"statusMessage\": \"Service Instance was created successfully.\"," + + " \"percentProgress\": 100," + + " \"finishTime\": \"Mon, 13 Aug 2018 18:13:39 GMT\"" + + " }" + + " }" + + "},{" + + " \"request\":{" + + " \"requestId\":\"688d40cd-6bfd-4a4b-95f4-5e4ffa6d6fc5\"," + + " \"startTime\":\"Mon, 13 Aug 2018 18:15:14 GMT\"," + + " \"requestScope\":\"vnf\"," + + " \"requestType\":\"createInstance\"," + + " \"requestDetails\":{" + + " \"modelInfo\":{" + + " \"modelCustomizationName\":\"CGWY27-VF 0\"," + + " \"modelInvariantId\":\"8f508753-a546-48be-b931-2c949e215972\"," + + " \"modelType\":\"vnf\"," + + " \"modelName\":\"CGWY27-VF\"," + + " \"modelVersion\":\"1.0\"," + + " \"modelCustomizationUuid\":\"fa35ceb6-38de-428a-93b2-89be64c19f86\"," + + " \"modelVersionId\":\"4d279e16-de09-4108-b32f-82b05df2f41a\"," + + " \"modelCustomizationId\":\"fa35ceb6-38de-428a-93b2-89be64c19f86\"," + + " \"modelUuid\":\"4d279e16-de09-4108-b32f-82b05df2f41a\"," + + " \"modelInvariantUuid\":\"8f508753-a546-48be-b931-2c949e215972\"," + + " \"modelInstanceName\":\"CGWY27-VF 0\"" + + " }," + + " \"requestInfo\":{" + + " \"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"," + + " \"source\":\"VID\"," + + " \"instanceName\":\"instance name 2\"," + + " \"suppressRollback\":false," + + " \"requestorId\":\"cb4449\"" + + " }," + + " \"relatedInstanceList\":[" + + " {" + + " \"relatedInstance\":{" + + " \"instanceId\":\"64f3123a-f9a8-4591-b481-d662134bcb52\"," + + " \"modelInfo\":{" + + " \"modelInvariantId\":\"c42c7d13-435e-4a38-84e5-158972673ff2\"," + + " \"modelType\":\"service\"," + + " \"modelName\":\"CGWY27-SVC\"," + + " \"modelVersion\":\"1.0\"," + + " \"modelVersionId\":\"c0e6858a-e467-412c-9766-3872f03ac0ab\"," + + " \"modelUuid\":\"c0e6858a-e467-412c-9766-3872f03ac0ab\"," + + " \"modelInvariantUuid\":\"c42c7d13-435e-4a38-84e5-158972673ff2\"" + + " }" + + " }" + + " }" + + " ]," + + " \"cloudConfiguration\":{" + + " \"tenantId\":\"8830e9086a0f40cc9cf868e792602c4d\"," + + " \"lcpCloudRegionId\":\"olson5b\"" + + " }," + + " \"requestParameters\":{" + + " \"testApi\":\"VNF_API\"" + + " }," + + " \"platform\":{" + + " \"platformName\":\"AIC\"" + + " }," + + " \"lineOfBusiness\":{" + + " \"lineOfBusinessName\":\"EMANUEL-CONSUMER\"" + + " }" + + " }," + + " \"instanceReferences\":{" + + " \"serviceInstanceId\":\"64f3123a-f9a8-4591-b481-d662134bcb52\"," + + " \"vnfInstanceId\":\"96c98f10-d20a-47a9-a790-94e3ac3dfb7e\"," + + " \"vnfInstanceName\":\"zolson5bcgwy22\"," + + " \"requestorId\":\"cb4449\"" + + " }," + + " \"requestStatus\":{" + + " \"requestState\":\"COMPLETE\"," + + " \"statusMessage\":\"Vnf has been created successfully.\"," + + " \"percentProgress\":100," + + " \"finishTime\":\"Mon, 13 Aug 2018 18:15:23 GMT\"" + + " }" + + " }" + + "}"+ + " ] " + + "} "; + + + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsManyInstanceStatusesGet.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsManyInstanceStatusesGet.java new file mode 100644 index 000000000..63d6110ba --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsManyInstanceStatusesGet.java @@ -0,0 +1,160 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import com.google.common.collect.ImmutableMap; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset; +import org.springframework.http.HttpMethod; + +import java.util.List; +import java.util.Map; + +import static java.util.Collections.singletonList; + +public class PresetMSOOrchestrationRequestsManyInstanceStatusesGet extends BaseMSOPreset { + + + private String instanceIdType; + + private String instanceType; + + + public PresetMSOOrchestrationRequestsManyInstanceStatusesGet(String instanceIdType, String instanceType) { + this.instanceIdType = instanceIdType; + this.instanceType = instanceType; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return getRootPath() + "/orchestrationRequests/v."; + } + + @Override + public Map<String, List> getQueryParams() { + return ImmutableMap.of("filter", singletonList(instanceIdType+":EQUALS:df305d54-75b4-431b-adb2-eb6b9e5460df")); + } + + @Override + public Object getResponseBody() { + return "" + + "{ " + + " \"requestList\": [{ " + + " \"request\": { " + + " \"requestId\": \"28502bd2-3aff-4a03-9f2b-5a0d1cb1ca24\", " + + " \"startTime\": \"Thu, 04 Jun 2009 02:51:59 GMT\", " + + " \"instanceReferences\": { " + + " \"instanceGroupId\": \"df305d54-75b4-431b-adb2-eb6b9e5460df\" " + + " }, " + + " \"requestScope\": \""+instanceType+"\", " + + " \"requestType\": \"createInstance\", " + + " \"requestDetails\": { " + + " \"modelInfo\": { " + + " \"modelType\": \""+instanceType+"\", " + + " \"modelVersionId\": \"ddcbbf3d-f2c1-4ca0-8852-76a807285efc\" " + + " }, " + + " \"requestInfo\": { " + + " \"instanceName\": \"groupTestName\", " + + " \"source\": \"VID\", " + + " \"suppressRollback\": true, " + + " \"requestorId\": \"ah2345\" " + + " } " + + " }, " + + " \"requestStatus\": { " + + " \"timestamp\": \"Thu, 04 Jun 2009 02:53:39 GMT\", " + + " \"requestState\": \"IN_PROGRESS\", " + + " \"statusMessage\": \""+instanceType+" instance creation\", " + + " \"percentProgress\": \"50\" " + + " } " + + " } " + + " }, { " + + " \"request\": { " + + " \"requestId\": \"28502bd2-3aff-4a03-9f2b-5a0d1cb1ca24\", " + + " \"startTime\": \"Thu, 04 Jun 2009 02:51:59 GMT\", " + + " \"instanceReferences\": { " + + " \"instanceGroupId\": \"df305d54-75b4-431b-adb2-eb6b9e5460df\" " + + " }, " + + " \"requestScope\": \""+instanceType+"\", " + + " \"requestType\": \"createInstance\", " + + " \"requestDetails\": { " + + " \"modelInfo\": { " + + " \"modelType\": \""+instanceType+"\", " + + " \"modelVersionId\": \"ddcbbf3d-f2c1-4ca0-8852-76a807285efc\" " + + " }, " + + " \"requestInfo\": { " + + " \"instanceName\": \"groupTestName\", " + + " \"source\": \"VID\", " + + " \"suppressRollback\": true, " + + " \"requestorId\": \"ah2345\" " + + " } " + + " }, " + + " \"requestStatus\": { " + + " \"timestamp\": \"Thu, 04 Jun 2009 02:53:39 GMT\", " + + " \"requestState\": \"COMPLETE\", " + + " \"statusMessage\": \""+instanceType+" instance creation\", " + + " \"percentProgress\": \"100\" " + + " } " + + " } " + + " }, { " + + " \"request\": { " + + " \"requestId\": \"f711f0ff-24b6-4d7f-9314-4b4eae15f48c\", " + + " \"startTime\": \"Thu, 04 Jun 2009 02:51:59 GMT\", " + + " \"instanceReferences\": { " + + " \"instanceGroupId\": \"df305d54-75b4-431b-adb2-eb6b9e5460df\" " + + " }, " + + " \"requestScope\": \""+instanceType+"\", " + + " \"requestType\": \"deleteInstance\", " + + " \"requestDetails\": { " + + " \"modelInfo\": { " + + " \"modelType\": \""+instanceType+"\", " + + " \"modelVersionId\": \"ddcbbf3d-f2c1-4ca0-8852-76a807285efc\" " + + " }, " + + " \"requestInfo\": { " + + " \"instanceName\": \"groupTestName\", " + + " \"source\": \"VID\", " + + " \"suppressRollback\": true, " + + " \"requestorId\": \"ah2345\" " + + " } " + + " }, " + + " \"requestStatus\": { " + + " \"timestamp\": \"Thu, 04 Jun 2009 02:53:39 GMT\", " + + " \"requestState\": \"IN_PROGRESS\", " + + " \"statusMessage\": \""+instanceType+" instance deletion\", " + + " \"percentProgress\": \"50\" " + + " } " + + " } " + + " }, { " + + " \"request\": { " + + " \"requestId\": \"f711f0ff-24b6-4d7f-9314-4b4eae15f48c\", " + + " \"startTime\": \"Thu, 04 Jun 2009 02:51:59 GMT\", " + + " \"instanceReferences\": { " + + " \"instanceGroupId\": \"df305d54-75b4-431b-adb2-eb6b9e5460df\" " + + " }, " + + " \"requestScope\": \""+instanceType+"\", " + + " \"requestType\": \"deleteInstance\", " + + " \"requestDetails\": { " + + " \"modelInfo\": { " + + " \"modelType\": \""+instanceType+"\", " + + " \"modelVersionId\": \"ddcbbf3d-f2c1-4ca0-8852-76a807285efc\" " + + " }, " + + " \"requestInfo\": { " + + " \"instanceName\": \"groupTestName\", " + + " \"source\": \"VID\", " + + " \"suppressRollback\": true, " + + " \"requestorId\": \"ah2345\" " + + " } " + + " }, " + + " \"requestStatus\": { " + + " \"timestamp\": \"Thu, 04 Jun 2009 02:53:39 GMT\", " + + " \"requestState\": \"COMPLETE\", " + + " \"statusMessage\": \""+instanceType+" instance deletion\", " + + " \"percentProgress\": \"100\" " + + " } " + + " } " + + " } " + + " ] " + + "} "; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsManyStatusesGet.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsManyStatusesGet.java new file mode 100644 index 000000000..268103588 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsManyStatusesGet.java @@ -0,0 +1,210 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import com.google.common.collect.ImmutableMap; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset; +import org.springframework.http.HttpMethod; + +import java.util.List; +import java.util.Map; + +import static java.util.Collections.singletonList; + +public class PresetMSOOrchestrationRequestsManyStatusesGet extends BaseMSOPreset { + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return getRootPath() + "/orchestrationRequests/v."; + } + + @Override + public Map<String, List> getQueryParams() { + return ImmutableMap.of("filter", singletonList("requestExecutionDate:EQUALS:01-01-2100")); + } + + @Override + public Object getResponseBody() { + return "" + + "{ " + + " \"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-ab121484a333\", " + + " \"modelName\": \"WanBonding\", " + + " \"modelVersion\": \"1.0\" " + + " }, " + + " \"subscriberInfo\": { " + + " \"globalSubscriberId\": \"C12345\", " + + " \"subscriberName\": \"General Electric Division 12\" " + + " }, " + + " \"requestInfo\": { " + + " \"instanceName\": \"WanBonding Service\", " + + " \"source\": \"VID\", " + + " \"suppressRollback\": true, " + + " \"requestorId\": \"ah2345\" " + + " }, " + + " \"requestParameters\": { " + + " \"subscriptionServiceType\": \"Trinity\" " + + " } " + + " }, " + + " \"requestStatus\": { " + + " \"timestamp\": \"Thu, 04 Jun 2009 02:53:39 GMT\", " + + " \"requestState\": \"Complete\", " + + " \"statusMessage\": \"Service created successfully\", " + + " \"percentProgress\": \"100\" " + + " } " + + " } " + + " }, { " + + " \"request\": { " + + " \"requestId\": \"25faf364-6031-4f58-9703-26955815562a\", " + + " \"startTime\": \"Thu, 30 Jun 2009 03:52:59 GMT\", " + + " \"instanceReferences\": { " + + " \"serviceInstanceId\": \"bc305d54-75b4-431b-adb2-eb6b9e546014\" " + + " }, " + + " \"requestScope\": \"vnf\", " + + " \"requestType\": \"applyUpdatedConfig\", " + + " \"requestDetails\": { " + + " \"modelInfo\": { " + + " \"modelType\": \"service\", " + + " \"modelInvariantId\": \"sn5256d1-5a33-55df-13ab-12abad84e764\", " + + " \"modelName\": \"WanBonding\", " + + " \"modelVersion\": \"1.0\" " + + " }, " + + " \"requestInfo\": { " + + " \"source\": \"VID\" " + + " } " + + " }, " + + " \"requestStatus\": { " + + " \"timestamp\": \"Thu, 30 Jun 2009 03:53:39 GMT\", " + + " \"requestState\": \"IN_PROGRESS\", " + + " \"statusMessage\": \"\", " + + " \"percentProgress\": \"30\" " + + " } " + + " } " + + " }, { " + + " \"request\": { " + + " \"requestId\": \"eaee7411-9281-4c25-a65f-aad5a725a61a\", " + + " \"startTime\": \"Thu, 30 Jun 2009 03:52:59 GMT\", " + + " \"instanceReferences\": { " + + " \"serviceInstanceId\": \"28d8a15f-c32c-475f-a7ae-5d23f3caee0e\" " + + " }, " + + " \"requestScope\": \"vnf\", " + + " \"requestType\": \"applyUpdatedConfig\", " + + " \"requestDetails\": { " + + " \"modelInfo\": { " + + " \"modelType\": \"service\", " + + " \"modelInvariantId\": \"sn5256d1-5a33-55df-13ab-12abad84e764\", " + + " \"modelName\": \"WanBonding\", " + + " \"modelVersion\": \"1.0\" " + + " }, " + + " \"requestInfo\": { " + + " \"source\": \"VID\" " + + " } " + + " }, " + + " \"requestStatus\": { " + + " \"timestamp\": \"Thu, 30 Jun 2009 03:53:39 GMT\", " + + " \"requestState\": \"PENDING\", " + + " \"statusMessage\": \"\", " + + " \"percentProgress\": \"30\" " + + " } " + + " } " + + " }, { " + + " \"request\": { " + + " \"requestId\": \"da6c17ba-4e8c-4983-b000-e4dcdbb60a51\", " + + " \"startTime\": \"Thu, 30 Jun 2009 03:52:59 GMT\", " + + " \"instanceReferences\": { " + + " \"serviceInstanceId\": \"39b5f85b-60bd-4ca6-8586-8340182b89b7\" " + + " }, " + + " \"requestScope\": \"vnf\", " + + " \"requestType\": \"applyUpdatedConfig\", " + + " \"requestDetails\": { " + + " \"modelInfo\": { " + + " \"modelType\": \"service\", " + + " \"modelInvariantId\": \"sn5256d1-5a33-55df-13ab-12abad84e764\", " + + " \"modelName\": \"WanBonding\", " + + " \"modelVersion\": \"1.0\" " + + " }, " + + " \"requestInfo\": { " + + " \"source\": \"VID\" " + + " } " + + " }, " + + " \"requestStatus\": { " + + " \"timestamp\": \"Thu, 30 Jun 2009 03:53:39 GMT\", " + + " \"requestState\": \"PENDING_MANUAL_TASK\", " + + " \"statusMessage\": \"\", " + + " \"percentProgress\": \"30\" " + + " } " + + " } " + + " }, { " + + " \"request\": { " + + " \"requestId\": \"7d6b6261-bede-4bfb-bde3-f225d63ee315\", " + + " \"startTime\": \"Thu, 30 Jun 2009 03:52:59 GMT\", " + + " \"instanceReferences\": { " + + " \"serviceInstanceId\": \"d4f74570-a03b-40f6-abe1-e979467ebbc1\" " + + " }, " + + " \"requestScope\": \"vnf\", " + + " \"requestType\": \"applyUpdatedConfig\", " + + " \"requestDetails\": { " + + " \"modelInfo\": { " + + " \"modelType\": \"service\", " + + " \"modelInvariantId\": \"sn5256d1-5a33-55df-13ab-12abad84e764\", " + + " \"modelName\": \"WanBonding\", " + + " \"modelVersion\": \"1.0\" " + + " }, " + + " \"requestInfo\": { " + + " \"source\": \"VID\" " + + " } " + + " }, " + + " \"requestStatus\": { " + + " \"timestamp\": \"Thu, 30 Jun 2009 03:53:39 GMT\", " + + " \"requestState\": \"STAM STATE\", " + + " \"statusMessage\": \"MSO just had a bad day :-(\", " + + " \"percentProgress\": \"30\" " + + " } " + + " } " + + " }, { " + + " \"request\": { " + + " \"requestId\": \"08e4a296-2fac-49c9-8a29-90c7eeee5ac2\", " + + " \"startTime\": \"Thu, 30 Jun 2009 03:52:59 GMT\", " + + " \"instanceReferences\": { " + + " \"serviceInstanceId\": \"48962b01-f021-4f75-ad52-1d54b6ee0bdb\" " + + " }, " + + " \"requestScope\": \"vnf\", " + + " \"requestType\": \"applyUpdatedConfig\", " + + " \"requestDetails\": { " + + " \"modelInfo\": { " + + " \"modelType\": \"service\", " + + " \"modelInvariantId\": \"sn5256d1-5a33-55df-13ab-12abad84e764\", " + + " \"modelName\": \"WanBonding\", " + + " \"modelVersion\": \"1.0\" " + + " }, " + + " \"requestInfo\": { " + + " \"source\": \"VID\" " + + " } " + + " }, " + + " \"requestStatus\": { " + + " \"timestamp\": \"Thu, 30 Jun 2009 03:53:39 GMT\", " + + " \"requestState\": \"FAILED\", " + + " \"statusMessage\": \"\", " + + " \"percentProgress\": \"30\" " + + " } " + + " } " + + " } " + + " ] " + + "} "; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsManyStatusesInvalidResponseGet.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsManyStatusesInvalidResponseGet.java new file mode 100644 index 000000000..10222fee8 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOOrchestrationRequestsManyStatusesInvalidResponseGet.java @@ -0,0 +1,19 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +public class PresetMSOOrchestrationRequestsManyStatusesInvalidResponseGet extends PresetMSOOrchestrationRequestsManyStatusesGet { + private final int responseCode; + + public PresetMSOOrchestrationRequestsManyStatusesInvalidResponseGet(int responseCode) { + this.responseCode = responseCode; + } + + @Override + public int getResponseCode() { + return responseCode; + } + + @Override + public Object getResponseBody() { + return "this payload is an invalid json"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOServiceInstanceGen2ErrorResponse.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOServiceInstanceGen2ErrorResponse.java index 881cc4634..9997f0a6d 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOServiceInstanceGen2ErrorResponse.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOServiceInstanceGen2ErrorResponse.java @@ -1,6 +1,6 @@ package org.onap.simulator.presetGenerator.presets.mso; -public class PresetMSOServiceInstanceGen2ErrorResponse extends PresetMSOBaseCreateServiceInstancePost { +public class PresetMSOServiceInstanceGen2ErrorResponse extends PresetMSOBaseCreateInstancePost { private final int responseCode; @@ -15,7 +15,7 @@ public class PresetMSOServiceInstanceGen2ErrorResponse extends PresetMSOBaseCrea @Override public String getReqPath() { - return getRootPath() + "/serviceInstantiation/v7/serviceInstances/assign"; + return getRootPath() + "/serviceInstantiation/v./serviceInstances/assign"; } @Override diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOServiceInstanceGen2WithNames.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOServiceInstanceGen2WithNames.java index 98187b9a2..b851da2d2 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOServiceInstanceGen2WithNames.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOServiceInstanceGen2WithNames.java @@ -1,22 +1,55 @@ package org.onap.simulator.presetGenerator.presets.mso; -import java.util.Map; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.SERVICE_NAME; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.VFM_NAME1; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.VFM_NAME2; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.VG_NAME; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.VNF_NAME; -import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.*; +import java.util.Map; +import vid.automation.test.infra.Features; -public abstract class PresetMSOServiceInstanceGen2WithNames extends PresetMSOBaseCreateServiceInstancePost{ +public abstract class PresetMSOServiceInstanceGen2WithNames extends PresetMSOBaseCreateInstancePost { public enum Keys { - SERVICE_NAME, VNF_NAME, VFM_NAME1, VFM_NAME2, VG_NAME + SERVICE_NAME, VNF_NAME, VNF_NAME2, VFM_NAME1, VFM_NAME2, VG_NAME + , VNF_GROUP1_ACTION, RELATED_VNF1_ACTION, RELATED_VNF2_ACTION, } - private final Map<Keys, String> names; + protected final Map<Keys, String> names; - private final String suffix; + protected final String suffix; public PresetMSOServiceInstanceGen2WithNames(Map<Keys, String> names, int suffix) { + this(names, suffix, PresetMSOBaseCreateInstancePost.DEFAULT_REQUEST_ID); + } + + public PresetMSOServiceInstanceGen2WithNames(Map<Keys, String> names, int suffix, String requestId) { + super(requestId); + this.names = names; + this.suffix = formatSuffix(suffix); + } + + public PresetMSOServiceInstanceGen2WithNames(Map<Keys, String> names, int suffix, String requestId, String responseInstanceId) { + super(requestId, responseInstanceId); this.names = names; - this.suffix = "_" + String.format("%03d", suffix); + this.suffix = formatSuffix(suffix); + } + + @Override + public boolean isStrictMatch() { + return true; + } + + protected String getVnfInstanceParams() { + if (!Features.FLAG_SHIFT_VFMODULE_PARAMS_TO_VNF.isActive()) { + return ""; + } + return " {" + + " \"vmx_int_net_len\": \"24\"," + + " \"vre_a_volume_size_0\": \"100\"," + + " \"availability_zone_0\": \"mtpocdv-kvm-az01\"" + + "}"; } @Override @@ -45,7 +78,7 @@ public abstract class PresetMSOServiceInstanceGen2WithNames extends PresetMSOBas " \"productFamilyId\": \"myProductFamilyId\"," + " \"source\": \"VID\"," + " \"suppressRollback\": false," + - " \"requestorId\": \"vid1\"" + + " \"requestorId\": \"us16807000\"" + " }," + " \"requestParameters\": {" + " \"subscriptionServiceType\": \"mySubType\"," + @@ -71,7 +104,8 @@ public abstract class PresetMSOServiceInstanceGen2WithNames extends PresetMSOBas " \"modelType\": \"vnf\"" + " }," + " \"cloudConfiguration\": {" + - " \"lcpCloudRegionId\": \"mtn3\"," + + " \"lcpCloudRegionId\": \"hvf3\"," + + addCloudOwnerIfNeeded() + " \"tenantId\": \"greatTenant\"" + " }," + " \"platform\": {" + @@ -81,7 +115,7 @@ public abstract class PresetMSOServiceInstanceGen2WithNames extends PresetMSOBas " \"lineOfBusinessName\": \"lineOfBusinessName\"" + " }," + " \"productFamilyId\": \"myProductFamilyId\"," + - " \"instanceParams\": []," + + " \"instanceParams\": ["+getVnfInstanceParams()+"]," + " \"vfModules\": [" + " {" + " \"modelInfo\": {" + diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/changeManagement/PresetMsoChangeManagementBase.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/changeManagement/PresetMsoChangeManagementBase.java new file mode 100644 index 000000000..758e15e6e --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/changeManagement/PresetMsoChangeManagementBase.java @@ -0,0 +1,28 @@ +package org.onap.simulator.presetGenerator.presets.mso.changeManagement; + +import org.apache.commons.lang3.StringUtils; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateInstancePost; + +public abstract class PresetMsoChangeManagementBase extends PresetMSOBaseCreateInstancePost { + + protected final String serviceInstanceId; + protected final String vnfInstanceId; + private final String actionName; + + public PresetMsoChangeManagementBase(String serviceInstanceId, String vnfInstanceId, String actionName) { + super(DEFAULT_REQUEST_ID, vnfInstanceId); + this.serviceInstanceId = serviceInstanceId; + this.vnfInstanceId = vnfInstanceId; + this.actionName = actionName; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstances/v./" + serviceInstanceId + "/vnfs/"+vnfInstanceId+ getReqPathTrailer(); + } + + protected String getReqPathTrailer() { + return StringUtils.isEmpty(actionName) ? "" : "/"+ actionName; + } + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/changeManagement/PresetMsoVnfInPlaceSoftwareUpdate.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/changeManagement/PresetMsoVnfInPlaceSoftwareUpdate.java new file mode 100644 index 000000000..897db26bd --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/changeManagement/PresetMsoVnfInPlaceSoftwareUpdate.java @@ -0,0 +1,37 @@ +package org.onap.simulator.presetGenerator.presets.mso.changeManagement; + +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId; +import org.springframework.http.HttpMethod; + +public class PresetMsoVnfInPlaceSoftwareUpdate extends PresetMsoChangeManagementBase { + + public PresetMsoVnfInPlaceSoftwareUpdate(String serviceInstanceId, String vnfInstanceId) { + super(serviceInstanceId, vnfInstanceId, "inPlaceSoftwareUpdate"); + this.cloudOwner = PresetAAIGetCloudOwnersByCloudRegionId.ATT_NC; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.POST; + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"cloudConfiguration\": {" + + " \"lcpCloudRegionId\": \"mdt1\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\"" + + " }," + + " \"requestInfo\": {" + + " \"source\": \"VID\"," + + " \"requestorId\": \"az2016\"" + + " }," + + " \"requestParameters\": {" + + " \"payload\": \"{\\\"existing_software_version\\\": \\\"3.1\\\", \\\"new_software_version\\\": \\\"3.2\\\", \\\"operations_timeout\\\": \\\"3600\\\"}\"" + + " }" + + " }" + + "}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/changeManagement/PresetMsoVnfReplace.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/changeManagement/PresetMsoVnfReplace.java new file mode 100644 index 000000000..cbdb8f5f6 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/changeManagement/PresetMsoVnfReplace.java @@ -0,0 +1,58 @@ +package org.onap.simulator.presetGenerator.presets.mso.changeManagement; + +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId; +import org.springframework.http.HttpMethod; + +public class PresetMsoVnfReplace extends PresetMsoChangeManagementBase { + + public PresetMsoVnfReplace(String serviceInstanceId, String vnfInstanceId) { + super(serviceInstanceId, vnfInstanceId, "replace"); + this.cloudOwner = PresetAAIGetCloudOwnersByCloudRegionId.ATT_NC; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.POST; + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"modelInfo\": {" + + " \"modelType\": \"vnf\"," + + " \"modelInvariantId\": \"ff5256d1-5a33-55df-13ab-12abad84e7ff\"," + + " \"modelVersionId\": \"254583ad-b38c-498b-bdbd-b8de5e07541b\"," + + " \"modelName\": \"vSAMP12\"," + + " \"modelVersion\": \"2.0\"," + + " \"modelCustomizationId\": \"c539433a-84a6-4082-a12e-5c9b00c3b960\"" + + " }," + + " \"cloudConfiguration\": {" + + " \"lcpCloudRegionId\": \"mdt1\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\"" + + " }," + + " \"requestInfo\": {" + + " \"source\": \"VID\"," + + " \"requestorId\": \"az2016\"" + + " }," + + " \"relatedInstanceList\": [{" + + " \"relatedInstance\": {" + + " \"instanceId\": \""+serviceInstanceId+"\"," + + " \"modelInfo\": {" + + " \"modelType\": \"service\"," + + " \"modelInvariantId\": \"ff3514e3-5a33-55df-13ab-12abad84e7ff\"," + + " \"modelVersionId\": \"9ebb1521-2e74-47a4-aac7-e71a79f73a79\"," + + " \"modelName\": \"fakeModelName\"," + + " \"modelVersion\": \"2.0\"" + + " }" + + " }" + + " }" + + " ]," + + " \"requestParameters\": {" + + " \"rebuildVolumeGroups\": false" + + " }" + + " }" + + "}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/changeManagement/PresetMsoVnfUpdate.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/changeManagement/PresetMsoVnfUpdate.java new file mode 100644 index 000000000..dee516005 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/changeManagement/PresetMsoVnfUpdate.java @@ -0,0 +1,67 @@ +package org.onap.simulator.presetGenerator.presets.mso.changeManagement; + +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId; +import org.springframework.http.HttpMethod; + +public class PresetMsoVnfUpdate extends PresetMsoChangeManagementBase { + + + public PresetMsoVnfUpdate(String serviceInstanceId, String vnfInstanceId) { + super(serviceInstanceId, vnfInstanceId, ""); + this.cloudOwner = PresetAAIGetCloudOwnersByCloudRegionId.ATT_NC; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.PUT; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstantiation/v./serviceInstances/" + serviceInstanceId + "/vnfs/" + vnfInstanceId; + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"modelInfo\": {" + + " \"modelType\": \"vnf\"," + + " \"modelInvariantId\": \"ff5256d1-5a33-55df-13ab-12abad84e7ff\"," + + " \"modelVersionId\": \"254583ad-b38c-498b-bdbd-b8de5e07541b\"," + + " \"modelName\": \"vSAMP12\"," + + " \"modelVersion\": \"2.0\"," + + // TODO Ask ZITELLA, MICHAEL V if the field is mandatory. Vid currently not send it + //" \"modelCustomizationName\": \"vSAMP12 1\"," + + " \"modelCustomizationId\": \"c539433a-84a6-4082-a12e-5c9b00c3b960\"" + + " }," + + " \"cloudConfiguration\": {" + + " \"lcpCloudRegionId\": \"mdt1\"," + + addCloudOwnerIfNeeded() + + " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\"" + + " }," + + " \"requestInfo\": {" + + " \"source\": \"VID\"," + + " \"suppressRollback\": false," + + " \"requestorId\": \"az2016\"" + + " }," + + " \"relatedInstanceList\": [" + + " {" + + " \"relatedInstance\": {" + + " \"instanceId\": \""+serviceInstanceId+"\"," + + " \"modelInfo\": {" + + " \"modelType\": \"service\"," + + " \"modelInvariantId\": \"ff3514e3-5a33-55df-13ab-12abad84e7ff\"," + + " \"modelVersionId\": \"9ebb1521-2e74-47a4-aac7-e71a79f73a79\"," + + " \"modelName\": \"fakeModelName\"," + + " \"modelVersion\": \"2.0\"" + + " }" + + " }" + + " }" + + " ]," + + " \"requestParameters\": {" + + " \"usePreload\": true" + + " }" + + "}}"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/configuration/PresetMSOActOnConfiguration.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/configuration/PresetMSOActOnConfiguration.java new file mode 100644 index 000000000..6c4b722d6 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/configuration/PresetMSOActOnConfiguration.java @@ -0,0 +1,70 @@ +package org.onap.simulator.presetGenerator.presets.mso.configuration; + +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateInstancePost; + +public class PresetMSOActOnConfiguration extends PresetMSOBaseCreateInstancePost { + + private final String action; + + public PresetMSOActOnConfiguration(String action) { + this.action = action; + this.cloudOwner = "att-nc"; + } + + public PresetMSOActOnConfiguration(String action, String requestId, String responseInstanceId) { + super(requestId, responseInstanceId); + this.action = action; + this.cloudOwner = "att-nc"; + } + + + @Override + public boolean isStrictMatch() { + return true; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstances/v./c187e9fe-40c3-4862-b73e-84ff056205f6/configurations/9533-config-LB1113/" + action; + } + + @Override + public Object getRequestBody() { + return "" + + "{" + + " \"requestDetails\": {" + + " \"modelInfo\": {" + + " \"modelType\": \"configuration\"," + + " \"modelInvariantId\": \"model-invariant-id-9533\"," + + " \"modelVersionId\": \"model-version-id-9533\"," + + " \"modelCustomizationId\": \"08a181aa-72eb-435f-9593-e88a3ad0a86b\"" + + " }," + + " \"cloudConfiguration\": {" + + addCloudOwnerIfNeeded() + + " \"lcpCloudRegionId\": \"mdt1\"," + + " }," + + " \"requestInfo\": {" + + " \"source\": \"VID\"," + + " \"requestorId\": \"us16807000\"" + + " }," + + " \"relatedInstanceList\": [{" + + " \"relatedInstance\": {" + + " \"instanceId\": \"c187e9fe-40c3-4862-b73e-84ff056205f6\"," + + " \"modelInfo\": {" + + " \"modelType\": \"service\"," + + " \"modelInvariantId\": \"b7d923c9-6175-41f1-91ba-4565c4953408\"," + + " \"modelVersionId\": \"ee6d61be-4841-4f98-8f23-5de9da846ca7\"," + + " \"modelName\": \"ServiceContainerMultiplepProbes\"," + + " \"modelVersion\": \"1.0\"" + + " }" + + " }" + + " }" + + " ]," + + " \"requestParameters\": {" + + " \"userParams\": []" + + " }" + + " }" + + "}"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/configuration/PresetMSOCreateConfiguration.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/configuration/PresetMSOCreateConfiguration.java new file mode 100644 index 000000000..bba0f20d8 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/configuration/PresetMSOCreateConfiguration.java @@ -0,0 +1,117 @@ +package org.onap.simulator.presetGenerator.presets.mso.configuration; + +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateInstancePost; + +public class PresetMSOCreateConfiguration extends PresetMSOBaseCreateInstancePost { + + protected final String serviceInstanceId; + protected final boolean isError; + private final int errorCode; + private final String errorPayload; + + public PresetMSOCreateConfiguration(String serviceInstanceId) { + super("b6dc9806-b094-42f7-9386-a48de8218ce8", "f36f5734-e9df-4fbf-9f35-61be13f028a1"); + this.serviceInstanceId = serviceInstanceId; + this.cloudOwner = "irma-aic"; + this.isError = false; + this.errorCode = 0; + this.errorPayload = null; + } + + public PresetMSOCreateConfiguration(String serviceInstanceId, int errorCode, String errorPayload) { + super("b6dc9806-b094-42f7-9386-a48de8218ce8", "f36f5734-e9df-4fbf-9f35-61be13f028a1"); + this.serviceInstanceId = serviceInstanceId; + this.cloudOwner = "irma-aic"; + this.isError = true; + this.errorCode = errorCode; + this.errorPayload = errorPayload; + } + + @Override + public boolean isStrictMatch() { + return true; + } + + @Override + public int getResponseCode() { + return isError ? errorCode : super.getResponseCode(); + } + + @Override + public Object getResponseBody() { + return isError ? errorPayload : super.getResponseBody(); + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstances/v./" + this.serviceInstanceId + "/configurations"; + } + + @Override + public Object getRequestBody() { + return "" + + "{" + + " \"requestDetails\": {" + + " \"modelInfo\": {" + + " \"modelType\": \"configuration\"," + + " \"modelInvariantId\": \"c30a024e-a6c6-4670-b73c-3df64eb57ff6\"," + + " \"modelVersionId\": \"f58d039d-4cfc-40ec-bd75-1f05f0458a6c\"," + + " \"modelName\": \"Port Mirroring Configuration By Policy\"," + + " \"modelVersion\": \"1.0\"," + + " \"modelCustomizationId\": \"4b7ebace-bad6-4526-9be6-bf248e20fc5f\"," + + " \"modelCustomizationName\": \"Port Mirroring Configuration By Policy 1\"" + + " }," + + " \"cloudConfiguration\": {" + + addCloudOwnerIfNeeded() + + " \"lcpCloudRegionId\": \"JANET25\"" + + " }," + + " \"requestInfo\": {" + + " \"instanceName\": \"dummy_instance\"," + + " \"source\": \"VID\"," + + " \"requestorId\": \"us16807000\"" + + " }," + + " \"relatedInstanceList\": [" + + " {" + + " \"relatedInstance\": {" + + " \"instanceId\": \"c187e9fe-40c3-4862-b73e-84ff056205f6\"," + + " \"modelInfo\": {" + + " \"modelType\": \"service\"," + + " \"modelInvariantId\": \"b7d923c9-6175-41f1-91ba-4565c4953408\"," + + " \"modelVersionId\": \"ee6d61be-4841-4f98-8f23-5de9da846ca7\"," + + " \"modelName\": \"ServiceContainerMultiplepProbes\"," + + " \"modelVersion\": \"1.0\"" + + " }" + + " }" + + " }," + + " {" + + " \"relatedInstance\": {" + + " \"instanceId\": \"9be14a4f-7367-4cf9-96a1-f08f10f485a7\"," + + " \"instanceDirection\": \"source\"," + + " \"modelInfo\": {" + + " \"modelType\": \"vnf\"," + + " \"modelInvariantId\": \"51f2c559-1aba-4fd4-bbf9-8cbbef85ff2a\"," + + " \"modelVersionId\": \"cb05b259-9f26-4b33-b96c-13c2c202c091\"," + + " \"modelName\": \"vf_vEPDG\"," + + " \"modelVersion\": \"2.0\"," + + " \"modelCustomizationId\": \"35aeaae9-74f7-4b6a-adda-65edb0110361\"" + + " }" + + " }" + + " }," + + " {" + + " \"relatedInstance\": {" + + " \"instanceName\": \"AS-pnf2-10219--as988q\"," + + " \"instanceDirection\": \"destination\"," + + " \"modelInfo\": {" + + " \"modelType\": \"pnf\"" + + " }" + + " }" + + " }" + + " ]," + + " \"requestParameters\": {" + + " \"userParams\": []" + + " }" + + " }" + + "}"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/configuration/PresetMSODeleteConfiguration.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/configuration/PresetMSODeleteConfiguration.java new file mode 100644 index 000000000..4d0582c91 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/configuration/PresetMSODeleteConfiguration.java @@ -0,0 +1,53 @@ +package org.onap.simulator.presetGenerator.presets.mso.configuration; + +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateInstancePost; +import org.springframework.http.HttpMethod; + +public class PresetMSODeleteConfiguration extends PresetMSOBaseCreateInstancePost { + + public PresetMSODeleteConfiguration() { + this.cloudOwner = "att-nc"; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.DELETE; + } + + @Override + public boolean isStrictMatch() { + return true; + } + + @Override + public String getReqPath() { + return getRootPath() + "/serviceInstances/v./c187e9fe-40c3-4862-b73e-84ff056205f6/configurations/9533-config-LB1113"; + } + + @Override + public Object getRequestBody() { + return "" + + "{" + + " \"requestDetails\": {" + + " \"cloudConfiguration\": {" + + addCloudOwnerIfNeeded() + + " \"lcpCloudRegionId\": \"mdt1\"" + + " }," + + " \"modelInfo\": {" + + " \"modelCustomizationId\": \"08a181aa-72eb-435f-9593-e88a3ad0a86b\"," + + " \"modelInvariantId\": \"model-invariant-id-9533\"," + + " \"modelVersionId\": \"model-version-id-9533\"," + + " \"modelType\": \"configuration\"" + + " }," + + " \"requestInfo\": {" + + " \"source\": \"VID\"," + + " \"requestorId\": \"us16807000\"" + + " }," + + " \"requestParameters\": {" + + " \"userParams\": []" + + " }" + + " }" + + "}"; + } + +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/configuration/PresetMsoEnableDisablePort.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/configuration/PresetMsoEnableDisablePort.java new file mode 100644 index 000000000..db18e0104 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/configuration/PresetMsoEnableDisablePort.java @@ -0,0 +1,76 @@ +package org.onap.simulator.presetGenerator.presets.mso.configuration; + +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateInstancePost; +import org.springframework.http.HttpMethod; + +public class PresetMsoEnableDisablePort extends PresetMSOBaseCreateInstancePost { + + private final String serviceInstanceId; + private final String configurationId; + private final String action; + + + public PresetMsoEnableDisablePort(String serviceInstanceId, String configurationId, String action) { + super("314cc766-b673-4a50-b9c5-471f68914585", serviceInstanceId); + this.serviceInstanceId = serviceInstanceId; + this.configurationId = configurationId; + this.action = action; + this.cloudOwner = PresetAAIGetCloudOwnersByCloudRegionId.ATT_NC; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.POST; + } + + @Override + public String getReqPath() { + return "/mso/serviceInstances/v./"+serviceInstanceId+"/configurations/"+configurationId+"/" + action; + } + + @Override + public Object getRequestBody() { + return "{" + + " \"requestDetails\": {" + + " \"cloudConfiguration\": {" + + addCloudOwnerIfNeeded() + + " \"lcpCloudRegionId\": \"mdt1\"" + + " }," + + " \"modelInfo\": {" + + " \"modelCustomizationId\": \"08a181aa-72eb-435f-9593-e88a3ad0a86b\"," + + " \"modelInvariantId\": \"model-invariant-id-9533\"," + + " \"modelVersionId\": \"model-version-id-9533\"," + + " \"modelType\": \"configuration\"" + + " }," + + " \"requestInfo\": {" + + " \"source\": \"VID\"," + + " \"requestorId\": \"us16807000\"" + + " }," + + " \"relatedInstanceList\": [" + + " {" + + " \"relatedInstance\": {" + + " \"instanceId\": \""+serviceInstanceId+"\"," + + " \"modelInfo\": {" + + " \"modelType\": \"service\"," + + " \"modelInvariantId\": \"b7d923c9-6175-41f1-91ba-4565c4953408\"," + + " \"modelName\": \"ServiceContainerMultiplepProbes\"," + + " \"modelVersionId\": \"ee6d61be-4841-4f98-8f23-5de9da846ca7\"," + + " \"modelVersion\": \"1.0\"" + + " }" + + " }" + + " }," + + " {" + + " \"relatedInstance\": {" + + " \"instanceId\": \"d35bf534-7d8e-4cb4-87f9-0a8bb6cd47b2\"," + + " \"instanceDirection\": \"source\"," + + " \"modelInfo\": {" + + " \"modelType\": \"connectionPoint\"" + + " }" + + " }" + + " }" + + " ]" + + " }" + + " }"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/scheduler/PresetGetSchedulerChangeManagementInvalidResponse.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/scheduler/PresetGetSchedulerChangeManagementInvalidResponse.java new file mode 100644 index 000000000..b79dc3ed2 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/scheduler/PresetGetSchedulerChangeManagementInvalidResponse.java @@ -0,0 +1,17 @@ +package org.onap.simulator.presetGenerator.presets.scheduler; + +public class PresetGetSchedulerChangeManagementInvalidResponse extends PresetGetSchedulerChangeManagements { + private int httpCode; + + public PresetGetSchedulerChangeManagementInvalidResponse(int httpCode) { + this.httpCode = httpCode; + } + + @Override + public int getResponseCode() { return httpCode; } + + @Override + public Object getResponseBody() { + return "this payload is an invalid json"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/scheduler/PresetGetSchedulerChangeManagements.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/scheduler/PresetGetSchedulerChangeManagements.java new file mode 100644 index 000000000..3763db2da --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/scheduler/PresetGetSchedulerChangeManagements.java @@ -0,0 +1,162 @@ +package org.onap.simulator.presetGenerator.presets.scheduler; + +import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset; +import org.springframework.http.HttpMethod; + +public class PresetGetSchedulerChangeManagements extends BasePreset { + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return getRootPath() + "/scheduleDetails/"; + } + + @Override + protected String getRootPath() { + return "/scheduler/v1/ChangeManagement/schedules"; + } + + @Override + public Object getResponseBody() { + return "[" + + " {" + + " \"vnfName\": \"dbox0001v\"," + + " \"status\": \"Triggered\"," + + " \"aotsChangeId\": \"CHG000000000001\"," + + " \"aotsApprovalStatus\": \"Approved\"," + + " \"groupId\": \"groupId\"," + + " \"dispatchTime\": \"2018-05-09T14:05:43Z\"," + + " \"msoRequestId\": \"2fb4edd1-01c4-4fee-bd4a-4ae6282aa213\"," + + " \"scheduleRequest\": {" + + " \"id\": 1," + + " \"createDateTime\": \"2018-05-09T14:05:34Z\"," + + " \"optimizerAttemptsToSchedule\": 0," + + " \"optimizerTransactionId\": \"70f05563-6705-4be0-802a-8b6b78a69d63\"," + + " \"scheduleId\": \"70f05563-6705-4be0-802a-8b6b78a69d63\"," + + " \"scheduleName\": \"70f05563-6705-4be0-802a-8b6b78a69d63\"," + + " \"status\": \"Notifications Initiated\"," + + " \"userId\": \"wl849v\"," + + " \"domain\": \"ChangeManagement\"," + + " \"domainData\": [" + + " {" + + " \"id\": 1," + + " \"name\": \"WorkflowName\"," + + " \"value\": \"VNF In Place Software Update\"" + + " }," + + " {" + + " \"id\": 2," + + " \"name\": \"CallbackUrl\"," + + " \"value\": \"https://vid.onap.org:8000/vid/change-management/workflow/\"" + + " }," + + " {" + + " \"id\": 3," + + " \"name\": \"CallbackData\"," + + " \"value\": \"{\\\"requestType\\\":\\\"VNF In Place Software Update\\\",\\\"requestDetails\\\":[{\\\"vnfName\\\":\\\"dbox0001v\\\",\\\"vnfInstanceId\\\":\\\"815d38c0-b686-491c-9a74-0b49add524ca\\\",\\\"modelInfo\\\":{\\\"modelType\\\":\\\"vnf\\\",\\\"modelInvariantId\\\":\\\"59f4e0b2-e1b0-4e3b-bae3-e7b8c5d32985\\\",\\\"modelVersionId\\\":\\\"345643c1-3a51-423f-aac1-502e027d8dab\\\",\\\"modelName\\\":\\\"dbox0001v\\\",\\\"modelCustomizationId\\\":\\\"01ce23cb-d276-4d71-a5f1-f9d42d0df543\\\"},\\\"cloudConfiguration\\\":{\\\"lcpCloudRegionId\\\":\\\"dpa2b\\\",\\\"tenantId\\\":\\\"b60da4f71c1d4b35b8113d4eca6deaa1\\\"},\\\"requestInfo\\\":{\\\"source\\\":\\\"VID\\\",\\\"suppressRollback\\\":false,\\\"requestorId\\\":\\\"wl849v\\\"},\\\"relatedInstanceList\\\":[{\\\"relatedInstance\\\":{\\\"instanceId\\\":\\\"eb774932-e9fa-4c7f-bbc1-229b6b2b11e2\\\",\\\"modelInfo\\\":{\\\"modelType\\\":\\\"service\\\",\\\"modelInvariantId\\\":\\\"57dd617b-d64e-4441-a287-4d158b24ba65\\\",\\\"modelVersionId\\\":\\\"345643c1-3a51-423f-aac1-502e027d8dab\\\",\\\"modelName\\\":\\\"control_loop_dbe_svc\\\",\\\"modelVersion\\\":\\\"2.0\\\"}}}],\\\"requestParameters\\\":{\\\"payload\\\":\\\"{\\\\\\\"existing_software_version\\\\\\\":\\\\\\\"2\\\\\\\",\\\\\\\"new_software_version\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"operations_timeout\\\\\\\":\\\\\\\"3\\\\\\\"}\\\",\\\"testApi\\\":\\\"GR_API\\\"}}]}\"" + + " }" + + " ]," + + " \"scheduleApprovals\": []" + + " }," + + " \"schedulesId\": 0" + + " }," + + " {" + + " \"vnfName\": \"aaiaic25ctsf0002v\"," + + " \"vnfId\": \"\"," + + " \"status\": \"Cancelled\"," + + " \"aotsChangeId\": \"CHG000000000001\"," + + " \"aotsApprovalStatus\": \"Approved\"," + + " \"startTime\": \"2018-06-07T04:00:24Z\"," + + " \"finishTime\": \"2018-06-07T04:02:14Z\"," + + " \"groupId\": \"group\"," + + " \"lastInstanceStartTime\": \"2018-06-07T04:00:24Z\"," + + " \"policyId\": \"SNIRO_CM.TimeLimitAndVerticalTopology_pserver\"," + + " \"scheduleRequest\": {" + + " \"id\": 5," + + " \"createDateTime\": \"2018-06-06T13:00:25Z\"," + + " \"optimizerDateTime\": \"2018-06-06T13:00:34Z\"," + + " \"optimizerMessage\": \"A feasible scheduled has been found\"," + + " \"optimizerStatus\": \"complete\"," + + " \"optimizerAttemptsToSchedule\": 0," + + " \"optimizerReturnDateTime\": \"2018-06-06T13:07:02Z\"," + + " \"optimizerTransactionId\": \"01da00a6-9664-4db6-b97d-50847bc05144\"," + + " \"schedule\": \"[{\\\"groupId\\\":\\\"group\\\",\\\"startTime\\\":\\\"2018-06-07 04:00:24\\\",\\\"finishTime\\\":\\\"2018-06-07 04:02:14\\\",\\\"latestInstanceStartTime\\\":\\\"2018-06-07 04:00:24\\\",\\\"node\\\":[\\\"aaiaic25ctsf0002v\\\"]}]\"," + + " \"scheduleId\": \"01da00a6-9664-4db6-b97d-50847bc05144\"," + + " \"scheduleName\": \"01da00a6-9664-4db6-b97d-50847bc05144\"," + + " \"status\": \"Cancelled\"," + + " \"userId\": \"jf9860\"," + + " \"domain\": \"ChangeManagement\"," + + " \"deleteDateTime\": \"2018-06-06T13:07:11Z\"," + + " \"domainData\": [" + + " {" + + " \"id\": 5," + + " \"name\": \"CallbackData\"," + + " \"value\": \"{\\\"requestType\\\": \\\"Update\\\", \\\"requestDetails\\\": [{\\\"vnfInstanceId\\\": \\\"b8d99523-1e83-4fd1-b42f-849361ef7024\\\", \\\"relatedInstanceList\\\": [{\\\"relatedInstance\\\": {\\\"instanceId\\\": \\\"54ba3628-9ee5-4b32-8a2a-3abf001bed4e\\\", \\\"modelInfo\\\": {\\\"modelVersionId\\\": \\\"4ec07a2d-6bb5-4373-8ed6-4bc7ac1246fd\\\", \\\"modelVersion\\\": \\\"4.0\\\", \\\"modelName\\\": \\\"CHARLOTTE_2017_1011\\\", \\\"modelInvariantId\\\": \\\"e58733ef-43cb-4b6b-b641-922078b6c88b\\\", \\\"modelType\\\": \\\"service\\\"}}}], \\\"requestParameters\\\": {\\\"usePreload\\\": true}, \\\"requestInfo\\\": {\\\"source\\\": \\\"VID\\\", \\\"requestorId\\\": \\\"az2016\\\", \\\"suppressRollback\\\": false}, \\\"vnfName\\\": \\\"CHARLOTTE_2017_1011_oh22u_20171103\\\", \\\"modelInfo\\\": {\\\"modelVersionId\\\": \\\"4ec07a2d-6bb5-4373-8ed6-4bc7ac1246fd\\\", \\\"modelName\\\": \\\"CHARLOTTE_2017_1011_oh22u_20171103\\\", \\\"modelInvariantId\\\": \\\"93e16072-715a-42ef-9d0a-080052d6b716\\\", \\\"modelType\\\": \\\"vnf\\\", \\\"modelCustomizationId\\\": \\\"1779a999-ea17-4f31-98e9-75b6fbdd0acb\\\"}, \\\"cloudConfiguration\\\": {\\\"tenantId\\\": \\\"88a6ca3ee0394ade9403f075db23167e\\\", \\\"lcpCloudRegionId\\\": \\\"mdt1\\\"}}]}\"" + + " }," + + " {" + + " \"id\": 9," + + " \"name\": \"WorkflowName\"," + + " \"value\": \"Update\"" + + " }," + + " {" + + " \"id\": 13," + + " \"name\": \"CallbackUrl\"," + + " \"value\": \"http://127.0.0.1:8900/scheduler/v1/loopbacktest/vid\"" + + " }" + + " ]," + + " \"scheduleApprovals\": [" + + " {" + + " \"approvalDateTime\": \"2018-06-06T13:07:08Z\"," + + " \"status\": \"Accepted\"," + + " \"userId\": \"jf9860\"," + + " \"approvalTypeId\": 1" + + " }" + + " ]" + + " }," + + " \"schedulesId\": 0" + + " }," + + " {" + + " \"vnfName\": \"Zolson1MMSC04ee0f\"," + + " \"status\": \"Pending Schedule\"," + + " \"groupId\": \"\"," + + " \"policyId\": \"SNIRO.TimeLimitAndVerticalTopology\"," + + " \"scheduleRequest\": {" + + " \"id\": 9," + + " \"createDateTime\": \"2018-06-06T13:07:16Z\"," + + " \"optimizerDateTime\": \"2018-06-06T13:07:24Z\"," + + " \"optimizerMessage\": \"Error while processing request ID: CM-502adbb3-1c37-4cc6-bc9f-6777ad4227a3 -- Failed Processing; cause: Traceback (most recent call last):\\n File \\\"/opt/app/sniro/sniroapp/sniro/optimizers/cmopt/rcscheduler/local_opt_processor.py\\\", line 15, in process_local_cm_scheduler_opt\\n full_process_local_cm_scheduler_opt(request_json, policies, sniro_config)\\n File \\\"/opt/app/sniro/sniroapp/sniro/optimizers/cmopt/rcscheduler/local_opt_processor.py\\\", line 38, in full_process_local_cm_scheduler_opt\\n json_req = create_cm_scheduler_request(request_json, policies, all_req_info)\\n File \\\"/opt/app/sniro/sniroapp/sniro/optimizers/cmopt/rcscheduler/request_builder.py\\\", line 16, in create_cm_scheduler_request\\n cm = vertical_topology.VerticalConflicts(request_json) # TODO: rename + refactor\\n File \\\"/opt/app/sniro/sniroapp/sniro/datasources/aai/vertical_topology.py\\\", line 68, in __init__\\n self.tzinfo = dict((x, tzxref[self.clli[x]]) for x in self.vnfs)\\n File \\\"/opt/app/sniro/sniroapp/sniro/datasources/aai/vertical_topology.py\\\", line 68, in <genexpr>\\n self.tzinfo = dict((x, tzxref[self.clli[x]]) for x in self.vnfs)\\nKeyError: ('Zolson1MMSC04ee0f', '(Unable to get timezones for some elements)')\\n\"," + + " \"optimizerStatus\": \"failed\"," + + " \"optimizerAttemptsToSchedule\": 0," + + " \"optimizerReturnDateTime\": \"2018-06-06T13:13:47Z\"," + + " \"optimizerTransactionId\": \"645c4cfb-e00f-4995-bf23-a7df892eee0f\"," + + " \"scheduleId\": \"645c4cfb-e00f-4995-bf23-a7df892eee0f\"," + + " \"scheduleName\": \"645c4cfb-e00f-4995-bf23-a7df892eee0f\"," + + " \"status\": \"Optimization Failed\"," + + " \"userId\": \"jf9860\"," + + " \"domain\": \"ChangeManagement\"," + + " \"domainData\": [" + + " {" + + " \"id\": 17," + + " \"name\": \"CallbackData\"," + + " \"value\": \"{\\\"requestType\\\": \\\"Update\\\", \\\"requestDetails\\\": [{\\\"vnfInstanceId\\\": \\\"b8d99523-1e83-4fd1-b42f-849361ef7024\\\", \\\"relatedInstanceList\\\": [{\\\"relatedInstance\\\": {\\\"instanceId\\\": \\\"54ba3628-9ee5-4b32-8a2a-3abf001bed4e\\\", \\\"modelInfo\\\": {\\\"modelVersionId\\\": \\\"4ec07a2d-6bb5-4373-8ed6-4bc7ac1246fd\\\", \\\"modelVersion\\\": \\\"4.0\\\", \\\"modelName\\\": \\\"CHARLOTTE_2017_1011\\\", \\\"modelInvariantId\\\": \\\"e58733ef-43cb-4b6b-b641-922078b6c88b\\\", \\\"modelType\\\": \\\"service\\\"}}}], \\\"requestParameters\\\": {\\\"usePreload\\\": true}, \\\"requestInfo\\\": {\\\"source\\\": \\\"VID\\\", \\\"requestorId\\\": \\\"az2016\\\", \\\"suppressRollback\\\": false}, \\\"vnfName\\\": \\\"CHARLOTTE_2017_1011_oh22u_20171103\\\", \\\"modelInfo\\\": {\\\"modelVersionId\\\": \\\"4ec07a2d-6bb5-4373-8ed6-4bc7ac1246fd\\\", \\\"modelName\\\": \\\"CHARLOTTE_2017_1011_oh22u_20171103\\\", \\\"modelInvariantId\\\": \\\"93e16072-715a-42ef-9d0a-080052d6b716\\\", \\\"modelType\\\": \\\"vnf\\\", \\\"modelCustomizationId\\\": \\\"1779a999-ea17-4f31-98e9-75b6fbdd0acb\\\"}, \\\"cloudConfiguration\\\": {\\\"tenantId\\\": \\\"88a6ca3ee0394ade9403f075db23167e\\\", \\\"lcpCloudRegionId\\\": \\\"mdt1\\\"}}]}\"" + + " }," + + " {" + + " \"id\": 21," + + " \"name\": \"WorkflowName\"," + + " \"value\": \"Replace\"" + + " }," + + " {" + + " \"id\": 25," + + " \"name\": \"CallbackUrl\"," + + " \"value\": \"http://127.0.0.1:8900/scheduler/v1/loopbacktest/vid\"" + + " }" + + " ]," + + " \"scheduleApprovals\": []" + + " }," + + " \"schedulesId\": 0" + + " }" + + "]"; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/sdc/PresetSDCGetServiceMetadataGet.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/sdc/PresetSDCGetServiceMetadataGet.java index 9b1ea80af..00a47b7db 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/sdc/PresetSDCGetServiceMetadataGet.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/sdc/PresetSDCGetServiceMetadataGet.java @@ -1,12 +1,14 @@ package org.onap.simulator.presetGenerator.presets.sdc; import org.springframework.http.HttpMethod; +import vid.automation.test.infra.ModelInfo; -/** - * Created by itzikliderman on 21/12/2017. - */ public class PresetSDCGetServiceMetadataGet extends SdcPresetWithModelVersionId { + public PresetSDCGetServiceMetadataGet(ModelInfo modelInfo) { + this(modelInfo.modelVersionId, modelInfo.modelInvariantId, modelInfo.zipFileName); + } + public PresetSDCGetServiceMetadataGet(String modelVersionId, String modelInvariantId, String zipFileName) { super(modelVersionId); this.modelInvariantId = modelInvariantId; @@ -25,7 +27,7 @@ public class PresetSDCGetServiceMetadataGet extends SdcPresetWithModelVersionId " \"name\": \"action-data\"," + " \"version\": \"1.0\"," + " \"toscaModelURL\": \"./"+zipFileName+"\"," + - " \"category\": \"Mobility\"," + + " \"category\": \"Emanuel\"," + " \"lifecycleState\": \"CERTIFIED\"," + " \"lastUpdaterUserId\": \"rg276b\"," + " \"lastUpdaterFullName\": null," + diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/sdc/PresetSDCGetServiceToscaModelGet.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/sdc/PresetSDCGetServiceToscaModelGet.java index e243dc321..303f5a4e1 100644 --- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/sdc/PresetSDCGetServiceToscaModelGet.java +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/sdc/PresetSDCGetServiceToscaModelGet.java @@ -1,14 +1,16 @@ package org.onap.simulator.presetGenerator.presets.sdc; import org.springframework.http.HttpMethod; +import vid.automation.test.infra.ModelInfo; -/** - * Created by itzikliderman on 21/12/2017. - */ public class PresetSDCGetServiceToscaModelGet extends SdcPresetWithModelVersionId { private String file; + public PresetSDCGetServiceToscaModelGet(ModelInfo modelInfo) { + this(modelInfo.modelVersionId, modelInfo.zipFileName); + } + public PresetSDCGetServiceToscaModelGet(String modelVersionId, String file) { super(modelVersionId); this.file = file; diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/sdc/PresetSDCGetServiceToscaModelGetEmptyResult.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/sdc/PresetSDCGetServiceToscaModelGetEmptyResult.java new file mode 100644 index 000000000..f6f67136e --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/sdc/PresetSDCGetServiceToscaModelGetEmptyResult.java @@ -0,0 +1,24 @@ +package org.onap.simulator.presetGenerator.presets.sdc; + +import org.springframework.http.HttpMethod; + +public class PresetSDCGetServiceToscaModelGetEmptyResult extends SdcPresetWithModelVersionId { + + public PresetSDCGetServiceToscaModelGetEmptyResult(String modelVersionId) { + super(modelVersionId); + } + + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return super.getReqPath()+"/toscaModel"; + } + + @Override + public Object getResponseBody() { + return ""; + } +} diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/sdc/PresetSDCGetServiceToscaModelGetInvalidResponse.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/sdc/PresetSDCGetServiceToscaModelGetInvalidResponse.java new file mode 100644 index 000000000..7676062e5 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/sdc/PresetSDCGetServiceToscaModelGetInvalidResponse.java @@ -0,0 +1,32 @@ +package org.onap.simulator.presetGenerator.presets.sdc; + +import org.springframework.http.HttpMethod; + +public class PresetSDCGetServiceToscaModelGetInvalidResponse extends SdcPresetWithModelVersionId { + + private final int httpCode; + + public PresetSDCGetServiceToscaModelGetInvalidResponse(String modelVersionId, int httpCode) { + super(modelVersionId); + this.httpCode = httpCode; + } + + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return super.getReqPath()+"/toscaModel"; + } + + @Override + public Object getResponseBody() { + return "simulated error description from sdc"; + } + + @Override + public int getResponseCode() { + return httpCode; + } +} diff --git a/vid-automation/src/main/java/org/onap/vid/api/AsyncInstantiationBase.java b/vid-automation/src/main/java/org/onap/vid/api/AsyncInstantiationBase.java new file mode 100644 index 000000000..2a6b012fe --- /dev/null +++ b/vid-automation/src/main/java/org/onap/vid/api/AsyncInstantiationBase.java @@ -0,0 +1,573 @@ +package org.onap.vid.api; + +import static java.lang.Boolean.FALSE; +import static java.lang.Boolean.TRUE; +import static java.util.Collections.emptyList; +import static java.util.stream.Collectors.joining; +import static java.util.stream.Collectors.toMap; +import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; +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.utils.ExtendedHamcrestMatcher.hasItemsFromCollection; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.util.concurrent.Uninterruptibles; +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; +import org.apache.commons.lang3.StringUtils; +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.hamcrest.MatcherAssert; +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.ecompportal_att.PresetGetSessionSlotCheckIntervalGet; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateInstancePost; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseDelete; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2WithNames; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet; +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.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; +import org.testng.Assert; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import vid.automation.test.infra.Features; +import vid.automation.test.infra.Wait; +import vid.automation.test.model.JobStatus; +import vid.automation.test.model.ServiceAction; +import vid.automation.test.services.AsyncJobsService; +import vid.automation.test.services.SimulatorApi; + +public class AsyncInstantiationBase extends BaseMsoApiTest { + + public static final String CREATE_BULK_OF_ALACARTE_REQUEST_WITH_VNF = "asyncInstantiation/vidRequestCreateALaCarteWithVnf.json"; + protected static final String CREATE_BULK_OF_MACRO_REQUEST = "asyncInstantiation/vidRequestCreateBulkOfMacro.json"; + + protected 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 []."; + protected static final String MSO_ERROR = MSO_BASE_ERROR + StringUtils.repeat(" and a lot of sentences for long message", 60); + + @BeforeClass + protected void muteAndDropNameCounter() { + AsyncJobsService asyncJobsService = new AsyncJobsService(); + asyncJobsService.muteAllAsyncJobs(); + asyncJobsService.dropAllFromNameCounter(); + } + + @AfterMethod + protected void muteAllAsyncJobs() { + AsyncJobsService asyncJobsService = new AsyncJobsService(); + asyncJobsService.muteAllAsyncJobs(); + } + + @DataProvider + public static Object[][] trueAndFalse() { + return new Object[][]{{TRUE},{FALSE}}; + } + + protected String getCreateBulkUri() { + return uri.toASCIIString() + "/asyncInstantiation/bulk"; + } + + protected String getHideServiceUri(String jobId) { + return uri.toASCIIString() + "/asyncInstantiation/hide/"+jobId; + } + + protected String getServiceInfoUrl() { + return uri.toASCIIString() + "/asyncInstantiation"; + } + + protected String getJobAuditUrl() { + return uri.toASCIIString() + "/asyncInstantiation/auditStatus/{JOB_ID}?source={SOURCE}"; + } + + protected String getMsoJobAuditUrl() { + return uri.toASCIIString() + "/asyncInstantiation/auditStatus/{JOB_ID}/mso"; + } + + protected String getDeleteServiceUrl(String uuid) { + return uri.toASCIIString() + "/asyncInstantiation/job/" + uuid; + } + + protected String getInstanceAuditInfoUrl() { + return uri.toASCIIString() + "/asyncInstantiation/auditStatus/{TYPE}/{INSTANCE_ID}/mso"; + } + + protected String getRetryJobUrl() { + return uri.toASCIIString() + "/asyncInstantiation/retry/{JOB_ID}"; + } + protected String getTopologyForRetryUrl() { + return uri.toASCIIString() + "/asyncInstantiation/bulkForRetry/{JOB_ID}"; + } + + + protected String getRetryJobWithChangedDataUrl() { + return uri.toASCIIString() + "/asyncInstantiation/retryJobWithChangedData/{JOB_ID}"; + } + + protected boolean getExpectedRetryEnabled(JobStatus jobStatus) { + return Features.FLAG_1902_RETRY_JOB.isActive() && (jobStatus==JobStatus.FAILED || jobStatus==JobStatus.COMPLETED_WITH_ERRORS); + } + + public List<BasePreset> getPresets(List<PresetMSOBaseDelete> presetOnDeleteList, List<PresetMSOBaseCreateInstancePost> presetOnCreateList, List<PresetMSOOrchestrationRequestGet> presetInProgressList) { + + final ImmutableList.Builder<BasePreset> basePresetBuilder = new ImmutableList.Builder<>(); + basePresetBuilder + .add(new PresetGetSessionSlotCheckIntervalGet()) + .add(new PresetAAIGetSubscribersGet()) + .addAll(presetOnDeleteList) + .addAll(presetOnCreateList) + .addAll(presetInProgressList); + return basePresetBuilder.build(); + } + + public List<BasePreset> getDeletePresets(List<PresetMSOBaseDelete> presetOnDeleteList, List<PresetMSOOrchestrationRequestGet> presetInProgressList) { + return getPresets(presetOnDeleteList, emptyList(), presetInProgressList); + } + + public List<BasePreset> getPresets(List<PresetMSOBaseCreateInstancePost> presetOnCreateList, List<PresetMSOOrchestrationRequestGet> presetInProgressList) { + return getPresets(emptyList(), presetOnCreateList, presetInProgressList); + } + + public void assertServiceInfoSpecific1(String jobId, JobStatus jobStatus, String serviceInstanceName, String userName) { + assertServiceInfoSpecific1(jobId, jobStatus, serviceInstanceName, userName, null, ServiceAction.INSTANTIATE); + } + + public void assertServiceInfoSpecific1(String jobId, JobStatus jobStatus, String serviceInstanceName, String userName, String instanceId, ServiceAction action) { + assertExpectedStatusAndServiceInfo(jobStatus, jobId, new ServiceInfo( + userName, jobStatus, false, + "038d99af-0427-42c2-9d15-971b99b9b489", "Lucine Sarika", "zasaki", + "de738e5f-3704-4a14-b98f-3bf86ac0c0a0", "voloyakane-senamo", + "c85f0e80-0636-44a4-8cb2-4ec00d056e79", "Hedvika Wendelin", + "a93f8383-707e-43fa-8191-a6e69a1aab17", null, + "TYLER SILVIA", "SILVIA ROBBINS", + instanceId, serviceInstanceName, + "e3c34d88-a216-4f1d-a782-9af9f9588705", "gayawabawe", "5.1", + jobId, null, action, false) + ); + } + + public void assertServiceInfoSpecific1(String jobId, JobStatus jobStatus, String serviceInstanceName) { + assertServiceInfoSpecific1(jobId, jobStatus, serviceInstanceName, "us16807000"); + } + + protected void assertAuditStatuses(String jobId, List<JobAuditStatus> expectedVidStatuses, List<JobAuditStatus> expectedMsoStatuses) { + assertAuditStatuses(jobId, expectedVidStatuses, expectedMsoStatuses, 15); + } + + protected void assertAuditStatuses(String jobId, List<JobAuditStatus> expectedVidStatuses, List<JobAuditStatus> expectedMsoStatuses, long timeoutInSeconds) { + assertAndRetryIfNeeded(() -> { + final List<JobAuditStatus> auditVidStatuses = getAuditStatuses(jobId, JobAuditStatus.SourceStatus.VID.name()); + assertThat(auditVidStatuses, hasItemsFromCollection(expectedVidStatuses)); + if (expectedMsoStatuses!=null) { + final List<JobAuditStatus> auditMsoStatuses = getAuditStatuses(jobId, JobAuditStatus.SourceStatus.MSO.name()); + assertThat(auditMsoStatuses, containsInAnyOrder(expectedMsoStatuses.toArray())); + } + }, timeoutInSeconds); + } + + protected void assertAndRetryIfNeeded(Runnable asserter, long timeoutInSeconds) { + final Instant expiry = Instant.now().plusSeconds(timeoutInSeconds); + while (true) { + try { + asserter.run(); + break; // we're cool, assertion passed + } catch (AssertionError fail) { + Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS); + if (Instant.now().isAfter(expiry)) { + throw fail; + } else { + System.out.println("retrying after: " + fail); + } + } + } + } + + protected ImmutableList<JobAuditStatus> vidAuditStatusesCompletedWithErrors(String jobId) { + return ImmutableList.of( + vidAuditStatus(jobId, "PENDING", false), + vidAuditStatus(jobId, "IN_PROGRESS", false), + vidAuditStatus(jobId, "COMPLETED_WITH_ERRORS", true) + ); + } + + protected ImmutableList<JobAuditStatus> vidAuditStatusesFailed(String jobId) { + return ImmutableList.of( + vidAuditStatus(jobId, "PENDING", false), + vidAuditStatus(jobId, "IN_PROGRESS", false), + vidAuditStatus(jobId, "FAILED", true) + ); + } + + protected JobAuditStatus vidAuditStatus(String jobId, String jobStatus, boolean isFinal) { + return new JobAuditStatus(UUID.fromString(jobId), jobStatus, JobAuditStatus.SourceStatus.VID, null, null, isFinal); + } + + public static class JobIdAndStatusMatcher extends BaseMatcher<ServiceInfo> { + protected 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); + } + } + + + + protected Map<Keys,String> generateNames() { + return Stream.of(Keys.values()).collect( + Collectors.toMap(x->x, x -> UUID.randomUUID().toString().replace("-",""))); + } + + protected ImmutableList<BasePreset> addPresetsForCreateBulkOfCreateInstances(int bulkSize, Map<Keys, String> names){ + ImmutableList<BasePreset> msoBulkPresets = generateMsoCreateBulkPresets(bulkSize, names); + ImmutableList<BasePreset> presets = new ImmutableList.Builder<BasePreset>() + .add(new PresetGetSessionSlotCheckIntervalGet()) + .add(new PresetAAIGetSubscribersGet()) + .add(PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MTN3_TO_ATT_SABABA) + .addAll(msoBulkPresets) + .add(new PresetMSOOrchestrationRequestGet()) + .build(); + return presets; + + } + + protected ImmutableList<BasePreset> generateMsoCreateBulkPresets(int bulkSize, Map<Keys, String> names) { + return IntStream.rangeClosed(0, bulkSize-1). + mapToObj(i-> new PresetMSOCreateServiceInstanceGen2WithNames(names, i)) + .collect(ImmutableList.toImmutableList()); + } + + protected 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}}; + } + + + + protected List<String> createBulkAndWaitForBeCompleted(int bulkSize){ + Map<Keys, String> names = generateNames(); + ImmutableList<BasePreset> presets = addPresetsForCreateBulkOfCreateInstances(bulkSize, names); + final List<String> jobIds = createBulkOfMacroInstances(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; + } + + protected List<JobAuditStatus> getJobMsoAuditStatusForAlaCarte(String jobUUID, String requestId, String serviceInstanceId){ + String url = getMsoJobAuditUrl().replace("{JOB_ID}",jobUUID); + + if(!StringUtils.isEmpty(requestId)) { + url = url + "?requestId=" + requestId; + if(!StringUtils.isEmpty(serviceInstanceId)) { + url = url + "&serviceInstanceId=" + serviceInstanceId; + } + } + return callAuditStatus(url); + } + + protected List<JobAuditStatus> getAuditStatuses(String jobUUID, String source){ + String url = getJobAuditUrl().replace("{JOB_ID}",jobUUID).replace("{SOURCE}", source); + return callAuditStatus(url); + } + + protected List<JobAuditStatus> getAuditStatusesForInstance(String type, String instanceId){ + String url = getInstanceAuditInfoUrl().replace("{TYPE}",type).replace("{INSTANCE_ID}", instanceId); + return callAuditStatus(url); + } + + private List<JobAuditStatus> callAuditStatus(String url) { + ResponseEntity<List<JobAuditStatus>> statusesResponse = auditStatusCall(url); + assertThat(statusesResponse.getStatusCode(), CoreMatchers.equalTo(HttpStatus.OK)); + return statusesResponse.getBody(); + } + + protected Map<String, JobStatus> addBulkAllPendingButOneInProgress(){ + return addBulkAllPendingButOneInProgress(3); + } + + protected Map<String, JobStatus> addBulkAllPendingButOneInProgress(int bulkSize){ + Map<Keys, String> names = generateNames(); + ImmutableList<BasePreset> msoBulkPresets = generateMsoCreateBulkPresets(bulkSize, names); + ImmutableList<BasePreset> presets = new ImmutableList.Builder<BasePreset>() + .add(new PresetGetSessionSlotCheckIntervalGet()) + .add(new PresetAAIGetSubscribersGet()) + .add(PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MTN3_TO_ATT_SABABA) + .addAll(msoBulkPresets) + .add(new PresetMSOOrchestrationRequestGet("IN_PROGRESS")) + .build(); + final List<String> jobIds = createBulkOfMacroInstances(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; + } + + protected 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; + } + + + protected MsoResponseWrapper2 hideService(String jobId) { + MsoResponseWrapper2 responseWrapper2 = callMsoForResponseWrapper(org.springframework.http.HttpMethod.POST, getHideServiceUri(jobId), ""); + return responseWrapper2; + } + + protected List<String> createBulkOfInstancesAndAssert(ImmutableList<BasePreset> presets, boolean isPause, int bulkSize, JobStatus finalState, Map<Keys, String> names){ + List<String> jobIds = createBulkOfMacroInstances(presets, isPause, bulkSize, names); + Assert.assertEquals(jobIds.size(), bulkSize); + for(String jobId: jobIds) { + assertExpectedStatusAndServiceInfo(isPause, finalState, names, jobId); + } + + return jobIds; + } + + protected void assertExpectedStatusAndServiceInfo(boolean isPause, JobStatus finalState, Map<Keys, String> names, String jobId) { + assertExpectedStatusAndServiceInfo(finalState, jobId, new ServiceInfo("us16807000", JobStatus.IN_PROGRESS, isPause, "someID", + "someName", "myProject", "NFT1", "NFTJSSSS-NFT1", "greatTenant", "greatTenant", "hvf3", null, + "mySubType", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", null, names.get(Keys.SERVICE_NAME), + "5c9e863f-2716-467b-8799-4a67f378dcaa", "AIM_TRANSPORT_00004", "1.0", jobId, null, ServiceAction.INSTANTIATE, false)); + } + + protected void assertExpectedStatusAndServiceInfo(JobStatus finalState, String jobId, ServiceInfo expectedServiceInfo) { + assertExpectedStatusAndServiceInfo(finalState, jobId, false, expectedServiceInfo); + } + + protected void assertExpectedStatusAndServiceInfo(JobStatus finalState, String jobId, boolean longWait, ServiceInfo expectedServiceInfo) { + JobInfoChecker<Integer> 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==null) { + expectedServiceInfo.serviceInstanceId = BaseMSOPreset.DEFAULT_INSTANCE_ID; + } + result = Wait.waitFor(jobInfoChecker, null, 30, longWait ? 2 : 1); + assertTrue("service info of jobId: " + jobId + " was in status: " + jobInfoChecker.lastStatus, result); + } + + protected List<String> createBulkOfMacroInstances(ImmutableList<BasePreset> presets, boolean isPause, int bulkSize, Map<Keys, String> names) { + SimulatorApi.registerExpectationFromPresets(presets, SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET); + return createBulkOfInstances(isPause, bulkSize, names, CREATE_BULK_OF_MACRO_REQUEST); + } + + public List<String> createBulkOfInstances(boolean isPause, int bulkSize, Map<Keys, String> names, String requestDetailsFileName){ + + String requestBody = TestUtils.convertRequest(objectMapper, requestDetailsFileName); + 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(); + } + + protected List<String> retryJob(String jobId) { + ResponseEntity<String> retryBulkPayload = getRetryBulk(jobId); + return retryJobWithChangedData(jobId, retryBulkPayload.getBody()); + } + + protected List<String> retryJobWithChangedData(String jobId, String requestBody) { + String retryUri = getRetryJobWithChangedDataUrl(); + retryUri = retryUri.replace("{JOB_ID}", jobId); + MsoResponseWrapper2 responseWrapper2 = callMsoForResponseWrapper(HttpMethod.POST, retryUri, requestBody); + assertNotNull(responseWrapper2); + return (List<String>)responseWrapper2.getEntity(); + } + + protected ResponseEntity<String> getRetryBulk(String jobId) { + String retryUri = getTopologyForRetryUrl(); + retryUri = retryUri.replace("{JOB_ID}", jobId); + return restTemplateErrorAgnostic.getForEntity(retryUri, String.class); + } + + protected Object getResourceAuditInfo(String trackById) { + return restTemplate.getForObject(buildUri("/asyncInstantiation/auditStatusForRetry/{trackById}"), Object.class, trackById); + } + + public class JobInfoChecker<Integer> implements Predicate<Integer> { + + protected final RestTemplate restTemplate; + protected Set<JobStatus> expectedJobStatus; + protected ServiceInfo expectedServiceInfo; + protected final String jobId; + protected 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(expectedServiceInfo), serviceInfoDataReflected(serviceInfoFromDB)); + assertTrue("actual service instance doesn't contain template service name:" + expectedServiceInfo.serviceInstanceName, + serviceInfoFromDB.serviceInstanceName.contains(expectedServiceInfo.serviceInstanceName)); + + if (expectedServiceInfo.serviceInstanceId != null && ImmutableList.of(JobStatus.COMPLETED, JobStatus.PAUSE, JobStatus.COMPLETED_WITH_ERRORS).contains(serviceInfoFromDB.jobStatus)) { + MatcherAssert.assertThat("service instance id is wrong", serviceInfoFromDB.serviceInstanceId, CoreMatchers.is(expectedServiceInfo.serviceInstanceId)); + } + if (expectedJobStatus.size()==1) { + assertEquals("job status is wrong", getExpectedRetryEnabled((JobStatus)(expectedJobStatus.toArray()[0])), serviceInfoFromDB.isRetryEnabled); + } + lastStatus = serviceInfoFromDB.jobStatus; + return expectedJobStatus.contains(serviceInfoFromDB.jobStatus); + } + } + + protected 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 + protected static String serviceInfoDataReflected(ServiceInfo service1) { + return new ReflectionToStringBuilder(service1, ToStringStyle.SHORT_PREFIX_STYLE) + .setExcludeFieldNames("jobStatus", "templateId", "statusModifiedDate", "createdBulkDate", "serviceInstanceId", "serviceInstanceName", "isRetryEnabled") + .toString(); + } + + protected void addBulkPendingWithCustomList(List<BasePreset> customPresets){ + Map<Keys, String> names = generateNames(); + final int bulkSize = 2 + customPresets.size(); + + List<BasePreset> msoBulkPresets = generateMsoCreateBulkPresets(bulkSize, names); + ImmutableList<BasePreset> presets = new ImmutableList.Builder<BasePreset>() + .add(new PresetGetSessionSlotCheckIntervalGet()) + .add(new PresetAAIGetSubscribersGet()) + .addAll(msoBulkPresets) + .addAll(customPresets) + .build(); + + List<String> jobIds = createBulkOfMacroInstances(presets, false, bulkSize, names); + Assert.assertEquals(jobIds.size(),bulkSize); + } + + protected void verifyAuditStatuses(String jobId, List<String> statuses, JobAuditStatus.SourceStatus source) { + int statusesSize = statuses.size(); + AtomicReference<List<JobAuditStatus>> actualAudits = new AtomicReference<>(); + if (source.equals(JobAuditStatus.SourceStatus.VID)) { + actualAudits.set(getAuditStatuses(jobId, JobAuditStatus.SourceStatus.VID.name())); + org.junit.Assert.assertEquals("Received number of VID statuses is not as expected", statusesSize, actualAudits.get().size()); + } else { + boolean isStatusedSizeAsExpected = Wait.waitFor(x-> { + actualAudits.set(getAuditStatuses(jobId, JobAuditStatus.SourceStatus.MSO.name())); + return actualAudits.get().size() == statusesSize; + },null,5,1); + org.junit.Assert.assertTrue("Received number of MSO statuses is not as expected. Expected: " + statusesSize + ". Received: " + actualAudits.get().size(), isStatusedSizeAsExpected); + } + IntStream.range(0, statusesSize).forEach(i-> org.junit.Assert.assertEquals(source + " status #" + i + " is not as expected", statuses.get(i), actualAudits.get().get(i).getJobStatus())); + } + + protected void verifyInstanceAuditStatuses(List<JobAuditStatus> expectedStatuses, List<JobAuditStatus> actualStatuses) { + final int expectedSize = expectedStatuses.size(); + assertTrue("Expected statuses size is "+ expectedSize +", actual size is "+actualStatuses.size(), new Integer(expectedSize).equals(actualStatuses.size())); + IntStream.range(0, expectedSize).forEach(i-> { + + final JobAuditStatus expectedStatus = expectedStatuses.get(i); + final JobAuditStatus actualStatus = actualStatuses.get(i); + org.junit.Assert.assertEquals("MSO status #" + i + " is not as expected", expectedStatus.getJobStatus(), actualStatus.getJobStatus()); + org.junit.Assert.assertEquals("MSO requestId #" + i + " is not as expected", expectedStatus.getRequestId(), actualStatus.getRequestId()); + org.junit.Assert.assertEquals("MSO additionalInfo #" + i + " is not as expected", expectedStatus.getAdditionalInfo(), actualStatus.getAdditionalInfo()); + org.junit.Assert.assertEquals("MSO jobID #" + i + " is not as expected", expectedStatus.getJobId(), actualStatus.getJobId()); + org.junit.Assert.assertEquals("MSO instanceName #" + i + " is not as expected", expectedStatus.getInstanceName(), actualStatus.getInstanceName()); + org.junit.Assert.assertEquals("MSO instanceType #" + i + " is not as expected", expectedStatus.getInstanceType(), actualStatus.getInstanceType()); + }); + } +} diff --git a/vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java b/vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java new file mode 100644 index 000000000..5b7b1b214 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java @@ -0,0 +1,163 @@ +package org.onap.vid.api; + +import static java.util.Collections.singletonList; +import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals; +import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER; +import static org.apache.commons.text.StringEscapeUtils.unescapeJson; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.isEmptyOrNullString; +import static org.hamcrest.Matchers.not; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URL; +import java.util.List; +import java.util.Properties; +import java.util.Random; +import java.util.TimeZone; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import org.apache.commons.io.IOUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.glassfish.jersey.client.ClientProperties; +import org.glassfish.jersey.uri.internal.JerseyUriBuilder; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.springframework.http.client.ClientHttpRequestInterceptor; +import org.springframework.http.client.ClientHttpResponse; +import org.springframework.web.client.DefaultResponseErrorHandler; +import org.springframework.web.client.HttpStatusCodeException; +import org.springframework.web.client.RestTemplate; +import org.testng.annotations.BeforeClass; +import vid.automation.test.infra.FeaturesTogglingConfiguration; +import vid.automation.test.services.UsersService; +import vid.automation.test.utils.CookieAndJsonHttpHeadersInterceptor; + +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(SerializationFeature.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", "10.0.0.10"); + int port = Integer.valueOf(System.getProperty("VID_PORT", "8080")); + return new JerseyUriBuilder().host(host).port(port).scheme("http").path("vid").build(); + } + + public void login() { + login(getUserCredentials()); + } + + public void login(UserCredentials userCredentials) { + final List<ClientHttpRequestInterceptor> interceptors = singletonList(new CookieAndJsonHttpHeadersInterceptor(getUri(), userCredentials)); + restTemplate.setInterceptors(interceptors); + restTemplate.setErrorHandler(new DefaultResponseErrorHandler() { + @Override + public void handleError(ClientHttpResponse response) throws IOException { + try { + super.handleError(response); + } catch (HttpStatusCodeException e) { + LOGGER.error("HTTP {}: {}", e.getStatusCode(), e.getResponseBodyAsString(), e); + throw e; + } + } + }); + + restTemplateErrorAgnostic.setInterceptors(interceptors); + restTemplateErrorAgnostic.setErrorHandler(new DefaultResponseErrorHandler() { + @Override + public boolean hasError(ClientHttpResponse response) { + return false; + } + }); + } + + + //set time zone to UTC so clock will go closely with VID app + @BeforeClass + public void setDefaultTimeZoneToUTC() { + System.setProperty("user.timezone", "UTC"); + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); //since TimeZone cache previous user.timezone + } + + public 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); + } + + 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); + } + } + + protected void assertJsonEquals(String actual, String expected) { + LOGGER.info(actual); + assertThat(actual, not(isEmptyOrNullString())); + + assertThat(actual, jsonEquals(expected) + .when(IGNORING_ARRAY_ORDER) + ); + } + +} diff --git a/vid-automation/src/main/java/org/onap/vid/api/BaseMsoApiTest.java b/vid-automation/src/main/java/org/onap/vid/api/BaseMsoApiTest.java new file mode 100644 index 000000000..175638008 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/vid/api/BaseMsoApiTest.java @@ -0,0 +1,108 @@ +package org.onap.vid.api; + +import com.google.common.collect.ImmutableMap; +import org.json.JSONException; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset; +import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset; +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 java.util.List; + +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; + +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); + callMsoAndAssertError(targetUri, basicRequestBody, expectedErrorCode, expectedResult, method); + } + + protected void callMsoWithSimulatedErrorResponse(BaseMSOPreset expectation, String targetUri, String basicRequestBody, int expectedErrorCode, String expectedResult, HttpMethod method) throws IOException { + SimulatorApi.registerExpectationFromPreset(expectation, RegistrationStrategy.CLEAR_THEN_SET); + callMsoAndAssertError(targetUri, basicRequestBody, expectedErrorCode, expectedResult, method); + } + + protected void callMsoWithSimulatedErrorResponse(List<BasePreset> expectations, String targetUri, String basicRequestBody, int expectedErrorCode, String expectedResult, HttpMethod method) throws IOException { + SimulatorApi.registerExpectationFromPresets(expectations, RegistrationStrategy.CLEAR_THEN_SET); + callMsoAndAssertError(targetUri, basicRequestBody, expectedErrorCode, expectedResult, method); + } + + private void callMsoAndAssertError(String targetUri, String basicRequestBody, int expectedErrorCode, String expectedResult, HttpMethod method) throws IOException { + 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); + callMsoAndAssertSuccess(targetUri, requestBody, expectedStatusCode, expectedResult, method); + } + + protected void callMsoWithFineRequest(BaseMSOPreset expectation, String targetUri, String requestBody, int expectedStatusCode, String expectedResult, HttpMethod method) throws IOException { + SimulatorApi.registerExpectationFromPreset(expectation, RegistrationStrategy.CLEAR_THEN_SET); + callMsoAndAssertSuccess(targetUri, requestBody, expectedStatusCode, expectedResult, method); + } + + protected void callMsoWithFineRequest(List<BasePreset> expectations, String targetUri, String requestBody, int expectedStatusCode, String expectedResult, HttpMethod method) throws IOException { + SimulatorApi.registerExpectationFromPresets(expectations, RegistrationStrategy.CLEAR_THEN_SET); + callMsoAndAssertSuccess(targetUri, requestBody, expectedStatusCode, expectedResult, method); + } + + private void callMsoAndAssertSuccess(String targetUri, String requestBody, int expectedStatusCode, String expectedResult, HttpMethod method) throws IOException { + 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/main/java/org/onap/vid/api/CreateInstanceWithFailedService.java b/vid-automation/src/main/java/org/onap/vid/api/CreateInstanceWithFailedService.java new file mode 100644 index 000000000..6c8f3fade --- /dev/null +++ b/vid-automation/src/main/java/org/onap/vid/api/CreateInstanceWithFailedService.java @@ -0,0 +1,87 @@ +package org.onap.vid.api; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId; +import org.onap.simulator.presetGenerator.presets.mso.*; +import org.springframework.http.ResponseEntity; +import vid.automation.test.model.JobStatus; +import vid.automation.test.model.ServiceAction; +import vid.automation.test.services.SimulatorApi; + +import java.util.List; + +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.mso.PresetMSOServiceInstanceGen2WithNames.Keys.SERVICE_NAME; +import static org.onap.vid.api.AsyncInstantiationBase.CREATE_BULK_OF_ALACARTE_REQUEST_WITH_VNF; +import static org.onap.vid.api.TestUtils.hasOrLacksOfEntry; +import static vid.automation.test.services.SimulatorApi.registerExpectationFromPreset; +import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets; + +public class CreateInstanceWithFailedService { + private CreateServiceWithFailedVnf.ResourceIds firstIds = new CreateServiceWithFailedVnf.ResourceIds(); + private AsyncInstantiationBase asyncInstantiationBase; + private List<PresetMSOBaseCreateInstancePost> createPresets; + private String serviceInstanceName = TestUtils.generateRandomAlphaNumeric(10); + private ImmutableMap<PresetMSOServiceInstanceGen2WithNames.Keys, String> names; + private List<PresetMSOOrchestrationRequestGet> inProgressPresets; + private List<String> uuids; + private String originalJobId; + ObjectMapper objectMapper = new ObjectMapper(); + + + public CreateInstanceWithFailedService(AsyncInstantiationBase asyncInstantiationALaCarteApiTest) { + this.asyncInstantiationBase = asyncInstantiationALaCarteApiTest; + } + + private CreateInstanceWithFailedService createInstanceWithFailedService() { + + names = ImmutableMap.of(SERVICE_NAME, serviceInstanceName); + + final String serviceFailedStatusMessage = "The service instantiation is failed."; + createPresets = ImmutableList.of( + new PresetMSOCreateServiceInstanceGen2WithNamesAlacarteService(names, 0, firstIds.serviceReqId, firstIds.serviceId) + ); + inProgressPresets = ImmutableList.of( + new PresetMSOOrchestrationRequestGet("FAILED", firstIds.serviceReqId, serviceFailedStatusMessage) + ); + List<BasePreset> presets = asyncInstantiationBase.getPresets(createPresets, inProgressPresets); + + registerExpectationFromPresets(presets, SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET); + registerExpectationFromPreset(PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MDT1_TO_ATT_NC, SimulatorApi.RegistrationStrategy.APPEND); + + uuids = asyncInstantiationBase.createBulkOfInstances(false, 1, names, CREATE_BULK_OF_ALACARTE_REQUEST_WITH_VNF); + return this; + } + + protected void deployServiceFailedInstance() { + createInstanceWithFailedService(); + firstTimeAssertion(); + prepareAndAssertJsonFileForCypressTest(); + } + + private void prepareAndAssertJsonFileForCypressTest() { + final ResponseEntity<String> responseEntity = asyncInstantiationBase.getRetryBulk(originalJobId); + String expected = TestUtils.convertRequest(objectMapper, "asyncInstantiation/ServiceWithFailedServiceInstance.json"); + expected = expected + .replace("SERVICE_NAME", serviceInstanceName); + String originalResponse = responseEntity.getBody(); + String responseToCompare = originalResponse.replaceFirst("(instanceName\":\")(.*?)(\")", "$1INSTANCE_NAME$3").replaceAll("(trackById\":\")(.*?)(\")", "$1TRACK_BY_ID$3"); + asyncInstantiationBase.assertJsonEquals(responseToCompare, expected); + } + + private void firstTimeAssertion() { + assertThat(uuids, hasSize(1)); + originalJobId = uuids.get(0); + asyncInstantiationBase.assertServiceInfoSpecific1(originalJobId, JobStatus.FAILED, names.get(SERVICE_NAME), "us16807000", firstIds.serviceId, ServiceAction.INSTANTIATE); + asyncInstantiationBase.assertAuditStatuses(originalJobId, asyncInstantiationBase.vidAuditStatusesFailed(originalJobId), null); + assertThat(SimulatorApi.retrieveRecordedRequestsPathCounter(), allOf( + hasOrLacksOfEntry(createPresets.get(0).getReqPath(), 1L), + hasOrLacksOfEntry(inProgressPresets.get(0).getReqPath(), 1L) + )); + } +} diff --git a/vid-automation/src/main/java/org/onap/vid/api/CreateServiceWithFailedVnf.java b/vid-automation/src/main/java/org/onap/vid/api/CreateServiceWithFailedVnf.java new file mode 100644 index 000000000..30076a964 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/vid/api/CreateServiceWithFailedVnf.java @@ -0,0 +1,226 @@ +package org.onap.vid.api; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import org.hamcrest.Matchers; +import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId; +import org.onap.simulator.presetGenerator.presets.mso.*; +import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceMetadataGet; +import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGet; +import org.onap.vid.model.asyncInstantiation.ServiceInfo; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import vid.automation.test.infra.ModelInfo; +import vid.automation.test.model.JobStatus; +import vid.automation.test.model.ServiceAction; +import vid.automation.test.services.SimulatorApi; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.hamcrest.collection.IsCollectionWithSize.hasSize; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.SERVICE_NAME; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.VNF_NAME; +import static org.onap.vid.api.TestUtils.hasOrLacksOfEntry; +import static org.testng.Assert.assertTrue; +import static org.testng.AssertJUnit.assertFalse; +import static vid.automation.test.services.SimulatorApi.registerExpectationFromPreset; +import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets; + +//CreateServiceWithFailedVnf is common for API test and UI test, +//so if you change it, make sure both test are compatible with your changes +public class CreateServiceWithFailedVnf { + private AsyncInstantiationBase asyncInstantiationBase; + private ImmutableMap<PresetMSOServiceInstanceGen2WithNames.Keys, String> names; + private List<PresetMSOBaseCreateInstancePost> createPresets; + private List<PresetMSOOrchestrationRequestGet> inProgressPresets; + private List<String> uuids; + private List<String> retryUuids; + private String originalJobId; + private String serviceInstanceName = TestUtils.generateRandomAlphaNumeric(10); + private ResourceIds firstIds = new ResourceIds(); + private ResourceIds retryIds = new ResourceIds(); + private String vnfEditedName = TestUtils.generateRandomAlphaNumeric(10); + ObjectMapper objectMapper = new ObjectMapper(); + public final ModelInfo serviceComplexService = new ModelInfo("e3c34d88-a216-4f1d-a782-9af9f9588705", "0367689e-d41e-483f-b200-eab17e4a7f8d", "service-Complexservice-aLaCarte-csar-2.zip"); + + public CreateServiceWithFailedVnf(AsyncInstantiationBase asyncInstantiationALaCarteApiTest) { + this.asyncInstantiationBase = asyncInstantiationALaCarteApiTest; + } + + public ImmutableMap<PresetMSOServiceInstanceGen2WithNames.Keys, String> getNames() { + return names; + } + + public ResourceIds getFirstIds() { + return firstIds; + } + + public static class ResourceIds { + public String serviceId =UUID.randomUUID().toString(); + public String serviceReqId =UUID.randomUUID().toString(); + public String vnfId =UUID.randomUUID().toString(); + public String vnfReqId =UUID.randomUUID().toString(); + } + + + public CreateServiceWithFailedVnf createServicesWithVnfCompletedWithError() { +/* +Legit Preset || deploy 1 Service, 1 VNF which will fail + -> JobStatus of service is COMPLETED_WITH_ERRORS, audit + is adequate; strict simulator comapre + */ + + names = ImmutableMap.of(SERVICE_NAME, serviceInstanceName, VNF_NAME, serviceInstanceName+"_vnf"); + + + + final String vnfFailedStatusMessage = "Vnf failed."; + createPresets = ImmutableList.of( + new PresetMSOCreateServiceInstanceGen2WithNamesAlacarteService(names, 0, firstIds.serviceReqId, firstIds.serviceId), + new PresetMSOCreateVNFInstanceOnlyRelatedServiceInstance(names.get(VNF_NAME),firstIds.vnfReqId , firstIds.serviceId, firstIds.vnfId, 0) + ); + inProgressPresets = ImmutableList.of( + new PresetMSOOrchestrationRequestGet("COMPLETE", firstIds.serviceReqId), + new PresetMSOOrchestrationRequestGet("FAILED", firstIds.vnfReqId, vnfFailedStatusMessage) + ); + List<BasePreset> presets = asyncInstantiationBase.getPresets(createPresets, inProgressPresets); + + registerExpectationFromPresets(presets, SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET); + registerExpectationFromPreset(PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MDT1_TO_ATT_NC, SimulatorApi.RegistrationStrategy.APPEND); + + uuids = asyncInstantiationBase.createBulkOfInstances(false, 1, names, AsyncInstantiationBase.CREATE_BULK_OF_ALACARTE_REQUEST_WITH_VNF); + return this; + } + + public void firstTimeAssertion() { + assertThat(uuids, hasSize(1)); + originalJobId = uuids.get(0); + + asyncInstantiationBase.assertServiceInfoSpecific1(originalJobId, JobStatus.COMPLETED_WITH_ERRORS, names.get(SERVICE_NAME), "us16807000", firstIds.serviceId, ServiceAction.INSTANTIATE); + asyncInstantiationBase.assertAuditStatuses(originalJobId, asyncInstantiationBase.vidAuditStatusesCompletedWithErrors(originalJobId),null); + assertThat(SimulatorApi.retrieveRecordedRequestsPathCounter(), allOf( + hasOrLacksOfEntry(createPresets.get(0).getReqPath(), 1L), + hasOrLacksOfEntry(createPresets.get(1).getReqPath(), 1L), + hasOrLacksOfEntry(inProgressPresets.get(0).getReqPath(), 1L), + hasOrLacksOfEntry(inProgressPresets.get(1).getReqPath(), 1L) + )); + } + + public String getBulkForRetry(){ + final ResponseEntity<String> responseEntity= asyncInstantiationBase.getRetryBulk(originalJobId); + String expected = TestUtils.convertRequest(objectMapper, "asyncInstantiation/ServiceTreeForRetry_serviceInstance.json"); + expected = expected + .replace("SERVICE_NAME", serviceInstanceName); + String originalResponse = responseEntity.getBody(); + String responseToCompare = originalResponse.replaceFirst( "(instanceId\":\")(.*?)(\")", "$1INSTANCE_ID$3") + .replaceAll( "(trackById\":\")(.*?)(\")", "$1TRACK_BY_ID$3"); + asyncInstantiationBase.assertJsonEquals(responseToCompare, expected); + return originalResponse; + } + + public void getBulkForRetryNotFound() { + UUID jobId= UUID.randomUUID(); + final ResponseEntity<String> response = asyncInstantiationBase.getRetryBulk(jobId.toString()); + assertThat(response.getStatusCode(), is(HttpStatus.NOT_FOUND)); + assertThat(response.getBody(),containsString("Failed to retrieve class org.onap.vid.dao.JobRequest with JOB_ID "+jobId+" from table. no resource found")); + } + + private void secondRegistration(String vnfName) { + createPresets = ImmutableList.of( + new PresetMSOCreateVNFInstanceOnlyRelatedServiceInstance(vnfName, retryIds.vnfReqId, firstIds.serviceId, retryIds.vnfId, 0) + ); + inProgressPresets = ImmutableList.of( + new PresetMSOOrchestrationRequestGet("COMPLETE", retryIds.vnfReqId) + ); + + registerExpectationFromPresets(asyncInstantiationBase.getPresets(createPresets, inProgressPresets), SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET); + registerExpectationFromPresets(ImmutableList.of( + PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MDT1_TO_ATT_NC, + new PresetSDCGetServiceMetadataGet(serviceComplexService), + new PresetSDCGetServiceToscaModelGet(serviceComplexService)), + SimulatorApi.RegistrationStrategy.APPEND); + + + } + + public String deployService1FailedVnf(){ + createServicesWithVnfCompletedWithError(); + firstTimeAssertion(); + return getBulkForRetry(); + } + + public void assertResourceAuditStatus(String bulkForRetry) { + String vnfTrackById = extractVnfTrackById(bulkForRetry); + + Map<String, Object> auditStatus = (Map) asyncInstantiationBase.getResourceAuditInfo(vnfTrackById); + assertThat(auditStatus.get("jobStatus"), equalTo("FAILED")); + assertThat(auditStatus.get("additionalInfo"), equalTo("Vnf failed.")); + assertThat(auditStatus.get("requestId"), equalTo(firstIds.vnfReqId)); + } + + private String extractVnfTrackById(String bulk) { + Map<String, Object> serviceInstantiation = null; + try { + serviceInstantiation = objectMapper.readValue(bulk, new TypeReference<Map<String, Object>>(){}); + Map<String, Object> vnf = (Map) ((Map) serviceInstantiation.get("vnfs")).get("vSAMP12 1"); + return vnf.get("trackById").toString(); + } catch (IOException e) { + return null; + } + } + + + public void secondRegistration() { + secondRegistration(names.get(VNF_NAME)); + } + + public void retryJob() { + //retry the previous job + retryUuids = asyncInstantiationBase.retryJob(originalJobId); + } + + public void retryJobWithOtherDataAndAssert(String requestBody){ + retryUuids = asyncInstantiationBase.retryJobWithChangedData(originalJobId, requestBody); + retryAssertion(); + simulatorCallsAssertion(); + } + + public String changeSomeDataAndRegisterToSimulator(String payload){ + payload = payload.replace(names.get(VNF_NAME), vnfEditedName); + secondRegistration(vnfEditedName); + return payload; + } + + + public void retryAssertion() { + + assertThat(retryUuids, Matchers.hasSize(1)); + String retryJobId = retryUuids.get(0); + assertThat(retryJobId, not(equalTo(originalJobId))); + asyncInstantiationBase.assertServiceInfoSpecific1(retryJobId, JobStatus.COMPLETED, names.get(SERVICE_NAME), "us16807000", firstIds.serviceId, ServiceAction.UPDATE); + + //make sure original job is retry is disabled. + Optional<ServiceInfo> optionalServiceInfo = asyncInstantiationBase.serviceListCall().getBody().stream().filter(si -> originalJobId.equals(si.jobId)).findFirst(); + assertTrue(optionalServiceInfo.isPresent()); + assertFalse(optionalServiceInfo.get().isRetryEnabled); + } + + public void simulatorCallsAssertion() { + assertThat(SimulatorApi.retrieveRecordedRequestsPathCounter(), allOf( + hasOrLacksOfEntry(createPresets.get(0).getReqPath(), 1L), + hasOrLacksOfEntry(inProgressPresets.get(0).getReqPath(), 1L) + )); + } + + +} diff --git a/vid-automation/src/main/java/org/onap/vid/api/TestUtils.java b/vid-automation/src/main/java/org/onap/vid/api/TestUtils.java new file mode 100644 index 000000000..a2fe82e9d --- /dev/null +++ b/vid-automation/src/main/java/org/onap/vid/api/TestUtils.java @@ -0,0 +1,99 @@ +package org.onap.vid.api; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import org.apache.commons.text.RandomStringGenerator; +import org.hamcrest.Matcher; +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.IOException; +import java.io.InputStream; +import java.util.Map; +import java.util.Scanner; + +import static org.apache.commons.text.CharacterPredicates.DIGITS; +import static org.apache.commons.text.CharacterPredicates.LETTERS; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.*; +import static vid.automation.test.utils.RegExMatcher.matchesRegEx; + +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(SerializationFeature.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 = TestUtils.class.getClassLoader(); + ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(cl); + Resource[] resources; + try { + resources = resolver.getResources(msoRequestDetailsFileName); + //using InputStream and not file. see https://stackoverflow.com/questions/14876836/file-inside-jar-is-not-visible-for-spring/51131841#51131841 + InputStream inputStream = resources[0].getInputStream(); + String content = new Scanner(inputStream).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); + } + + static Matcher hasOrLacksOfEntry(String pathRegex, Long expectedCounter) { + return expectedCounter.equals(0L) ? not(hasKey(matchesRegEx(pathRegex))) : hasEntry(matchesRegEx(pathRegex), is(expectedCounter)); + } + + private static RandomStringGenerator generator = new RandomStringGenerator.Builder() + .withinRange('0', 'z') + .filteredBy(LETTERS, DIGITS) + .build(); + + public static String generateRandomAlphaNumeric(int length) { + return generator.generate(length); + } +} diff --git a/vid-automation/src/main/java/org/onap/vid/model/asyncInstantiation/JobAuditStatus.java b/vid-automation/src/main/java/org/onap/vid/model/asyncInstantiation/JobAuditStatus.java new file mode 100644 index 000000000..b012628e0 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/vid/model/asyncInstantiation/JobAuditStatus.java @@ -0,0 +1,141 @@ +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 JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source, UUID requestId, String additionalInfo, Boolean isFinal, String instanceName) { + this(jobId, jobStatus, source, requestId, additionalInfo, isFinal); + this.instanceName = instanceName; + } + + public JobAuditStatus(String instanceName, String jobStatus, UUID requestId, String additionalInfo, Boolean isFinal, String instanceType) { + this.instanceType = instanceType; + this.instanceName = instanceName; + this.jobStatus = jobStatus; + 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 String instanceName; + private String instanceType; + + public String getInstanceType() {return instanceType;} + + public void setInstanceType(String instanceType) {this.instanceType = instanceType; } + + 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 String getInstanceName() { + return instanceName; + } + + 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 + '\'' + + ", instanceName='" + instanceName + '\'' + + ", isFinal=" + isFinal + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + + if (!(o instanceof JobAuditStatus)) 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(instanceName, that.instanceName) + .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(instanceName) + .append(isFinal) + .toHashCode(); + } +} diff --git a/vid-automation/src/main/java/org/onap/vid/model/asyncInstantiation/ServiceInfo.java b/vid-automation/src/main/java/org/onap/vid/model/asyncInstantiation/ServiceInfo.java new file mode 100644 index 000000000..8f40fc098 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/vid/model/asyncInstantiation/ServiceInfo.java @@ -0,0 +1,80 @@ +package org.onap.vid.model.asyncInstantiation; + + +import vid.automation.test.model.JobStatus; +import vid.automation.test.model.ServiceAction; + +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 ServiceAction action; + public boolean isRetryEnabled; + + 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, ServiceAction action, boolean isRetryEnabled) { + 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; + this.action = action; + this.isRetryEnabled = isRetryEnabled; + } + + public JobStatus getJobStatus() { + return jobStatus; + } + + public String getServiceInstanceName() { + return serviceInstanceName; + } + + public String getJobId() { + return jobId; + } + +} diff --git a/vid-automation/src/main/java/org/onap/vid/model/mso/MsoResponseWrapper2.java b/vid-automation/src/main/java/org/onap/vid/model/mso/MsoResponseWrapper2.java new file mode 100644 index 000000000..40bf86b26 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/vid/model/mso/MsoResponseWrapper2.java @@ -0,0 +1,60 @@ +package org.onap.vid.model.mso; + +import com.fasterxml.jackson.annotation.JsonIgnore; +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 + @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/main/java/org/onap/vid/model/mso/MsoResponseWrapperInterface.java b/vid-automation/src/main/java/org/onap/vid/model/mso/MsoResponseWrapperInterface.java new file mode 100644 index 000000000..8a20ff187 --- /dev/null +++ b/vid-automation/src/main/java/org/onap/vid/model/mso/MsoResponseWrapperInterface.java @@ -0,0 +1,15 @@ +package org.onap.vid.model.mso; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +public interface MsoResponseWrapperInterface { + @JsonProperty("entity") + Object getEntity(); + + @JsonProperty("status") + int getStatus(); + + @JsonIgnore + String getResponse(); +} diff --git a/vid-automation/src/main/java/org/onap/vid/model/mso/RestObject.java b/vid-automation/src/main/java/org/onap/vid/model/mso/RestObject.java new file mode 100644 index 000000000..043766dac --- /dev/null +++ b/vid-automation/src/main/java/org/onap/vid/model/mso/RestObject.java @@ -0,0 +1,119 @@ +/*- + * ============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; + +/** + * The Class RestObject. + * + * @param <T> the generic type + */ +public class RestObject<T> { + + 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(); + } +} + |