diff options
Diffstat (limited to 'vid-automation/src/main/java')
264 files changed, 21299 insertions, 1970 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(); + } +} + diff --git a/vid-automation/src/main/java/vid/automation/test/Constants.java b/vid-automation/src/main/java/vid/automation/test/Constants.java index e10a9675b..3df26f6ab 100644 --- a/vid-automation/src/main/java/vid/automation/test/Constants.java +++ b/vid-automation/src/main/java/vid/automation/test/Constants.java @@ -27,6 +27,7 @@ public class Constants { public static final String DROPDOWN_PERMITTED_ASSERT_FAIL_MESSAGE = "Dropdown permitted options are not according to user permissions."; public static final String CONFIRM_BUTTON_TESTS_ID = "confirmButton"; public static final String CONFIRM_RESUME_DELETE_TESTS_ID = "confirmResumeDeleteButton"; + public static final String SOFT_DELETE_TESTS_ID = "softDeleteButton"; public static final String CLOSE_BUTTON_TEXT = "Close"; public static final String CANCEL_BUTTON_TEST_ID = "cancelButton"; public static final String COMMIT_CLOSE_BUTTON_ID = "msoCommitDialogCloseButton"; @@ -59,8 +60,10 @@ public class Constants { public static final String DELETE_CONFIGURATION_BUTTON = "deleteConfigurationButton"; public static final String ACTIVATE_DEACTIVATE_BUTTON = "activateDeactivateButton"; public static final String ENABLE_DISABLE_BUTTON = "enableDisableButton"; + public static final String SUBSCRIBER_SELECT_ID= "subscriber-name-select"; public static final String PNF_SERVICE_TYPE = "pnf"; + public static final String GR_API = "GR_API"; public class bugFixes{ public static final String HEADER_CONTAINER = "headerContainer"; @@ -96,11 +99,11 @@ public class Constants { public static final String newModalWorkFlowInputId = "workflow"; public static final String newModalConfigUpdateInputId = "config-update-input"; public static final String newModalTargetVersionInputsClass = "vnf-versions-select-as-text"; - public static final String newModalSubscriberText = "FIREWALL/MISC"; - public static final String newModalServiceTypeText = "vFlowLogic"; + public static final String newModalSubscriberText = "CRAIG/ROBERTS"; + public static final String newModalServiceTypeText = "vRichardson"; public static final String newModalVnfTypeText = "vMobileDNS"; public static final String newModalSourceVersionText = "1.0"; - public static final String newModalVnfNameText = "zrdm3amdns02test2"; + public static final String newModalVnfNameText = "zolson3amdns02test2"; public static final String newModalWorkflowText = "VNF Config Update"; @@ -168,11 +171,11 @@ public class Constants { public static final String AVAILABLE_MODELS_TREE = "available-models-tree"; public static final String DRAWING_BOARD_TREE = "drawing-board-tree"; public static final String NODE_PREFIX = "node-"; - public static final String SEARCH_LEFT_TREE = "search-left-tree"; + public static final String SEARCH_LEFT_TREE = "search-left-tree-input"; public static final String ADD_BUTTON = "-add-btn"; public static final String CONTEXT_MENU_BUTTON = "-menu-btn"; public static final String ALERT_ICON = "-alert-icon"; - public static final String CONTEXT_MENU_ITEM = "context-menu-item"; + public static final String CONTEXT_MENU_EDIT = "context-menu-edit"; public static final String TOGGLE_CHILDREN = "toggle-children"; public static final String TREE_NODE_LEAF = "tree-node-leaf"; public static final String HIGHLIGHTED_COLOR = "rgb(0, 159, 219)"; @@ -182,6 +185,8 @@ public class Constants { public static final String CONTEXT_MENU_HEADER_DELETE_ITEM = "context-menu-header-delete-item"; public static final String SERVICE_QUANTITY = "servicesQuantity"; public static final String BACK_BUTTON = "backBtn"; + public static final String STOP_INSTANTIATION_BUTTON = "button-stop-instantiation"; + public static final String CANCEL_BUTTON = "button-cancel"; public static final String DEPLOY_BUTTON = "deployBtn"; public static final String DEFAULT_SERVICE_NAME = "<Automatically Assigned>"; public static final String SERVICE_NAME = "serviceName"; @@ -190,16 +195,20 @@ public class Constants { public static final String SERVICE_INSTANCE_TEST_ID = "serviceInstance"; public static final String QUANTITY_LABEL_TEST_ID = "quantityLabel"; public static final String QUANTITY_LABEL_VALUE = "Scale Times:"; + public static final String CONTEXT_MENU_SHOW_AUDIT = "context-menu-showAuditInfo"; } public class InstantiationStatus { + public static final String CONTEXT_MENU_REMOVE = "context-menu-remove"; public static final String CONTEXT_MENU_DELETE = "context-menu-delete"; public static final String CONTEXT_MENU_HIDE = "context-menu-hide"; public static final String CONTEXT_MENU_HEADER_OPEN_ITEM = "context-menu-open"; + public static final String CONTEXT_MENU_RETRY = "context-menu-retry"; public static final String CONTEXT_MENU_HEADER_AUDIT_INFO_ITEM = "context-menu-audit-info"; + public static final String CONTEXT_MENU_DUPLICATE = "context-menu-duplicate"; public static final String TD_JOB_STATUS_ICON = "jobStatusIcon"; } @@ -270,7 +279,7 @@ public class Constants { public static final String CREATE_SERVICE_INSTANCE = "Create Service Instance"; public static final String AIC_OPTION_CLASS = "aicZoneOption"; public static class NewServicePopup { - public static final String SET_BUTTON = "service-form-set"; + public static final String SET_BUTTON = "form-set"; public static final String CANCEL_BUTTON = "cancelButton"; public static final String INSTANCE_NAME = "instanceName"; public static final String SERVICE_UUID = "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"; @@ -287,7 +296,7 @@ public class Constants { }}; } - public static final String CREATE_SERVICE_INSTANCE_MACRO_MODAL = "create a new service instance"; + public static final String CREATE_SERVICE_INSTANCE_MACRO_MODAL = "Set a new service instance"; } @@ -366,6 +375,7 @@ public class Constants { public static final String DELETE_VF_MODULE_BUTTON_TEST_ID = "deleteVFModuleButton-"; public static final String DELETE_VNF_VOLUME_GROUP_BUTTON_TEST_ID = "deleteVNFVolumeGroupButton"; public static final String ACTIVATE_BUTTON_TEST_ID = "activateButton"; + public static final String ACTIVATE_FABRIC_CONFIGURATION_BUTTON_TEST_ID = "activateFabricConfigurationButton"; public static final String SHOW_ASSIGNMENTS_BUTTON_TEST_ID = "showAssignmentsButton"; public static final String OPTION_IN_DROPDOWN_NOT_EXISTS = "the option %s in dropdown %s not exists"; public static final String DISSOCIATE_BTN_CLASS = "dissociate-pnf"; @@ -445,6 +455,7 @@ public class Constants { public static final String INFO_TEST_ID_PREFIX = "info-test-data-id-"; public static final String SERVIICE_NAME_KEY = "ServiceName"; public static final String ROLLBACK_ON_FAILURE_ID = "rollbackOnFailure"; + public static final String ROLLBACK_ON_FAILURE_TEST_ID = "rollback"; public static final String SUBSCRIBER_NAME_KEY = "SubscriberName"; public static final String SERVICE_INSTANCE_NAME = "ServiceInstanceName"; public static final String MODEL_NAME = "ModelName"; @@ -491,10 +502,10 @@ public class Constants { public class Users { public static final String READONLY = "readonly"; - public static final String USP_VOICE_VIRTUAL_USP = "uspVoiceVirtualUsp"; - public static final String MOBILITY_MOBILITY = "mobilityMobility"; - public static final String FIREWALL_MISC_AIM_TRANSPORT = "FIREWALL_AIM_Trans"; - public static final String MOBILITY_VMMSC = "mobilityVMMSC"; + public static final String SILVIA_ROBBINS_TYLER_SILVIA = "uspVoiceVirtualUsp"; + public static final String EMANUEL_EMANUEL = "emanuelEmanuel"; + public static final String CRAIG_ROBERTS_AIM_TRANSPORT = "FIREWALL_AIM_Trans"; + public static final String EMANUEL_vWINIFRED = "emanuelvWINIFRED"; public static final String SUPRE_USER = "su"; } @@ -502,18 +513,17 @@ public class Constants { //separated simulated json files according to pages public class SearchForServiceInstance { - public static final String GET_FULL_SUBSCRIBERS = "search_for_service_instance/aai_get_full_subscribers.json"; public static final String GET_SERVICES = "search_for_service_instance/aai_get_services.json"; public static final String FILTER_SERVICE_INSTANCE_BY_ID = "search_for_service_instance/aai_filter_service_instance_by_id.json"; public static final String FILTER_CR_SERVICE_INSTANCE_BY_ID = "search_for_service_instance/aai_filter_cr_service_instance_by_id.json"; public static final String FILTER_SERVICE_INSTANCE_BY_ID_2 = "search_for_service_instance/aai_filter_service_instance_by_id_2.json"; public static final String FILTER_SERVICE_INSTANCE_BY_ID_PM = "search_for_service_instance/aai_filter_service_instance_by_id_test_sssdad.json"; public static final String FILTER_SERVICE_INSTANCE_BY_ID_NO_MODEL_VER_ID = "search_for_service_instance/aai_filter_service_instance_by_id_test_without_model_ver_id.json"; - public static final String GET_SUBSCRIBERS_FOR_CUSTOMER_USP_VOICE = "search_for_service_instance/aai_get_subscribers_for_customer_USP-VOICE.json"; - public static final String GET_SUBSCRIBERS_FOR_CUSTOMER_USP_VOICE_CR = "search_for_service_instance/aai_get_subscribers_for_customer_USP-VOICE_cr.json"; + public static final String GET_SUBSCRIBERS_FOR_CUSTOMER_SILVIA_ROBBINS = "search_for_service_instance/aai_get_subscribers_for_customer_SILVIA-ROBBINS.json"; + public static final String GET_SUBSCRIBERS_FOR_CUSTOMER_SILVIA_ROBBINS_CR = "search_for_service_instance/aai_get_subscribers_for_customer_SILVIA-ROBBINS_cr.json"; public static final String GET_MSO_INSTANCE_ORCH_STATUS_REQ = "search_for_service_instance/mso_instance_orch_status_req.json"; - public static final String GET_SUBSCRIBERS_FOR_CUSTOMER_Mobility = "search_for_service_instance/aai_get_subscribers_for_customer_Mobility.json"; - public static final String GET_SUBSCRIBERS_FOR_CUSTOMER_FIREWALL_MISC = "search_for_service_instance/aai_get_subscribers_for_customer_FIREWALL-MISC.json"; + public static final String GET_SUBSCRIBERS_FOR_CUSTOMER_Emanuel = "search_for_service_instance/aai_get_subscribers_for_customer_Emanuel.json"; + public static final String GET_SUBSCRIBERS_FOR_CUSTOMER_CRAIG_ROBERTS = "search_for_service_instance/aai_get_subscribers_for_customer_CRAIG-ROBERTS.json"; public static final String NAMED_QUERY_VIEW_EDIT = "search_for_service_instance/aai_named_query_for_view_edit.json"; public static final String NAMED_QUERY_CR_VIEW_EDIT = "search_for_service_instance/aai_named_query_for_cr_view_edit.json"; public static final String NAMED_QUERY_VIEW_EDIT_2 = "search_for_service_instance/aai_named_query_for_view_edit_2.json"; @@ -525,7 +535,7 @@ public class Constants { public class AddSubinterface { public static final String FILTER_VFC_IG_SERVICE_INSTANCE_BY_ID = "add_subinterface/aai_filter_vfc_ig_service_instance_by_id.json"; - public static final String GET_SUBSCRIBERS_FOR_CUSTOMER_USP_VOICE_VFC_IG = "add_subinterface/aai_get_subscribers_for_customer_USP-VOICE_vfc_ig.json"; + public static final String GET_SUBSCRIBERS_FOR_CUSTOMER_SILVIA_ROBBINS_VFC_IG = "add_subinterface/aai_get_subscribers_for_customer_SILVIA-ROBBINS_vfc_ig.json"; public static final String GET_MSO_VFC_IG_INSTANCE_ORCH_STATUS_REQ = "add_subinterface/mso_vfc_ig_instance_orch_status_req.json"; public static final String NAMED_QUERY_VFC_IG_VIEW_EDIT = "add_subinterface/aai_named_query_for_vfc_ig_view_edit.json"; public static final String GET_SDC_CATALOG_SERVICE_VID_TEST_444 = "add_subinterface/get_sdc_catalog_services_vid-test-333.json"; @@ -555,16 +565,6 @@ public class Constants { public static final String GET_PNF_INSTANCES = "create_configuration/aai_get_pnf_instances_by_region.json"; public static final String GET_MODEL_BY_ONE_INVARIANT_ID = "create_configuration/aai_get_model_by_one_invariant_id.json"; public static final String GET_MODEL_BY_2_INVARIANT_IDS = "create_configuration/aai_get_model_by_2_invariant_ids.json"; - public static final String MSO_CREATE_CONFIGURATION = "create_configuration/mso_create_configuration_pProbe.json"; - public static final String MSO_CREATE_CONFIGURATION_ORCH_REQ = "create_configuration/mso_create_configuration_orch_req.json"; - public static final String MSO_CREATE_CONFIGURATION_ERROR = "create_configuration/mso_create_configuration_pProbe_error.json"; - public static final String MSO_UNASSIGN_ACTIVE_SERVICE = "mso_unassign_service.json"; - public static final String MSO_DELETE_CONFIGURATION = "create_configuration/mso_delete_configuration.json"; - public static final String MSO_ACTIVATE_CONFIGURATION = "create_configuration/mso_activate_configuration.json"; - public static final String MSO_ENABLE_DISABLE_PORT = "create_configuration/mso_enable_disable_port.json"; - - - public static final String MSO_DEACTIVATE_CONFIGURATION = "create_configuration/mso_activate_configuration.json"; } public class addNetwork{ @@ -574,17 +574,14 @@ public class Constants { public static final String AAI_NAMED_QUERY_FOR_VIEW_EDIT ="add_network/aai_named_query_for_view_edit_test_network-vl.json"; public static final String AAI_GET_TENANTS = "add_network/aai_get_tenants.json"; public static final String MSO_ADD_NETWORK_ERROR = "add_network/mso_add_network_error.json"; - public static final String MSO_ADD_NETWORK = "add_network/mso_add_network.json"; - public static final String MSO_ADD_NETWORK_ORCH_REQ = "add_network/mso_add_network_orch_req.json"; } public class CreateNewServiceInstance { - public static final String GET_FULL_SUBSCRIBES = "create_new_instance/aai_get_full_subscribers.json"; public static final String GET_SERVICES = "create_new_instance/aai_get_services.json"; - public static final String GET_SUBSCRIBERS_FOR_CUSTOMER_MSO_1610_ST = "create_new_instance/aai_get_subscribers_for_customer_MSO_1610_ST.json"; - public static final String GET_MODELS_BY_SERVICE_TYPE_MSO_1610_ST = "create_new_instance/aai_get_models_by_service_type_MSO_1610_ST.json"; - public static final String GET_SUBSCRIBERS_FOR_CUSTOMER_USP_VOICE = "create_new_instance/aai_get_subscribers_for_customer_USP_VOICE.json"; - public static final String GET_MODELS_BY_SERVICE_TYPE_USP_VOICE= "create_new_instance/aai_get_models_by_service_type_USP_VOICE.json"; + public static final String GET_SUBSCRIBERS_FOR_CUSTOMER_CAR_2020_ER = "create_new_instance/aai_get_subscribers_for_customer_CAR_2020_ER.json"; + public static final String GET_MODELS_BY_SERVICE_TYPE_CAR_2020_ER = "create_new_instance/aai_get_models_by_service_type_CAR_2020_ER.json"; + public static final String GET_SUBSCRIBERS_FOR_CUSTOMER_SILVIA_ROBBINS = "create_new_instance/aai_get_subscribers_for_customer_SILVIA_ROBBINS.json"; + public static final String GET_MODELS_BY_SERVICE_TYPE_SILVIA_ROBBINS= "create_new_instance/aai_get_models_by_service_type_SILVIA_ROBBINS.json"; public class deploy { public static final String SDC_GET_CATALOG = "create_new_instance/deploy/get_sdc_catalog_services_1707vidnf.json"; diff --git a/vid-automation/src/main/java/vid/automation/test/infra/Click.java b/vid-automation/src/main/java/vid/automation/test/infra/Click.java index 8c6bf4831..0b5f40b84 100644 --- a/vid-automation/src/main/java/vid/automation/test/infra/Click.java +++ b/vid-automation/src/main/java/vid/automation/test/infra/Click.java @@ -1,10 +1,8 @@ package vid.automation.test.infra; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.Alert; -import org.openqa.selenium.By; -import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.Select; @@ -12,38 +10,40 @@ import org.openqa.selenium.support.ui.WebDriverWait; import java.util.List; +import static org.onap.sdc.ci.tests.utilities.GeneralUIUtils.getDriver; + public class Click { public static void byText(String text) { WebElement element = GeneralUIUtils.findByText(text); Assert.assertTrue(element != null); - element.click(); + clickWhenClickable(element); } public static void byId(String id) { WebElement element = Get.byId(id); Assert.assertTrue(element != null); - element.click(); + clickWhenClickable(element); } public static void byTestId(String testId) { WebElement element = Get.byTestId(testId); Assert.assertTrue(element != null); - element.click(); + clickWhenClickable(element); } public static void byClass(String className) { List<WebElement> elements = Get.byClass(className); Assert.assertTrue(elements != null && elements.size() > 0); - elements.get(0).click(); + clickWhenClickable(elements.get(0)); } public static void byXpath(String xpath) { WebElement element = Get.byXpath(xpath); Assert.assertNotNull(element); - element.click(); + clickWhenClickable(element); } @@ -73,7 +73,7 @@ public class Click { public static void byClassAndVisibleText(String className, String text ) { WebElement element = Get.byClassAndText(className, text); - element.click(); + clickWhenClickable(element); } @@ -83,4 +83,11 @@ public class Click { Assert.assertTrue(alert != null); alert.accept(); } + + private static void clickWhenClickable(WebElement element) { + new WebDriverWait(getDriver(), 1) + .until(ExpectedConditions.elementToBeClickable(element)) + .click(); + } + } diff --git a/vid-automation/src/main/java/vid/automation/test/infra/Features.java b/vid-automation/src/main/java/vid/automation/test/infra/Features.java index 37698fe36..cd632ff12 100644 --- a/vid-automation/src/main/java/vid/automation/test/infra/Features.java +++ b/vid-automation/src/main/java/vid/automation/test/infra/Features.java @@ -7,7 +7,6 @@ public enum Features implements Feature { CREATE_INSTANCE_TEST, EMPTY_DRAWING_BOARD_TEST, - FLAG_REGION_ID_FROM_REMOTE, FLAG_ASYNC_JOBS, FLAG_ADD_MSO_TESTAPI_FIELD, FLAG_ASYNC_INSTANTIATION, @@ -16,8 +15,32 @@ public enum Features implements Feature { FLAG_NETWORK_TO_ASYNC_INSTANTIATION, FLAG_COLLECTION_RESOURCE_SUPPORT, FLAG_SHOW_ASSIGNMENTS, + FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS, FLAG_SHOW_VERIFY_SERVICE, - FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD; + FLAG_DUPLICATE_VNF, + FLAG_DEFAULT_VNF, + FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD, + FLAG_RESTRICTED_SELECT, + FLAG_5G_IN_NEW_INSTANTIATION_UI, + FLAG_ASYNC_ALACARTE_VNF, + FLAG_A_LA_CARTE_AUDIT_INFO, + FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS, + FLAG_ASYNC_ALACARTE_VFMODULE, + FLAG_SUPPLEMENTARY_FILE, + FLAG_SHIFT_VFMODULE_PARAMS_TO_VNF, + FLAG_EXP_ANY_ALACARTE_NEW_INSTANTIATION_UI, + FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY, + FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST, + FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE, + FLAG_1810_IDENTIFY_SERVICE_FOR_NEW_UI, + FLAG_1902_NEW_VIEW_EDIT, + FLAG_EXP_USE_DEFAULT_HOST_NAME_VERIFIER, + FLAG_1902_VNF_GROUPING, + FLAG_1902_RETRY_JOB, + FLAG_VF_MODULE_RESUME_STATUS_CREATE, + FLAG_EXP_CREATE_RESOURCES_IN_PARALLEL, + FLAG_1906_INSTANTIATION_API_USER_VALIDATION, + ; public boolean isActive() { return FeatureContext.getFeatureManager().isActive(this); diff --git a/vid-automation/src/main/java/vid/automation/test/infra/Get.java b/vid-automation/src/main/java/vid/automation/test/infra/Get.java index fc1d06070..9bcad7b64 100644 --- a/vid-automation/src/main/java/vid/automation/test/infra/Get.java +++ b/vid-automation/src/main/java/vid/automation/test/infra/Get.java @@ -1,7 +1,7 @@ package vid.automation.test.infra; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.*; import org.openqa.selenium.support.ui.WebDriverWait; @@ -20,7 +20,7 @@ public class Get { public static WebElement byTestId(String dataTestId) { try { - return GeneralUIUtils.getDriver().findElement(By.xpath("//*[@data-tests-id='" + dataTestId + "']")); + return GeneralUIUtils.getDriver().findElement(getXpathForDataTestId(dataTestId)); } catch (Exception var2) { return null; } @@ -34,6 +34,14 @@ public class Get { } } + public static WebElement byXpath(WebElement context, String xpath) { + try { + return context.findElement(By.xpath(xpath)); + } catch (Exception var2) { + return null; + } + } + public static WebElement byXpath(String xpath, int timeout) { try { return GeneralUIUtils.getWebElementBy(By.xpath(xpath), timeout); @@ -152,4 +160,16 @@ public class Get { } }; } + + public static List<WebElement> listByTestId(String dataTestId) { + try { + return GeneralUIUtils.getDriver().findElements(getXpathForDataTestId(dataTestId)); + } catch (Exception var2) { + return null; + } + } + + public static By getXpathForDataTestId(String dataTestId) { + return By.xpath("//*[@data-tests-id='" + dataTestId + "']"); + } } diff --git a/vid-automation/src/main/java/vid/automation/test/infra/Input.java b/vid-automation/src/main/java/vid/automation/test/infra/Input.java index 896ceae56..b937a9d42 100644 --- a/vid-automation/src/main/java/vid/automation/test/infra/Input.java +++ b/vid-automation/src/main/java/vid/automation/test/infra/Input.java @@ -1,6 +1,6 @@ package vid.automation.test.infra; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; import vid.automation.test.utils.ReadFile; diff --git a/vid-automation/src/main/java/vid/automation/test/infra/ModelInfo.java b/vid-automation/src/main/java/vid/automation/test/infra/ModelInfo.java new file mode 100644 index 000000000..1284a8b42 --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/infra/ModelInfo.java @@ -0,0 +1,81 @@ +package vid.automation.test.infra; + +import com.google.common.collect.ImmutableList; + +public class ModelInfo { + public final String modelVersionId; //aka model uuid + public final String modelInvariantId; + public final String zipFileName; + + public static class ModelInfoWithMultipleVersions { + public final String modelInvariantId; + public final String modelVersionId1; + public final String modelVersionId2; + public final String modelVersionId3; + public final String modelName; + + + ModelInfoWithMultipleVersions(String modelInvariantId, String modelVersionId1, String modelVersionId2, String modelVersionId3, String modelName) { + this.modelInvariantId = modelInvariantId; + this.modelVersionId1 = modelVersionId1; + this.modelVersionId2 = modelVersionId2; + this.modelVersionId3 = modelVersionId3; + this.modelName = modelName; + } + + public static final ModelInfoWithMultipleVersions modelInfoWithMultipleVersions = new ModelInfoWithMultipleVersions( + "5d353b28-e5b7-419b-98e8-cad5d258be13", + "5e7970bc-a292-4955-8a1b-8a44f586f527", + "04743c62-ab58-41a0-bc53-1052ef1c094a", + "d2415de6-dde3-4737-b9b0-4f9fa02fab68", + "serviceWithGreatNameForMultiple"); + } + + public ModelInfo(String modelVersionId, String modelInvariantId, String zipFileName) { + this.modelVersionId = modelVersionId; + this.modelInvariantId = modelInvariantId; + this.zipFileName = zipFileName; + } + + public ModelInfo(String modelVersionId, String modelInvariantId) { + this(modelVersionId, modelInvariantId, "fakeCsarName.zip"); + } + + public static final ModelInfo macroForBrowseSdc = new ModelInfo("4d71990b-d8ad-4510-ac61-496288d9078e","d27e42cf-087e-4d31-88ac-6c4b7585f800"); + public static final ModelInfo aLaCarteForBrowseSdc = new ModelInfo("4d71990b-d8ad-4510-ac61-496288d9078e","a8dcd72d-d44d-44f2-aa85-53aa9ca99cba"); + public static final ModelInfo serviceWithOneVersion = new ModelInfo("16a3133f-cd29-44df-aa3c-79a75e40802a", "a313c1fb-b8ce-4e5f-abfa-ad6611203350"); + + public static final ModelInfo instantiationTypeAlacarte_vidNotionsInstantiationUIByUUID = new ModelInfo ("95eb2c44-bff2-4e8b-ad5d-8266870b7717", "31a229a2-71d0-48e1-9003-850c2696d6d4", "csar15782222_instantiationTypeAlacarte_vidNotionsInstantiationUIByUUID.zip"); + public static final ModelInfo macroSriovWithDynamicFieldsEcompNamingTruePartialModelDetails = new ModelInfo ("2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd", "45aee87d-883b-4644-9006-e0ca48d33cbf", "csar-withDynamicFields-ecompNamingTrue-partialModelDetails.zip"); + public static final ModelInfo macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails = new ModelInfo ("1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd", "cdb90b57-ed78-4d44-a5b4-7f43a02ec632", "csar-noDynamicFields-ecompNamingFalse-fullModelDetails-1a80c596.zip"); + public static final ModelInfo macroSriovWithDynamicFieldsEcompNamingFalsePartialModelDetailsVnfEcompNamingFalse = new ModelInfo("6b528779-44a3-4472-bdff-9cd15ec93450", "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0" , "csar-withDynamicFields-ecompNamingFalse-partialModelDetails-vnfEcompNamingFalse.zip"); + public static final ModelInfo macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetailsVnfEcompNamingFalse = new ModelInfo("4a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd", "4140a873-00bb-4f57-ac46-0494cc9e674a", "csar-noDynamicFields-ecompNamingFalse-fullModelDetails-1a80c596-vnfEcompNamingFalse.zip"); + public static final ModelInfo aLaCarteNetworkProvider5G = new ModelInfo("4659e8bd-0920-4eed-8ec5-550b4c8dceeb", "16e56d12-40b3-4db1-a40e-d48c36679e2e", "service-SrIovProvider1-csar.zip"); + public static final ModelInfo PASQUALEVmxVpeBvService488Annotations = new ModelInfo("f4d84bb4-a416-4b4e-997e-0059973630b9", "598e3f9e-3244-4d8f-a8e0-0e5d7a29eda9", "service-PASQUALEVmxVpeBvService488-csar-annotations.zip"); + public static final ModelInfo macroDrawingBoardComplexService = new ModelInfo("6e59c5de-f052-46fa-aa7e-2fca9d674c44","cfef8302-d90f-475f-87cc-3f49a62ef14c", "service-Complexservice-csar.zip" ); + public static final ModelInfo aLaCarteServiceCreationTest = new ModelInfo("f913c5d0-206e-45c2-9284-1c68f4e67dc7", "45e61192-876c-4e28-9139-5a0c47410379", "serviceCreationTest.zip"); + public static final ModelInfo aLaCarteVnfGroupingService = new ModelInfo("4117a0b6-e234-467d-b5b9-fe2f68c8b0fc", "7ee41ce4-4827-44b0-a48e-2707a59905d2", "csar15782222_instantiationTypeAlacarte_VnfGrouping.zip"); + public static final ModelInfo serviceFabricSriovService = new ModelInfo("253f1467-fe68-4e80-ba71-308000caec31", "c15fe228-7d40-4f99-afa7-10abeedf9aac", "service-fabric-SriovService-csar.zip"); + + public static final ImmutableList<ModelInfo> superSetOfModelInfos = buildModelInfos(); + + public static ImmutableList<ModelInfo> buildModelInfos() { + return new ImmutableList.Builder<ModelInfo>() + .add(macroForBrowseSdc) + .add(aLaCarteForBrowseSdc) + .add(serviceWithOneVersion) + .add(instantiationTypeAlacarte_vidNotionsInstantiationUIByUUID) + .add(macroSriovWithDynamicFieldsEcompNamingTruePartialModelDetails) + .add(macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails) + .add(macroSriovWithDynamicFieldsEcompNamingFalsePartialModelDetailsVnfEcompNamingFalse) + .add(macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetailsVnfEcompNamingFalse) + .add(aLaCarteNetworkProvider5G) + .add(PASQUALEVmxVpeBvService488Annotations) + .add(macroDrawingBoardComplexService) + .add(aLaCarteServiceCreationTest) + .add(aLaCarteVnfGroupingService) + .build(); + } +} + + diff --git a/vid-automation/src/main/java/vid/automation/test/infra/SelectOption.java b/vid-automation/src/main/java/vid/automation/test/infra/SelectOption.java index dc792cfc3..cd766c5bf 100644 --- a/vid-automation/src/main/java/vid/automation/test/infra/SelectOption.java +++ b/vid-automation/src/main/java/vid/automation/test/infra/SelectOption.java @@ -1,11 +1,14 @@ package vid.automation.test.infra; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import com.google.common.collect.ImmutableList; +import org.apache.commons.lang3.ObjectUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.Select; import vid.automation.test.Constants; import java.util.List; +import java.util.concurrent.TimeUnit; /** * Created by itzikliderman on 18/07/2017. @@ -56,6 +59,13 @@ public class SelectOption { } + public static void waitForOptionInSelect(String option, String selectTestId) { + Wait.waitFor(foo -> + ObjectUtils.defaultIfNull(SelectOption.getList(selectTestId), ImmutableList.<WebElement>of()) + .stream().map(o -> o.getText()).filter(o -> option.equals(o)).findAny().isPresent(), + "", 10, 200, TimeUnit.MILLISECONDS); + } + public static void selectOptionsFromMultiselectById(String multiSelectId, List<String> options) { Click.byId(multiSelectId); try { diff --git a/vid-automation/src/main/java/vid/automation/test/infra/Wait.java b/vid-automation/src/main/java/vid/automation/test/infra/Wait.java index 848107c83..cab3a2d5b 100644 --- a/vid-automation/src/main/java/vid/automation/test/infra/Wait.java +++ b/vid-automation/src/main/java/vid/automation/test/infra/Wait.java @@ -1,7 +1,7 @@ package vid.automation.test.infra; import org.apache.commons.collections.CollectionUtils; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.NoSuchElementException; import vid.automation.test.Constants; @@ -58,6 +58,10 @@ public class Wait { return waitFor((x->Get.byTestId(dataTestId)!=null),null, timeoutInSeconds, 1); } + public static boolean waitByIdAndText(String id, String text, int timeoutInSeconds) { + return waitFor((x->Get.byId(id).getText().equals(text)),null, timeoutInSeconds, 1); + } + public static void angularHttpRequestsLoaded() { JavascriptExecutor js = (JavascriptExecutor) GeneralUIUtils.getDriver(); for (int i=0; i<Constants.generalRetries; i++) { diff --git a/vid-automation/src/main/java/vid/automation/test/model/Credentials.java b/vid-automation/src/main/java/vid/automation/test/model/Credentials.java index 0dc26aefd..46d44b296 100644 --- a/vid-automation/src/main/java/vid/automation/test/model/Credentials.java +++ b/vid-automation/src/main/java/vid/automation/test/model/Credentials.java @@ -1,8 +1,5 @@ package vid.automation.test.model; -/** - * Created by itzikliderman on 26/06/2017. - */ public class Credentials { public String userId; public String password; diff --git a/vid-automation/src/main/java/vid/automation/test/model/JobBulk.java b/vid-automation/src/main/java/vid/automation/test/model/JobBulk.java deleted file mode 100644 index 80d4109a6..000000000 --- a/vid-automation/src/main/java/vid/automation/test/model/JobBulk.java +++ /dev/null @@ -1,23 +0,0 @@ -package vid.automation.test.model; - -import java.util.List; - -public class JobBulk { - - private List<JobModel> jobs; - - public JobBulk() { - } - - public JobBulk(List<JobModel> jobs) { - this.jobs = jobs; - } - - public List<JobModel> getJobs() { - return jobs; - } - - public void setJobs(List<JobModel> jobs) { - this.jobs = jobs; - } -} diff --git a/vid-automation/src/main/java/vid/automation/test/model/JobStatus.java b/vid-automation/src/main/java/vid/automation/test/model/JobStatus.java index 0e92a1f35..a51336ec6 100644 --- a/vid-automation/src/main/java/vid/automation/test/model/JobStatus.java +++ b/vid-automation/src/main/java/vid/automation/test/model/JobStatus.java @@ -2,9 +2,11 @@ package vid.automation.test.model; public enum JobStatus { COMPLETED, + COMPLETED_WITH_NO_ACTION, FAILED, IN_PROGRESS, PAUSE, PENDING, - STOPPED; + STOPPED, + COMPLETED_WITH_ERRORS; } diff --git a/vid-automation/src/main/java/vid/automation/test/model/Service.java b/vid-automation/src/main/java/vid/automation/test/model/Service.java index 4ed51eeb1..4aa4a7f9e 100644 --- a/vid-automation/src/main/java/vid/automation/test/model/Service.java +++ b/vid-automation/src/main/java/vid/automation/test/model/Service.java @@ -1,5 +1,7 @@ package vid.automation.test.model; +import com.google.common.base.MoreObjects; + /** * Created by itzikliderman on 19/06/2017. */ @@ -33,4 +35,18 @@ public class Service { this.description = description; this.serviceRole = serviceRole; } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("type", type) + .add("uuid", uuid) + .add("invariantUuid", invariantUuid) + .add("name", name) + .add("version", version) + .add("category", category) + .add("description", description) + .add("serviceRole", serviceRole) + .toString(); + } } diff --git a/vid-automation/src/main/java/vid/automation/test/model/ServiceAction.java b/vid-automation/src/main/java/vid/automation/test/model/ServiceAction.java new file mode 100644 index 000000000..a155c6c72 --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/model/ServiceAction.java @@ -0,0 +1,7 @@ +package vid.automation.test.model; + +public enum ServiceAction { + INSTANTIATE, + DELETE, + UPDATE +}
\ No newline at end of file diff --git a/vid-automation/src/main/java/vid/automation/test/sections/BrowseASDCPage.java b/vid-automation/src/main/java/vid/automation/test/sections/BrowseASDCPage.java index 53a67821d..febbe6e83 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/BrowseASDCPage.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/BrowseASDCPage.java @@ -1,7 +1,7 @@ package vid.automation.test.sections; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; import vid.automation.test.Constants; import vid.automation.test.infra.Get; diff --git a/vid-automation/src/main/java/vid/automation/test/sections/ChangeManagementPage.java b/vid-automation/src/main/java/vid/automation/test/sections/ChangeManagementPage.java index ca0b55b36..953219547 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/ChangeManagementPage.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/ChangeManagementPage.java @@ -1,6 +1,6 @@ package vid.automation.test.sections; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import vid.automation.test.Constants; import vid.automation.test.infra.Click; diff --git a/vid-automation/src/main/java/vid/automation/test/sections/CreateConfigurationPage.java b/vid-automation/src/main/java/vid/automation/test/sections/CreateConfigurationPage.java index bb68d9b9e..4b837a0ac 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/CreateConfigurationPage.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/CreateConfigurationPage.java @@ -1,7 +1,7 @@ package vid.automation.test.sections; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; import vid.automation.test.Constants; import vid.automation.test.infra.SelectOption; diff --git a/vid-automation/src/main/java/vid/automation/test/sections/CreateNewInstancePage.java b/vid-automation/src/main/java/vid/automation/test/sections/CreateNewInstancePage.java index d63b8a191..68e673b68 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/CreateNewInstancePage.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/CreateNewInstancePage.java @@ -1,6 +1,6 @@ package vid.automation.test.sections; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import vid.automation.test.Constants; import vid.automation.test.model.Service; diff --git a/vid-automation/src/main/java/vid/automation/test/sections/DeployMacroDialog.java b/vid-automation/src/main/java/vid/automation/test/sections/DeployMacroDialog.java index ae7573333..e7288ea79 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/DeployMacroDialog.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/DeployMacroDialog.java @@ -1,6 +1,6 @@ package vid.automation.test.sections; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; import vid.automation.test.Constants; @@ -13,7 +13,7 @@ public class DeployMacroDialog extends DeployMacroDialogBase { public void assertTitle(){ WebElement modalTitle = GeneralUIUtils.getWebElementByTestID(Constants.CREATE_MODAL_TITLE_ID, 30); - assertThat(modalTitle.getText().toLowerCase(), containsString(dialogTitle)); + assertThat(modalTitle.getText(), containsString(dialogTitle)); } @Override public void closeDialog(){ diff --git a/vid-automation/src/main/java/vid/automation/test/sections/DeployMacroDialogOld.java b/vid-automation/src/main/java/vid/automation/test/sections/DeployMacroDialogOld.java index 032852099..e0e391b4d 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/DeployMacroDialogOld.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/DeployMacroDialogOld.java @@ -1,7 +1,7 @@ package vid.automation.test.sections; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; import vid.automation.test.Constants; diff --git a/vid-automation/src/main/java/vid/automation/test/sections/DrawingBoardPage.java b/vid-automation/src/main/java/vid/automation/test/sections/DrawingBoardPage.java index 7cffd37b9..acbb4d991 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/DrawingBoardPage.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/DrawingBoardPage.java @@ -1,7 +1,8 @@ package vid.automation.test.sections; import com.google.common.collect.ImmutableList; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import com.google.common.collect.Sets; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.NoSuchElementException; @@ -12,9 +13,9 @@ import vid.automation.test.infra.Click; import vid.automation.test.infra.Get; import vid.automation.test.infra.Wait; -import java.util.Collection; -import java.util.Map; +import java.util.*; import java.util.function.Function; +import java.util.function.Predicate; import java.util.stream.Collectors; import static org.hamcrest.CoreMatchers.equalTo; @@ -189,7 +190,7 @@ public class DrawingBoardPage extends VidBasePage { public void checkContextMenu(String node){ String contextMenuButton = Constants.DrawingBoard.NODE_PREFIX + node + Constants.DrawingBoard.CONTEXT_MENU_BUTTON; - final String contextMenu = Constants.DrawingBoard.CONTEXT_MENU_ITEM; + final String contextMenu = Constants.DrawingBoard.CONTEXT_MENU_EDIT; checkThatPseudoElementNotExist(contextMenuButton); checkThatContextMenuNotExist(contextMenu); @@ -254,4 +255,33 @@ public class DrawingBoardPage extends VidBasePage { Assert.assertEquals(Get.byTestId(SERVICE_QUANTITY).getText(), (String.valueOf(expectedQuantity))); } + public static class ServiceStatusChecker implements Predicate<Boolean> { + private String actualInstanceName; + private Set<String> expectedStatuses; + private Set<String> columnClassesSet; + + public ServiceStatusChecker(String actualInstanceName, Set<String> expectedStatuses) { + this.actualInstanceName = actualInstanceName; + this.expectedStatuses = expectedStatuses; + } + + @Override + public boolean test(Boolean noMeaning) { + InstantiationStatusPage.clickRefreshButton(); + final WebElement row = InstantiationStatusPage.getInstantiationStatusRow(actualInstanceName); + if (row == null) { + System.err.println("**********************" + actualInstanceName + "************************************************"); + columnClassesSet = Collections.singleton(actualInstanceName + " NOT FOUND"); + return false; // treat missing row as if test condition not fulfilled + } else { + columnClassesSet = new HashSet<>(Arrays.asList( + row.findElements(By.xpath(".//*[@id='" + "jobStatus" + "']")).get(0).getAttribute("class").split(" "))); + return !(Sets.intersection(expectedStatuses, columnClassesSet).isEmpty()); + } + } + + public Set<String> getColumnClassesSet() { + return columnClassesSet; + } + } } diff --git a/vid-automation/src/main/java/vid/automation/test/sections/InstantiationStatusPage.java b/vid-automation/src/main/java/vid/automation/test/sections/InstantiationStatusPage.java index e5dd1bb39..1bb095fda 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/InstantiationStatusPage.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/InstantiationStatusPage.java @@ -1,22 +1,36 @@ package vid.automation.test.sections; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.apache.http.NameValuePair; +import org.apache.http.client.utils.URLEncodedUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; +import vid.automation.test.Constants; +import vid.automation.test.infra.Click; import vid.automation.test.infra.Get; +import vid.automation.test.infra.Wait; +import java.nio.charset.Charset; +import java.util.List; import java.util.Map; +import java.util.function.Consumer; import java.util.stream.Collectors; +import static java.util.stream.Collectors.toMap; +import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.testng.Assert.assertEquals; public abstract class InstantiationStatusPage extends VidBasePage { public static final String refreshButtonId = "refresh-btn"; + private static final String NEW_VIEW_EDIT_RELATIVE_URL = "serviceModels.htm#/servicePlanning"; + + public static String getWebTrTdSpanElementByParentID(WebElement tr, String id, int timeout) { return tr.findElements(By.xpath(".//*[@id='" + id + "']//span")).get(0).getText(); } @@ -55,5 +69,78 @@ public abstract class InstantiationStatusPage extends VidBasePage { GeneralUIUtils.ultimateWait(); } + public static void checkMenuItem(String actualInstanceName, String contextMenuItem, boolean shouldBeEnabled, Consumer<String> doIfEnabled) { + Wait.waitFor(name -> { + if (null == getInstantiationStatusRow(name)) { + clickRefreshButton(); + return false; + } else { + return true; + } + }, actualInstanceName, 8, 1); + final WebElement row = getInstantiationStatusRow(actualInstanceName); + row.findElement(By.className("menu-div")).click(); + String clazz = Get.byXpath("//div[@data-tests-id='" + contextMenuItem + "']/ancestor::li").getAttribute("class"); + assertThat("item " + contextMenuItem + " of " + actualInstanceName + + " should be " + (shouldBeEnabled ? "enabled" : "disabled"), !clazz.equals("disabled"), is(shouldBeEnabled)); + if (shouldBeEnabled) { + doIfEnabled.accept(contextMenuItem); + } else { + // dismiss menu + Get.byTestId("instantiation-status-title").click(); + } + } + public void showTooltipByHoverAboveStatusIcon(String elementTestId){ + WebElement selectedElement = GeneralUIUtils.getWebElementByTestID(elementTestId, 30); + } + + public static void openDrawingBoardForRetry(String serviceInstanceName) { + InstantiationStatusPage.checkMenuItem(serviceInstanceName, Constants.InstantiationStatus.CONTEXT_MENU_RETRY, true, contextMenuRetry -> { + Click.byTestId(contextMenuRetry); + VidBasePage.goOutFromIframe(); + verifyUrlPrefixMatchNewViewEdit("RETRY_EDIT"); + }); + } + + public static void verifyOpenNewViewEdit(String serviceInstanceName, String serviceInstanceId, String serviceModelId, String serviceType, String subscriberId, String mode) { + InstantiationStatusPage.checkMenuItem(serviceInstanceName, Constants.InstantiationStatus.CONTEXT_MENU_HEADER_OPEN_ITEM, true, contextMenuOpen -> { + Click.byTestId(contextMenuOpen); + VidBasePage.goOutFromIframe(); + verifyUrlMatchNewViewEdit(serviceInstanceId, serviceModelId, serviceType, subscriberId, mode); + SideMenu.navigateToMacroInstantiationStatus(); + }); + } + + public static void verifyOpenNewViewEdit(String serviceInstanceName, boolean openShouldBeEnabled, String expectedMode) { + InstantiationStatusPage.checkMenuItem(serviceInstanceName, Constants.InstantiationStatus.CONTEXT_MENU_HEADER_OPEN_ITEM, openShouldBeEnabled, contextMenuOpen -> { + Click.byTestId(contextMenuOpen); + VidBasePage.goOutFromIframe(); + verifyUrlPrefixMatchNewViewEdit(expectedMode); + SideMenu.navigateToMacroInstantiationStatus(); + }); + } + + public static void verifyUrlMatchNewViewEdit(String serviceInstanceId, String serviceModelId, String serviceType, String subscriberId, String expectedMode) { + verifyUrlPrefixMatchNewViewEdit(expectedMode); + Map<String, String> paramsMap = extractQueryParamsFromCurrentURL(NEW_VIEW_EDIT_RELATIVE_URL + "/" + expectedMode + "?"); + //assertEquals(paramsMap.get("mode"), expectedMode); + assertEquals(paramsMap.get("serviceInstanceId"), serviceInstanceId); + assertEquals(paramsMap.get("serviceModelId"), serviceModelId); + assertEquals(paramsMap.get("serviceType"), serviceType); + assertEquals(paramsMap.get("subscriberId"), subscriberId); + } + + protected static Map<String, String> extractQueryParamsFromCurrentURL(String relativePath) { + String currentUrl = GeneralUIUtils.getDriver().getCurrentUrl(); + //unfortunately parse(final URI uri, final String charset) can't handle with the #/ part of the uri + String urlSuffix = currentUrl.substring(currentUrl.indexOf(relativePath)+relativePath.length()); + List<NameValuePair> params = URLEncodedUtils.parse(urlSuffix, Charset.forName("UTF-8")); + return params.stream().collect(toMap(NameValuePair::getName, NameValuePair::getValue)); + } + + public static void verifyUrlPrefixMatchNewViewEdit(String expectedMode) { + String currentUrl = GeneralUIUtils.getDriver().getCurrentUrl(); + assertThat(currentUrl, containsString(NEW_VIEW_EDIT_RELATIVE_URL + "/" + expectedMode)); + } } diff --git a/vid-automation/src/main/java/vid/automation/test/sections/LoginExternalPage.java b/vid-automation/src/main/java/vid/automation/test/sections/LoginExternalPage.java index c1053d2a5..7a13e4d1b 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/LoginExternalPage.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/LoginExternalPage.java @@ -1,7 +1,7 @@ package vid.automation.test.sections; -import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import static org.junit.Assert.*; diff --git a/vid-automation/src/main/java/vid/automation/test/sections/PnfSearchAssociationPage.java b/vid-automation/src/main/java/vid/automation/test/sections/PnfSearchAssociationPage.java index 3f8061a78..2efb9f3c8 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/PnfSearchAssociationPage.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/PnfSearchAssociationPage.java @@ -1,7 +1,7 @@ package vid.automation.test.sections; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; import vid.automation.test.Constants; diff --git a/vid-automation/src/main/java/vid/automation/test/sections/PreviousVersionDialog.java b/vid-automation/src/main/java/vid/automation/test/sections/PreviousVersionDialog.java index d5f39d959..cfbf025a6 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/PreviousVersionDialog.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/PreviousVersionDialog.java @@ -1,7 +1,7 @@ package vid.automation.test.sections; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebElement; import vid.automation.test.infra.Get; diff --git a/vid-automation/src/main/java/vid/automation/test/sections/SearchExistingPage.java b/vid-automation/src/main/java/vid/automation/test/sections/SearchExistingPage.java index edfcd0e56..aa9675b76 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/SearchExistingPage.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/SearchExistingPage.java @@ -1,7 +1,7 @@ package vid.automation.test.sections; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; import vid.automation.test.Constants; import vid.automation.test.infra.Click; diff --git a/vid-automation/src/main/java/vid/automation/test/sections/ServiceProxyPage.java b/vid-automation/src/main/java/vid/automation/test/sections/ServiceProxyPage.java index a47870290..82f45ce7f 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/ServiceProxyPage.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/ServiceProxyPage.java @@ -1,7 +1,7 @@ package vid.automation.test.sections; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; import vid.automation.test.Constants; import vid.automation.test.infra.SelectOption; @@ -24,6 +24,11 @@ public class ServiceProxyPage extends VidBasePage { GeneralUIUtils.ultimateWait(); return this; } + public void assertCollectorServiceType(String collectorServiceType) { + String displayedCollectorServiceType = SelectOption.getSelectedOption("collectorServiceType"); + Assert.assertEquals("The displayed collector service type is incorrect", collectorServiceType, displayedCollectorServiceType); + } + public ServiceProxyPage chooseCollector(String collector){ GeneralUIUtils.ultimateWait(); SelectOption.byTestIdAndVisibleText(collector, Constants.ConfigurationCreation.COLLECTOR_DROPDOWN_TEST_ID); diff --git a/vid-automation/src/main/java/vid/automation/test/sections/SideMenu.java b/vid-automation/src/main/java/vid/automation/test/sections/SideMenu.java index 0ba49f2d8..dc3de78dd 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/SideMenu.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/SideMenu.java @@ -1,12 +1,16 @@ package vid.automation.test.sections; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.ElementClickInterceptedException; import org.openqa.selenium.UnhandledAlertException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import vid.automation.test.Constants; public class SideMenu { + static final Logger logger = LoggerFactory.getLogger(SideMenu.class); + public static void navigateToBrowseASDCPage() { navigateToPage(Constants.SideMenu.BROWSE_ASDC_SERVICE_MODELS); } @@ -24,7 +28,7 @@ public class SideMenu { } public static void navigateToMacroInstantiationStatus() { - navigateToPage("Macro Instantiation Status"); + navigateToPage("Instantiation Status"); new VidBasePage().goToIframe(); } @@ -47,6 +51,7 @@ public class SideMenu { } }); GeneralUIUtils.ultimateWait(); + logger.info("navigated to {}", PageName); } public static void navigateToWelcomePage() { diff --git a/vid-automation/src/main/java/vid/automation/test/sections/TestEnvironmentPage.java b/vid-automation/src/main/java/vid/automation/test/sections/TestEnvironmentPage.java index f63906323..71c6e0bd4 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/TestEnvironmentPage.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/TestEnvironmentPage.java @@ -1,6 +1,6 @@ package vid.automation.test.sections; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.testng.Assert; diff --git a/vid-automation/src/main/java/vid/automation/test/sections/VidBasePage.java b/vid-automation/src/main/java/vid/automation/test/sections/VidBasePage.java index 69aee494a..f749df02b 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/VidBasePage.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/VidBasePage.java @@ -1,17 +1,10 @@ package vid.automation.test.sections; -import com.aventstack.extentreports.Status; -import org.junit.Assert; -import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; -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; -import vid.automation.test.Constants; -import vid.automation.test.infra.*; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.onap.sdc.ci.tests.utilities.GeneralUIUtils.getDriver; +import com.aventstack.extentreports.Status; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @@ -20,11 +13,25 @@ import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.function.Function; - -import static org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils.getDriver; +import org.junit.Assert; +import org.onap.sdc.ci.tests.execute.setup.ExtentTestActions; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; +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; +import vid.automation.test.Constants; +import vid.automation.test.infra.Click; +import vid.automation.test.infra.Exists; +import vid.automation.test.infra.Get; +import vid.automation.test.infra.Input; +import vid.automation.test.infra.SelectOption; +import vid.automation.test.infra.Wait; public class VidBasePage { + public VidBasePage setInstanceName(String name) { setInputText(Constants.INSTANCE_NAME_SELECT_TESTS_ID, name); return this; @@ -97,6 +104,7 @@ public class VidBasePage { public VidBasePage clickDeployServiceButtonByServiceUUID(String serviceUUID) { Input.replaceText(serviceUUID, Constants.BROWSE_SEARCH); + GeneralUIUtils.ultimateWait(); String elementTestId = Constants.DEPLOY_BUTTON_TESTS_ID_PREFIX + serviceUUID; GeneralUIUtils.clickOnElementByTestId(elementTestId, 30); GeneralUIUtils.ultimateWait(); @@ -158,6 +166,11 @@ public class VidBasePage { return this; } + public VidBasePage clickButtonByTestId(String testId) { + GeneralUIUtils.clickOnElementByTestId(testId); + return this; + } + public VidBasePage clickCommitCloseButton() { GeneralUIUtils.clickOnElementByTestId(Constants.COMMIT_CLOSE_BUTTON_ID, 30); return this; @@ -174,11 +187,13 @@ public class VidBasePage { public VidBasePage selectLcpRegion(String lcpRegion) { + GeneralUIUtils.ultimateWait(); SelectOption.byValue(lcpRegion, Constants.ViewEdit.LCP_REGION_SELECT_TESTS_ID); return this; } public VidBasePage selectTenant(String tenant) { + GeneralUIUtils.ultimateWait(); SelectOption.byValue(tenant, Constants.ViewEdit.TENANT_SELECT_TESTS_ID); return this; } @@ -263,12 +278,12 @@ public class VidBasePage { Assert.assertEquals(expectedText, alertText); Click.acceptAlert(); } - public void goToIframe() { + public static void goToIframe() { final long start = System.currentTimeMillis(); goOutFromIframe(); GeneralUIUtils.ultimateWait(); System.out.println("ultimateWait waited " + (System.currentTimeMillis() - start)); - final WebDriver iframeReady = new WebDriverWait(getDriver(), 10).until( + final WebDriver iframeReady = new WebDriverWait(getDriver(), 20).until( ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.tagName("iframe")) ); Assert.assertNotNull("failed going into iframe", iframeReady); @@ -278,12 +293,41 @@ public class VidBasePage { System.out.println("ultimateWait waited " + (System.currentTimeMillis() - start2)); } - public void goOutFromIframe(){ + public static void goOutFromIframe(){ getDriver().switchTo().defaultContent(); } + public void verifyOpenOldViewEdit(String serviceInstanceName, String serviceInstanceId, boolean openShouldBeEnabled, boolean checkPortMirroring, boolean checkAddVnf) { + InstantiationStatusPage.checkMenuItem(serviceInstanceName, Constants.InstantiationStatus.CONTEXT_MENU_HEADER_OPEN_ITEM, openShouldBeEnabled, contextMenuOpen -> { + Click.byTestId(contextMenuOpen); + VidBasePage.goOutFromIframe(); + GeneralUIUtils.ultimateWait(); + Wait.byText("View/Edit Service Instance"); + if (serviceInstanceId != null) { + Wait.byText(serviceInstanceId); + } + Wait.byText(serviceInstanceName); + + if (checkPortMirroring) { + Wait.byText("Add node instance"); + Wait.byText("i'm a port"); + } + + if (checkAddVnf) { + // Validate bug fix - we open old popup in view/edit + Click.byTestId("addVNFButton"); + Click.byTestId("addVNFOption-2017-488_PASQUALE-vPE 0"); + assertThat(Get.byTestId("create-modal-title").getText(), containsString("a la carte")); + Click.byTestId("cancelButton"); + //end of bug fix validation + } + + screenshotDeployDialog("view-edit-" + serviceInstanceName); + SideMenu.navigateToMacroInstantiationStatus(); + }); + } public static WebDriverWait waitUntilDriverIsReady(int time) { diff --git a/vid-automation/src/main/java/vid/automation/test/sections/ViewEditPage.java b/vid-automation/src/main/java/vid/automation/test/sections/ViewEditPage.java index 633feb83d..e10c872ee 100644 --- a/vid-automation/src/main/java/vid/automation/test/sections/ViewEditPage.java +++ b/vid-automation/src/main/java/vid/automation/test/sections/ViewEditPage.java @@ -1,19 +1,16 @@ package vid.automation.test.sections; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import vid.automation.test.Constants; +import vid.automation.test.infra.Features; import vid.automation.test.infra.Get; import vid.automation.test.infra.SelectOption; -import vid.automation.test.infra.Wait; -import org.hamcrest.core.Is; import static org.hamcrest.core.Is.is; -import java.util.List; - /** * Created by itzikliderman on 13/06/2017. */ @@ -70,8 +67,12 @@ public class ViewEditPage extends VidBasePage { return this; } - public ViewEditPage selectLCPRegion(String lcpRegion){ - SelectOption.byValue(lcpRegion, Constants.ViewEdit.LCP_REGION_SELECT_TESTS_ID); + public ViewEditPage selectLcpRegion(String lcpRegion, String cloudOwner){ + selectLcpRegion(lcpRegion); + if (Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST.isActive()) { + String selectedOption = SelectOption.getSelectedOption(Constants.ViewEdit.LCP_REGION_SELECT_TESTS_ID); + Assert.assertEquals(lcpRegion + " (" + cloudOwner.toUpperCase() + ")", selectedOption); + } return this; } @@ -91,6 +92,10 @@ public class ViewEditPage extends VidBasePage { return this; } + public VidBasePage clickActivateFabricConfigurationButton() { + GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.ACTIVATE_FABRIC_CONFIGURATION_BUTTON_TEST_ID, 60); + return this; + } public VidBasePage clickInfoButton() { GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.INFOSERVICEBUTTON, 30); return this; diff --git a/vid-automation/src/main/java/vid/automation/test/services/AsyncJobsService.java b/vid-automation/src/main/java/vid/automation/test/services/AsyncJobsService.java index 01158fa66..35849b481 100644 --- a/vid-automation/src/main/java/vid/automation/test/services/AsyncJobsService.java +++ b/vid-automation/src/main/java/vid/automation/test/services/AsyncJobsService.java @@ -1,44 +1,54 @@ package vid.automation.test.services; +import com.google.common.collect.ImmutableList; import vid.automation.test.utils.DB_CONFIG; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; +import java.util.List; public class AsyncJobsService { public void dropAllAsyncJobs() { + runStatementsInDb(ImmutableList.of( + "DELETE FROM `vid_service_info`", + "DELETE FROM `vid_job`", + "DELETE FROM `vid_job_audit_status`", + "DELETE FROM `vid_name_counter`" + )); + } + + public void runStatementsInDb(List<String> sqlStatements) { System.out.println("Connecting database..."); try (Connection connection = DriverManager.getConnection(DB_CONFIG.url, DB_CONFIG.username, DB_CONFIG.password)) { System.out.println("Database connected!"); - Statement stmt = connection.createStatement(); - stmt.addBatch("DELETE FROM `vid_service_info`"); - stmt.addBatch("DELETE FROM `vid_job`"); - stmt.addBatch("DELETE FROM `vid_job_audit_status`"); - int[] executeBatch = stmt.executeBatch(); + try (Statement stmt = connection.createStatement()) { + for (String sql: sqlStatements) { + stmt.addBatch(sql); + } + stmt.executeBatch(); + } } catch (SQLException e) { throw new IllegalStateException("Cannot connect the database!", e); } } - public void muteAllAsyncJobs() { - System.out.println("Connecting database..."); + public void runStatementInDb(String sqlStatement) { + runStatementsInDb(ImmutableList.of(sqlStatement)); + } - try (Connection connection = DriverManager.getConnection(DB_CONFIG.url, DB_CONFIG.username, DB_CONFIG.password)) { - System.out.println("Database connected!"); - Statement stmt = connection.createStatement(); - stmt.addBatch("UPDATE `vid_job` set `TAKEN_BY`='muteAllAsyncJobs', `AGE`=`AGE`+5"); - int[] executeBatch = stmt.executeBatch(); + public void muteAllAsyncJobs() { + runStatementInDb("UPDATE `vid_job` SET `TAKEN_BY`='muteAllAsyncJobs', `JOB_STATUS`=CONCAT('MUTED_', `JOB_STATUS`), `AGE`=`AGE`+5 WHERE `TAKEN_BY` is NULL or `TAKEN_BY`<>'muteAllAsyncJobs'"); + } - } catch (SQLException e) { - throw new IllegalStateException("Cannot connect the database!", e); - } + public void dropAllFromNameCounter() { + runStatementInDb("DELETE FROM `vid_name_counter`"); } } diff --git a/vid-automation/src/main/java/vid/automation/test/services/BulkRegistration.java b/vid-automation/src/main/java/vid/automation/test/services/BulkRegistration.java index c6de040ea..0f0839537 100644 --- a/vid-automation/src/main/java/vid/automation/test/services/BulkRegistration.java +++ b/vid-automation/src/main/java/vid/automation/test/services/BulkRegistration.java @@ -1,14 +1,28 @@ package vid.automation.test.services; +import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.ATT_NC; +import static vid.automation.test.infra.ModelInfo.serviceFabricSriovService; +import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import org.onap.simulator.presetGenerator.presets.aai.PresetAAICloudRegionAndSourceFromConfigurationPut; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIFilterServiceInstanceById; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetHomingForVfModule; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetModelsByOwningEntity; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetModelsByProject; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetNetworkZones; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetPortMirroringSourcePorts; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubDetailsGet; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubDetailsWithoutInstancesGet; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetTenants; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIPostNamedQueryForViewEdit; -import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVfModuleInstancePost; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOActivateFabricConfiguration; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateInstancePost; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVfModule; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeactivateAndCloudDelete; import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteInstanceOrchestrationRequestGet; import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteNetwork; import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteService; @@ -16,33 +30,57 @@ import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteVfModule; import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteVnf; import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteVolumeGroup; import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet; +import org.onap.simulator.presetGenerator.presets.mso.configuration.PresetMSOActOnConfiguration; +import org.onap.simulator.presetGenerator.presets.mso.configuration.PresetMSOCreateConfiguration; +import org.onap.simulator.presetGenerator.presets.mso.configuration.PresetMSODeleteConfiguration; +import org.onap.simulator.presetGenerator.presets.mso.configuration.PresetMsoEnableDisablePort; import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceMetadataGet; import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGet; import vid.automation.test.Constants; -import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; - public class BulkRegistration { public static void searchExistingServiceInstance() { searchExistingServiceInstance("Active"); } - public static void searchExistingServiceInstance(String orchStatus) { + public static void searchExistingServiceInstance(String orchStatus) { + searchExistingServiceInstance(orchStatus, "pending-delete"); + } + + public static void searchExistingServiceInstance(String orchStatus, String vfModuleOrchStatus) { genericSearchExistingServiceInstance(); SimulatorApi.registerExpectation( new String [] { - Constants.RegisterToSimulator.SearchForServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_USP_VOICE, + Constants.RegisterToSimulator.SearchForServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_SILVIA_ROBBINS, Constants.RegisterToSimulator.SearchForServiceInstance.FILTER_SERVICE_INSTANCE_BY_ID, Constants.RegisterToSimulator.SearchForServiceInstance.NAMED_QUERY_VIEW_EDIT, Constants.RegisterToSimulator.SearchForServiceInstance.GET_SDC_CATALOG_SERVICE_VID_TEST_444, Constants.RegisterToSimulator.CreateNewServiceInstance.deploy.GET_AIC_ZONES - }, ImmutableMap.<String, Object>of("<ORCH_STATUS>", orchStatus), SimulatorApi.RegistrationStrategy.APPEND); + }, ImmutableMap.<String, Object>of("<ORCH_STATUS>", orchStatus, "<VF_MODULE_ORCH_STATUS>", vfModuleOrchStatus), SimulatorApi.RegistrationStrategy.APPEND); + } + + public static void searchExistingServiceInstanceWithFabric(String orchStatus) { + genericSearchExistingServiceInstance(); + SimulatorApi.registerExpectationFromPresets( + ImmutableList.of( + new PresetAAIFilterServiceInstanceById("e433710f-9217-458d-a79d-1c7aff376d89", + "TYLER SILVIA", + "c187e9fe-40c3-4862-b73e-84ff056205f61234"), + new PresetAAIGetSubDetailsGet("e433710f-9217-458d-a79d-1c7aff376d89", orchStatus), + new PresetAAIGetSubDetailsWithoutInstancesGet("e433710f-9217-458d-a79d-1c7aff376d89", true), + new PresetAAIPostNamedQueryForViewEdit("c187e9fe-40c3-4862-b73e-84ff056205f61234", false, true), + new PresetSDCGetServiceMetadataGet(serviceFabricSriovService), + new PresetSDCGetServiceToscaModelGet(serviceFabricSriovService), + new PresetAAIGetNetworkZones(), + new PresetMSOActivateFabricConfiguration("c187e9fe-40c3-4862-b73e-84ff056205f61234"), + new PresetMSOOrchestrationRequestGet("COMPLETE", "318cc766-b673-4a50-b9c5-471f68914584", "Success")), + SimulatorApi.RegistrationStrategy.APPEND); } public static void searchExistingServiceInstanceByOEAndProject(){ SimulatorApi.registerExpectationFromPresets(ImmutableList.of( - new PresetAAIGetModelsByOwningEntity("Wireline"), + new PresetAAIGetModelsByOwningEntity("Melissa"), new PresetAAIGetModelsByProject("x1"), new PresetAAIGetModelsByProject("yyy1") ), APPEND); @@ -52,7 +90,7 @@ public class BulkRegistration { genericSearchExistingServiceInstance(); SimulatorApi.registerExpectation( new String [] { - Constants.RegisterToSimulator.SearchForServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_USP_VOICE_CR, + Constants.RegisterToSimulator.SearchForServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_SILVIA_ROBBINS_CR, Constants.RegisterToSimulator.SearchForServiceInstance.FILTER_CR_SERVICE_INSTANCE_BY_ID, Constants.RegisterToSimulator.SearchForServiceInstance.NAMED_QUERY_CR_VIEW_EDIT, Constants.RegisterToSimulator.SearchForServiceInstance.GET_SDC_CATALOG_SERVICE_VID_TEST_CR, @@ -65,7 +103,7 @@ public class BulkRegistration { genericSearchExistingServiceInstance(); SimulatorApi.registerExpectation( new String [] { - Constants.RegisterToSimulator.AddSubinterface.GET_SUBSCRIBERS_FOR_CUSTOMER_USP_VOICE_VFC_IG, + Constants.RegisterToSimulator.AddSubinterface.GET_SUBSCRIBERS_FOR_CUSTOMER_SILVIA_ROBBINS_VFC_IG, Constants.RegisterToSimulator.AddSubinterface.FILTER_VFC_IG_SERVICE_INSTANCE_BY_ID, Constants.RegisterToSimulator.AddSubinterface.NAMED_QUERY_VFC_IG_VIEW_EDIT, Constants.RegisterToSimulator.AddSubinterface.GET_SDC_CATALOG_SERVICE_VID_TEST_444, @@ -77,17 +115,16 @@ public class BulkRegistration { SimulatorApi.registerExpectation( new String [] { Constants.RegisterToSimulator.genericRequest.ECOMP_PORTAL_GET_SESSION_SLOT_CHECK_INTERVAL, - Constants.RegisterToSimulator.SearchForServiceInstance.GET_FULL_SUBSCRIBERS, Constants.RegisterToSimulator.SearchForServiceInstance.GET_SERVICES - }, ImmutableMap.<String, Object>of(), SimulatorApi.RegistrationStrategy.APPEND); + SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(),SimulatorApi.RegistrationStrategy.APPEND); } public static void searchExistingServiceInstance2(String orchStatus) { genericSearchExistingServiceInstance(); SimulatorApi.registerExpectation( new String [] { - Constants.RegisterToSimulator.SearchForServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_FIREWALL_MISC, + Constants.RegisterToSimulator.SearchForServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_CRAIG_ROBERTS, Constants.RegisterToSimulator.SearchForServiceInstance.FILTER_SERVICE_INSTANCE_BY_ID_2, Constants.RegisterToSimulator.SearchForServiceInstance.NAMED_QUERY_VIEW_EDIT_2 }, ImmutableMap.<String, Object>of("<ORCH_STATUS>", orchStatus), SimulatorApi.RegistrationStrategy.APPEND); @@ -105,9 +142,10 @@ public class BulkRegistration { SimulatorApi.registerExpectationFromPreset(new PresetAAICloudRegionAndSourceFromConfigurationPut(configurationId, desiredCloudRegionId), APPEND); SimulatorApi.registerExpectationFromPreset(new PresetAAIGetPortMirroringSourcePorts(configurationId, portInterfaceId, "i'm a port", isMirrored), APPEND); + SimulatorApi.registerExpectationFromPreset(PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MDT1_TO_ATT_NC, APPEND); SimulatorApi.registerExpectation( new String [] { - Constants.RegisterToSimulator.SearchForServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_USP_VOICE, + Constants.RegisterToSimulator.SearchForServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_SILVIA_ROBBINS, Constants.RegisterToSimulator.SearchForServiceInstance.FILTER_SERVICE_INSTANCE_BY_ID_PM, Constants.RegisterToSimulator.SearchForServiceInstance.NAMED_QUERY_VIEW_EDIT_PM, Constants.RegisterToSimulator.SearchForServiceInstance.GET_SDC_CATALOG_SERVICE_PM, @@ -170,33 +208,24 @@ public class BulkRegistration { } - public static void activateDeactivateConfiguration(String orchStatus, String action, String desiredCloudRegionId) { - SimulatorApi.registerExpectation( - new String [] { - Constants.RegisterToSimulator.createConfiguration.MSO_ACTIVATE_CONFIGURATION, - }, ImmutableMap.<String, Object>of("<ACTION>",action,"mdt1", desiredCloudRegionId), SimulatorApi.RegistrationStrategy.APPEND); + public static void activateDeactivateConfiguration(String action) { + appendWithGetStatus(new PresetMSOActOnConfiguration(action), PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MDT1_TO_ATT_NC); } - public static void deleteConfiguration(String desiredCloudRegionId) { - SimulatorApi.registerExpectation( - new String [] { - Constants.RegisterToSimulator.createConfiguration.MSO_DELETE_CONFIGURATION, - Constants.RegisterToSimulator.createConfiguration.MSO_CREATE_CONFIGURATION_ORCH_REQ - }, ImmutableMap.of("mdt1", desiredCloudRegionId), SimulatorApi.RegistrationStrategy.APPEND); + public static void deleteConfiguration() { + appendWithGetStatus(new PresetMSODeleteConfiguration(), PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MDT1_TO_ATT_NC); } - public static void enableDisablePort(String action, String desiredCloudRegionId){ - SimulatorApi.registerExpectation( - new String [] { - Constants.RegisterToSimulator.createConfiguration.MSO_ACTIVATE_CONFIGURATION, - Constants.RegisterToSimulator.createConfiguration.MSO_ENABLE_DISABLE_PORT, - }, ImmutableMap.<String, Object>of("<ACTION>", action,"mdt1", desiredCloudRegionId), SimulatorApi.RegistrationStrategy.APPEND); + public static void enableDisablePort(String action){ + appendWithGetStatus(new PresetMsoEnableDisablePort( + "c187e9fe-40c3-4862-b73e-84ff056205f6", + "9533-config-LB1113", action), PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MDT1_TO_ATT_NC); } public static void addNetwork() { SimulatorApi.registerExpectation( new String [] { - Constants.RegisterToSimulator.SearchForServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_Mobility, + Constants.RegisterToSimulator.SearchForServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_Emanuel, Constants.RegisterToSimulator.addNetwork.AAI_GET_TENANTS, Constants.RegisterToSimulator.addNetwork.AAI_NAMED_QUERY_FOR_VIEW_EDIT, Constants.RegisterToSimulator.addNetwork.FILTER_SERVICE_INSTANCE_BY_ID, @@ -205,13 +234,7 @@ public class BulkRegistration { }, ImmutableMap.<String, Object>of(), SimulatorApi.RegistrationStrategy.APPEND); } - public static void msoAddNetwork(String instanceName){ - SimulatorApi.registerExpectation( - new String [] { - Constants.RegisterToSimulator.addNetwork.MSO_ADD_NETWORK_ORCH_REQ, - Constants.RegisterToSimulator.addNetwork.MSO_ADD_NETWORK - }, ImmutableMap.<String, Object>of("<SERVICE_INSTANCE_NAME>",instanceName), SimulatorApi.RegistrationStrategy.APPEND); - } + public static void msoAddNetworkError(String instanceName){ SimulatorApi.registerExpectation( new String [] { @@ -227,13 +250,15 @@ public class BulkRegistration { } - public static void createPolicyConfiguration(boolean isSuccessFlow, String desiredCloudRegionId) { + public static void createPolicyConfiguration(boolean isSuccessFlow, String serviceType) { createConfiguration(); - SimulatorApi.registerExpectation( - new String []{ - Constants.RegisterToSimulator.createConfiguration.GET_PNF_INSTANCES, - Constants.RegisterToSimulator.createConfiguration.GET_MODEL_BY_ONE_INVARIANT_ID - } , ImmutableMap.<String, Object>of("mdt1", desiredCloudRegionId), SimulatorApi.RegistrationStrategy.APPEND); + + SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.APPEND, + Constants.RegisterToSimulator.createConfiguration.GET_MODEL_BY_ONE_INVARIANT_ID); + + SimulatorApi.registerExpectation(Constants.RegisterToSimulator.createConfiguration.GET_PNF_INSTANCES, + ImmutableMap.of("<SERVICE-TYPE>", serviceType), SimulatorApi.RegistrationStrategy.APPEND); + if (isSuccessFlow) { msoCreatePProbeConfiguration(); } else { @@ -241,38 +266,33 @@ public class BulkRegistration { } } - public static void deletePolicyConfiguration(boolean isSuccessFlow, String desiredCloudRegionId) { + public static void deletePolicyConfiguration(boolean isSuccessFlow) { createConfiguration(); - SimulatorApi.registerExpectation( - new String []{ - Constants.RegisterToSimulator.createConfiguration.GET_PNF_INSTANCES, - Constants.RegisterToSimulator.createConfiguration.GET_MODEL_BY_ONE_INVARIANT_ID, - Constants.RegisterToSimulator.createConfiguration.MSO_DELETE_CONFIGURATION, - - } , ImmutableMap.<String, Object>of("mdt1", desiredCloudRegionId), SimulatorApi.RegistrationStrategy.APPEND); - if (isSuccessFlow) { - msoCreatePProbeConfiguration(); - } else { - msoCreatePProbeConfigurationError(); - } + SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.APPEND, + Constants.RegisterToSimulator.createConfiguration.GET_MODEL_BY_ONE_INVARIANT_ID); + appendWithGetStatus(new PresetMSODeleteConfiguration(), PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MDT1_TO_ATT_NC); } private static void msoCreatePProbeConfiguration() { - SimulatorApi.registerExpectation( - new String []{ - Constants.RegisterToSimulator.createConfiguration.MSO_CREATE_CONFIGURATION, - Constants.RegisterToSimulator.createConfiguration.MSO_CREATE_CONFIGURATION_ORCH_REQ - } , ImmutableMap.<String, Object>of(), SimulatorApi.RegistrationStrategy.APPEND); + appendWithGetStatus(new PresetMSOCreateConfiguration("c187e9fe-40c3-4862-b73e-84ff056205f6"), PresetAAIGetCloudOwnersByCloudRegionId.PRESET_AAIAIC25_TO_ATT_AIC); + } + + private static void appendWithGetStatus(PresetMSOBaseCreateInstancePost createInstancePreset, PresetAAIGetCloudOwnersByCloudRegionId cloudOwnerPreset) { + SimulatorApi.registerExpectationFromPresets(ImmutableList.of( + createInstancePreset, + cloudOwnerPreset, + new PresetMSOOrchestrationRequestGet(PresetMSOOrchestrationRequestGet.COMPLETE, createInstancePreset.getRequestId(), "Success")), + SimulatorApi.RegistrationStrategy.APPEND); } private static void msoCreatePProbeConfigurationError() { - SimulatorApi.registerExpectation( - new String []{ - Constants.RegisterToSimulator.createConfiguration.MSO_CREATE_CONFIGURATION_ERROR - } , ImmutableMap.<String, Object>of(), SimulatorApi.RegistrationStrategy.APPEND); + SimulatorApi.registerExpectationFromPresets(ImmutableList.of( + new PresetMSOCreateConfiguration("c187e9fe-40c3-4862-b73e-84ff056205f6", 500, null), + PresetAAIGetCloudOwnersByCloudRegionId.PRESET_AAIAIC25_TO_ATT_AIC), + SimulatorApi.RegistrationStrategy.APPEND); } public static void createConfiguration() { @@ -295,31 +315,28 @@ public class BulkRegistration { } public static void createNewServiceInstance(String subscriber) { - SimulatorApi.registerExpectation( - new String []{ - Constants.RegisterToSimulator.CreateNewServiceInstance.GET_FULL_SUBSCRIBES, - Constants.RegisterToSimulator.CreateNewServiceInstance.GET_SERVICES - } , ImmutableMap.<String, Object>of(), SimulatorApi.RegistrationStrategy.APPEND); + SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(),SimulatorApi.RegistrationStrategy.APPEND); + SimulatorApi.registerExpectation(Constants.RegisterToSimulator.CreateNewServiceInstance.GET_SERVICES, SimulatorApi.RegistrationStrategy.APPEND); switch (subscriber) { - case "USP VOICE": createNewServiceInstanceUspVoice(); break; - case "MSO_1610_ST": createNewServiceInstanceMso1610ST(); break; + case "SILVIA ROBBINS": createNewServiceInstanceUspVoice(); break; + case "CAR_2020_ER": createNewServiceInstanceMso1610ST(); break; } } private static void createNewServiceInstanceMso1610ST() { SimulatorApi.registerExpectation( new String []{ - Constants.RegisterToSimulator.CreateNewServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_MSO_1610_ST, - Constants.RegisterToSimulator.CreateNewServiceInstance.GET_MODELS_BY_SERVICE_TYPE_MSO_1610_ST + Constants.RegisterToSimulator.CreateNewServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_CAR_2020_ER, + Constants.RegisterToSimulator.CreateNewServiceInstance.GET_MODELS_BY_SERVICE_TYPE_CAR_2020_ER } , ImmutableMap.<String, Object>of(), SimulatorApi.RegistrationStrategy.APPEND); } private static void createNewServiceInstanceUspVoice() { SimulatorApi.registerExpectation( new String []{ - Constants.RegisterToSimulator.CreateNewServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_USP_VOICE, - Constants.RegisterToSimulator.CreateNewServiceInstance.GET_MODELS_BY_SERVICE_TYPE_USP_VOICE + Constants.RegisterToSimulator.CreateNewServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_SILVIA_ROBBINS, + Constants.RegisterToSimulator.CreateNewServiceInstance.GET_MODELS_BY_SERVICE_TYPE_SILVIA_ROBBINS } , ImmutableMap.<String, Object>of(), SimulatorApi.RegistrationStrategy.APPEND); } @@ -336,26 +353,34 @@ public class BulkRegistration { public static void searchExistingServiceInstanceWithoutModelVerId() { SimulatorApi.registerExpectation( new String []{ - Constants.RegisterToSimulator.SearchForServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_FIREWALL_MISC, + Constants.RegisterToSimulator.SearchForServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_CRAIG_ROBERTS, Constants.RegisterToSimulator.SearchForServiceInstance.FILTER_SERVICE_INSTANCE_BY_ID_NO_MODEL_VER_ID, // Constants.RegisterToSimulator.SearchForServiceInstance.NAMED_QUERY_VIEW_EDIT_NO_MODEL_VER_ID } , ImmutableMap.<String, Object>of(), SimulatorApi.RegistrationStrategy.APPEND); } - public static void deleteExistingInstance(String orchStatus, String type) { + public static void deleteExistingInstance(String orchStatus, String type) { + deleteExistingInstance(orchStatus, type, "pending-delete"); + } + + public static void deleteExistingInstance(String orchStatus, String type, String vfModuleOrchStatus) { genericSearchExistingServiceInstance(); SimulatorApi.registerExpectation( new String [] { - Constants.RegisterToSimulator.SearchForServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_USP_VOICE, + Constants.RegisterToSimulator.SearchForServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_SILVIA_ROBBINS, Constants.RegisterToSimulator.SearchForServiceInstance.NAMED_QUERY_VIEW_EDIT, Constants.RegisterToSimulator.CreateNewServiceInstance.deploy.GET_AIC_ZONES - }, ImmutableMap.<String, Object>of("<ORCH_STATUS>", orchStatus), SimulatorApi.RegistrationStrategy.APPEND); + }, ImmutableMap.<String, Object>of("<ORCH_STATUS>", orchStatus, "<VF_MODULE_ORCH_STATUS>", vfModuleOrchStatus), SimulatorApi.RegistrationStrategy.APPEND); SimulatorApi.registerExpectationFromPresets( ImmutableList.of( new PresetAAIGetTenants(), new PresetMSODeleteInstanceOrchestrationRequestGet(type), new PresetSDCGetServiceMetadataGet("7a6ee536-f052-46fa-aa7e-2fca9d674c44", "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", "service-Complexservice-aLaCarte-csar.zip"), - new PresetSDCGetServiceToscaModelGet("7a6ee536-f052-46fa-aa7e-2fca9d674c44", "service-Complexservice-aLaCarte-csar.zip")), + new PresetSDCGetServiceToscaModelGet("7a6ee536-f052-46fa-aa7e-2fca9d674c44", "service-Complexservice-aLaCarte-csar.zip"), + new PresetMSODeactivateAndCloudDelete("3f93c7cb-2fd0-4557-9514-e189b7b04f9d", "c015cc0f-0f37-4488-aabf-53795fd93cd3", + "a231a99c-7e75-4d6d-a0fb-5c7d26f30f77", "c0011670-0e1a-4b74-945d-8bf5aede1d9c", "irma-aic"), + PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MTN6_TO_ATT_AIC + ), SimulatorApi.RegistrationStrategy.APPEND); } @@ -383,7 +408,23 @@ public class BulkRegistration { deleteExistingInstance(orchStatus, "Service"); SimulatorApi.registerExpectationFromPresets(ImmutableList.of( new PresetMSODeleteService(), - new PresetAAIPostNamedQueryForViewEdit("3f93c7cb-2fd0-4557-9514-e189b7b04f9d", false)), SimulatorApi.RegistrationStrategy.APPEND); + new PresetAAIPostNamedQueryForViewEdit("3f93c7cb-2fd0-4557-9514-e189b7b04f9d", false, false)), SimulatorApi.RegistrationStrategy.APPEND); + } + + public static void resumeWithHomingDataVfModule(String serviceOrchStatus, String vfModuleOrchStatus, String vfModuleName) { + SimulatorApi.registerExpectation(Constants.RegisterToSimulator.SearchForServiceInstance.NAMED_QUERY_VIEW_EDIT, + ImmutableMap.<String, Object>of("<ORCH_STATUS>", serviceOrchStatus, "<VF_MODULE_ORCH_STATUS>", vfModuleOrchStatus), + SimulatorApi.RegistrationStrategy.APPEND); + + SimulatorApi.registerExpectationFromPresets( + ImmutableList.of ( + PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MDT1_TO_ATT_NC, + new PresetAAIGetHomingForVfModule("c015cc0f-0f37-4488-aabf-53795fd93cd3", "a231a99c-7e75-4d6d-a0fb-5c7d26f30f77", "092eb9e8e4b7412e8787dd091bc58e86", "mdt1"), + new PresetMSOCreateVfModule("3f93c7cb-2fd0-4557-9514-e189b7b04f9d", + "c015cc0f-0f37-4488-aabf-53795fd93cd3", ATT_NC, vfModuleName, + "7a6ee536-f052-46fa-aa7e-2fca9d674c44", "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", "ComplexService"), + new PresetMSOOrchestrationRequestGet("COMPLETE","c0011670-0e1a-4b74-945d-8bf5aede1d9c",Constants.ViewEdit.VF_MODULE_CREATED_SUCCESSFULLY_TEXT)), + SimulatorApi.RegistrationStrategy.APPEND); } public static void resumeVfModule(String serviceInstanceId, String vnfInstanceId ){ @@ -391,7 +432,8 @@ public class BulkRegistration { SimulatorApi.registerExpectationFromPresets( ImmutableList.of ( new PresetAAIGetTenants(), - new PresetMSOCreateVfModuleInstancePost(serviceInstanceId,vnfInstanceId), + PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MDT1_TO_ATT_NC, + new PresetMSOCreateVfModule(serviceInstanceId,vnfInstanceId, ATT_NC), new PresetMSOOrchestrationRequestGet("COMPLETE","c0011670-0e1a-4b74-945d-8bf5aede1d9c",Constants.ViewEdit.VF_MODULE_CREATED_SUCCESSFULLY_TEXT)), SimulatorApi.RegistrationStrategy.APPEND); diff --git a/vid-automation/src/main/java/vid/automation/test/services/DropTestApiField.java b/vid-automation/src/main/java/vid/automation/test/services/DropTestApiField.java index e175b88b1..bb50438ca 100644 --- a/vid-automation/src/main/java/vid/automation/test/services/DropTestApiField.java +++ b/vid-automation/src/main/java/vid/automation/test/services/DropTestApiField.java @@ -1,64 +1,73 @@ -package vid.automation.test.services; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; -import vid.automation.test.infra.Features; - -import java.io.IOException; -import java.util.Arrays; -import java.util.function.UnaryOperator; - -public class DropTestApiField { - - public static UnaryOperator<String> dropTestApiFieldFromString() { - if (Features.FLAG_ADD_MSO_TESTAPI_FIELD.isActive()) { - // do nothing - return in -> in; - } else { - final ObjectMapper objectMapper = new ObjectMapper(); - return in -> { - if (!in.contains("testApi")) { - // short circuit - return in; - } - - try { - final JsonNode tree = objectMapper.readTree(in); - final JsonNode node = tree.path("simulatorRequest"); - if (removePath(node, "body", "requestDetails", "requestParameters", "testApi") != null) { - // tree modified, write back to string - return objectMapper.writeValueAsString(tree); - } else { - // else... - return in; - } - } catch (IOException e) { - return in; - } - }; - } - } - - private static JsonNode removePath(JsonNode tree, String... nodes) { - // remove the nodes; remove also the parent, if an empty object was left - // returns the removed node - // returns null if no modification to tree - if (nodes.length > 1) { - final JsonNode node = tree.path(nodes[0]); - final JsonNode removed = removePath(node, Arrays.copyOfRange(nodes, 1, nodes.length)); - if (removed != null && node.size() == 0) { - return removePath(tree, nodes[0]); - } else { - return removed; // non-null if node.size() != 0 - } - } else { - if (tree instanceof ObjectNode) { - return ((ObjectNode) tree).remove(nodes[0]); - } else { - return null; - } - } - } - -} +package vid.automation.test.services;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import vid.automation.test.infra.Features;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.function.UnaryOperator;
+
+public class DropTestApiField {
+
+ public static UnaryOperator<String> dropTestApiFieldFromString() {
+ return dropFieldFromString("testApi", Features.FLAG_ADD_MSO_TESTAPI_FIELD,
+ "simulatorRequest", "body", "requestDetails", "requestParameters", "testApi");
+ }
+
+ public static UnaryOperator<String> dropFieldCloudOwnerFromString() {
+ return dropFieldFromString("cloudOwner", Features.FLAG_ADD_MSO_TESTAPI_FIELD,
+ "simulatorRequest", "body", "requestDetails", "cloudConfiguration", "cloudOwner");
+ }
+ private static UnaryOperator<String> dropFieldFromString(String text, Features featureFlag, String basePath, String... nodes){
+ if (featureFlag.isActive()) {
+ // do nothing
+ return in -> in;
+ } else {
+ final ObjectMapper objectMapper = new ObjectMapper();
+ return in -> {
+ if (!in.contains(text)) {
+ // short circuit
+ return in;
+ }
+
+ try {
+ final JsonNode tree = objectMapper.readTree(in);
+ final JsonNode node = tree.path(basePath);
+ if (removePath(node, nodes) != null) {
+ // tree modified, write back to string
+ return objectMapper.writeValueAsString(tree);
+ } else {
+ // else...
+ return in;
+ }
+ } catch (IOException e) {
+ return in;
+ }
+ };
+ }
+ }
+
+ private static JsonNode removePath(JsonNode tree, String... nodes) {
+ // remove the nodes; remove also the parent, if an empty object was left
+ // returns the removed node
+ // returns null if no modification to tree
+ if (nodes.length > 1) {
+ final JsonNode node = tree.path(nodes[0]);
+ final JsonNode removed = removePath(node, Arrays.copyOfRange(nodes, 1, nodes.length));
+ if (removed != null && node.size() == 0) {
+ return removePath(tree, nodes[0]);
+ } else {
+ return removed; // non-null if node.size() != 0
+ }
+ } else {
+ if (tree instanceof ObjectNode) {
+ return ((ObjectNode) tree).remove(nodes[0]);
+ } else {
+ return null;
+ }
+ }
+ }
+
+}
diff --git a/vid-automation/src/main/java/vid/automation/test/services/ServicesService.java b/vid-automation/src/main/java/vid/automation/test/services/ServicesService.java index 34303a972..264b2c16d 100644 --- a/vid-automation/src/main/java/vid/automation/test/services/ServicesService.java +++ b/vid-automation/src/main/java/vid/automation/test/services/ServicesService.java @@ -1,7 +1,7 @@ package vid.automation.test.services; import com.fasterxml.jackson.databind.ObjectMapper; -import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.onap.sdc.ci.tests.utilities.FileHandling; import vid.automation.test.model.Service; import vid.automation.test.model.ServiceModel; import vid.automation.test.model.ServiceModelsList; diff --git a/vid-automation/src/main/java/vid/automation/test/services/SimulatorApi.java b/vid-automation/src/main/java/vid/automation/test/services/SimulatorApi.java index 29f6eae7c..65ef3679c 100644 --- a/vid-automation/src/main/java/vid/automation/test/services/SimulatorApi.java +++ b/vid-automation/src/main/java/vid/automation/test/services/SimulatorApi.java @@ -1,30 +1,36 @@ package vid.automation.test.services; -import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; -import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; +import static org.testng.Assert.assertEquals; +import static vid.automation.test.services.DropTestApiField.dropFieldCloudOwnerFromString; +import static vid.automation.test.services.DropTestApiField.dropTestApiFieldFromString; + +import com.fasterxml.jackson.databind.DeserializationFeature; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import org.glassfish.jersey.client.ClientProperties; -import org.glassfish.jersey.uri.internal.JerseyUriBuilder; -import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset; -import org.onap.simulator.presetGenerator.presets.model.RegistrationRequest; -import org.springframework.http.HttpStatus; -import vid.automation.test.utils.ReadFile; - +import java.net.URI; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.function.UnaryOperator; +import java.util.stream.Collectors; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Entity; import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.GenericType; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.net.URI; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.function.UnaryOperator; - -import static org.testng.Assert.assertEquals; -import static vid.automation.test.services.DropTestApiField.dropTestApiFieldFromString; +import org.glassfish.jersey.client.ClientProperties; +import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider; +import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider; +import org.glassfish.jersey.uri.internal.JerseyUriBuilder; +import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset; +import org.onap.simulator.presetGenerator.presets.model.RegistrationRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import vid.automation.test.utils.ReadFile; public class SimulatorApi { @@ -32,15 +38,31 @@ public class SimulatorApi { APPEND, CLEAR_THEN_SET } + private static final Logger logger = LoggerFactory.getLogger(SimulatorApi.class); + + /* + these classes are partial representation of org.mockserver.model.HttpRequest. + We can not use HttpRequest since it contains Map with NottableString and jackson throw the following error : + com.fasterxml.jackson.databind.JsonMappingException: Can not find a (Map) Key deserializer for type + [simple type, class org.mockserver.model.NottableString] + */ + public static class Path { + public String value; + } + + public static class HttpRequest{ + public Path path; + } + private static final URI uri; //uri for registration private static final URI simulationUri; //uri for getting simulated responses private static final Client client; private static final List<UnaryOperator<String>> presetStringPostProccessors = - ImmutableList.of(dropTestApiFieldFromString()); + ImmutableList.of(dropTestApiFieldFromString(), dropFieldCloudOwnerFromString()); static { - String host = System.getProperty("VID_HOST", "127.0.0.1" ); + String host = System.getProperty("VID_HOST", "10.0.0.10" ); Integer port = Integer.valueOf(System.getProperty("SIM_PORT", System.getProperty("VID_PORT", "8080"))); //port for registration uri = new JerseyUriBuilder().host(host).port(port).scheme("http").path("vidSimulator").build(); client = ClientBuilder.newClient(); @@ -49,6 +71,7 @@ public class SimulatorApi { // org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: // MessageBodyWriter not found for media type=application/json JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider(); + jacksonJsonProvider.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); client.register(jacksonJsonProvider); Integer simulationPort = Integer.valueOf(System.getProperty("SIMULATION_PORT", "1080")); //port getting simulated responses @@ -84,13 +107,13 @@ public class SimulatorApi { content = content.replaceAll(templateParam.getKey(), templateParam.getValue().toString()); } - registerToSimulatorAndAssertSuccess(content, registrationStrategy); + registerToSimulatorAndAssertSuccess(expectationTemplateFilename, content, registrationStrategy); } public static void registerExpectationFromPreset(BasePreset preset, RegistrationStrategy registrationStrategy) { RegistrationRequest content = preset.generateScenario(); - registerToSimulatorAndAssertSuccess(content, registrationStrategy); + registerToSimulatorAndAssertSuccess(preset.getClass().getCanonicalName(), content, registrationStrategy); } public static void registerExpectationFromPresets(Collection<BasePreset> presets, RegistrationStrategy registrationStrategy) { @@ -99,7 +122,7 @@ public class SimulatorApi { } presets.forEach( preset-> { - try {registerToSimulatorAndAssertSuccess(preset.generateScenario());} + try {registerToSimulatorAndAssertSuccess(preset.getClass().getCanonicalName(), preset.generateScenario());} catch (RuntimeException e) { throw new RuntimeException("Failed to register preset "+preset.getClass().getName(), e); } @@ -107,14 +130,31 @@ public class SimulatorApi { ); } - private static void registerToSimulatorAndAssertSuccess(Object content, RegistrationStrategy registrationStrategy) { +// public static List<HttpRequest> retrieveRecordedRequests() { +// Response response = client.target(uri).path("retrieveRecordedRequests").request().get(); +// return response.readEntity(new GenericType<List<HttpRequest>>(){}); +// } + + /* + This method return counter of requests that has been sent to simulator. + The key of the map is a path, and the value is counter + */ + public static Map<String, Long> retrieveRecordedRequestsPathCounter() { + Response response = client.target(uri).path("retrieveRecordedRequests").request().get(); + List<HttpRequest> httpRequests = response.readEntity(new GenericType<List<HttpRequest>>(){}); + return httpRequests.stream().map(x->x.path.value).collect( + Collectors.groupingBy(Function.identity(), Collectors.counting())); + } + + private static void registerToSimulatorAndAssertSuccess(String name, Object content, RegistrationStrategy registrationStrategy) { if (registrationStrategy == RegistrationStrategy.CLEAR_THEN_SET) { clearRegistrations(); } - registerToSimulatorAndAssertSuccess(content); + registerToSimulatorAndAssertSuccess(name, content); } - private static void registerToSimulatorAndAssertSuccess(Object content) { + private static void registerToSimulatorAndAssertSuccess(String name, Object content) { + logger.info("Setting {}", name); content = postProccessContent(content); @@ -137,6 +177,7 @@ public class SimulatorApi { } private static void clearRegistrations() { + logger.info("Clearing Registrations"); Response response = createSimulatorRegistrationWebTarget().request().delete(); assertEquals(response.getStatus(), HttpStatus.OK.value()); } diff --git a/vid-automation/src/main/java/vid/automation/test/services/UsersService.java b/vid-automation/src/main/java/vid/automation/test/services/UsersService.java index ac8af4511..aae7917f7 100644 --- a/vid-automation/src/main/java/vid/automation/test/services/UsersService.java +++ b/vid-automation/src/main/java/vid/automation/test/services/UsersService.java @@ -1,12 +1,10 @@ package vid.automation.test.services; -import com.google.common.primitives.Ints; -import org.apache.commons.lang3.StringUtils; -import vid.automation.test.model.User; -import vid.automation.test.model.UsersObject; -import vid.automation.test.utils.DB_CONFIG; -import vid.automation.test.utils.ReadFile; +import static org.hamcrest.CoreMatchers.everyItem; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.greaterThan; +import com.google.common.primitives.Ints; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; @@ -15,10 +13,11 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; - -import static org.hamcrest.CoreMatchers.everyItem; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.greaterThan; +import org.apache.commons.lang3.StringUtils; +import vid.automation.test.model.User; +import vid.automation.test.model.UsersObject; +import vid.automation.test.utils.DB_CONFIG; +import vid.automation.test.utils.ReadFile; /** * Created by itzikliderman on 08/09/2017. @@ -53,7 +52,7 @@ public class UsersService { /* Creates a user in the DB, were: - Login user name is a deterministic number, hashed from the userId string, with 3 trailing zeroes, - and two leading letters from the userId itself; e.g. "mo26063000" for mobility. + and two leading letters from the userId itself; e.g. "mo26063000" for emanuel. - Login user name == user password - 'user.credentials.userId' and 'user.credentials.password' input fields are overridden with the generated values. - Roles are "read" (roleId==16) and all other roles in object (like subscriberName___serviceType___tenant). @@ -77,7 +76,7 @@ public class UsersService { user.credentials.password = getLoginId(userId); stmt.addBatch("INSERT INTO `fn_user` (`USER_ID`, `ORG_USER_ID`, `FIRST_NAME`, `LOGIN_ID`, `LOGIN_PWD`) " + - "VALUES (" + userNumber + ", '" + userId + "', '" + userId + "', '" + user.credentials.userId + "', '" + user.credentials.password + "')"); + "VALUES (" + userNumber + ", '" + user.credentials.userId + "', '" + userId + "', '" + user.credentials.userId + "', '" + user.credentials.password + "')"); List<String> roles = user.roles != null ? user.roles : new LinkedList<>(); roles.add("Standard User"); diff --git a/vid-automation/src/main/java/vid/automation/test/test/ALaCarteflowTest.java b/vid-automation/src/main/java/vid/automation/test/test/ALaCarteflowTest.java index 7f641d303..69c619b2a 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/ALaCarteflowTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/ALaCarteflowTest.java @@ -1,9 +1,26 @@ package vid.automation.test.test; +import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.ATT_NC; +import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.MDT_1; +import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MDT1_TO_ATT_NC; +import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.PRESET_SOME_LEGACY_REGION_TO_ATT_AIC; +import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.SOME_LEGACY_REGION; +import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; + +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVfModuleOldViewEdit; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVnfALaCarteOldViewEdit; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVolumeGroupOldViewEdit; import org.openqa.selenium.WebElement; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; @@ -19,32 +36,26 @@ import vid.automation.test.sections.ViewEditPage; import vid.automation.test.services.ServicesService; import vid.automation.test.services.SimulatorApi; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; - public class ALaCarteflowTest extends CreateInstanceDialogBaseTest { - static final String SUBSCRIBER = "Mobility"; + static final String SUBSCRIBER = "Emanuel"; static final String SERVICE_NAME = "ggghhh"; static final String SERVICE_ID = "537d3eb0-b7ab-4fe8-a438-6166ab6af49b"; static final String VNF_ID = "0eb38f69-d96b-4d5e-b8c9-3736c292f0f7"; - static final String DEFAULT_TEST_API_VALUE = "GR_API"; + static final String DEFAULT_TEST_API_VALUE = "VNF_API"; public static final String SERVICE_INSTANCE_ID = "SERVICE_INSTANCE_ID"; public static final String A_LACARTE_FLOW_GET_ORCHESTRATION = "aLacarteFlow/get_orchestration_request_status.json"; public static final String ORCHESTRATION_REQUEST_ID = "orchestrationRequestId"; public static final String STATUS_MESSAGE = "status_message"; public static final String REQUEST_TYPE = "REQUEST-TYPE"; public static final String CREATE = "Create"; - public static final String AAIAIC_25 = "AAIAIC25"; + public static final String AAIAIC_25 = "JANET25"; + public static final String AIC = "AIC"; public static final String TENANT = "092eb9e8e4b7412e8787dd091bc58e86"; public static final String FALSE = "false"; - public static final String NODE_INSTANCE = "VSP1710PID298109_vMMSC 0"; + public static final String NODE_INSTANCE = "VSP1710PID298109_vWINIFRED 0"; public static final String MODEL = "959a7ba0-89ee-4984-9af6-65d5bdda4b0e"; - public static final String LEGACY_REGION = "some legacy region"; + private static final String CREATE_VNF_REQUEST_ID = "dbe54591-c8ed-46d3-abc7-d3a24873dfbd"; @BeforeClass @@ -54,12 +65,11 @@ public class ALaCarteflowTest extends CreateInstanceDialogBaseTest { "ecompportal_getSessionSlotCheckInterval.json", "search_for_service_instance/aai_get_services.json" , "create_configuration/aai_get_tenants.json" - , "sanity/get_aai_get_subscribers.json" , "sanity/get_aai_sub_details.json" , "aLacarteFlow/get_aai_search_named_query.json" , "aLacarteFlow/get_sdc_catalog_services_ggghhh.json" ); - + SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), SimulatorApi.RegistrationStrategy.APPEND); } @@ -68,15 +78,30 @@ public class ALaCarteflowTest extends CreateInstanceDialogBaseTest { withMsoTestApiConfiguration(msoTestApiOption, msoTestApiValue, () -> { final String REQUEST_ID = "dbe54591-c8ed-46d3-abc7-d3a24873bddd"; final String MODEL_UUID = "d205e01d-e5da-4e68-8c52-f95cb0607959"; - SimulatorApi.registerExpectation("aLacarteFlow/mso_create_vf_module.json", ImmutableMap.of(SERVICE_INSTANCE_ID, SERVICE_ID, "VNF_INSTANCE_ID", VNF_ID, "REQUEST_ID", REQUEST_ID, DEFAULT_TEST_API_VALUE, msoTestApiValue), APPEND); + + String vfModuleName = viewEditPage.generateInstanceName(Constants.ViewEdit.VF_MODULE_INSTANCE_NAME_PREFIX); + + SimulatorApi.registerExpectationFromPresets(ImmutableList.of( + PRESET_MDT1_TO_ATT_NC, + new PresetMSOCreateVfModuleOldViewEdit( + REQUEST_ID, + BaseMSOPreset.DEFAULT_INSTANCE_ID, + SERVICE_ID, + VNF_ID, + vfModuleName, + msoTestApiValue, + ATT_NC)), + SimulatorApi.RegistrationStrategy.APPEND); + + SimulatorApi.registerExpectation(A_LACARTE_FLOW_GET_ORCHESTRATION, ImmutableMap.of(ORCHESTRATION_REQUEST_ID, REQUEST_ID, STATUS_MESSAGE, Constants.ViewEdit.VF_MODULE_CREATED_SUCCESSFULLY_TEXT, REQUEST_TYPE, CREATE), APPEND); GeneralUIUtils.ultimateWait(); goToInstance(); ServiceModel serviceInstance = new ServicesService().getServiceModel(MODEL_UUID); - addVFModule("Vsp1710pid298109Vmmsc..mmsc_mod1_ltm..module-8", AAIAIC_25, - TENANT, FALSE, "mdt1", getCurrentUser().tenants, serviceInstance); + addVFModule("Vsp1710pid298109Vmmsc..mmsc_mod1_ltm..module-8", vfModuleName, AAIAIC_25, AIC, + TENANT, FALSE, MDT_1, getCurrentUser().tenants, serviceInstance); }); } @@ -84,17 +109,17 @@ public class ALaCarteflowTest extends CreateInstanceDialogBaseTest { @Test private void testTenant() throws Exception { ViewEditPage viewEditPage = new ViewEditPage(); - User user = usersService.getUser("Mobility_with_tenant"); + User user = usersService.getUser("Emanuel_with_tenant"); relogin(user.credentials); goToInstance(); viewEditPage.selectNodeInstanceToAdd(NODE_INSTANCE); viewEditPage.setInstanceName("New and fun instance"); viewEditPage.selectProductFamily("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); - viewEditPage.selectLCPRegion("mtn6"); + viewEditPage.selectLcpRegion("hvf6", AIC); List<WebElement> tenantOptions = Get.byClass(Constants.ViewEdit.TENANT_OPTION_CLASS); List<WebElement> enabledTenantOption = tenantOptions.stream().filter(webElement -> webElement.isEnabled()).collect(Collectors.toList()); Assert.assertTrue(enabledTenantOption.size() == 1); - Assert.assertTrue(enabledTenantOption.get(0).getText().equals("test-mtn6-09")); + Assert.assertTrue(enabledTenantOption.get(0).getText().equals("test-hvf6-09")); // SimulatorApi.registerExpectation("aLacarteFlow/get_sdc_catalog_services_ggghhh.json",APPEND); } @@ -104,20 +129,23 @@ public class ALaCarteflowTest extends CreateInstanceDialogBaseTest { withMsoTestApiConfiguration(msoTestApiOption, msoTestApiValue, () -> { final String MODEL_UUID = MODEL; String instanceName = new VidBasePage().generateInstanceName(Constants.ViewEdit.VNF_INSTANCE_NAME_PREFIX); - SimulatorApi.registerExpectation("aLacarteFlow/mso_create_vnf.json", ImmutableMap.of( - SERVICE_INSTANCE_ID, SERVICE_ID, - "</?LOB>", "", - "INSTANCE_NAME", instanceName, - DEFAULT_TEST_API_VALUE, msoTestApiValue - ), APPEND); + SimulatorApi.registerExpectationFromPresets(ImmutableList.of( + PRESET_SOME_LEGACY_REGION_TO_ATT_AIC, + new PresetMSOCreateVnfALaCarteOldViewEdit( + CREATE_VNF_REQUEST_ID, + SERVICE_ID, + instanceName, + true, + msoTestApiValue)), + SimulatorApi.RegistrationStrategy.APPEND); SimulatorApi.registerExpectation(A_LACARTE_FLOW_GET_ORCHESTRATION, ImmutableMap.of(ORCHESTRATION_REQUEST_ID, "dbe54591-c8ed-46d3-abc7-d3a24873dfbd", STATUS_MESSAGE, Constants.ViewEdit.VNF_CREATED_SUCCESSFULLY_TEXT, REQUEST_TYPE, CREATE), APPEND); GeneralUIUtils.ultimateWait(); goToInstance(); ServiceModel serviceInstance = new ServicesService().getServiceModel(MODEL_UUID); - addVNF(NODE_INSTANCE, AAIAIC_25, TENANT, - FALSE, LEGACY_REGION, "ebc3bc3d-62fd-4a3f-a037-f619df4ff034", "platform", getCurrentUser().tenants, new ArrayList<>(Arrays.asList("ECOMP")), serviceInstance, instanceName); + addVNF(NODE_INSTANCE, AAIAIC_25, AIC, TENANT, + FALSE, SOME_LEGACY_REGION, "ebc3bc3d-62fd-4a3f-a037-f619df4ff034", "platform", getCurrentUser().tenants, new ArrayList<>(Arrays.asList("ONAP")), serviceInstance, instanceName); }); } @@ -126,19 +154,22 @@ public class ALaCarteflowTest extends CreateInstanceDialogBaseTest { withMsoTestApiConfiguration(msoTestApiOption, msoTestApiValue, () -> { goToInstance(); String instanceName = new VidBasePage().generateInstanceName(Constants.ViewEdit.VNF_INSTANCE_NAME_PREFIX); - SimulatorApi.registerExpectation("aLacarteFlow/mso_create_vnf.json", ImmutableMap.of( - SERVICE_INSTANCE_ID, SERVICE_ID, - "<LOB>.*</LOB>", "", - "INSTANCE_NAME", instanceName, - DEFAULT_TEST_API_VALUE, msoTestApiValue - ), APPEND); + SimulatorApi.registerExpectationFromPresets(ImmutableList.of( + PRESET_SOME_LEGACY_REGION_TO_ATT_AIC, + new PresetMSOCreateVnfALaCarteOldViewEdit( + CREATE_VNF_REQUEST_ID, + SERVICE_ID, + instanceName, + false, + msoTestApiValue)), + SimulatorApi.RegistrationStrategy.APPEND); SimulatorApi.registerExpectation(A_LACARTE_FLOW_GET_ORCHESTRATION, ImmutableMap.of( ORCHESTRATION_REQUEST_ID, "dbe54591-c8ed-46d3-abc7-d3a24873dfbd", STATUS_MESSAGE, Constants.ViewEdit.VNF_CREATED_SUCCESSFULLY_TEXT, REQUEST_TYPE, CREATE ), APPEND); - openAndFillVnfPopup(NODE_INSTANCE, AAIAIC_25, TENANT, - FALSE, LEGACY_REGION, "ebc3bc3d-62fd-4a3f-a037-f619df4ff034", "platform", getCurrentUser().tenants, null, null, instanceName); + openAndFillVnfPopup(NODE_INSTANCE, AAIAIC_25, AIC, TENANT, + FALSE, SOME_LEGACY_REGION, "ebc3bc3d-62fd-4a3f-a037-f619df4ff034", "platform", getCurrentUser().tenants, null, null, instanceName); assertConfirmShowMissingDataErrorOnCurrentPopup(Constants.ViewEdit.LINE_OF_BUSINESS_TEXT); successConfirmVnfAndClosePopup(); }); @@ -146,7 +177,7 @@ public class ALaCarteflowTest extends CreateInstanceDialogBaseTest { @Test private void emptyLobAfterReopenCreateVnfDialog() throws Exception { - final String lobToSelect = "ECOMP"; + final String lobToSelect = "ONAP"; goToInstance(); ViewEditPage viewEditPage = new ViewEditPage(); viewEditPage.selectNodeInstanceToAdd(NODE_INSTANCE); @@ -164,20 +195,30 @@ public class ALaCarteflowTest extends CreateInstanceDialogBaseTest { withMsoTestApiConfiguration(msoTestApiOption, msoTestApiValue, () -> { final String REQUEST_ID = "dbe54591-c8ed-46d3-abc7-d3a24873bdaa"; final String MODEL_UUID = "13f022c4-651e-4326-b8e1-61e9a8c7a7ad"; - SimulatorApi.registerExpectation("aLacarteFlow/mso_create_volume_group.json", ImmutableMap.of(SERVICE_INSTANCE_ID, SERVICE_ID, "VNF_INSTANCE_ID", VNF_ID, "REQUEST_ID", REQUEST_ID, DEFAULT_TEST_API_VALUE, msoTestApiValue), SimulatorApi.RegistrationStrategy.APPEND); + String vgName = viewEditPage.generateInstanceName(Constants.ViewEdit.VOLUME_GROUP_INSTANCE_NAME_PREFIX); + SimulatorApi.registerExpectationFromPresets(ImmutableList.of( + PRESET_SOME_LEGACY_REGION_TO_ATT_AIC, + new PresetMSOCreateVolumeGroupOldViewEdit( + REQUEST_ID, + BaseMSOPreset.DEFAULT_INSTANCE_ID, + SERVICE_ID, + VNF_ID, + vgName, + msoTestApiValue)), + SimulatorApi.RegistrationStrategy.APPEND); SimulatorApi.registerExpectation(A_LACARTE_FLOW_GET_ORCHESTRATION, ImmutableMap.of(ORCHESTRATION_REQUEST_ID, REQUEST_ID, STATUS_MESSAGE, Constants.ViewEdit.VOLUME_GROUP_CREATED_SUCCESSFULLY_TEXT, REQUEST_TYPE, CREATE), SimulatorApi.RegistrationStrategy.APPEND); GeneralUIUtils.ultimateWait(); goToInstance(); ServiceModel serviceInstance = new ServicesService().getServiceModel(MODEL_UUID); - addVolumeGroup("Vsp1710pid298109Vmmsc..mmsc_mod6_eca_oam..module-3", AAIAIC_25, TENANT, - FALSE, LEGACY_REGION, getCurrentUser().tenants, serviceInstance); + addVolumeGroup("Vsp1710pid298109Vmmsc..mmsc_mod6_eca_oam..module-3", vgName, AAIAIC_25, AIC, TENANT, + FALSE, SOME_LEGACY_REGION, getCurrentUser().tenants, serviceInstance); }); } private User getCurrentUser() { - return usersService.getUser(Constants.Users.MOBILITY_VMMSC); + return usersService.getUser(Constants.Users.EMANUEL_vWINIFRED); } private void goToInstance() { @@ -189,14 +230,14 @@ public class ALaCarteflowTest extends CreateInstanceDialogBaseTest { @Override protected UserCredentials getUserCredentials() { User user = getCurrentUser(); - return new UserCredentials(user.credentials.userId, user.credentials.password, Constants.Users.MOBILITY_VMMSC, "", ""); + return new UserCredentials(user.credentials.userId, user.credentials.password, Constants.Users.EMANUEL_vWINIFRED, "", ""); } @DataProvider public static Object[][] msoTestApiOptions() { return new Object[][]{ - {"GR_API (new)", DEFAULT_TEST_API_VALUE} - , {"VNF_API (old)", "VNF_API"} + {"VNF_API (old)", DEFAULT_TEST_API_VALUE} + , {"GR_API (new)", "GR_API"} }; } @@ -209,7 +250,7 @@ public class ALaCarteflowTest extends CreateInstanceDialogBaseTest { test.run(); } finally { // back to default - selectMsoTestApiOption("GR_API (new)"); + selectMsoTestApiOption("VNF_API (old)"); } } } diff --git a/vid-automation/src/main/java/vid/automation/test/test/AddNetworkTest.java b/vid-automation/src/main/java/vid/automation/test/test/AddNetworkTest.java index 0251e365c..d53b5011a 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/AddNetworkTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/AddNetworkTest.java @@ -1,6 +1,13 @@ package vid.automation.test.test; -import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; +import com.google.common.collect.ImmutableList; +import java.util.HashMap; +import java.util.Map; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateInstancePost; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateNetworkALaCarteOldViewEdit; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet; import org.testng.annotations.Test; import vid.automation.test.Constants; import vid.automation.test.model.User; @@ -8,27 +15,37 @@ import vid.automation.test.sections.ViewEditPage; import vid.automation.test.services.BulkRegistration; import vid.automation.test.services.SimulatorApi; -import java.util.HashMap; -import java.util.Map; - public class AddNetworkTest extends VidBaseTestCase { private ViewEditPage viewEditPage = new ViewEditPage(); private String serviceInstanceIdWithNetwork = "d198cc45-158b-480e-8d2c-03943c51268e"; - private String currentUser; @Test - public void testAddNetworkFullFlow() throws Exception { - User user = usersService.getUser(Constants.Users.MOBILITY_MOBILITY); + public void testAddNetworkFullFlow() { + User user = usersService.getUser(Constants.Users.EMANUEL_EMANUEL); SimulatorApi.clearAll(); BulkRegistration.genericSearchExistingServiceInstance(); BulkRegistration.addNetwork(); String instanceName = viewEditPage.generateInstanceName(Constants.ViewEdit.NETWORK_INSTANCE_NAME_PREFIX); - BulkRegistration.msoAddNetwork(instanceName); + SimulatorApi.registerExpectationFromPresets( + ImmutableList.of( + PresetAAIGetCloudOwnersByCloudRegionId.PRESET_ONE_TO_ATT_AIC, + new PresetMSOCreateNetworkALaCarteOldViewEdit( + PresetMSOBaseCreateInstancePost.DEFAULT_REQUEST_ID, + "d198cc45-158b-480e-8d2c-03943c51268e", + "c187e9fe-40c3-4862-b73e-84ff056205f6", + instanceName + ), + new PresetMSOOrchestrationRequestGet( + PresetMSOOrchestrationRequestGet.COMPLETE, + PresetMSOOrchestrationRequestGet.DEFAULT_REQUEST_ID, + "Success")), + SimulatorApi.RegistrationStrategy.APPEND); + goToExistingInstanceById(serviceInstanceIdWithNetwork); Map<String, String> networkMetadata= getNetworkExpectedMetadata(); - addNetwork(networkMetadata,instanceName, "AIC30_CONTRAIL_BASIC 0", "One","a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb","xxx1", "y1","c630e297a3ae486497d63eacec1d7c14", + addNetwork(networkMetadata,instanceName, "AIC30_CONTRAIL_BASIC 0", "One", "FUSION", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb","xxx1", "y1","c630e297a3ae486497d63eacec1d7c14", "false", "some legacy region",user.tenants); } @@ -36,7 +53,7 @@ public class AddNetworkTest extends VidBaseTestCase { return new HashMap<String, String>(){ { put(Constants.NetworkModelInfo.SERVICE_NAME, "Using VID for VoIP Network Instantiations Shani"); - put(Constants.NetworkModelInfo.SUBSCRIBER_NAME, "Mobility"); + put(Constants.NetworkModelInfo.SUBSCRIBER_NAME, "Emanuel"); put(Constants.NetworkModelInfo.SERVICE_INSTANCE_NAME, "service_with_network_shani"); put(Constants.NetworkModelInfo.MODEL_NAME, "AIC30_CONTRAIL_BASIC"); put(Constants.NetworkModelInfo.MODEL_INVARIANT_UUID, "de01afb5-532b-451d-aac4-ff9ff0644060"); @@ -49,7 +66,7 @@ public class AddNetworkTest extends VidBaseTestCase { @Override protected UserCredentials getUserCredentials() { - User user = usersService.getUser(Constants.Users.MOBILITY_MOBILITY); - return new UserCredentials(user.credentials.userId, user.credentials.password, Constants.Users.MOBILITY_MOBILITY, "", ""); + User user = usersService.getUser(Constants.Users.EMANUEL_EMANUEL); + return new UserCredentials(user.credentials.userId, user.credentials.password, Constants.Users.EMANUEL_EMANUEL, "", ""); } } diff --git a/vid-automation/src/main/java/vid/automation/test/test/AssociatePnfTest.java b/vid-automation/src/main/java/vid/automation/test/test/AssociatePnfTest.java index 5ee961215..7bec56013 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/AssociatePnfTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/AssociatePnfTest.java @@ -1,12 +1,14 @@ package vid.automation.test.test; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import vid.automation.test.Constants; import vid.automation.test.infra.Wait; import vid.automation.test.sections.PnfSearchAssociationPage; +import vid.automation.test.sections.SideMenu; import vid.automation.test.sections.VidBasePage; import vid.automation.test.sections.ViewEditPage; import vid.automation.test.services.BulkRegistration; @@ -21,6 +23,11 @@ public class AssociatePnfTest extends VidBaseTestCase { private String pnfInstanceName = "MX_960-F722"; private String pnfModelName = "pnf 0"; + @BeforeMethod + public void navigateToWelcomePage() { + SideMenu.navigateToWelcomePage(); + } + @Test public void testAssociatePnf() throws Exception { SimulatorApi.clearAll(); @@ -132,7 +139,7 @@ public class AssociatePnfTest extends VidBaseTestCase { //ubscriber NameModel Invariant UUID elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.SUBSCRIBER_NAME_KEY; infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); - Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"USP VOICE"); + Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"SILVIA ROBBINS"); //Model Version elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.MODEL_VERSION; infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); diff --git a/vid-automation/src/main/java/vid/automation/test/test/BrowseASDCTest.java b/vid-automation/src/main/java/vid/automation/test/test/BrowseASDCTest.java index 4f055fe29..2b5a09823 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/BrowseASDCTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/BrowseASDCTest.java @@ -1,83 +1,82 @@ package vid.automation.test.test; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static vid.automation.test.infra.Features.FLAG_5G_IN_NEW_INSTANTIATION_UI; +import static vid.automation.test.infra.ModelInfo.aLaCarteForBrowseSdc; +import static vid.automation.test.infra.ModelInfo.aLaCarteServiceCreationTest; +import static vid.automation.test.infra.ModelInfo.instantiationTypeAlacarte_vidNotionsInstantiationUIByUUID; +import static vid.automation.test.infra.ModelInfo.macroForBrowseSdc; + import com.google.common.collect.ImmutableList; -import org.glassfish.jersey.uri.internal.JerseyUriBuilder; +import java.util.List; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.hamcrest.Matchers; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset; -import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetServiceModelList; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetServicesGet; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIServiceDesignAndCreationPut; import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet; -import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; -import org.springframework.http.client.ClientHttpRequestInterceptor; -import org.springframework.web.client.RestTemplate; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import vid.automation.test.Constants; -import vid.automation.test.infra.*; +import vid.automation.test.infra.Click; +import vid.automation.test.infra.Exists; +import vid.automation.test.infra.FeatureTogglingTest; +import vid.automation.test.infra.Features; +import vid.automation.test.infra.Get; +import vid.automation.test.infra.ModelInfo; +import vid.automation.test.infra.SelectOption; import vid.automation.test.model.Service; import vid.automation.test.model.User; -import vid.automation.test.sections.*; +import vid.automation.test.sections.BrowseASDCPage; +import vid.automation.test.sections.DeployMacroDialogBase; +import vid.automation.test.sections.DeployMacroDialogOld; +import vid.automation.test.sections.SideMenu; +import vid.automation.test.sections.ViewEditPage; import vid.automation.test.services.ServicesService; import vid.automation.test.services.SimulatorApi; -import vid.automation.test.utils.CookieAndJsonHttpHeadersInterceptor; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.List; - -import static java.util.Collections.singletonList; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; public class BrowseASDCTest extends CreateInstanceDialogBaseTest { - private final String invariantUUIDAlacarte = "a8dcd72d-d44d-44f2-aa85-53aa9ca99cba"; - private final String invariantUUIDMacro = "d27e42cf-087e-4d31-88ac-6c4b7585f800"; + private final String invariantUUIDAlacarte = aLaCarteForBrowseSdc.modelInvariantId; + private final String invariantUUIDMacro = macroForBrowseSdc.modelInvariantId; private final String instantiationTypeNameAlacarte = "a la carte"; private final String instantiationTypeNameMacro = "macro"; private final String oldMacro = "old macro"; - private String modelInvariantUUID1 = "aeababbc-010b-4a60-8df7-e64c07389466"; - private String modelInvariantUUID2 = "aa2f8e9c-9e47-4b15-a95c-4a9385599abc"; - private String modelInvariantUUID3 = "d849c57d-b6fe-4843-8349-4ab8bbb08d71"; - private String modelUuid = "a8dcd72d-d44d-44f2-aa85-53aa9ca99cba"; - protected final RestTemplate restTemplate = new RestTemplate(); + private final String newAlacarte = "new a la carte"; + public static final String modelInvariantUUID1 = "aeababbc-010b-4a60-8df7-e64c07389466"; + public static final String modelInvariantUUID2 = "aa2f8e9c-9e47-4b15-a95c-4a9385599abc"; + public static final String modelInvariantUUID3 = "d849c57d-b6fe-4843-8349-4ab8bbb08d71"; + public static final String modelUuid = "a8dcd72d-d44d-44f2-aa85-53aa9ca99cba"; private ServicesService servicesService = new ServicesService(); - final URI envUrI; - protected final URI uri; - public BrowseASDCTest() throws URISyntaxException { - this.envUrI = new URI(System.getProperty("ENV_URL")); - this.uri = new JerseyUriBuilder().host(envUrI.getHost()).port(envUrI.getPort()).scheme("http").path("vid").build(); - } + private final Logger logger = LogManager.getLogger(BrowseASDCTest.class); @BeforeClass - public void login() { - UserCredentials userCredentials = getUserCredentials(); - final List<ClientHttpRequestInterceptor> interceptors = singletonList(new CookieAndJsonHttpHeadersInterceptor(uri, userCredentials)); - restTemplate.setInterceptors(interceptors); + public void beforeClass() { + resetGetServicesCache(); } @BeforeMethod - public void invalidateTheCacheSelenium() { - if (Features.FLAG_SERVICE_MODEL_CACHE.isActive()) { - restTemplate.postForObject(uri + "/rest/models/reset", "", Object.class); - } + public void resetSdcModelCaches() { + invalidateSdcModelsCache(); } @Override protected UserCredentials getUserCredentials() { - User user = usersService.getUser(Constants.Users.MOBILITY_MOBILITY); - return new UserCredentials(user.credentials.userId, user.credentials.password, Constants.Users.MOBILITY_MOBILITY, "", ""); + User user = usersService.getUser(Constants.Users.EMANUEL_EMANUEL); + return new UserCredentials(user.credentials.userId, user.credentials.password, Constants.Users.EMANUEL_EMANUEL, "", ""); } @Test(groups = {"shouldBeMigratedToWorkWithSimulator"}) @@ -87,7 +86,7 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { SideMenu.navigateToBrowseASDCPage(); browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid); assertThatServiceCreationDialogIsVisible(); - validatePNFCreationDialog(service, "Mobility", "pnf"); + validatePNFCreationDialog(service, "Emanuel", "pnf"); } private void validatePNFCreationDialog(Service service, String serviceType, String serviceRole) { @@ -103,7 +102,7 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { @Test(groups = {"shouldBeMigratedToWorkWithSimulator"}) private void testPNFMacroInstantation() throws Exception { - User user = usersService.getUser(Constants.Users.MOBILITY_MOBILITY); + User user = usersService.getUser(Constants.Users.EMANUEL_EMANUEL); relogin(user.credentials); BrowseASDCPage browseASDCPage = new BrowseASDCPage(); @@ -115,9 +114,9 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { browseASDCPage.selectProductFamily("ebc3bc3d-62fd-4a3f-a037-f619df4ff034"); GeneralUIUtils.ultimateWait(); - browseASDCPage.selectServiceTypeByName("Mobility"); + browseASDCPage.selectServiceTypeByName("Emanuel"); GeneralUIUtils.ultimateWait(); - browseASDCPage.selectLcpRegion("mtn16"); + browseASDCPage.selectLcpRegion("hvf16"); browseASDCPage.selectTenant("a259ae7b7c3f493cb3d91f95a7c18149"); assertAllIsPermitted(Constants.BrowseASDC.AIC_OPTION_CLASS); @@ -136,15 +135,6 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { viewEditPage.clickActivateButton(); } -// @Test -// private void browseServiceModel_deployServiceUnexpectedDeploymentMode_creationPopupIsMacro() throws Exception { -// deployServiceAndAssertInstantiationType( -// "don't know.zip", -// "a8dcd72d-d44d-44f2-aa85-53aa9ca99cba", -// "macro" -// ); -// } - @Test private void browseServiceModel_deployServiceALaCarteByBackendInput_creationPopupIsALaCarte() throws Exception { // model uuid should be of macro @@ -156,6 +146,15 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { } @Test + @FeatureTogglingTest(FLAG_5G_IN_NEW_INSTANTIATION_UI) + private void browseServiceModel_deployServiceALaCarteByBackendInputHintNewUI_creationPopupIsAngular2() throws Exception { + deployServiceAndAssertInstantiationType( + instantiationTypeAlacarte_vidNotionsInstantiationUIByUUID, + newAlacarte + ); + } + + @Test private void browseServiceModel_deployServiceALaCarteBecauseNotOnMACRO_SERVICESConfig_creationPopupIsALaCarte() throws Exception { deployServiceAndAssertInstantiationType( "csar15782222_instantiationTypeEmpty_invariantUUIDAlacarte.zip", @@ -167,7 +166,7 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { @Test private void browseServiceModel_deployServiceMacroByBackendInput_creationPopupIsMacro() throws Exception { deployServiceAndAssertInstantiationType( - "csar15782222_instantiationTypeMacro_invariantUUIDAlacarte.zip", + "csar15782222_instantiationTypeMacro_invariantUUIDAlacarte_withoutNetworks.zip", invariantUUIDAlacarte, instantiationTypeNameMacro ); @@ -215,17 +214,20 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { private void deployServiceAndAssertInstantiationType(String modelZipFileName, String modelInvariantId, String expectedInstantiationType) throws Exception { - String modelVersionId = "4d71990b-d8ad-4510-ac61-496288d9078e"; + deployServiceAndAssertInstantiationType(new ModelInfo("4d71990b-d8ad-4510-ac61-496288d9078e", modelInvariantId, modelZipFileName), expectedInstantiationType); + } - registerExpectationForLegacyServiceDeployment(modelVersionId, modelInvariantId, modelZipFileName, null); - User user = usersService.getUser(Constants.Users.MOBILITY_MOBILITY); + private void deployServiceAndAssertInstantiationType(ModelInfo modelInfo, String expectedInstantiationType) throws Exception { + + registerExpectationForLegacyServiceDeployment(modelInfo, "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + User user = usersService.getUser(Constants.Users.EMANUEL_EMANUEL); relogin(user.credentials); BrowseASDCPage browseASDCPage = new BrowseASDCPage(); SideMenu.navigateToBrowseASDCPage(); GeneralUIUtils.ultimateWait(); - browseASDCPage.clickDeployServiceButtonByServiceUUID(modelVersionId); + browseASDCPage.clickDeployServiceButtonByServiceUUID(modelInfo.modelVersionId); DeployMacroDialogBase macroDialog = null; if (expectedInstantiationType.equals(instantiationTypeNameAlacarte)) { GeneralUIUtils.ultimateWait(); @@ -239,28 +241,26 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { @Test private void testServiceInstantiationAlaCarte() throws Exception { - User user = usersService.getUser(Constants.Users.MOBILITY_MOBILITY); + User user = usersService.getUser(Constants.Users.EMANUEL_EMANUEL); relogin(user.credentials); - String zipFileName = "serviceCreationTest.zip"; - String modelVersionId = "aa2f8e9c-9e47-4b15-a95c-4a9385599abc"; //uuid of model. must be same as in serviceCreationTest.zip - String modelInvariantId = invariantUUIDAlacarte; //must be same as in serviceCreationTest.zip - - registerExpectationForLegacyServiceDeployment(modelVersionId, modelInvariantId, zipFileName, null); + registerExpectationForLegacyServiceDeployment(aLaCarteServiceCreationTest, "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); BrowseASDCPage browseASDCPage = new BrowseASDCPage(); SideMenu.navigateToBrowseASDCPage(); Service service = new Service( "pnf", - modelVersionId, - modelInvariantId, + aLaCarteServiceCreationTest.modelVersionId, + aLaCarteServiceCreationTest.modelInvariantId, "action-data", "1.0", "Network L1-3", - "ADIOD vMX vPE based on Juniper 17.2 release. Updated with updated VF for v8.0 of VLM", + "PASQUALE vMX vPE based on Juniper 17.2 release. Updated with updated VF for v8.0 of VLM", null); + + logger.info("Expected service model properties: "+service.toString()); browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid); validateServiceCreationDialog(service); @@ -269,7 +269,7 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS); browseASDCPage.selectSubscriberById("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); - String serviceType = "Mobility"; + String serviceType = "Emanuel"; GeneralUIUtils.findAndWaitByText(serviceType, 30); assertDropdownPermittedItemsByValue(user.serviceTypes, Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS); @@ -297,14 +297,7 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { @Test(dataProvider = "filterTexts") public void testFilterOptionsInBrowseSdc(String filterText){ - SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.APPEND, - "ecompportal_getSessionSlotCheckInterval.json", - "browseASDC/aai_get_services.json", - "browseASDC/get_aai_get_subscribers.json", - "browseASDC/get_sdc_catalog_services_2f80c596.json", - "browseASDC/service_design_and_creation.json"); - SideMenu.navigateToBrowseASDCPage(); - BrowseASDCPage browseAsdcPage = new BrowseASDCPage(); + BrowseASDCPage browseAsdcPage = registerSimulatorAndGoToBrowseSDC(); GeneralUIUtils.ultimateWait(); assertThat(browseAsdcPage.countCurrentRowsInTable(),(Matchers.greaterThan(1))); browseAsdcPage.fillFilterText(filterText); @@ -316,16 +309,7 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { @Test private void testCategoryParamsDropdownsExistsInCreationDialog() throws Exception { - SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.APPEND, - "ecompportal_getSessionSlotCheckInterval.json", - "browseASDC/aai_get_services.json", - "browseASDC/get_aai_get_subscribers.json", - "browseASDC/get_sdc_catalog_services_2f80c596.json", - "browseASDC/service_design_and_creation.json"); - User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); - relogin(user.credentials); - BrowseASDCPage browseASDCPage = new BrowseASDCPage(); - SideMenu.navigateToBrowseASDCPage(); + BrowseASDCPage browseASDCPage = registerSimulatorAndGoToBrowseSDC(); Service service = servicesService.getService("2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"); browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid); DeployMacroDialogBase deployMacroDialog = getMacroDialog(); @@ -334,9 +318,24 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { deployMacroDialog.clickOwningEntitySelect(); } + private BrowseASDCPage registerSimulatorAndGoToBrowseSDC() { + SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET, + "ecompportal_getSessionSlotCheckInterval.json", + "browseASDC/aai_get_services.json", + "browseASDC/get_sdc_catalog_services_2f80c596.json" + ); + SimulatorApi.registerExpectationFromPresets(ImmutableList.of( + new PresetAAIGetSubscribersGet(), + new PresetAAIServiceDesignAndCreationPut() + ), + SimulatorApi.RegistrationStrategy.APPEND); + SideMenu.navigateToBrowseASDCPage(); + return new BrowseASDCPage(); + } + @Test(groups = {"shouldBeMigratedToWorkWithSimulator"}) private void testOwningEntityRequiredAndProjectOptional() throws Exception { - User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + User user = usersService.getUser(Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA); relogin(user.credentials); BrowseASDCPage browseASDCPage = new BrowseASDCPage(); @@ -352,7 +351,7 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS); browseASDCPage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89"); - String serviceType = "VIRTUAL USP"; + String serviceType = "TYLER SILVIA"; GeneralUIUtils.findAndWaitByText(serviceType, 30); assertDropdownPermittedItemsByValue(user.serviceTypes, Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS); @@ -371,7 +370,7 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { @Test(groups = {"shouldBeMigratedToWorkWithSimulator"}) protected void testLineOfBusinessOptionalAndPlatformRequired() throws Exception { - User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + User user = usersService.getUser(Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA); relogin(user.credentials); BrowseASDCPage browseASDCPage = new BrowseASDCPage(); @@ -387,7 +386,7 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS); browseASDCPage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89"); - String serviceType = "VIRTUAL USP"; + String serviceType = "TYLER SILVIA"; GeneralUIUtils.findAndWaitByText(serviceType, 30); assertDropdownPermittedItemsByValue(user.serviceTypes, Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS); @@ -404,10 +403,10 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { //now add the VNF ViewEditPage viewEditPage = new ViewEditPage(); - viewEditPage.selectNodeInstanceToAdd("VID-PCRF-05-15-17 0"); + viewEditPage.selectNodeInstanceToAdd("VID-RODERICK-05-15-17 0"); viewEditPage.generateAndSetInstanceName(Constants.ViewEdit.VNF_INSTANCE_NAME_PREFIX); viewEditPage.selectProductFamily("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); - viewEditPage.selectLCPRegion("AAIAIC25"); + viewEditPage.selectLcpRegion("JANET25", "AIC"); viewEditPage.selectTenant("092eb9e8e4b7412e8787dd091bc58e86"); viewEditPage.setLegacyRegion("llkjhlkjhlkjh"); @@ -427,7 +426,7 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { ImmutableList<BasePreset> presets = ImmutableList.of( new PresetGetSessionSlotCheckIntervalGet(), new PresetAAIGetSubscribersGet(), - new PresetAAIGetServiceModelList(modelUuid, modelInvariantUUID1, modelInvariantUUID2, modelInvariantUUID3), + new PresetAAIServiceDesignAndCreationPut(), new PresetAAIGetServicesGet()); SimulatorApi.registerExpectationFromPresets(presets, SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET); @@ -437,6 +436,8 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { private void browseSDCServiceModelListCheckAAIResponse(){ prepareSimulatorWithServiceModelListBeforeBrowseASDCService(); SideMenu.navigateToBrowseASDCPage(); + BrowseASDCPage browseASDCPage = new BrowseASDCPage(); + browseASDCPage.fillFilterText("CheckAAIResponse"); GeneralUIUtils.ultimateWait(); WebElement sdcTableElement = Get.byId("sdcModelsTable"); @@ -460,9 +461,9 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { //Check Names By name = By.className("name"); - assertEquals("AAAvIRC_mm779p_Service" , sdcFirstModel.findElement(name).getText()); - assertEquals("BBBvIRC_mm779p_Service" , sdcSecondModel.findElement(name).getText()); - assertEquals("CCCvIRC_mm779p_Service" , sdcThirdModel.findElement(name).getText()); + assertEquals("CheckAAIResponse_AAAvIRC_mm779p_Service" , sdcFirstModel.findElement(name).getText()); + assertEquals("CheckAAIResponse_BBBvIRC_mm779p_Service" , sdcSecondModel.findElement(name).getText()); + assertEquals("CheckAAIResponse_CCCvIRC_mm779p_Service" , sdcThirdModel.findElement(name).getText()); //Check distribution Status By distributionStatus = By.className("distributionStatus"); @@ -474,8 +475,10 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { assertEquals("service" , sdcFirstModel.findElement(By.className("category")).getText()); assertEquals("1.0" , sdcFirstModel.findElement(By.className("version")).getText()); } + @Test - public void browseSdcModel_getEmptyList_noModelsMessageIsShown() throws Exception { + public void browseSdcModel_getEmptyList_noModelsMessageIsShown() { + resetGetServicesCache(); SimulatorApi.clearAll(); SimulatorApi.registerExpectationFromPresets(ImmutableList.of( new PresetAAIServiceDesignAndCreationPut(true), @@ -484,5 +487,6 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest { GeneralUIUtils.ultimateWait(); WebElement serviceModelsTbody = Get.byXpath("//table[@data-tests-id='serviceModelsTable']/tbody"); assertFalse(Exists.tagNameInAnotherElement(serviceModelsTbody, "tr"), "Table should be empty on empty results"); + resetGetServicesCache(); } } diff --git a/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java b/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java index eadf38f4f..179eb968c 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java @@ -1,42 +1,54 @@ package vid.automation.test.test; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.everyItem; +import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.collection.IsEmptyCollection.empty; +import static org.hamcrest.core.IsNot.not; + import com.google.common.collect.ImmutableMap; import com.google.common.primitives.Ints; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.json.JSONException; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.remote.RemoteWebElement; import org.openqa.selenium.support.ui.Select; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; -import org.testng.annotations.*; +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; import vid.automation.test.Constants; -import vid.automation.test.infra.*; +import vid.automation.test.infra.Click; +import vid.automation.test.infra.Exists; +import vid.automation.test.infra.Get; +import vid.automation.test.infra.Input; +import vid.automation.test.infra.SelectOption; +import vid.automation.test.infra.Wait; import vid.automation.test.model.User; import vid.automation.test.sections.ChangeManagementPage; import vid.automation.test.services.SimulatorApi; import vid.automation.test.utils.DB_CONFIG; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.collection.IsEmptyCollection.empty; -import static org.hamcrest.core.IsNot.not; - public class ChangeManagementTest extends VidBaseTestCase { public static final String SCHEDULED_ID = "0b87fe60-50b0-4bac-a0a7-49e951b0ba9e"; @@ -119,16 +131,19 @@ public class ChangeManagementTest extends VidBaseTestCase { static final int vnfZrdm3amdns02test2Id = 11822; static final int vnfHarrisonKrisId = 12822; static String subscriberId = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"; - static String serviceType = "vFlowLogic"; + static String serviceType = "vRichardson"; static String vnfType = "vMobileDNS"; static String vnfSourceVersion = "1.0"; - static String vnfName = "zrdm3amdns02test2"; + static String vnfName = "zolson3amdns02test2"; static String vnfTargetVersion = "5.0"; static String workflowName = "VNF In Place Software Update"; } @AfterClass protected void dropSpecialVNFs() { + + resetGetServicesCache(); + System.out.println("Connecting database..."); try (Connection connection = DriverManager.getConnection(DB_CONFIG.url, DB_CONFIG.username, DB_CONFIG.password)) { @@ -154,7 +169,6 @@ public class ChangeManagementTest extends VidBaseTestCase { SimulatorApi.clearAll(); SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.APPEND, "changeManagement/ecompportal_getSessionSlotCheckInterval.json" - , "changeManagement/get_aai_get_subscribers.json" , "changeManagement/get_aai_sub_details.json" , "changeManagement/get_sdc_catalog_services_2f80c596.json" , "changeManagement/get_service-design-and-creation.json" @@ -163,8 +177,10 @@ public class ChangeManagementTest extends VidBaseTestCase { , "changeManagement/mso_get_manual_task.json" , "changeManagement/mso_post_manual_task.json" ); + SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(),SimulatorApi.RegistrationStrategy.APPEND); registerDefaultTablesData(); + resetGetServicesCache(); } private void registerDefaultTablesData() { @@ -217,7 +233,7 @@ public class ChangeManagementTest extends VidBaseTestCase { @Override protected UserCredentials getUserCredentials() { - String userName = Constants.Users.MOBILITY_VMMSC; + String userName = Constants.Users.EMANUEL_vWINIFRED; User user = usersService.getUser(userName); return new UserCredentials(user.credentials.userId, user.credentials.password, userName, "", ""); } @@ -520,11 +536,24 @@ public class ChangeManagementTest extends VidBaseTestCase { Click.byId(Constants.ChangeManagement.dashboardFinishedTabId); Assert.assertTrue(Exists.byId(Constants.ChangeManagement.dashboardFinishedTableId)); Assert.assertTrue(Exists.byId(Constants.ChangeManagement.dashboardFinishedTheadId)); + Click.byId(Constants.ChangeManagement.dashboardActiveTabId); } @Test - public void testMainDashboardTableContent() { + public void testFinishedSectionIncludeUnlockedItem() { + ChangeManagementPage.openChangeManagementPage(); + Click.byId(Constants.ChangeManagement.dashboardFinishedTabId); + Assert.assertThat(Get.byClassAndText("vnf-name","Unlocked instance"),is(notNullValue())); + + } + + + + + + @Test + public void testMainDashboardTableContent () { ChangeManagementPage.openChangeManagementPage(); GeneralUIUtils.ultimateWait(); List<WebElement> webElements = Get.multipleElementsByTestId(Constants.ChangeManagement.activeTableRowId); diff --git a/vid-automation/src/main/java/vid/automation/test/test/CreateInstanceDialogBaseTest.java b/vid-automation/src/main/java/vid/automation/test/test/CreateInstanceDialogBaseTest.java index b486d27df..0837f79ca 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/CreateInstanceDialogBaseTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/CreateInstanceDialogBaseTest.java @@ -1,7 +1,7 @@ package vid.automation.test.test; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; import vid.automation.test.Constants; import vid.automation.test.infra.Click; @@ -17,7 +17,7 @@ import java.util.List; public class CreateInstanceDialogBaseTest extends VidBaseTestCase { - private ViewEditPage viewEditPage= new ViewEditPage(); + protected ViewEditPage viewEditPage= new ViewEditPage(); void assertServiceMetadata(String expectedMetadata, String actualMetadata) { WebElement serviceNameElem = GeneralUIUtils.getWebElementByTestID(actualMetadata); @@ -67,18 +67,11 @@ public class CreateInstanceDialogBaseTest extends VidBaseTestCase { assertServiceMetadata(expectedServiceInstance.modelCustomizationUuid, Constants.CreateNewInstance.MODEL_CUSTOMIZATION_UUID); } - private String fillDetailsInDialogWithGeneratedName(String name, String lcpRegion, String tenant, String suppressRollback, - String legacyRegion, ArrayList<String> permittedTenants) - { - String generatedInstanceName = viewEditPage.generateInstanceName(name); - return fillDetailsInDialog(generatedInstanceName, lcpRegion, tenant, suppressRollback, legacyRegion, permittedTenants); - } - - private String fillDetailsInDialog(String name, String lcpRegion, String tenant, String suppressRollback, + private String fillDetailsInDialog(String name, String lcpRegion, String cloudOwner, String tenant, String suppressRollback, String legacyRegion, ArrayList<String> permittedTenants) { viewEditPage.setInstanceName(name); - viewEditPage.selectLCPRegion(lcpRegion); + viewEditPage.selectLcpRegion(lcpRegion, cloudOwner); assertDropdownPermittedItemsByValue(permittedTenants, Constants.ViewEdit.TENANT_OPTION_CLASS); viewEditPage.selectTenant(tenant); viewEditPage.selectSuppressRollback(suppressRollback); @@ -87,13 +80,13 @@ public class CreateInstanceDialogBaseTest extends VidBaseTestCase { } - protected String addVFModule(String name, String lcpRegion, String tenant, String suppressRollback, + protected String addVFModule(String modelName, String instanceName, String lcpRegion, String cloudOwner, String tenant, String suppressRollback, String legacyRegion, ArrayList<String> permittedTenants,ServiceModel expectedServiceInstance) { - viewEditPage.selectVfModuleToAdd(name); + viewEditPage.selectVfModuleToAdd(modelName); if(expectedServiceInstance != null) { validateNodeTemplateCreationDialog(expectedServiceInstance); } - String instanceName = fillDetailsInDialogWithGeneratedName(Constants.INSTANCE_NAME_SELECT_TESTS_ID, lcpRegion, tenant, suppressRollback, legacyRegion, permittedTenants); + fillDetailsInDialog(instanceName, lcpRegion, cloudOwner, tenant, suppressRollback, legacyRegion, permittedTenants); viewEditPage.clickConfirmButton(); assertSuccessfulVFModuleCreation(); viewEditPage.clickCloseButton(); @@ -101,28 +94,28 @@ public class CreateInstanceDialogBaseTest extends VidBaseTestCase { return instanceName; } - protected void addVolumeGroup (String name, String lcpRegion, String tenant, String suppressRollback, + protected void addVolumeGroup (String modelName, String instanceName, String lcpRegion, String cloudOwner, String tenant, String suppressRollback, String legacyRegion, ArrayList<String> permittedTenants, ServiceModel expectedServiceInstance) { - viewEditPage.selectVolumeGroupToAdd(name); + viewEditPage.selectVolumeGroupToAdd(modelName); if(expectedServiceInstance != null) { validateNodeTemplateCreationDialog(expectedServiceInstance); } - fillDetailsInDialogWithGeneratedName(Constants.ViewEdit.VOLUME_GROUP_INSTANCE_NAME_PREFIX, lcpRegion, tenant, suppressRollback, legacyRegion, permittedTenants); + fillDetailsInDialog(instanceName, lcpRegion, cloudOwner, tenant, suppressRollback, legacyRegion, permittedTenants); viewEditPage.clickConfirmButton(); assertSuccessfulVolumeGroupCreation(); viewEditPage.clickCloseButton(); GeneralUIUtils.ultimateWait(); } - protected void addVNF(String name, String lcpRegion, String tenant, String suppressRollback, + protected void addVNF(String name, String lcpRegion, String cloudOwner, String tenant, String suppressRollback, String legacyRegion, String productFamily, String platform, ArrayList<String> permittedTenants, List<String> lobs, ServiceModel serviceModel, String instanceName) { - openAndFillVnfPopup(name, lcpRegion, tenant, suppressRollback, legacyRegion, productFamily, platform,permittedTenants, lobs, serviceModel, instanceName); + openAndFillVnfPopup(name, lcpRegion, cloudOwner, tenant, suppressRollback, legacyRegion, productFamily, platform,permittedTenants, lobs, serviceModel, instanceName); viewEditPage.clickConfirmButton(); successConfirmVnfAndClosePopup(); } - protected void openAndFillVnfPopup(String name, String lcpRegion, String tenant, String suppressRollback, + protected void openAndFillVnfPopup(String name, String lcpRegion, String cloudOwner, String tenant, String suppressRollback, String legacyRegion, String productFamily, String platform, ArrayList<String> permittedTenants, List<String> lobs, ServiceModel serviceModel, String instanceName) { viewEditPage.selectNodeInstanceToAdd(name); GeneralUIUtils.ultimateWait(); @@ -139,7 +132,7 @@ public class CreateInstanceDialogBaseTest extends VidBaseTestCase { if(lobs != null) { SelectOption.selectOptionsFromMultiselectById(Constants.OwningEntity.LOB_SELECT_TEST_ID, lobs); } - fillDetailsInDialog(instanceName, lcpRegion, tenant, suppressRollback, legacyRegion, permittedTenants); + fillDetailsInDialog(instanceName, lcpRegion, cloudOwner, tenant, suppressRollback, legacyRegion, permittedTenants); } protected void successConfirmVnfAndClosePopup() { diff --git a/vid-automation/src/main/java/vid/automation/test/test/CreateNewInstanceTest.java b/vid-automation/src/main/java/vid/automation/test/test/CreateNewInstanceTest.java index 55a1e22ce..bb13514bf 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/CreateNewInstanceTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/CreateNewInstanceTest.java @@ -1,6 +1,8 @@ package vid.automation.test.test; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import java.io.IOException; +import java.util.List; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; import org.testng.Assert; import org.testng.annotations.Test; @@ -16,11 +18,6 @@ import vid.automation.test.services.BulkRegistration; import vid.automation.test.services.ServicesService; import vid.automation.test.services.SimulatorApi; -import java.io.IOException; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.List; - public class CreateNewInstanceTest extends CreateInstanceDialogBaseTest { private ServicesService servicesService = new ServicesService(); @@ -37,22 +34,22 @@ public class CreateNewInstanceTest extends CreateInstanceDialogBaseTest { } SimulatorApi.clearAll(); - BulkRegistration.createNewServiceInstance("USP VOICE"); + BulkRegistration.createNewServiceInstance("SILVIA ROBBINS"); - User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + User user = usersService.getUser(Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA); relogin(user.credentials); SideMenu.navigateToCreateNewServicePage(); CreateNewInstancePage createNewInstancePage = new CreateNewInstancePage(); - String subscriberName = "USP VOICE"; + String subscriberName = "SILVIA ROBBINS"; assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS); createNewInstancePage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89"); createNewInstancePage.clickSubmitButton(); assertSuccessfulSelection(Constants.CreateNewInstance.SELECTED_SUBSCRIBER_NAME_TEST_ID, subscriberName); - String serviceType = "VIRTUAL USP"; + String serviceType = "TYLER SILVIA"; assertDropdownPermittedItemsByName(user.serviceTypes, Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS); createNewInstancePage.selectServiceTypeByName(serviceType); createNewInstancePage.clickSubmitButton(); @@ -68,7 +65,7 @@ public class CreateNewInstanceTest extends CreateInstanceDialogBaseTest { validateServiceCreationDialog(service, subscriberName, serviceType); createNewInstancePage.setInstanceName(instanceName); - SelectOption.byTestIdAndVisibleText("MetroPacketCore", Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID); + SelectOption.byTestIdAndVisibleText("WayneHolland", Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID); SelectOption.byTestIdAndVisibleText("x1", Constants.OwningEntity.PROJECT_SELECT_TEST_ID); createNewInstancePage.selectSuppressRollback("false"); createNewInstancePage.clickConfirmButton(); @@ -79,20 +76,20 @@ public class CreateNewInstanceTest extends CreateInstanceDialogBaseTest { } @Test - public void testSearchServicesWithSubscriberMSO_1610_ST() throws Exception { + public void testSearchServicesWithSubscriberCAR_2020_ER() throws Exception { SimulatorApi.clearAll(); - BulkRegistration.createNewServiceInstance("MSO_1610_ST"); + BulkRegistration.createNewServiceInstance("CAR_2020_ER"); - User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + User user = usersService.getUser(Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA); relogin(user.credentials); SideMenu.navigateToCreateNewServicePage(); CreateNewInstancePage createNewInstancePage = new CreateNewInstancePage(); - String subscriberName = "MSO_1610_ST"; + String subscriberName = "CAR_2020_ER"; assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS); - createNewInstancePage.selectSubscriberById("MSO_1610_ST"); + createNewInstancePage.selectSubscriberById("CAR_2020_ER"); createNewInstancePage.clickSubmitButton(); assertSuccessfulSelection(Constants.CreateNewInstance.SELECTED_SUBSCRIBER_NAME_TEST_ID, subscriberName); diff --git a/vid-automation/src/main/java/vid/automation/test/test/CreatePortMirroringConfigurationTest.java b/vid-automation/src/main/java/vid/automation/test/test/CreatePortMirroringConfigurationTest.java index f4ba8c6dc..89e28d7a6 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/CreatePortMirroringConfigurationTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/CreatePortMirroringConfigurationTest.java @@ -1,22 +1,23 @@ package vid.automation.test.test; import com.google.common.collect.ImmutableMap; +import java.util.HashMap; +import java.util.Map; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import vid.automation.test.Constants; -import vid.automation.test.infra.*; +import vid.automation.test.infra.Exists; +import vid.automation.test.infra.Features; +import vid.automation.test.infra.Get; +import vid.automation.test.infra.Wait; import vid.automation.test.sections.CreateConfigurationPage; import vid.automation.test.sections.ServiceProxyPage; import vid.automation.test.sections.ViewEditPage; import vid.automation.test.services.BulkRegistration; import vid.automation.test.services.SimulatorApi; -import java.util.HashMap; -import java.util.Map; - public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { private ViewEditPage viewEditPage = new ViewEditPage(); @@ -27,29 +28,30 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { private String policyConfigurationModelName_0 = "Port Mirroring Configuration 0"; private String policyConfigurationModelName_1 = "Port Mirroring Configuration By Policy 1"; private String pnfInstanceName = "AS-pnf2-10219--as988q"; - private String vnfServiceType = "VIRTUAL USP"; - private String vnfInstanceName = "zmtn6aepdg01"; + private String pnfServiceType = "DARREN MCGEE"; + private String vnfServiceType = "TYLER SILVIA"; + private String defaultCollectorServiceType = "TYLER SILVIA"; + private String vnfInstanceName = "zhvf6aepdg01"; private String active = "Active"; - private String desiredCloudRegionId; - + private String desiredCloudRegionId = "mdt1"; - public CreatePortMirroringConfigurationTest() throws Exception {} + private boolean featureFlagLetsSelectingCollector() { + return Features.FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY.isActive(); + } - @BeforeMethod - public void setupDesiredCloudRegionId() { - desiredCloudRegionId = Features.FLAG_REGION_ID_FROM_REMOTE.isActive() ? "someCloudRegionIdFromAai" : "mdt1"; + private String expectedPnfCollectorServiceType() { + return (featureFlagLetsSelectingCollector() ? pnfServiceType : defaultCollectorServiceType).replace(" ", "%20"); } @Test public void testCreatePolicyConfiguration() { SimulatorApi.clearAll(); - BulkRegistration.searchExistingServiceInstancePortMirroring("Active", desiredCloudRegionId); - BulkRegistration.searchExistingServiceInstance(); + BulkRegistration.searchExistingServiceInstancePortMirroring("Active", "mdt1"); BulkRegistration.getNetworkNodeFormData(); - BulkRegistration.createPolicyConfiguration(true, desiredCloudRegionId); + BulkRegistration.createPolicyConfiguration(true, expectedPnfCollectorServiceType()); - goToExistingInstanceById(serviceInstanceId);//test_sssdad + navigateToViewEditPageOf_test_sssdad(); selectConfigurationNode(policyConfigurationModelName_1, getConfigurationExpectedMetadata()); fillAllFormFields(); createConfigurationPage.clickNextButton(); @@ -60,7 +62,7 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { createConfigurationPage.clickNextButton(); //assert service proxy models (circles) names - serviceProxyPage.assertSourceModelName("vmmeService2 Service Proxy"); + serviceProxyPage.assertSourceModelName("vflorenceService2 Service Proxy"); serviceProxyPage.assertCollectorModelName("pProbeService Service Proxy"); //assert service proxy models metadata @@ -68,6 +70,10 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { assertMetadataModal(Constants.ConfigurationCreation.COLLECTOR_INFO_BUTTON_TEST_ID, getCollectorServiceProxyExpectedMetadata()); //select source & collector + if (featureFlagLetsSelectingCollector()) { + serviceProxyPage.assertCollectorServiceType(defaultCollectorServiceType); + serviceProxyPage.chooseCollectorServiceType(pnfServiceType); + } serviceProxyPage.chooseCollector(pnfInstanceName); serviceProxyPage.assertSelectedInstanceIcon(Constants.ConfigurationCreation.COLLECTOR_INSTANCE_SELECTED_ICON_TEST_ID); @@ -91,10 +97,9 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { public void testDeletePolicyConfiguration() { SimulatorApi.clearAll(); BulkRegistration.searchExistingServiceInstancePortMirroring("Created", desiredCloudRegionId); - BulkRegistration.searchExistingServiceInstance(); BulkRegistration.getNetworkNodeFormData(); - BulkRegistration.deletePolicyConfiguration(true, desiredCloudRegionId); - goToExistingInstanceById(serviceInstanceId);//test_sssdad + BulkRegistration.deletePolicyConfiguration(true); + navigateToViewEditPageOf_test_sssdad(); serviceProxyPage.clickDeleteConfigurationButton(); serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT); } @@ -103,10 +108,9 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { public void testConfigurationCreatedPortEnabled(){ SimulatorApi.clearAll(); BulkRegistration.searchExistingServiceInstancePortMirroring("Created", desiredCloudRegionId); - BulkRegistration.searchExistingServiceInstance(); BulkRegistration.getNetworkNodeFormData(); - BulkRegistration.activateDeactivateConfiguration("deactivate","deactivate", desiredCloudRegionId); - goToExistingInstanceById(serviceInstanceId);//test_sssdad + BulkRegistration.activateDeactivateConfiguration("deactivate"); + navigateToViewEditPageOf_test_sssdad(); WebElement isPortEnableButtonExists = Get.byTestId("enableDisableButton"); Assert.assertNull(isPortEnableButtonExists); } @@ -114,8 +118,8 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { @Test public void testDisablePort() { enableDisablePortPresets(active, true); - BulkRegistration.enableDisablePort("disablePort", desiredCloudRegionId); - goToExistingInstanceById(serviceInstanceId);//test_sssdad + BulkRegistration.enableDisablePort("disablePort"); + navigateToViewEditPageOf_test_sssdad(); serviceProxyPage.clickEnableDisableButton(); serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT); } @@ -123,8 +127,8 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { @Test public void testEnablePort() { enableDisablePortPresets(active, false); - BulkRegistration.enableDisablePort("enablePort", desiredCloudRegionId); - goToExistingInstanceById(serviceInstanceId);//test_sssdad + BulkRegistration.enableDisablePort("enablePort"); + navigateToViewEditPageOf_test_sssdad(); serviceProxyPage.clickEnableDisableButton(); serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT); } @@ -135,7 +139,6 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { private void enableDisablePortPresets(String orchStatus, boolean isMirrored){ SimulatorApi.clearAll(); BulkRegistration.searchExistingServiceInstancePortMirroring(orchStatus, isMirrored, desiredCloudRegionId); - BulkRegistration.searchExistingServiceInstance(); BulkRegistration.getNetworkNodeFormData(); } @@ -145,10 +148,9 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { public void testActivateConfigurationTest(){ SimulatorApi.clearAll(); BulkRegistration.searchExistingServiceInstancePortMirroring("Created", desiredCloudRegionId); - BulkRegistration.searchExistingServiceInstance(); BulkRegistration.getNetworkNodeFormData(); - BulkRegistration.activateDeactivateConfiguration("activate","activate", desiredCloudRegionId); - goToExistingInstanceById(serviceInstanceId);//test_sssdad + BulkRegistration.activateDeactivateConfiguration("activate"); + navigateToViewEditPageOf_test_sssdad(); serviceProxyPage.assertDeleteConfigurationButtonExists(true); serviceProxyPage.clickActivateDeactivateButton(); serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT); @@ -159,10 +161,9 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { public void testDeleteConfigurationTest(){ SimulatorApi.clearAll(); BulkRegistration.searchExistingServiceInstancePortMirroring("Created", desiredCloudRegionId); - BulkRegistration.searchExistingServiceInstance(); BulkRegistration.getNetworkNodeFormData(); - BulkRegistration.deleteConfiguration(desiredCloudRegionId); - goToExistingInstanceById(serviceInstanceId);//test_sssdad + BulkRegistration.deleteConfiguration(); + navigateToViewEditPageOf_test_sssdad(); serviceProxyPage.clickDeleteConfigurationButton(); serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT); } @@ -172,10 +173,9 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { public void testDeactivateConfigurationTest(){ SimulatorApi.clearAll(); BulkRegistration.searchExistingServiceInstancePortMirroring("Active", desiredCloudRegionId); - BulkRegistration.searchExistingServiceInstance(); BulkRegistration.getNetworkNodeFormData(); - BulkRegistration.activateDeactivateConfiguration("deactivate","deactivate", desiredCloudRegionId); - goToExistingInstanceById(serviceInstanceId);//test_sssdad + BulkRegistration.activateDeactivateConfiguration("deactivate"); + navigateToViewEditPageOf_test_sssdad(); serviceProxyPage.assertDeleteConfigurationButtonExists(false); serviceProxyPage.clickActivateDeactivateButton(); serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT); @@ -186,19 +186,18 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { @Test public void testCreatePortMirroringConfiguration() { SimulatorApi.clearAll(); -// BulkRegistration.searchExistingServiceInstancePortMirroring(); BulkRegistration.searchExistingServiceInstance(); BulkRegistration.getNetworkNodeFormData(); - BulkRegistration.createPolicyConfiguration(true, desiredCloudRegionId); + BulkRegistration.createPolicyConfiguration(true, expectedPnfCollectorServiceType()); BulkRegistration.createConfiguration("model-version-id=7482279e-5901-492f-a963-6331aa6b995e&model-invariant-id=f2ae9911-95c4-40d0-8908-0175c206ab2d"); - goToExistingInstanceById(serviceInstanceId_vidTest444);//test_sssdad + navigateToViewEditPageOfuspVoiceVidTest444("240376de-870e-48df-915a-31f140eedd2c"); selectConfigurationNode(policyConfigurationModelName_0, ImmutableMap.<String, String>builder() .put(Constants.ServiceModelInfo.SERVIICE_NAME_KEY, "Demo Service 1") .put(Constants.ServiceModelInfo.MODEL_NAME, "Port Mirroring Configuration") .put(Constants.ServiceModelInfo.SERVICE_INSTANCE_NAME, "vid-test-444") .put(Constants.ServiceModelInfo.MODEL_INVARIANT_UUID, "5dd839fa-5e09-47d4-aa5c-5ba62161b569") - .put(Constants.ServiceModelInfo.SUBSCRIBER_NAME_KEY, "USP VOICE") + .put(Constants.ServiceModelInfo.SUBSCRIBER_NAME_KEY, "SILVIA ROBBINS") .put(Constants.ServiceModelInfo.MODEL_VERSION, "1.0") .put(Constants.ServiceModelInfo.MODEL_UUID, "9d6b09b1-7527-49b1-b6cf-398cb67c5523") .put(Constants.ServiceModelInfo.MODEL_CUSTOMIZATION_UUID, "3db39baa-35bc-4b97-b199-44e758823502") @@ -224,7 +223,6 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { .put(Constants.ServiceProxyModelInfo.MODEL_TYPE, "Service Proxy") .put(Constants.ServiceProxyModelInfo.MODEL_INVARIANT_UUID, "0aaefad3-9409-4ab1-be00-a1571e8a0545") .put(Constants.ServiceProxyModelInfo.MODEL_UUID, "8685fd6a-c0b1-40f7-be94-ab232e4424c1") -// .put(Constants.ServiceProxyModelInfo.MODEL_CUSTOMIZATION_UUID, "2ac4bd62-dee8-452f-b799-b9c925ee1b9f") .put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_UUID, "7482279e-5901-492f-a963-6331aa6b995e") .put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_INVARIANT, "f2ae9911-95c4-40d0-8908-0175c206ab2d") .put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_NAME, "Service 1") @@ -233,6 +231,7 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { assertMetadataModal(Constants.ConfigurationCreation.COLLECTOR_INFO_BUTTON_TEST_ID, expectedMetadata); //select source & collector + serviceProxyPage.assertCollectorServiceType(defaultCollectorServiceType); serviceProxyPage.chooseCollectorServiceType(vnfServiceType); serviceProxyPage.chooseCollector(vnfInstanceName); serviceProxyPage.assertSelectedInstanceIcon(Constants.ConfigurationCreation.COLLECTOR_INSTANCE_SELECTED_ICON_TEST_ID); @@ -242,14 +241,6 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { serviceProxyPage.assertSelectedInstanceIcon(Constants.ConfigurationCreation.SOURCE_INSTANCE_SELECTED_ICON_TEST_ID); serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,true); -// serviceProxyPage.clickCreateButton(); -// serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,false); -// serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT); -// serviceProxyPage.clickCloseButton(); - - //assert redirect back to view/edit -// GeneralUIUtils.ultimateWait(); -// Assert.assertTrue(Exists.byTestId(Constants.ViewEdit.ADD_VNF_BUTTON_TEST_ID)); } @Test @@ -258,13 +249,19 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { SimulatorApi.clearAll(); BulkRegistration.searchExistingServiceInstancePortMirroring("Active", desiredCloudRegionId); BulkRegistration.getNetworkNodeFormData(); - BulkRegistration.createPolicyConfiguration(false, desiredCloudRegionId); + BulkRegistration.createPolicyConfiguration(false, expectedPnfCollectorServiceType()); - goToExistingInstanceById(serviceInstanceId);//test_sssdad + navigateToViewEditPageOf_test_sssdad(); selectConfigurationNode(policyConfigurationModelName_1, getConfigurationExpectedMetadata()); fillAllFormFields(); createConfigurationPage.clickNextButton(); - //select source & collector + serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,false); + + //select source & collector + if (featureFlagLetsSelectingCollector()) { + serviceProxyPage.assertCollectorServiceType(defaultCollectorServiceType); + serviceProxyPage.chooseCollectorServiceType(pnfServiceType); + } serviceProxyPage.chooseCollector(pnfInstanceName); serviceProxyPage.chooseSourceServiceType(vnfServiceType); serviceProxyPage.chooseSource(vnfInstanceName); @@ -273,6 +270,7 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { serviceProxyPage.clickCloseButton(); serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,true); } + @Test public void testRainyNoResultsInDropdowns(){ SimulatorApi.clearAll(); @@ -280,7 +278,7 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { BulkRegistration.getNetworkNodeFormData(); //not register createPolicyConfiguration for no results in DDLs - goToExistingInstanceById(serviceInstanceId);//test_sssdad + navigateToViewEditPageOf_test_sssdad(); selectConfigurationNode(policyConfigurationModelName_1, getConfigurationExpectedMetadata()); fillAllFormFields(); createConfigurationPage.clickNextButton(); @@ -313,7 +311,7 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { createConfigurationPage.assertButtonState(Constants.ConfigurationCreation.TENANT_DROPDOWN_TEST_ID,false); //WebElement tenantDDL= Get.byTestId(Constants.ConfigurationCreation.TENANT_DROPDOWN_TEST_ID); - createConfigurationPage.chooseRegion("AAIAIC25"); + createConfigurationPage.chooseRegion("JANET25"); GeneralUIUtils.ultimateWait(); // Wait.waitByTestId(Constants.ConfigurationCreation.TENANT_DROPDOWN_TEST_ID, 30); createConfigurationPage.chooseTenant("USP-SIP-IC-24335-T-01"); @@ -321,7 +319,7 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { } private void assertFormFields() { Assert.assertEquals("dummy_instance",createConfigurationPage.getInstanceName()); - Assert.assertEquals("AAIAIC25", createConfigurationPage.getRegion()); + Assert.assertEquals("JANET25", createConfigurationPage.getRegion()); Assert.assertEquals("USP-SIP-IC-24335-T-01",createConfigurationPage.getTenant()); createConfigurationPage.assertButtonState(Constants.ConfigurationCreation.NEXT_BUTTON_TEST_ID,true); @@ -334,7 +332,7 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { put(Constants.ServiceModelInfo.MODEL_NAME, "Port Mirroring Configuration By Policy"); put(Constants.ServiceModelInfo.SERVICE_INSTANCE_NAME, "test_sssdad"); put(Constants.ServiceModelInfo.MODEL_INVARIANT_UUID, "c30a024e-a6c6-4670-b73c-3df64eb57ff6"); - put(Constants.ServiceModelInfo.SUBSCRIBER_NAME_KEY, "USP VOICE"); + put(Constants.ServiceModelInfo.SUBSCRIBER_NAME_KEY, "SILVIA ROBBINS"); put(Constants.ServiceModelInfo.MODEL_VERSION, "1.0"); put(Constants.ServiceModelInfo.MODEL_UUID, "f58d039d-4cfc-40ec-bd75-1f05f0458a6c"); put(Constants.ServiceModelInfo.MODEL_CUSTOMIZATION_UUID, "4b7ebace-bad6-4526-9be6-bf248e20fc5f"); @@ -346,16 +344,16 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase { private Map<String, String> getSourceServiceProxyExpectedMetadata() { return new HashMap<String, String>(){ { - put(Constants.ServiceProxyModelInfo.MODEL_NAME, "vmmeService2 Service Proxy"); + put(Constants.ServiceProxyModelInfo.MODEL_NAME, "vflorenceService2 Service Proxy"); put(Constants.ServiceProxyModelInfo.MODEL_VERSION, "1.0"); - put(Constants.ServiceProxyModelInfo.MODEL_DESCRIPTION, "A Proxy for Service vmmeService2"); + put(Constants.ServiceProxyModelInfo.MODEL_DESCRIPTION, "A Proxy for Service vflorenceService2"); put(Constants.ServiceProxyModelInfo.MODEL_TYPE, "Service Proxy"); put(Constants.ServiceProxyModelInfo.MODEL_INVARIANT_UUID, "2933b574-d28d-45ea-bf22-4df2907e4a10"); put(Constants.ServiceProxyModelInfo.MODEL_UUID, "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee"); put(Constants.ServiceProxyModelInfo.MODEL_CUSTOMIZATION_UUID, "060be63d-5f9c-4fd0-8ef7-830d5e8eca17"); put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_UUID, "2a2ea15f-07c6-4b89-bfca-e8aba39a34d6"); put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_INVARIANT, "a7eac2b3-8444-40ee-92e3-b3359b32445c"); - put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_NAME, "vmmeService2"); + put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_NAME, "vflorenceService2"); } }; } diff --git a/vid-automation/src/main/java/vid/automation/test/test/DeleteResumeTest.java b/vid-automation/src/main/java/vid/automation/test/test/DeleteResumeTest.java index 2e3580f0c..55ab567dc 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/DeleteResumeTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/DeleteResumeTest.java @@ -1,30 +1,22 @@ package vid.automation.test.test; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.testng.annotations.Test; import vid.automation.test.Constants; import vid.automation.test.model.User; import vid.automation.test.services.BulkRegistration; import vid.automation.test.services.SimulatorApi; -import vid.automation.test.services.UsersService; - -import java.io.IOException; public class DeleteResumeTest extends CreateInstanceDialogBaseTest { - private UsersService usersService = new UsersService(); - - public DeleteResumeTest() throws IOException { - } - @Test() - private void testResumePendingActivationVfModule() throws Exception { - User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + @Test + private void testResumePendingActivationVfModule() { + User user = usersService.getUser(Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA); String serviceInstanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d"; String vnfInstanceId = "c015cc0f-0f37-4488-aabf-53795fd93cd3"; SimulatorApi.clearAll(); BulkRegistration.resumeVfModule(serviceInstanceId,vnfInstanceId); navigateToViewEditPageOfuspVoiceVidTest444("240376de-870e-48df-915a-31f140eedd2c"); - resumeVFModule("aa","AAIAIC25","092eb9e8e4b7412e8787dd091bc58e86","mdt1",user.tenants); + resumeVFModule("aa","JANET25", "AIC", "092eb9e8e4b7412e8787dd091bc58e86","mdt1",user.tenants); } }
\ No newline at end of file diff --git a/vid-automation/src/main/java/vid/automation/test/test/DrawingBoardTest.java b/vid-automation/src/main/java/vid/automation/test/test/DrawingBoardTest.java index d022f5c9b..bacd83155 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/DrawingBoardTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/DrawingBoardTest.java @@ -1,40 +1,51 @@ package vid.automation.test.test; -import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import static org.testng.AssertJUnit.assertFalse; +import static vid.automation.test.Constants.DrawingBoard.AVAILABLE_MODELS_TREE; +import static vid.automation.test.Constants.DrawingBoard.BACK_BUTTON; +import static vid.automation.test.Constants.DrawingBoard.CONTEXT_MENU_BUTTON_HEADER; +import static vid.automation.test.Constants.DrawingBoard.CONTEXT_MENU_HEADER_EDIT_ITEM; +import static vid.automation.test.Constants.DrawingBoard.DEFAULT_SERVICE_NAME; +import static vid.automation.test.Constants.DrawingBoard.DRAWING_BOARD_TREE; +import static vid.automation.test.Constants.DrawingBoard.SEARCH_LEFT_TREE; +import static vid.automation.test.Constants.DrawingBoard.SERVICE_QUANTITY; +import static vid.automation.test.infra.Features.FLAG_ASYNC_INSTANTIATION; +import static vid.automation.test.infra.ModelInfo.macroDrawingBoardComplexService; +import static vid.automation.test.infra.ModelInfo.macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails; + +import com.google.common.collect.ImmutableList; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2; import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import vid.automation.test.Constants; -import vid.automation.test.infra.*; +import vid.automation.test.infra.Click; +import vid.automation.test.infra.Exists; +import vid.automation.test.infra.FeatureTogglingTest; +import vid.automation.test.infra.Get; +import vid.automation.test.infra.Input; +import vid.automation.test.infra.ModelInfo; +import vid.automation.test.infra.SelectOption; +import vid.automation.test.infra.Wait; import vid.automation.test.model.User; import vid.automation.test.sections.BrowseASDCPage; import vid.automation.test.sections.DrawingBoardPage; import vid.automation.test.sections.VidBasePage; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.endsWith; -import static org.testng.Assert.assertNotNull; -import static org.testng.AssertJUnit.assertEquals; -import static vid.automation.test.Constants.DrawingBoard.*; -import static vid.automation.test.infra.Features.FLAG_ASYNC_INSTANTIATION; - @FeatureTogglingTest(FLAG_ASYNC_INSTANTIATION) public class DrawingBoardTest extends VidBaseTestCase { private DrawingBoardPage drawingBoardPage = new DrawingBoardPage(); - private String loadedServiceModelId = ""; - private final String defaultServiceModelForMostTests = "6e59c5de-f052-46fa-aa7e-2fca9d674c44"; - + private String loadedServiceModelId = macroDrawingBoardComplexService.modelVersionId; @Override protected UserCredentials getUserCredentials() { - String userName = Constants.Users.USP_VOICE_VIRTUAL_USP; + String userName = Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA; User user = usersService.getUser(userName); return new UserCredentials(user.credentials.userId, user.credentials.password, userName, "", ""); } @@ -44,7 +55,7 @@ public class DrawingBoardTest extends VidBaseTestCase { @AfterClass private void goOutFromIframe() { - new VidBasePage().goOutFromIframe(); + VidBasePage.goOutFromIframe(); } @@ -53,21 +64,22 @@ public class DrawingBoardTest extends VidBaseTestCase { final String currentUrl = getDriver().getCurrentUrl(); System.out.println("currentUrl in @BeforeMethod setNewServiceToDefault: " + currentUrl); - if (currentUrl.endsWith("/servicePlanning?serviceModelId=" + defaultServiceModelForMostTests)) { + if (currentUrl.endsWith("/servicePlanning?serviceModelId=" + macroDrawingBoardComplexService.modelVersionId)) { getDriver().navigate().refresh(); } else { - setNewService("service-Complexservice-csar.zip", defaultServiceModelForMostTests, null); + setNewService(macroDrawingBoardComplexService, null); } GeneralUIUtils.ultimateWait(); drawingBoardPage.goToIframe(); } - private void setNewService(String zipFileName, String serviceModelId, String instanceName) { + private void setNewService(ModelInfo modelInfo, String instanceName) { goOutFromIframe(); BrowseASDCPage browseASDCPage = new BrowseASDCPage(); - loadedServiceModelId = serviceModelId; - loadServicePopup(zipFileName, serviceModelId); + prepareServicePreset(modelInfo.zipFileName, modelInfo.modelVersionId); + + loadServicePopup(modelInfo.modelVersionId); if (instanceName != null) { Input.text(instanceName,Constants.BrowseASDC.NewServicePopup.INSTANCE_NAME); @@ -76,37 +88,50 @@ public class DrawingBoardTest extends VidBaseTestCase { Wait.waitByClassAndText("subscriber","",3); GeneralUIUtils.ultimateWait(); VidBasePage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89"); + + GeneralUIUtils.ultimateWait(); GeneralUIUtils.ultimateWait(); browseASDCPage.selectProductFamily("e433710f-9217-458d-a79d-1c7aff376d89"); - String serviceType = "VIRTUAL USP"; - Wait.waitByClassAndText(Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS, serviceType, 30); + GeneralUIUtils.ultimateWait(); + String serviceType = "TYLER SILVIA"; +// Wait.waitByClassAndText(Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS, serviceType, 30); browseASDCPage.selectServiceTypeByName(serviceType); GeneralUIUtils.ultimateWait(); GeneralUIUtils.ultimateWait(); - browseASDCPage.selectLcpRegion("mtn6"); + browseASDCPage.selectLcpRegion("hvf6"); browseASDCPage.selectTenant("3f21eeea6c2c486bba31dab816c05a32"); - Click.onFirstSelectOptionById(Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID); + Click.onFirstSelectOptionByTestId(Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID); browseASDCPage.selectAicZone("NFT1"); - Click.onFirstSelectOptionById(Constants.OwningEntity.PROJECT_SELECT_TEST_ID); + Click.onFirstSelectOptionByTestId(Constants.OwningEntity.PROJECT_SELECT_TEST_ID); // select mandatory field - Click.onFirstSelectOptionById(Constants.ServiceModelInfo.ROLLBACK_ON_FAILURE_ID); + Click.onFirstSelectOptionByTestId(Constants.ServiceModelInfo.ROLLBACK_ON_FAILURE_TEST_ID); + + Click.byTestId("form-set"); + VidBasePage.goOutFromIframe(); + } - Click.byTestId("service-form-set"); - browseASDCPage.goOutFromIframe(); + private void prepareServicePreset(String zipFileName, String serviceModelId) { + String modelInvariantId = "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0"; + String subscriberId = "e433710f-9217-458d-a79d-1c7aff376d89"; + registerExpectationForServiceDeployment( + ImmutableList.of( + new ModelInfo(serviceModelId, modelInvariantId, zipFileName) + ), + subscriberId, new PresetMSOCreateServiceInstanceGen2()); } - static final String leftTreeNodeName = "VF_vMee 0"; + static final String leftTreeNodeName = "VF_vGeraldine 0"; static final String leftTreeNodeNameWithoutChildren = "Port Mirroring Configuration By Policy 0"; - static final String[] leftTreeNodeChildren = {"vf_vmee0..VfVmee..vmme_vlc..module-1", "vf_vmee0..VfVmee..vmme_gpb..module-2", "vf_vmee0..VfVmee..base_vmme..module-0"}; - static final String[] leftTreeInitialElements = new String[]{"V", "VF_vMee 0", "C","Port Mirroring Configuration By Policy 0","N", "ExtVL 0"}; + static final String[] leftTreeNodeChildren = {"vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1", "vf_vgeraldine0..VfVgeraldine..vflorence_gpb..module-2", "vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0"}; + static final String[] leftTreeInitialElements = new String[]{"VNF", "VF_vGeraldine 0", "1", "C","Port Mirroring Configuration By Policy 0"}; - static final String rightTreeNodeName = "d6557200-ecf2-4641-8094-5393ae3aae60-VF_vMee 0"; + static final String rightTreeNodeName = "d6557200-ecf2-4641-8094-5393ae3aae60-VF_vGeraldine 0"; static final String rightTreeNodeNameWithoutChildren = "ddc3f20c-08b5-40fd-af72-c6d14636b986-ExtVL 0"; - static final String[] rightTreeNodeChildren = {"522159d5-d6e0-4c2a-aa44-5a542a12a830-vf_vmee0..VfVmee..vmme_vlc..module-1", "41708296-e443-4c71-953f-d9a010f059e1-vf_vmee0..VfVmee..vmme_gpb..module-2", "a27f5cfc-7f12-4f99-af08-0af9c3885c87-vf_vmee0..VfVmee..base_vmme..module-0"}; + static final String[] rightTreeNodeChildren = {"522159d5-d6e0-4c2a-aa44-5a542a12a830-vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1", "41708296-e443-4c71-953f-d9a010f059e1-vf_vgeraldine0..VfVgeraldine..vflorence_gpb..module-2", "a27f5cfc-7f12-4f99-af08-0af9c3885c87-vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0"}; - private static final String EMPTY_BOARD_TITLE = "Please add objects (VNFs, network, modules etc.) from the left tree to design the service instance"; + private static final String EMPTY_BOARD_TITLE = "Please add objects (VNF a-la-carteVNFs, network, modules etc.) from the left tree to design the service instance"; private static final String EMPTY_BOARD_SUBTITLE = "Once done, click Deploy to start instantiation"; @@ -127,7 +152,7 @@ public class DrawingBoardTest extends VidBaseTestCase { private void expandCollapseLeftTreeByClickOnRow() { Wait.byText(leftTreeNodeName); drawingBoardPage.expandTreeByClickingNode(leftTreeNodeName, leftTreeNodeChildren); - //should checking with Golan if click also collapse + //should chec king with Golan if click also collapse //drawingBoardPage.collapseTreeByClickingNode(leftTreeNodeName, leftTreeNodeChildren))); drawingBoardPage.verifyNonCollapsableTreeByClickingNode(leftTreeNodeName, leftTreeNodeChildren); } @@ -178,17 +203,6 @@ public class DrawingBoardTest extends VidBaseTestCase { drawingBoardPage.checkLeafNodeHasNoExpander(rightTreeNodeNameWithoutChildren); } - @Test - public void testEmptyDrawingBoard() { - assertNotNull(Get.byClassAndText("text-title", EMPTY_BOARD_TITLE)); - assertNotNull(Get.byClassAndText("text-subtitle", EMPTY_BOARD_SUBTITLE)); - WebElement icon = Get.byTestId("no-content-icon"); - assertEquals("img", icon.getTagName()); - assertThat(icon.getAttribute("src"), endsWith("UPLOAD.svg")); - assertThat(icon.getAttribute("class"), containsString("no-content-icon")); - assertThat(icon.getAttribute("class"), containsString("upload-icon-service-planing")); - } - @Test(groups = { "underDevelopment" }) private void clickRightTreeNode_verifyLeftTreeNodeIsBlueAndExpanded() { @@ -259,12 +273,12 @@ public class DrawingBoardTest extends VidBaseTestCase { */ @Test private void insertTestInSerachBox_verifyMatchesMarkedAndVisible() { - Wait.byText("vf_vmee0..VfVmee..vmme_vlc..module-1"); + Wait.byText("vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1"); drawingBoardPage.checkSearch(); - final String searchTerm = "Vmee..vmme"; + final String searchTerm = "Vgeraldine..vflorence"; GeneralUIUtils.setWebElementByTestId(SEARCH_LEFT_TREE, searchTerm); - drawingBoardPage.checkNodesVisibleAndMatchIsHighlighted(searchTerm,"vf_vmee0..VfVmee..vmme_vlc..module-1", "vf_vmee0..VfVmee..vmme_gpb..module-2"); + drawingBoardPage.checkNodesVisibleAndMatchIsHighlighted(searchTerm,"vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1", "vf_vgeraldine0..VfVgeraldine..vflorence_gpb..module-2"); } /* @@ -308,7 +322,7 @@ public class DrawingBoardTest extends VidBaseTestCase { private void setAndAssertServiceWithName(String instanceName){ goOutFromIframe(); - setNewService("csar-noDynamicFields-ecompNamingFalse-fullModelDetails-1a80c596.zip", "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd", instanceName); + setNewService(macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails, instanceName); GeneralUIUtils.ultimateWait(); drawingBoardPage.goToIframe(); drawingBoardPage.checkServiceInstanceName(instanceName); @@ -324,7 +338,7 @@ public class DrawingBoardTest extends VidBaseTestCase { final int updatedQuantity = 10; Click.byTestId(CONTEXT_MENU_BUTTON_HEADER); Click.byTestId(CONTEXT_MENU_HEADER_EDIT_ITEM); - Assert.assertTrue(Exists.byId("service-popup"), "context menu should not appear"); + Assert.assertTrue(Exists.byId("instance-popup"), "context menu should not appear"); SelectOption.byIdAndVisibleText("quantity-select", String.valueOf(updatedQuantity)); Input.replaceText(updatedInstanceName,Constants.BrowseASDC.NewServicePopup.INSTANCE_NAME ); Click.byTestId(Constants.BrowseASDC.NewServicePopup.SET_BUTTON); @@ -342,7 +356,7 @@ public class DrawingBoardTest extends VidBaseTestCase { String initialQuantity = Get.byTestId(SERVICE_QUANTITY).getText(); Click.byTestId(CONTEXT_MENU_BUTTON_HEADER); Click.byTestId(CONTEXT_MENU_HEADER_EDIT_ITEM); - Assert.assertTrue(Exists.byId("service-popup"), "context menu should not appear"); + Assert.assertTrue(Exists.byId("instance-popup"), "context menu should not appear"); SelectOption.byIdAndVisibleText("quantity-select", String.valueOf(updatedQuantity)); Input.replaceText(updatedInstanceName,Constants.BrowseASDC.NewServicePopup.INSTANCE_NAME ); Click.byTestId(Constants.BrowseASDC.NewServicePopup.CANCEL_BUTTON); @@ -356,10 +370,10 @@ public class DrawingBoardTest extends VidBaseTestCase { private void checkHeader_verifyElementsExist(){ drawingBoardPage.checkExistsAndEnabled(BACK_BUTTON); drawingBoardPage.checkServiceInstanceName(DEFAULT_SERVICE_NAME); - drawingBoardPage.checkServiceStatus(); drawingBoardPage.checkQuantityNumberIsCorrect(1); drawingBoardPage.checkExistsAndEnabled(CONTEXT_MENU_BUTTON_HEADER); - //drawingBoardPage.checkDeployButtonDisabled(); + assertFalse(Get.byTestId("orchStatusLabel").isDisplayed()); + assertFalse(Get.byTestId("orchStatusValue").isDisplayed()); } private void assertResultsInBrowseAsdcPage(){ @@ -372,7 +386,7 @@ public class DrawingBoardTest extends VidBaseTestCase { private void BackButtonWithCancel_verifyStayInTheSamePage(){ String currentUrl = getCurrentUrl(); Click.byTestId(BACK_BUTTON); - Click.byText(Constants.Modals.CANCEL); + Click.byTestId(Constants.DrawingBoard.CANCEL_BUTTON); String newUrl = getCurrentUrl(); org.testng.Assert.assertEquals(currentUrl, newUrl); } @@ -385,22 +399,9 @@ public class DrawingBoardTest extends VidBaseTestCase { @Test private void BackButton_verifyReturnToSearchResults(){ Click.byTestId(BACK_BUTTON); - Click.byText(Constants.Modals.STOP_INSTANTIATION); - assertResultsInBrowseAsdcPage(); - } - - @Test - private void deleteButon_verifyReturnToSearchResults() { - Click.byTestId(CONTEXT_MENU_BUTTON_HEADER); - Click.byTestId(CONTEXT_MENU_HEADER_DELETE_ITEM); - Click.byText(Constants.Modals.STOP_INSTANTIATION); + Click.byTestId(Constants.DrawingBoard.STOP_INSTANTIATION_BUTTON); assertResultsInBrowseAsdcPage(); } - - - - - } diff --git a/vid-automation/src/main/java/vid/automation/test/test/EnvironmentsTest.java b/vid-automation/src/main/java/vid/automation/test/test/EnvironmentsTest.java index 01af276e5..f21a76d83 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/EnvironmentsTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/EnvironmentsTest.java @@ -2,7 +2,7 @@ package vid.automation.test.test; import com.google.common.collect.ImmutableMap; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; @@ -385,11 +385,12 @@ public class EnvironmentsTest extends VidBaseTestCase { assertTrue("Failed to find Activate button for test env with id: "+envId, activationButton.isDisplayed()); activationButton.click(); updateEnvManifestFile(inputFileName); - WebElement manifestFileName = Get.byId("manifestFileName"); - assertEquals("Manifest file name is wrong in test environment activation modal", inputFileName, manifestFileName.getText()); + assertTrue("Manifest file name is wrong in test environment activation modal", + Wait.waitByIdAndText("manifestFileName", inputFileName, 10)); } private void updateEnvManifestFile(String inputFileName) { + GeneralUIUtils.ultimateWait(); Input.file("applicationEnvironment/"+inputFileName, "testEnvManifestFileInput"); GeneralUIUtils.ultimateWait(); } diff --git a/vid-automation/src/main/java/vid/automation/test/test/HealthStatusTest.java b/vid-automation/src/main/java/vid/automation/test/test/HealthStatusTest.java index 184592188..2bb97aa2e 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/HealthStatusTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/HealthStatusTest.java @@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableList; import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.remote.RemoteWebElement; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -59,6 +60,7 @@ public class HealthStatusTest extends VidBaseTestCase { private void refreshStatus() { vidBasePage.navigateTo("app/ui/#/healthStatus"); + GeneralUIUtils.ultimateWait(); Click.byClass("icon-refresh"); } diff --git a/vid-automation/src/main/java/vid/automation/test/test/InstantiationStatusTest.java b/vid-automation/src/main/java/vid/automation/test/test/InstantiationStatusTest.java index 899eed9a1..a3480f8c2 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/InstantiationStatusTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/InstantiationStatusTest.java @@ -1,42 +1,60 @@ package vid.automation.test.test; +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.testng.Assert.assertEquals; +import static org.testng.AssertJUnit.assertTrue; +import static vid.automation.test.Constants.DrawingBoard.DEPLOY_BUTTON; +import static vid.automation.test.infra.Features.FLAG_ASYNC_INSTANTIATION; + import com.google.common.collect.ImmutableMap; +import java.util.Collections; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; -import org.openqa.selenium.JavascriptExecutor; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames; +import org.onap.vid.api.AsyncInstantiationBase; +import org.onap.vid.api.CreateServiceWithFailedVnf; +import org.onap.vid.api.TestUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import vid.automation.test.Constants; +import vid.automation.test.infra.Click; import vid.automation.test.infra.FeatureTogglingTest; +import vid.automation.test.infra.Features; +import vid.automation.test.infra.Get; +import vid.automation.test.infra.Wait; +import vid.automation.test.sections.DrawingBoardPage; import vid.automation.test.sections.InstantiationStatusPage; import vid.automation.test.sections.SideMenu; +import vid.automation.test.sections.VidBasePage; import vid.automation.test.services.AsyncJobsService; -import java.util.UUID; - -import static vid.automation.test.infra.Features.FLAG_ASYNC_INSTANTIATION; -import static vid.automation.test.sections.InstantiationStatusPage.assertInstantiationStatusRow; -import static vid.automation.test.sections.InstantiationStatusPage.getNumberOfTableRows; - @FeatureTogglingTest(FLAG_ASYNC_INSTANTIATION) public class InstantiationStatusTest extends VidBaseTestCase { + private final String serviceModelVersion = "5.1"; + private final String regionId = "a93f8383-707e-43fa-8191-a6e69a1aab17"; + final static String owningEntityName = "Lucine Sarika"; + final static String subscriberName = "SILVIA ROBBINS"; + private static final String COMPLETED = "COMPLETED"; + private static final String CREATE_BULK_OF_ALACARTE_REQUEST = "asyncInstantiation/vidRequestCreateALaCarte.json"; + private final VidBasePage vidBasePage = new VidBasePage(); - private final String serviceModelVersion = "1.0"; - private final String subscriberId = "ac040e8a-b43a-441b-ab87-603f5b70be55"; - private final String regionId = "my-expected-region-id"; - private final String projectName = "a-project-name"; - final static String owningEntityName = "expected-owningEntityName"; - final static String subscriberName = "expected-subscriberName"; - - - private String currentUUI; + private AsyncInstantiationBase asyncInstantiationBase; @BeforeClass protected void dropAllAsyncJobs() { AsyncJobsService asyncJobsService = new AsyncJobsService(); asyncJobsService.dropAllAsyncJobs(); + asyncInstantiationBase = new AsyncInstantiationBase(); + asyncInstantiationBase.init(); + UserCredentials userCredentials = getUserCredentials(); + //login for API test (needed besides selenium test via browser) + asyncInstantiationBase.login(userCredentials); } @AfterClass @@ -45,58 +63,21 @@ public class InstantiationStatusTest extends VidBaseTestCase { asyncJobsService.muteAllAsyncJobs(); } - @BeforeMethod - protected void createJobsData() { - addOneJob(); - SideMenu.navigateToMacroInstantiationStatus(); - } - private String addOneJob() { - currentUUI = UUID.randomUUID().toString(); - final JavascriptExecutor javascriptExecutor = (JavascriptExecutor) GeneralUIUtils.getDriver(); - Object result = javascriptExecutor.executeScript( - "return (function postJob(){var xhttp = new XMLHttpRequest(); " + - " " + - " xhttp.onreadystatechange = function() { " + - " return this.responseText; " + - " }; " + - " " + - " xhttp.open(\"POST\", '/vid/asyncInstantiation/bulk', false); " + - " xhttp.setRequestHeader(\"Content-type\", \"application/json\"); " + - " xhttp.send(`{ " + - " \"modelInfo\": { " + - " \"modelType\": \"service\", " + - " \"modelInvariantId\": \"300adb1e-9b0c-4d52-bfb5-fa5393c4eabb\", " + - " \"modelVersionId\": \"5c9e863f-2716-467b-8799-4a67f378dcaa\", " + - " \"modelName\": \"AIM_TRANSPORT_00004\", " + - " \"modelVersion\": \"" + serviceModelVersion + "\" " + - " }, " + - " \"owningEntityId\" : \"someID\", " + - " \"owningEntityName\": \"" + owningEntityName + "\", " + - " \"projectName\" : \"" + projectName + currentUUI + "\", " + - " \"globalSubscriberId\": \"" + subscriberId + "\", " + - " \"subscriberName\": \"" + subscriberName + "\", " + - " \"productFamilyId\" : \"myProductFamilyId\", " + - " \"instanceName\" : \"MichaelJordan\", " + - " \"subscriptionServiceType\" : \"mySubType\", " + - " \"lcpCloudRegionId\" : \"" + regionId + "\", " + - " \"tenantId\" : \"greatTenant\", " + - " \"bulkSize\": 1, " + - " \"isUserProvidedNaming\": \"true\", " + - " \"vnfs\": {} " + - "} `); " + - " " + - "return JSON.parse(xhttp.responseText).entity;})()" - ); - - return result.toString(); + String serviceName = TestUtils.generateRandomAlphaNumeric(8); + final ImmutableMap<PresetMSOServiceInstanceGen2WithNames.Keys, String> names = + ImmutableMap.of(SERVICE_NAME, serviceName); + asyncInstantiationBase.createBulkOfInstances(false, 1, names, CREATE_BULK_OF_ALACARTE_REQUEST).get(0); + return serviceName; } @Test public void testServiceInfoIsPresentedInTable() { + String serviceName = addOneJob(); + SideMenu.navigateToMacroInstantiationStatus(); InstantiationStatusPage.clickRefreshButton(); - assertInstantiationStatusRow(projectName + currentUUI, ImmutableMap.of( + InstantiationStatusPage.assertInstantiationStatusRow(serviceName, ImmutableMap.of( "subscriberName", subscriberName, "regionId", regionId, "serviceModelVersion", serviceModelVersion, @@ -104,15 +85,84 @@ public class InstantiationStatusTest extends VidBaseTestCase { )); } - @Test public void testServiceInfoDataUpdatingAfterClickRefresh() { - long numberOfRows = getNumberOfTableRows(60); + addOneJob(); + SideMenu.navigateToMacroInstantiationStatus(); + InstantiationStatusPage.clickRefreshButton(); + long numberOfRows = InstantiationStatusPage.getNumberOfTableRows(60); addOneJob(); InstantiationStatusPage.clickRefreshButton(); - int numberOfRowsAfterRefresh = getNumberOfTableRows(60); + int numberOfRowsAfterRefresh = InstantiationStatusPage.getNumberOfTableRows(60); Assert.assertEquals(numberOfRows + 1 , numberOfRowsAfterRefresh); } + + @Test + @FeatureTogglingTest(Features.FLAG_1902_RETRY_JOB) + public void testRedeployFromDrawingBoardOfServiceWithFailedVnf() { + SideMenu.navigateToMacroInstantiationStatus(); + + CreateServiceWithFailedVnf createServiceWithFailedVnf = createServiceWithFailedVnfAssertStausAndSimulatorRegistration(); + String originalServiceName = createServiceWithFailedVnf.getNames().get(SERVICE_NAME); + + InstantiationStatusPage.clickRefreshButton(); + + //Open job + InstantiationStatusPage.openDrawingBoardForRetry(originalServiceName); + DrawingBoardPage.goToIframe(); + + Wait.waitByTestId("error-msg-wrapper", 10); + boolean isErrorShown = Wait.waitByClassAndText("sub-title", "Attention: You are currently viewing instances from the MSO. 1 of the instances failed, please try again.", 10); + assertTrue(isErrorShown); + + //validate audit info for failed vnf + String originalVnfName = createServiceWithFailedVnf.getNames().get(VNF_NAME); + hoverAndClickMenuByName(originalVnfName, "fe042c22-ba82-43c6-b2f6-8f1fc4164091-vSAMP12 1", Constants.DrawingBoard.CONTEXT_MENU_SHOW_AUDIT); + checkFailedAuditInfoOnRetry(originalVnfName, createServiceWithFailedVnf.getFirstIds().vnfReqId, "Vnf failed."); + + Click.byTestId(DEPLOY_BUTTON); + VidBasePage.goOutFromIframe(); + GeneralUIUtils.ultimateWait(); + vidBasePage.goToIframe(); + GeneralUIUtils.ultimateWait(); + + checkRetryRequestToBeComplete(createServiceWithFailedVnf, originalServiceName); + } + + private void checkFailedAuditInfoOnRetry(String instanceName, String requestId, String message) { + WebElement webElement = Get.byTestId("model-item-value-instance_name"); + assertEquals(webElement.getText(), instanceName, "Instance Name must be equal"); + + WebElement msoTableElement = Get.byId("service-instantiation-audit-info-mso"); + assertEquals(3, msoTableElement.findElement(By.tagName("thead")).findElements(By.tagName("th")).size(), "Audit info MSO table must contain 3 columns"); + assertEquals(requestId, msoTableElement.findElement(By.id("msoRequestId")).getText(), "Audit info Request Id is not equal"); + assertEquals("Failed", msoTableElement.findElement(By.id("msoJobStatus")).getText(), "Audit info Job Status is not equal"); + assertEquals(message, msoTableElement.findElement(By.id("msoAdditionalInfo")).getText(), "Audit info AdditionalInfo is not equal"); + + vidBasePage.screenshotDeployDialog("retry-audit-info-" + instanceName); + Click.byId(Constants.AuditInfoModal.CANCEL_BUTTON); + GeneralUIUtils.ultimateWait(); + } + + private CreateServiceWithFailedVnf createServiceWithFailedVnfAssertStausAndSimulatorRegistration() { + + //CreateServiceWithFailedVnf is common for API test and UI test, + //so if you change it, make sure both test are compatible with your changes + CreateServiceWithFailedVnf createServiceWithFailedVnf = new CreateServiceWithFailedVnf(asyncInstantiationBase); + createServiceWithFailedVnf.createServicesWithVnfCompletedWithError(); + createServiceWithFailedVnf.firstTimeAssertion(); + createServiceWithFailedVnf.secondRegistration(); + return createServiceWithFailedVnf; + } + + private void checkRetryRequestToBeComplete(CreateServiceWithFailedVnf createServiceWithFailedVnf, String originalServiceName) { + DrawingBoardPage.ServiceStatusChecker serviceStatusChecker = new DrawingBoardPage.ServiceStatusChecker(originalServiceName, Collections.singleton(COMPLETED)); + //there shall be 2 rows with same service name, one with completed with error and one completed + //so the following line might be buggy, and we need to improve it one day ... + boolean statusIsShown = Wait.waitFor(serviceStatusChecker, null, 30, 2); + assertTrue("service " + originalServiceName + " wasn't completed after in time", statusIsShown); + createServiceWithFailedVnf.simulatorCallsAssertion(); + } } diff --git a/vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java b/vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java index 173897095..42749c15f 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java @@ -1,51 +1,110 @@ package vid.automation.test.test; -import com.google.common.collect.*; -import org.apache.commons.lang3.RandomStringUtils; -import org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateServiceInstancePost; -import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2; +import static junit.framework.TestCase.assertNull; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.startsWith; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.PRESET_SOME_LEGACY_REGION_TO_ATT_AIC; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet.COMPLETE; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet.DEFAULT_SERVICE_INSTANCE_ID; +import static org.testng.Assert.assertEquals; +import static org.testng.AssertJUnit.assertTrue; +import static vid.automation.test.infra.Features.FLAG_1902_VNF_GROUPING; +import static vid.automation.test.infra.Features.FLAG_5G_IN_NEW_INSTANTIATION_UI; +import static vid.automation.test.infra.Features.FLAG_ASYNC_INSTANTIATION; +import static vid.automation.test.infra.ModelInfo.PASQUALEVmxVpeBvService488Annotations; +import static vid.automation.test.infra.ModelInfo.aLaCarteNetworkProvider5G; +import static vid.automation.test.infra.ModelInfo.aLaCarteVnfGroupingService; +import static vid.automation.test.infra.ModelInfo.macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails; +import static vid.automation.test.infra.ModelInfo.macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetailsVnfEcompNamingFalse; +import static vid.automation.test.infra.ModelInfo.macroSriovWithDynamicFieldsEcompNamingFalsePartialModelDetailsVnfEcompNamingFalse; +import static vid.automation.test.infra.ModelInfo.macroSriovWithDynamicFieldsEcompNamingTruePartialModelDetails; +import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; +import static vid.automation.test.services.SimulatorApi.registerExpectationFromPreset; +import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets; +import static vid.automation.test.test.ALaCarteflowTest.AIC; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; +import org.apache.commons.lang3.mutable.MutableInt; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.hamcrest.Matchers; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetTenants; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIPostNamedQueryForViewEdit; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateInstancePost; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateNetworkALaCarte5G; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceAlacarte5GServiceWithNetwork; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2WithNamesAlacarteGroupingService; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2WithNamesEcompNamingFalse; import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet; -import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestsGet5GServiceInstanceAndNetwork; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestsGet5GServiceInstanceAndNetwork.ResponseDetails; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.RemoteWebElement; import org.testng.Assert; -import org.testng.annotations.*; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import vid.automation.test.Constants; import vid.automation.test.Constants.BrowseASDC.NewServicePopup; -import vid.automation.test.infra.*; +import vid.automation.test.infra.Click; +import vid.automation.test.infra.FeatureTogglingTest; +import vid.automation.test.infra.Features; +import vid.automation.test.infra.Get; +import vid.automation.test.infra.Input; +import vid.automation.test.infra.ModelInfo; +import vid.automation.test.infra.SelectOption; +import vid.automation.test.infra.Wait; import vid.automation.test.model.Service; import vid.automation.test.model.User; -import vid.automation.test.sections.*; +import vid.automation.test.sections.BrowseASDCPage; +import vid.automation.test.sections.DrawingBoardPage; +import vid.automation.test.sections.InstantiationStatusPage; +import vid.automation.test.sections.SideMenu; +import vid.automation.test.sections.VidBasePage; import vid.automation.test.services.AsyncJobsService; import vid.automation.test.services.ServicesService; import vid.automation.test.services.SimulatorApi; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.function.Consumer; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -import static junit.framework.TestCase.assertNull; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.testng.Assert.assertEquals; -import static org.testng.AssertJUnit.assertTrue; -import static vid.automation.test.infra.Features.FLAG_ASYNC_INSTANTIATION; -import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; +import vid.automation.test.utils.ReadFile; @FeatureTogglingTest(FLAG_ASYNC_INSTANTIATION) public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest { + private static final String COMPLETED = "COMPLETED"; + private static final String IN_PROGRESS = "IN_PROGRESS"; + private static final String PENDING = "PENDING"; + private final String vfModule0Name = "2017488_PASQUALEvpe0..2017488PASQUALEVpe..PASQUALE_base_vPE_BV..module-0"; + private final String vfModule0UUID = "f8360508-3f17-4414-a2ed-6bc71161e8db"; private ServicesService servicesService = new ServicesService(); private DrawingBoardPage drawingBoardPage = new DrawingBoardPage(); List<String> serviceModelLabelList = Arrays.asList("Model version", "Description", "Category", "UUID", "Invariant UUID", "Service type", "Service role"); List<String> mandatoryServiceModelLabelList = Arrays.asList("Model version", "UUID", "Invariant UUID"); - private final String defaultServiceModelForMostTests = "6e59c5de-f052-46fa-aa7e-2fca9d674c44"; private final VidBasePage vidBasePage = new VidBasePage(); + public static final String VNF_SET_BUTTON_TEST_ID = "form-set"; + private static final Logger logger = LogManager.getLogger(NewServiceInstanceTest.class); @BeforeClass protected void dropAllAsyncJobs() { @@ -60,36 +119,77 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest { } @BeforeMethod - protected void refreshPage() { - GeneralUIUtils.ultimateWait(); - - vidBasePage.refreshPage(); + protected void goToWelcome() { + SideMenu.navigateToWelcomePage(); } @Override protected UserCredentials getUserCredentials() { - String userName = Constants.Users.USP_VOICE_VIRTUAL_USP; + String userName = Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA; User user = usersService.getUser(userName); return new UserCredentials(user.credentials.userId, user.credentials.password, userName, "", ""); } @Test public void createNewServiceInstance_fullModelData_LeftPaneLabelsCorrect() throws Exception { - loadMacroServicePopup_noDynamicFields_fullModelDetails_ecompNamingFalse(); + prepareServicePreset(macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails, false); + loadServicePopup(macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails); assertServiceModelLabelsCorrect(serviceModelLabelList); } @Test public void createNewServiceInstance_partialModelData_LeftPaneLabelsCorrect() throws Exception { - loadMacroServicePopup_withDynamicFields_partialModelDetails_ecompNamingTrue(); + prepareServicePreset(macroSriovWithDynamicFieldsEcompNamingTruePartialModelDetails, false); + loadServicePopup(macroSriovWithDynamicFieldsEcompNamingTruePartialModelDetails); assertServiceModelLabelsCorrect(mandatoryServiceModelLabelList); } + @Test + public void createNewServiceInstance_setFieldValue_resetDependenciesListsAndValues() { + resetGetTenantsCache(); + try { + BrowseASDCPage browseASDCPage = new BrowseASDCPage(); + prepareServicePreset(macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails, false); + SimulatorApi.registerExpectation(Constants.RegisterToSimulator.CreateNewServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_CAR_2020_ER, SimulatorApi.RegistrationStrategy.APPEND); + registerExpectationFromPreset( + new PresetAAIGetTenants( + "CAR_2020_ER", + "MSO-dev-service-type", + "registration_to_simulator/create_new_instance/aai_get_tenants_for_customer_CAR_2020_ER.json"), + SimulatorApi.RegistrationStrategy.APPEND); + + loadServicePopup(macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails); + Wait.waitByClassAndText(Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS, "SILVIA ROBBINS", 30); + VidBasePage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89"); + GeneralUIUtils.ultimateWait(); + String serviceType = "TYLER SILVIA"; + Wait.waitByClassAndText(Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS, serviceType, 30); + browseASDCPage.selectServiceTypeByName(serviceType); + String lcpRegion = "hvf6"; + Wait.waitByClassAndText("lcpRegionOption", lcpRegion, 30); + viewEditPage.selectLcpRegion(lcpRegion, AIC); + browseASDCPage.selectTenant("bae71557c5bb4d5aac6743a4e5f1d054"); + + VidBasePage.selectSubscriberById("CAR_2020_ER"); + assertElementDisabled("lcpRegion-select"); + serviceType = "MSO-dev-service-type"; + Wait.waitByClassAndText(Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS, serviceType, 30); + browseASDCPage.selectServiceTypeByName(serviceType); + lcpRegion = "CAR_2020_ER"; + Wait.waitByClassAndText("lcpRegionOption", lcpRegion, 30); + viewEditPage.selectLcpRegion(lcpRegion, AIC); + browseASDCPage.selectTenant("092eb9e8e4b7412e8787dd091bc58e66"); + } finally { + resetGetTenantsCache(); + } + } + /** * asserts that the provided labels list is visible and that no other detail item appears in the model details panel. */ protected void assertServiceModelLabelsCorrect(List<String> serviceModelLabelList) throws Exception { - WebElement modelInformation = getDriver().findElement(By.id("model-information")); + WebElement genericPopup = getDriver().findElement(By.tagName("generic-form-popup")); + WebElement modelInformation = genericPopup.findElement(By.id("model-information")); List<WebElement> modelInformationItems = modelInformation.findElements(By.xpath("./div")); assertEquals(modelInformationItems.size(), serviceModelLabelList.size()); serviceModelLabelList.forEach(label -> { @@ -101,179 +201,456 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest { @Test public void createNewServiceInstance_leftPane_serviceModelDataCorrect() { - Service service = servicesService.getService(NewServicePopup.SERVICE_UUID); + Service service = servicesService.getService(macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails.modelVersionId); String prefix = NewServicePopup.SERVICE_MODEL_DATA_TEST_ID_VALUE_PREFIX; - loadMacroServicePopup_noDynamicFields_fullModelDetails_ecompNamingFalse(); - setNewInstance_leftPane_assertModelDataCorrect(NewServicePopup.SERVICE_MODEL_FIELD_TO_DATA_TESTS_ID, prefix, service); + prepareServicePreset(macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails, false); + loadServicePopup(macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails); + logger.info("Expected service model properties: "+service.toString()); + assertModelDataCorrect(NewServicePopup.SERVICE_MODEL_FIELD_TO_DATA_TESTS_ID, prefix, service); } @Test public void createNewServiceInstance_macro_validPopupDataAndUI__ecompNamingFalse() { - ServiceData serviceData = new ServiceData("csar-noDynamicFields-ecompNamingFalse-fullModelDetails-1a80c596.zip", - "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd", + ServiceData serviceData = new ServiceData( + macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails.modelVersionId, new ArrayList<>(), false, true, true, true, - "2017-488_ADIOD-vPE 0", - "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1", 0, 1, ImmutableList.of("Bandwidth", "Bandwidth units")); + "2017-488_PASQUALE-vPE 0", + "2017488_PASQUALEvpe0..2017488PASQUALEVpe..PASQUALE_vRE_BV..module-1", 0, 1, new ArrayList<>(), "25284168-24bb-4698-8cb4-3f509146eca5"); - String serviceInstanceName = deployServiceInstance(serviceData, false); - vidBasePage.screenshotDeployDialog(serviceInstanceName); - deployAndVerifyModuleInPendingTable(serviceInstanceName); - verifyOpenAuditInfo(serviceInstanceName); - verifyOpenViewEdit(serviceInstanceName); - verifyDeleteJob(serviceInstanceName); - verifyHideJob(serviceInstanceName); + prepareServicePreset(macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails, false); + + final String serviceInstanceName = createSriovService(serviceData, true); + createVnf(serviceData, true, true, serviceInstanceName); + + createVfModule(serviceData, serviceInstanceName, false, false); + + } + + @Test(groups = "underDevelopment") + public void createNewServiceInstance_macro_validPopupDataAndUI__dynamicFieldsEcompNamingFalse_DEV() { + /* + Upon failure in test dynamicFieldsEcompNamingFalse_FLESH(), exception will provide + the needed data for this DEV method: + + 1. "Current step" when the failure occurred + 2. "Random alphabetic" that was randomized while test + 3. "Starting reduxState" that was on the step that failed. + + These data can be used for, accordingly, 1. startInStep param; 2, randomAlphabetic + param; 3. reduxForStep param. + */ + + // It should be easier to put `reduxForStep` in this file, to avoid Java's code-clutter and json escaping. + final String reduxForStep = ReadFile.loadResourceAsString( + "NewServiceInstanceTest/createNewServiceInstance_macro_validPopupDataAndUI__dynamicFieldsEcompNamingFalse.json"); + + createNewServiceInstance_macro_validPopupDataAndUI__dynamicFieldsEcompNamingFalse_FLESH("DEV", 5, reduxForStep, "mCaNk"); + } + + @Test + public void createNewServiceInstance_macro_validPopupDataAndUI__dynamicFieldsEcompNamingFalse() { + createNewServiceInstance_macro_validPopupDataAndUI__dynamicFieldsEcompNamingFalse_FLESH("RUNTIME", 0, null, randomAlphabetic(5)); + } + + private void createNewServiceInstance_macro_validPopupDataAndUI__dynamicFieldsEcompNamingFalse_FLESH(String mode, int startInStep, String reduxForStep, String randomAlphabetic) { + + MutableInt i = new MutableInt(); + Map<String, String> reduxStates = new HashMap<>(); + + ServiceData serviceData = new ServiceData( + macroSriovWithDynamicFieldsEcompNamingFalsePartialModelDetailsVnfEcompNamingFalse.modelVersionId, + Collections.singletonList("2017488 PASQUALEvpe0 asn:"), + false, false, true, false, + "2017-488_PASQUALE-vPE 0", + "2017488_PASQUALEvpe0..2017488PASQUALEVpe..PASQUALE_vRE_BV..module-1", 0, 1, ImmutableList.of("Bandwidth", "Bandwidth units"), + "25284168-24bb-4698-8cb4-3f509146eca5"); + + // this is the instance-name that createSriovService is going to use + String serviceInstanceName = randomAlphabetic + "instancename"; + + doReduxStep(reduxStates, randomAlphabetic, startInStep, reduxForStep, i, mode, () -> { + prepareServicePreset(macroSriovWithDynamicFieldsEcompNamingFalsePartialModelDetailsVnfEcompNamingFalse, + false); + createSriovService(serviceData, false, randomAlphabetic); + }); + + doReduxStep(reduxStates, randomAlphabetic, startInStep, reduxForStep, i, mode, () -> + createVnf(serviceData, false, true, serviceInstanceName) + ); + + final String vnfInstanceName2 = randomAlphabetic + "instanceName"; + final String vnfName2 = "2017-388_PASQUALE-vPE"; + + doReduxStep(reduxStates, randomAlphabetic, startInStep, reduxForStep, i, mode, () -> + createVnf(new VnfData(vnfName2 + " 0", "afacccf6-397d-45d6-b5ae-94c39734b168", vnfInstanceName2, false), + false, Features.FLAG_DEFAULT_VNF.isActive(), serviceInstanceName) + ); + + doReduxStep(reduxStates, randomAlphabetic, startInStep, reduxForStep, i, mode, () -> + createVfModule(serviceData, serviceInstanceName, false, true) + ); + + doReduxStep(reduxStates, randomAlphabetic, startInStep, reduxForStep, i, mode, () -> { + + editVfModuleAndJustSetName(vfModule0Name, vfModule0UUID); + if (Features.FLAG_DUPLICATE_VNF.isActive()) { + duplicateVnf(serviceData.vnfData, 2); + } + vidBasePage.screenshotDeployDialog(serviceInstanceName); + }); + + doReduxStep(reduxStates, randomAlphabetic, startInStep, reduxForStep, i, mode, () -> { + prepareServicePreset(macroSriovWithDynamicFieldsEcompNamingFalsePartialModelDetailsVnfEcompNamingFalse, + true); + + final String vfModuleName1 = "2017488PASQUALEVpe..PASQUALE_base_vPE_BV..module-0"; + final String vfModuleName2 = "2017488PASQUALEVpe..PASQUALE_vRE_BV..module-1"; + final String request1 = PresetMSOBaseCreateInstancePost.DEFAULT_REQUEST_ID; + final String request2 = "ce010256-3fdd-4cb5-aed7-37112a2c6e93"; + final ImmutableMap<Keys, String> vars = ImmutableMap.<Keys, String>builder() + .put(Keys.SERVICE_NAME, serviceInstanceName) + .put(Keys.VNF_NAME, cleanSeparators("2017-488_PASQUALE-vPE", serviceData.vnfData.vnfInstanceName)) + .put(Keys.VFM_NAME1, cleanSeparators(vfModuleName1 , "VF instance name ZERO")) + .put(Keys.VFM_NAME2, cleanSeparators(vfModuleName2 , "VF instance name")) + .put(Keys.VG_NAME, cleanSeparators(vfModuleName2 , "VF instance name") + "_vol_abc") + .put(Keys.VNF_NAME2, cleanSeparators(vnfName2, vnfInstanceName2)) + .build(); + registerExpectationFromPresets(ImmutableList.of( + // although "some legacy region" is provided for vnf, Service's region "hvf6" overrides it + PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MTN6_TO_ATT_AIC, + new PresetMSOCreateServiceInstanceGen2WithNamesEcompNamingFalse(vars, 0, request1), + new PresetMSOCreateServiceInstanceGen2WithNamesEcompNamingFalse(vars, 1, request2) + ), SimulatorApi.RegistrationStrategy.APPEND); + + deployAndVerifyModuleInPendingTableMacro(serviceInstanceName, request1, request2); + verifyOpenAuditInfo(serviceInstanceName); + verifyOpenViewEdit(serviceInstanceName); + verifyDeleteJob(serviceInstanceName); + verifyHideJob(serviceInstanceName); + }); + } + + @Test + @FeatureTogglingTest(FLAG_1902_VNF_GROUPING) + public void createNewServiceInstance_aLaCarte_VnfGrouping() { + + String randomAlphabetic = randomAlphabetic(5); + + ServiceData serviceData = new ServiceData( + aLaCarteVnfGroupingService.modelVersionId, + ImmutableList.of(), + false, false, true, false, + null, null, 0, 1, ImmutableList.of(), null); + prepareServicePreset(aLaCarteVnfGroupingService, false); + + createALaCarteService(serviceData, randomAlphabetic); + + // this is the instance-name that createALaCarteService is using + String serviceInstanceName = randomAlphabetic + "instancename"; + + final String requestId = PresetMSOBaseCreateInstancePost.DEFAULT_REQUEST_ID; + final String serviceInstanceId = "d2391436-8d55-4fde-b4d5-72dd2cf13cgh"; + final ImmutableMap<Keys, String> names = ImmutableMap.<Keys, String>builder() + .put(Keys.SERVICE_NAME, serviceInstanceName) + .build(); + SimulatorApi.registerExpectationFromPresets(ImmutableList.of( + new PresetMSOCreateServiceInstanceGen2WithNamesAlacarteGroupingService(names, 0, requestId, serviceInstanceId, "us16807000"), + new PresetAAIPostNamedQueryForViewEdit(serviceInstanceId, serviceInstanceName, false, false) + ), SimulatorApi.RegistrationStrategy.APPEND); + + deploy(); + verifyModuleInPendingTable(serviceInstanceName, requestId, null, ImmutableSet.of(IN_PROGRESS), false, false); + verifyModuleInPendingTable(serviceInstanceName, requestId, null, ImmutableSet.of(COMPLETED), false, true); + InstantiationStatusPage.verifyOpenNewViewEdit(serviceInstanceName, serviceInstanceId, aLaCarteVnfGroupingService.modelVersionId, "TYLER SILVIA", "e433710f-9217-458d-a79d-1c7aff376d89", "EDIT"); + } + + public interface Invoker{ + void invoke(); + } + + private void doReduxStep(Map<String, String> reduxStates, String randomAlphabetic, int startInStep, String reduxForStep, MutableInt currentStep, String mode, Invoker todo) { + try { + switch (mode) { + case "DEV": + if (currentStep.getValue() < startInStep) { + // skip up to startInStep + return; + } else if (currentStep.getValue() == startInStep) { + + setReduxState(reduxForStep); + + vidBasePage.navigateTo("serviceModels.htm#/servicePlanning?serviceModelId=6b528779-44a3-4472-bdff-9cd15ec93450"); + vidBasePage.goToIframe(); + } + + reduxStates.put(String.valueOf(currentStep), getReduxState()); + break; + + case "RUNTIME": + default: + // log current redux state, before invocation + reduxStates.put(String.valueOf(currentStep), getReduxState()); + logger.info("reduxGator runtime reduxState for step {}:\n{}", currentStep, getReduxState()); + break; + } + + try { + todo.invoke(); + } catch (AssertionError | Exception e) { + throw new AssertionError(String.join("\n", + "Current step: " + currentStep, + "Random alphabetic: " + randomAlphabetic, + "Starting reduxState: " + reduxStates.get(String.valueOf(currentStep)), + "Current reduxState: " + getReduxState() + ), e); + } + } finally { + logger.info("Cumulative reduxState: {}", reduxStates); + currentStep.increment(); + } + } + + private void duplicateVnf(VnfData vnfData, int count) { + hoverAndClickDuplicateButton(extractNodeToEdit(vnfData)); + vidBasePage.screenshotDeployDialog("duplicateVnf-" + vnfData.vnfName); + List<WebElement> options = ((RemoteWebElement)Get.byId("duplicate-select")).findElementsByTagName("option"); + assertThat(options.stream().map(x -> x.getText()).collect(Collectors.toList()), Matchers.contains("1","2")); + SelectOption.byIdAndVisibleText("duplicate-select", String.valueOf(count)); + Click.byClassAndVisibleText("sdc-button__primary", "DUPLICATE"); + } + + private String cleanSeparators(String... s) { + return String.join("", s).replace(" ", ""); + } + + private void editVfModuleAndJustSetName(String vfModuleName, String vfModuleUUID) { + if (Features.FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD.isActive()) { + hoverAndClickEditButton(vfModuleUUID + "-" + vfModuleName); + } else { + drawingBoardPage.clickAddButtonByNodeName(vfModuleName); + } + Input.text("VF instance name ZERO", "instanceName"); + Click.byTestId("form-set"); } @Test public void createNewServiceInstance_macro_validPopupDataAndUI__ecompNamingServiceFalseVnfTrue_vgNameFalse() { - ServiceData serviceData = new ServiceData("csar-noDynamicFields-ecompNamingFalse-fullModelDetails-1a80c596.zip", - "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd", + ServiceData serviceData = new ServiceData( + macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails.modelVersionId, new ArrayList<>(), false, true, false, true, - "2017-488_ADIOD-vPE 0", - "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0", 1, 1, new ArrayList<>()); + "2017-488_PASQUALE-vPE 0", + vfModule0Name, 1, 1, new ArrayList<>(), vfModule0UUID); + + prepareServicePreset(macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails, false); + + final String serviceInstanceName = createSriovService(serviceData, true); + createVnf(serviceData, true, true, serviceInstanceName); + createVfModule(serviceData, serviceInstanceName, true, false); - deployServiceInstance(serviceData); } @Test public void createNewServiceInstance_macro_validPopupDataAndUI__ecompNamingServiceFalseVnfFalse_vgNameFalse() { - ServiceData serviceData = new ServiceData("csar-noDynamicFields-ecompNamingFalse-fullModelDetails-1a80c596-vnfEcompNamingFalse.zip", - "4a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd", + ServiceData serviceData = new ServiceData( + macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetailsVnfEcompNamingFalse.modelVersionId, new ArrayList<>(), false, false, false, false, - "2017-488_ADIOD-vPE 0", - "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0", 1, 1, new ArrayList<>()); + "2017-488_PASQUALE-vPE 0", + vfModule0Name, 1, 1, new ArrayList<>(), vfModule0UUID); + + prepareServicePreset(macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetailsVnfEcompNamingFalse, false); + + final String serviceInstanceName = createSriovService(serviceData, true); + createVnf(serviceData, true, true, serviceInstanceName); + createVfModule(serviceData, serviceInstanceName, true, false); - deployServiceInstance(serviceData); } @Test - public void createNewServiceInstance_macro_validPopupDataAndUI__ecompNamingServiceFalseVnfFalse_vgNameTrue() { - ServiceData serviceData = new ServiceData("csar-noDynamicFields-ecompNamingFalse-fullModelDetails-1a80c596-vnfEcompNamingFalse.zip", - "4a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd", + public void createNewServiceInstance_macro_validPopupDataAndUI__ecompNamingServiceFalseVnfFalse_vgNameTrue() throws Exception { + ServiceData serviceData = new ServiceData( + macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetailsVnfEcompNamingFalse.modelVersionId, new ArrayList<>(), false, false, true, false, - "2017-488_ADIOD-vPE 0", - "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1", 0, 1, new ArrayList<>()); + "2017-488_PASQUALE-vPE 0", + "2017488_PASQUALEvpe0..2017488PASQUALEVpe..PASQUALE_vRE_BV..module-1", 0, 1, new ArrayList<>(), "25284168-24bb-4698-8cb4-3f509146eca5"); - deployServiceInstance(serviceData); - } + prepareServicePreset(macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetailsVnfEcompNamingFalse, false); + + final String serviceInstanceName = createSriovService(serviceData, true); + createVnf(serviceData, true, true, serviceInstanceName); + clickRemoveVfModule(vfModule0UUID, vfModule0Name); + createVfModule(serviceData, serviceInstanceName, false, true); - private void deployServiceInstance(ServiceData serviceData) { - deployServiceInstance(serviceData, true); } - private String deployServiceInstance(ServiceData serviceData, boolean tryCancelsAndReentries) { - User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); - final String serviceInstanceName = createSriovService( - user, serviceData.dynamicFields, serviceData.csarName, serviceData.modelUuid, - serviceData.isGeneratedNaming, serviceData.multiStageDesign, - tryCancelsAndReentries); + @Test + @FeatureTogglingTest(FLAG_5G_IN_NEW_INSTANTIATION_UI) + public void createNewServiceInstance_aLaCarte_validPopupDataAndUI() { + String serviceInstanceName = "NcService"+randomAlphabetic(5); + String networkInstanceName= "NcNetowrk"+randomAlphabetic(5); + String defactoNetworkInstanceName = "ExtVL"+networkInstanceName; + BrowseASDCPage browseASDCPage = new BrowseASDCPage(); + prepareServicePreset(aLaCarteNetworkProvider5G, true); + String serviceRequestId = UUID.randomUUID().toString(); + String networkRequestId = UUID.randomUUID().toString(); + String requestorID = getUserCredentials().getUserId(); + registerExpectationFromPresets( + ImmutableList.of( + new PresetMSOCreateServiceInstanceAlacarte5GServiceWithNetwork( + ImmutableMap.of(Keys.SERVICE_NAME, serviceInstanceName), + serviceRequestId, + requestorID), + new PresetMSOOrchestrationRequestGet(COMPLETE, serviceRequestId), + PRESET_SOME_LEGACY_REGION_TO_ATT_AIC, + new PresetMSOCreateNetworkALaCarte5G(networkRequestId, DEFAULT_SERVICE_INSTANCE_ID, defactoNetworkInstanceName, requestorID), + new PresetMSOOrchestrationRequestGet(COMPLETE, networkRequestId), + new PresetMSOOrchestrationRequestsGet5GServiceInstanceAndNetwork( + new ResponseDetails(serviceInstanceName, serviceRequestId, COMPLETE, "service"), + new ResponseDetails(defactoNetworkInstanceName, networkRequestId, COMPLETE, "network"), + DEFAULT_SERVICE_INSTANCE_ID) + ), + APPEND + ); + loadServicePopup(aLaCarteNetworkProvider5G.modelVersionId); + WebElement instanceNameInput = Get.byId("instanceName"); + instanceNameInput.sendKeys(serviceInstanceName); + VidBasePage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89"); + String serviceType = "TYLER SILVIA"; + Wait.waitByClassAndText(Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS, serviceType, 30); + browseASDCPage.selectServiceTypeByName(serviceType); + SelectOption.byTestIdAndVisibleText("WayneHolland", (Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID)); + SelectOption.byTestIdAndVisibleText("WATKINS", Constants.OwningEntity.PROJECT_SELECT_TEST_ID); + Click.byTestId("form-set"); + VidBasePage.goOutFromIframe(); + browseASDCPage.goToIframe(); + VnfData networkData = new VnfData("SR-IOV Provider-1", "840ffc47-e4cf-46de-8e23-525fd8c6fdc3", defactoNetworkInstanceName, false); + createNetwork(networkData, false, false, serviceInstanceName); + drawingBoardPage.clickDeployButton(); - createVnf(serviceData.vnfData.isGeneratedNaming, serviceData.vnfData.vnfName, serviceInstanceName, tryCancelsAndReentries); + VidBasePage.goOutFromIframe(); + GeneralUIUtils.ultimateWait(); + vidBasePage.goToIframe(); + GeneralUIUtils.ultimateWait(); - createVfModule( - serviceData.vfData.vfName, serviceData.vnfData.isGeneratedNaming, - serviceData.vfData.vgEnabled, serviceData.vfData.vfMin, serviceData.vfData.vfMax, - serviceData.vfData.dynamicFields, serviceInstanceName); + DrawingBoardPage.ServiceStatusChecker serviceStatusChecker = new DrawingBoardPage.ServiceStatusChecker(serviceInstanceName, Collections.singleton(COMPLETED)); + boolean statusIsShown = Wait.waitFor(serviceStatusChecker, null, 20, 2); + assertTrue("service "+serviceInstanceName+" wasnt completed after in time", statusIsShown); - return serviceInstanceName; + VidBasePage.goOutFromIframe(); } - @Test - public void createNewServiceInstance_macro_validPopupDataAndUI__ecompNamingTrue() { + public void createNewServiceInstance_macro_validPopupDataAndUI() { - List<String> serviceDynamicFields = Arrays.asList("2017488 adiodvpe0 asn:"); - ServiceData serviceData = new ServiceData("csar-withDynamicFields-ecompNamingTrue-partialModelDetails.zip", - "2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd", + List<String> serviceDynamicFields = Arrays.asList("2017488 PASQUALEvpe0 asn:"); + ServiceData serviceData = new ServiceData( + macroSriovWithDynamicFieldsEcompNamingTruePartialModelDetails.modelVersionId, serviceDynamicFields, - true, true, false, false, - "2017-488_ADIOD-vPE 0", - "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1", 0, 1, new ArrayList<>()); + true, true, true, false, + "2017-488_PASQUALE-vPE 0", + "2017488_PASQUALEvpe0..2017488PASQUALEVpe..PASQUALE_vRE_BV..module-1", 0, 1, new ArrayList<>(), "25284168-24bb-4698-8cb4-3f509146eca5"); - deployServiceInstance(serviceData); + prepareServicePreset(macroSriovWithDynamicFieldsEcompNamingTruePartialModelDetails, false); + + final String serviceInstanceName = createSriovService(serviceData, true); + createVnf(serviceData, true, true, serviceInstanceName); + clickRemoveVfModule(vfModule0UUID, vfModule0Name); + createVfModule(serviceData, serviceInstanceName, false, false); } - private void deployAndVerifyModuleInPendingTable(String serviceInstanceName) { - drawingBoardPage.clickDeployButton(); + private void deployAndVerifyModuleInPendingTableMacro(String serviceInstanceName, String requestId1, String requestId2) { + deploy(); boolean simulatorUpdated = false; - vidBasePage.goToIframe(); - GeneralUIUtils.ultimateWait(); - int[] ids = {1, 1, 2, 3}; - String[] statuses = {"IN_PROGRESS", "COMPLETED", "IN_PROGRESS", "PENDING"}; + int[] ids = {0, 0, 1, 2}; + String[] statuses = {IN_PROGRESS, COMPLETED, IN_PROGRESS, PENDING}; for (int i = 0; i < ids.length; i++) { String actualInstanceName = getActualInstanceName(serviceInstanceName, ids[i], statuses[i]); + verifyModuleInPendingTable(actualInstanceName, requestId1, requestId2, ImmutableSet.of(statuses[i]), true, simulatorUpdated); + simulatorUpdated = true; + } + vidBasePage.screenshotDeployDialog(serviceInstanceName); + } + + private void deploy() { + try { + logger.info("Redux state before deploy:"); + logger.info(getReduxState()); + } + catch (Exception e) { + //do nothing just logging + } + drawingBoardPage.clickDeployButton(); + + VidBasePage.goOutFromIframe(); + GeneralUIUtils.ultimateWait(); + vidBasePage.goToIframe(); + GeneralUIUtils.ultimateWait(); + } - final Set<String> expectedStatuses = ImmutableSet.of(statuses[i]); - ServiceStatusChecker serviceStatusChecker = new ServiceStatusChecker(actualInstanceName, expectedStatuses); - boolean statusIsShown = Wait.waitFor(serviceStatusChecker, null, 20, 2); - final String assertionMessage = String.format("service %s: none of rowClasses [%s] is in expectedStatuses: [%s] ", - actualInstanceName, - String.join(",", serviceStatusChecker.getColumnClassesSet()), - String.join(",", expectedStatuses)); + private void verifyModuleInPendingTable(String serviceInstanceName, String requestId1, String requestId2, Set<String> expectedStatuses, boolean isMacro, boolean simulatorUpdated) { + DrawingBoardPage.ServiceStatusChecker serviceStatusChecker = new DrawingBoardPage.ServiceStatusChecker(serviceInstanceName, expectedStatuses); + boolean statusIsShown = Wait.waitFor(serviceStatusChecker, null, 20, 2); + final String assertionMessage = String.format("service %s: none of rowClasses [%s] is in expectedStatuses: [%s] ", + serviceInstanceName, + String.join(",", serviceStatusChecker.getColumnClassesSet()), + String.join(",", expectedStatuses)); - assertTrue(assertionMessage, statusIsShown); + assertTrue(assertionMessage, statusIsShown); + if (isMacro) { InstantiationStatusPage.assertInstantiationStatusRow( - actualInstanceName, expectedRowFields(actualInstanceName)); - - if (!simulatorUpdated) { - simulatorUpdated = true; - final String request1 = PresetMSOBaseCreateServiceInstancePost.DEFAULT_REQUEST_ID; - final String request2 = "ce010256-3fdd-4cb5-aed7-37112a2c6e93"; - SimulatorApi.registerExpectationFromPreset(new PresetMSOCreateServiceInstanceGen2(request2), APPEND); - SimulatorApi.registerExpectationFromPreset(new PresetMSOOrchestrationRequestGet("IN_PROGRESS", request2), APPEND); - SimulatorApi.registerExpectationFromPreset(new PresetMSOOrchestrationRequestGet("COMPLETE", request1), APPEND); + serviceInstanceName, expectedRowFields(serviceInstanceName)); + } else { + InstantiationStatusPage.assertInstantiationStatusRow( + serviceInstanceName, expectedALaCarteRowFields(serviceInstanceName)); + } + + if (!simulatorUpdated) { + if (requestId2 != null) { + registerExpectationFromPreset(new PresetMSOOrchestrationRequestGet(IN_PROGRESS, requestId2), APPEND); } + registerExpectationFromPreset(new PresetMSOOrchestrationRequestGet("COMPLETE", requestId1), APPEND); } vidBasePage.screenshotDeployDialog(serviceInstanceName); } private String getActualInstanceName(String serviceInstanceName, Integer i, String status) { - return "PENDING".equals(status) ? serviceInstanceName : serviceInstanceName + "_00" + i; + return i==0 ? serviceInstanceName : serviceInstanceName + "_00" + i; } private void verifyOpenViewEdit(String serviceInstanceName) { boolean[] openEnabled = {true, false, false}; - String[] statuses = {"COMPLETED", "IN_PROGRESS", "PENDING"}; - ImmutableList.of(1, 2, 3).forEach(i -> { - String actualInstanceName = getActualInstanceName(serviceInstanceName, i, statuses[i - 1]); - checkMenuItem(actualInstanceName, Constants.InstantiationStatus.CONTEXT_MENU_HEADER_OPEN_ITEM, openEnabled[i - 1], contextMenuOpen -> { - Click.byTestId(contextMenuOpen); - vidBasePage.goOutFromIframe(); - GeneralUIUtils.ultimateWait(); - - Wait.byText("View/Edit Service Instance"); - Wait.byText("Add node instance"); - Wait.byText("i'm a port"); - Wait.byText("f8791436-8d55-4fde-b4d5-72dd2cf13cfb"); - - vidBasePage.screenshotDeployDialog("view-edit-" + actualInstanceName); - SideMenu.navigateToMacroInstantiationStatus(); - }); + String[] statuses = {COMPLETED, IN_PROGRESS, PENDING}; + ImmutableList.of(0, 1, 2).forEach(i -> { + String actualInstanceName = getActualInstanceName(serviceInstanceName, i, statuses[i]); + if (Features.FLAG_1902_NEW_VIEW_EDIT.isActive()) { + InstantiationStatusPage.verifyOpenNewViewEdit(actualInstanceName, openEnabled[i], "EDIT"); + } + else { + vidBasePage.verifyOpenOldViewEdit(actualInstanceName, null, openEnabled[i], true, true); + } }); } - private void verifyOpenAuditInfo(String serviceInstanceName) { boolean auditInfoEnabled = true; - String[] statuses = {"COMPLETED", "IN_PROGRESS", "PENDING"}; - for (Integer i : ImmutableList.of(1, 2, 3)) { - String actualInstanceName = getActualInstanceName(serviceInstanceName, i, statuses[i - 1]); - checkMenuItem(actualInstanceName, Constants.InstantiationStatus.CONTEXT_MENU_HEADER_AUDIT_INFO_ITEM, auditInfoEnabled, contextMenuOpen -> { + String[] statuses = {COMPLETED, IN_PROGRESS, PENDING}; + for (Integer i : ImmutableList.of(0, 1, 2)) { + String actualInstanceName = getActualInstanceName(serviceInstanceName, i, statuses[i]); + InstantiationStatusPage.checkMenuItem(actualInstanceName, Constants.InstantiationStatus.CONTEXT_MENU_HEADER_AUDIT_INFO_ITEM, auditInfoEnabled, contextMenuOpen -> { Click.byTestId(contextMenuOpen); checkAuditInfoModal(actualInstanceName, i, statuses); }); final WebElement row = InstantiationStatusPage.getInstantiationStatusRow(actualInstanceName); - row.findElement(By.id(Constants.InstantiationStatus.TD_JOB_STATUS_ICON + "-" + (i - 1))).click(); + row.findElement(By.id(Constants.InstantiationStatus.TD_JOB_STATUS_ICON + "-" + (i))).click(); checkAuditInfoModal(actualInstanceName, i, statuses); } } @@ -294,16 +671,16 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest { convertUITextCapitalizeAndFormatPipe(s.getText())) .collect(Collectors.toList()); - List<String> serviceStatus = Arrays.asList(Arrays.copyOfRange(statuses, i - 1, statuses.length)); + List<String> serviceStatus = Arrays.asList(Arrays.copyOfRange(statuses, i, statuses.length)); assertThat("statuses for " + actualInstanceName + " must be as expected", vidStatuses, is(Lists.reverse(serviceStatus))); String dateString = vidTableElement.findElements(By.id("vidStatusTime")).get(0).getText(); assertTrue("vid Status Time column must contains valid date in format : MMM dd, yyyy HH:mm", isDateValid(dateString, "MMM dd, yyyy HH:mm")); WebElement MSOTableElement = Get.byId("service-instantiation-audit-info-mso"); - assertEquals(4, MSOTableElement.findElement(By.tagName("thead")).findElements(By.tagName("th")).size(), "MSO table must contain 4 columns"); + assertEquals(3, MSOTableElement.findElement(By.tagName("thead")).findElements(By.tagName("th")).size(), "MSO table must contain 3 columns"); - if (statuses[i - 1].equals("PENDING")) { + if (statuses[i].equals(PENDING)) { assertEquals(0, MSOTableElement.findElement(By.tagName("tbody")).findElements(By.tagName("tr")).size(), "When status is PENDING MSO table is empty"); } @@ -335,20 +712,20 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest { private void verifyDeleteJob(String serviceInstanceName) { boolean[] deleteEnabled = {false, false, true}; - String[] statuses = {"COMPLETED", "IN_PROGRESS", "PENDING"}; - verifyDeleteOrHideOperation(serviceInstanceName, Constants.InstantiationStatus.CONTEXT_MENU_DELETE, statuses, deleteEnabled, "deleted"); + String[] statuses = {COMPLETED, IN_PROGRESS, PENDING}; + verifyDeleteOrHideOperation(serviceInstanceName, Constants.InstantiationStatus.CONTEXT_MENU_REMOVE, statuses, deleteEnabled, "deleted"); } private void verifyHideJob(String serviceInstanceName) { boolean[] hideEnabled = {true, false}; - String[] statuses = {"COMPLETED", "IN_PROGRESS"}; + String[] statuses = {COMPLETED, IN_PROGRESS}; verifyDeleteOrHideOperation(serviceInstanceName, Constants.InstantiationStatus.CONTEXT_MENU_HIDE, statuses, hideEnabled, "hidden"); } private void verifyDeleteOrHideOperation(String serviceInstanceName, String contextMenuItem, String[] statuses, boolean[] operationEnabled, String operationName) { - for (int i = 1; i <= statuses.length; i++) { - String actualInstanceName = getActualInstanceName(serviceInstanceName, i, statuses[i - 1]); - checkMenuItem(actualInstanceName, contextMenuItem, operationEnabled[i - 1], contextMenuDelete -> { + for (int i = 0; i < statuses.length; i++) { + String actualInstanceName = getActualInstanceName(serviceInstanceName, i, statuses[i]); + InstantiationStatusPage.checkMenuItem(actualInstanceName, contextMenuItem, operationEnabled[i], contextMenuDelete -> { Click.byTestId(contextMenuDelete); GeneralUIUtils.ultimateWait(); assertNull(actualInstanceName + " should be " + operationName, @@ -358,114 +735,117 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest { vidBasePage.screenshotDeployDialog(serviceInstanceName); } - private void checkMenuItem(String actualInstanceName, String contextMenuItem, boolean shouldBeEnabled, Consumer<String> doIfEnabled) { - Wait.waitFor(name -> { - if (null == InstantiationStatusPage.getInstantiationStatusRow(name)) { - InstantiationStatusPage.clickRefreshButton(); - return false; - } else { - return true; - } - }, actualInstanceName, 8, 1); - final WebElement row = InstantiationStatusPage.getInstantiationStatusRow(actualInstanceName); - row.findElement(By.className("menu-div")).click(); - String clazz = Get.byXpath("//div[@data-tests-id='" + contextMenuItem + "']/ancestor::li").getAttribute("class"); - assertThat("item " + contextMenuItem + " of " + actualInstanceName + - " should be " + (shouldBeEnabled ? "enabled" : "disabled"), !clazz.equals("disabled"), is(shouldBeEnabled)); - if (shouldBeEnabled) { - doIfEnabled.accept(contextMenuItem); - } else { - // dismiss menu - Get.byClass("title").get(0).click(); - } - } - private ImmutableMap<String, String> expectedRowFields(String actualInstanceName) { return ImmutableMap.<String, String>builder() .put("userId", getUserCredentials().getUserId()) .put("serviceModelName", "action-data") .put("serviceInstanceName", actualInstanceName) .put("serviceModelVersion", "1.0") - .put("subscriberName", "USP VOICE") - .put("serviceType", "VIRTUAL USP") - .put("regionId", "mtn6") - .put("tenantName", "AIN Web Tool-15-D-testgamma") + .put("subscriberName", "SILVIA ROBBINS") + .put("serviceType", "TYLER SILVIA") + .put("regionId", "hvf6") + .put("tenantName", "AIN Web Tool-15-D-testalexandria") .put("aicZoneName", "NFTJSSSS-NFT1") - .put("project", "DFW") - .put("owningEntityName", "MetroPacketCore") + .put("project", "WATKINS") + .put("owningEntityName", "WayneHolland") + .put("pause", "false") + .build(); + } + + private ImmutableMap<String, String> expectedALaCarteRowFields(String actualInstanceName) { + return ImmutableMap.<String, String>builder() + .put("userId", getUserCredentials().getUserId()) + .put("serviceModelName", "Grouping Service for Test") + .put("serviceInstanceName", actualInstanceName) + .put("serviceModelVersion", "1.0") + .put("subscriberName", "SILVIA ROBBINS") + .put("serviceType", "TYLER SILVIA") + .put("project", "WATKINS") + .put("owningEntityName", "WayneHolland") .put("pause", "false") .build(); } - private String createSriovService(User user, List<String> serviceDynamicFields, - String csarName, String modelId, boolean modelWithGeneratedName, - boolean multiStageDesign, boolean tryCancelsAndReentries) { + private String createSriovService(ServiceData serviceData, boolean tryCancelsAndReentries) { + return createSriovService(serviceData, tryCancelsAndReentries, randomAlphabetic(5)); + } + + private String createSriovService(ServiceData serviceData, boolean tryCancelsAndReentries, String randomAlphabetic) { BrowseASDCPage browseASDCPage = new BrowseASDCPage(); + User user = usersService.getUser(Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA); // simulate typing with spaces, but expected is without spaces - String serviceInstanceNameWithSpaces = RandomStringUtils.randomAlphabetic(5) + " instance name"; - String serviceInstanceName = serviceInstanceNameWithSpaces.replace(" ", ""); + String serviceInstanceNameWithSpaces = randomAlphabetic + " instance name"; + String serviceInstanceName = cleanSeparators(serviceInstanceNameWithSpaces); List<String> cycles = tryCancelsAndReentries ? ImmutableList.of("WILL_CANCEL", "AFTER_CANCEL") : ImmutableList.of("SINGLE_SHOT"); cycles.forEach(cycle -> { if ("AFTER_CANCEL".equals(cycle)) { - loadServicePopupOnBrowseASDCPage(modelId); + loadServicePopupOnBrowseASDCPage(serviceData.modelUuid); } else { - loadServicePopup(csarName, modelId); + loadServicePopup(serviceData.modelUuid); } - WebElement instanceName = Get.byId("instance-name"); - if (modelWithGeneratedName) { - Assert.assertNull(instanceName, "instance name input should be invisible when serviceEcompNaming == true."); + WebElement instanceName = Get.byId("instanceName"); + boolean isRequired = isElementByIdRequired("instanceName-label"); + if (serviceData.isGeneratedNaming) { + Assert.assertNotNull(instanceName, "instance name input should be visible when serviceEcompNaming == true."); + Assert.assertFalse(isRequired,"instance name input should be optional when ecompNaming == true."); + } else { - instanceName.sendKeys(serviceInstanceNameWithSpaces); + Assert.assertTrue(isRequired,"instance name input should be required when serviceEcompNaming == false."); + instanceName.sendKeys(serviceInstanceName); } //serviceType should be dependent on subscriber selection - assertElementDisabled("service-type-select"); - - GeneralUIUtils.ultimateWait(); - assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS); - VidBasePage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89"); + assertElementDisabled("serviceType-select"); + Wait.waitByClassAndText(Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS, "SILVIA ROBBINS", 30); GeneralUIUtils.ultimateWait(); + Click.byTestId(Constants.SUBSCRIBER_NAME_SELECT_TESTS_ID); + if (Features.FLAG_RESTRICTED_SELECT.isActive()) + assertElementExistAccordingTagNameAndTestId("select", Constants.SUBSCRIBER_SELECT_ID); + else{ + assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS); + } + VidBasePage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89"); //lcpRegion should be dependent on serviceType selection assertElementDisabled("lcpRegion-select"); - String serviceType = "VIRTUAL USP"; + String serviceType = "TYLER SILVIA"; Wait.waitByClassAndText(Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS, serviceType, 30); browseASDCPage.selectServiceTypeByName(serviceType); //tenant should be dependent on lcpRegion selection assertElementDisabled("tenant-select"); - String lcpRegion = "mtn6"; + String lcpRegion = "hvf6"; Wait.waitByClassAndText("lcpRegionOption", lcpRegion, 30); - browseASDCPage.selectLcpRegion(lcpRegion); + viewEditPage.selectLcpRegion(lcpRegion, AIC); + GeneralUIUtils.ultimateWait(); browseASDCPage.selectTenant("bae71557c5bb4d5aac6743a4e5f1d054"); - String setButtonTestId = "service-form-set"; + String setButtonTestId = "form-set"; assertSetButtonDisabled(setButtonTestId); - SelectOption.byTestIdAndVisibleText("MetroPacketCore", (Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID)); + SelectOption.byTestIdAndVisibleText("WayneHolland", (Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID)); assertSetButtonDisabled(setButtonTestId); - SelectOption.byTestIdAndVisibleText("DHV", Constants.ViewEdit.PRODUCT_FAMILY_SELECT_TESTS_ID); + SelectOption.byTestIdAndVisibleText("ERICA", Constants.ViewEdit.PRODUCT_FAMILY_SELECT_TESTS_ID); assertSetButtonEnabled(setButtonTestId); browseASDCPage.selectProductFamily("e433710f-9217-458d-a79d-1c7aff376d89"); - assertAllIsPermitted(Constants.BrowseASDC.AIC_OPTION_CLASS); browseASDCPage.selectAicZone("NFT1"); - SelectOption.byTestIdAndVisibleText("DFW", Constants.OwningEntity.PROJECT_SELECT_TEST_ID); + SelectOption.byTestIdAndVisibleText("WATKINS", Constants.OwningEntity.PROJECT_SELECT_TEST_ID); assertNotificationAreaVisibilityBehaviour(); - assertPauseOnPausePointsVisibility(multiStageDesign); + assertPauseOnPausePointsVisibility(serviceData.multiStageDesign); - validateDynamicFields(serviceDynamicFields); + validateDynamicFields(serviceData.dynamicFields); vidBasePage.screenshotDeployDialog("createSriovService-" + serviceInstanceName); @@ -475,7 +855,7 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest { Click.byTestId(setButtonTestId); } - browseASDCPage.goOutFromIframe(); + VidBasePage.goOutFromIframe(); browseASDCPage.goToIframe(); @@ -483,112 +863,268 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest { return serviceInstanceName; } - private void createVnf(boolean isInstanceNameGenerated, String vnfName, String serviceInstanceName, boolean tryCancelsAndReentries) { + private String createALaCarteService(ServiceData serviceData, String randomAlphabetic) { BrowseASDCPage browseASDCPage = new BrowseASDCPage(); - drawingBoardPage.clickAddButtonByNodeName(vnfName); + User user = usersService.getUser(Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA); + + // simulate typing with spaces, but expected is without spaces + String serviceInstanceNameWithSpaces = randomAlphabetic + " instance name"; + String serviceInstanceName = cleanSeparators(serviceInstanceNameWithSpaces); + + loadServicePopup(serviceData.modelUuid); - if (isInstanceNameGenerated) { - WebElement instanceName = Get.byId("instance-name"); + WebElement instanceName = Get.byId("instanceName"); + if (serviceData.isGeneratedNaming) { Assert.assertNull(instanceName, "instance name input should be invisible when serviceEcompNaming == true."); } else { - Input.text("VNF instance name", "instanceName"); + instanceName.sendKeys(serviceInstanceName); + } + + //serviceType should be dependent on subscriber selection + assertElementDisabled("serviceType-select"); + Wait.waitByClassAndText(Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS, "SILVIA ROBBINS", 30); + GeneralUIUtils.ultimateWait(); + Click.byTestId(Constants.SUBSCRIBER_NAME_SELECT_TESTS_ID); + if (Features.FLAG_RESTRICTED_SELECT.isActive()) + assertElementExistAccordingTagNameAndTestId("select", Constants.SUBSCRIBER_SELECT_ID); + else{ + assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS); + + } + VidBasePage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89"); + + String serviceType = "TYLER SILVIA"; + Wait.waitByClassAndText(Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS, serviceType, 30); + browseASDCPage.selectServiceTypeByName(serviceType); + + String setButtonTestId = "form-set"; + assertSetButtonDisabled(setButtonTestId); + + SelectOption.byTestIdAndVisibleText("WayneHolland", (Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID)); + + SelectOption.byTestIdAndVisibleText("WATKINS", Constants.OwningEntity.PROJECT_SELECT_TEST_ID); + + validateDynamicFields(serviceData.dynamicFields); + + vidBasePage.screenshotDeployDialog("createALaCarteService-" + serviceInstanceName); + + Click.byTestId(setButtonTestId); + + VidBasePage.goOutFromIframe(); + + browseASDCPage.goToIframe(); + + return serviceInstanceName; + } + + private void assertElementExistAccordingTagNameAndTestId(String tag, String testId) { + WebElement webElement = Get.byId(testId); + Assert.assertEquals(webElement.getTagName(), tag); + } + + private void createVnf(ServiceData serviceData, boolean tryCancelsAndReentries, boolean addedByDefault, String serviceInstanceName) { + createVnf(serviceData.vnfData, tryCancelsAndReentries, addedByDefault, serviceInstanceName); + } + + private void createNetwork(VnfData vnfData, boolean tryCancelsAndReentries, boolean addedByDefault, String serviceInstanceName) { + createVnf(vnfData, tryCancelsAndReentries, addedByDefault, serviceInstanceName, true); + } + + private void createVnf(VnfData vnfData, boolean tryCancelsAndReentries, boolean addedByDefault, String serviceInstanceName) { + createVnf(vnfData, tryCancelsAndReentries, addedByDefault, serviceInstanceName, false); + } + + private void createVnf(VnfData vnfData, boolean tryCancelsAndReentries, boolean addedByDefault, String serviceInstanceName, boolean isNetwork) { + BrowseASDCPage browseASDCPage = new BrowseASDCPage(); + + String nodeToEdit = extractNodeToEdit(vnfData); + if (addedByDefault && Features.FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD.isActive()) { + hoverAndClickEditButton(nodeToEdit); + } else { + drawingBoardPage.clickAddButtonByNodeName(vnfData.vnfName); + } + + GeneralUIUtils.ultimateWait(); + + if (vnfData.isGeneratedNaming) { + Assert.assertFalse(isElementByIdRequired("instanceName-label") ,"instance name input should be optional when EcompNaming == true, and required when false."); + } else { + Input.text(vnfData.vnfInstanceName, "instanceName"); } + //tenant should be dependent on lcpRegion selection assertElementDisabled("tenant-select"); WebElement legacyRegion = Get.byTestId("lcpRegionText"); - Assert.assertNull(legacyRegion, "legacy region shouldn't be visible when lcp region isn't AAIAIC25,rdm3 or rdm5a."); + Assert.assertNull(legacyRegion, "legacy region shouldn't be visible when lcp region isn't JANET25,olson3 or olson5a."); - browseASDCPage.selectLcpRegion("AAIAIC25"); + browseASDCPage.selectLcpRegion("JANET25"); legacyRegion = Get.byTestId("lcpRegionText"); - Assert.assertNotNull(legacyRegion, "legacy region should be visible when lcp region is AAIAIC25,rdm3 or rdm5a."); + Assert.assertNotNull(legacyRegion, "legacy region should be visible when lcp region is JANET25,olson3 or olson5a."); browseASDCPage.selectTenant("092eb9e8e4b7412e8787dd091bc58e86"); - String setButtonTestId = "vnf-form-set"; - assertSetButtonDisabled(setButtonTestId); + assertSetButtonDisabled(VNF_SET_BUTTON_TEST_ID); browseASDCPage.selectPlatform("platform"); - assertSetButtonEnabled(setButtonTestId); + assertSetButtonEnabled(VNF_SET_BUTTON_TEST_ID); browseASDCPage.setLegacyRegion("some legacy region"); - browseASDCPage.selectLineOfBusiness("ECOMP"); + browseASDCPage.selectLineOfBusiness("ONAP"); Wait.waitByTestId("model-item-value-subscriberName", 10); - Assert.assertEquals(Get.byTestId("model-item-value-subscriberName").getText(), "USP VOICE", "Subscriber name should be shown in vf module"); + Assert.assertEquals(Get.byTestId("model-item-value-subscriberName").getText(), "SILVIA ROBBINS", "Subscriber name should be shown in vf module"); Assert.assertEquals(Get.byTestId("model-item-value-min"), null, "Min value should not be shown in VNF popup"); Assert.assertEquals(Get.byTestId("model-item-value-max"), null, "Max value should not be show in VNF popup"); - if (!isInstanceNameGenerated) { + if (!vnfData.isGeneratedNaming) { Assert.assertEquals(Get.byTestId("model-item-value-serviceName").getText(), serviceInstanceName, "Subscriber name should be shown in vf module"); } vidBasePage.screenshotDeployDialog("createVnf-" + serviceInstanceName); - Click.byTestId(setButtonTestId); - - String nodeToEdit = "69e09f68-8b63-4cc9-b9ff-860960b5db09-2017-488_ADIOD-vPE 0"; + Click.byTestId(VNF_SET_BUTTON_TEST_ID); + if (isNetwork) { + return; + } if (tryCancelsAndReentries) { hoverAndClickEditButton(nodeToEdit); - Wait.byText("VIRTUAL USP"); + Wait.byText("TYLER SILVIA"); GeneralUIUtils.ultimateWait(); - Assert.assertEquals(Get.selectedOptionText(Constants.ViewEdit.LCP_REGION_SELECT_TESTS_ID), "AAIAIC25"); + assertThat(Get.selectedOptionText(Constants.ViewEdit.LCP_REGION_SELECT_TESTS_ID), startsWith("JANET25")); Assert.assertEquals(Get.selectedOptionText(Constants.ViewEdit.TENANT_SELECT_TESTS_ID), "USP-SIP-IC-24335-T-01"); - Assert.assertEquals(Get.selectedOptionText(Constants.ViewEdit.LINE_OF_BUSINESS_SELECT_TESTS_ID), "ECOMP"); + Assert.assertEquals(Get.selectedOptionText(Constants.ViewEdit.LINE_OF_BUSINESS_SELECT_TESTS_ID), "ONAP"); Assert.assertEquals(Get.selectedOptionText(Constants.OwningEntity.PLATFORM_SELECT_TEST_ID), "platform"); Click.byTestId(Constants.CANCEL_BUTTON_TEST_ID); + GeneralUIUtils.ultimateWait(); } else { - toggleItemInTree(nodeToEdit); + toggleItemInTree(Constants.DrawingBoard.AVAILABLE_MODELS_TREE); } + Click.byTestId("node-" + nodeToEdit); + } + + private String extractNodeToEdit(VnfData vnfData) { + return vnfData.vnfUuid + "-" + vnfData.vnfName; } - private void toggleItemInTree(String nodeToEdit) { - Click.byXpath("//tree-root[@data-tests-id='" + Constants.DrawingBoard.AVAILABLE_MODELS_TREE + "']//span[@class='" + Constants.DrawingBoard.TOGGLE_CHILDREN + "']"); + + private void toggleItemInTree(String tree) { + Click.byXpath("//tree-root[@data-tests-id='" + tree + "']//span[@class='" + Constants.DrawingBoard.TOGGLE_CHILDREN + "']"); } private void hoverAndClickEditButton(String nodeToEdit) { - String buttonOfEdit = Constants.DrawingBoard.NODE_PREFIX + nodeToEdit + Constants.DrawingBoard.CONTEXT_MENU_BUTTON; + hoverAndClickButton(nodeToEdit, Constants.DrawingBoard.CONTEXT_MENU_EDIT); + } + + private void hoverAndClickDeleteButton(String nodeToEdit) { + hoverAndClickButton(nodeToEdit, Constants.InstantiationStatus.CONTEXT_MENU_REMOVE); + } + + private void hoverAndClickDuplicateButton(String nodeToEdit) { + hoverAndClickButton(nodeToEdit, Constants.InstantiationStatus.CONTEXT_MENU_DUPLICATE); + } + private void hoverAndClickButton(String nodeToEdit, String contextMenuItem) { + String nodeOfEdit = Constants.DrawingBoard.NODE_PREFIX + nodeToEdit; + String buttonOfEdit = nodeOfEdit + Constants.DrawingBoard.CONTEXT_MENU_BUTTON; GeneralUIUtils.hoverOnAreaByTestId(buttonOfEdit); Click.byTestId(buttonOfEdit); - Click.byTestId(Constants.DrawingBoard.CONTEXT_MENU_ITEM); + Click.byTestId(contextMenuItem); } - private void createVfModule(String vfModuleName, boolean isInstanceNameGenerated, boolean vgEnabled, int vgMin, - int vgMax, List<String> vfModuleDynamicFields, String serviceInstanceName) { - String setButtonTestId = "vnf-form-set"; + private void uploadSupplementaryFile(String inputFileName, boolean isValid, BrowseASDCPage browseASDCPage, String setButtonTestId) { + if (Features.FLAG_SUPPLEMENTARY_FILE.isActive()) { + GeneralUIUtils.ultimateWait(); + Input.file("supplementaryFiles/" + inputFileName, "supplementaryFile"); + GeneralUIUtils.ultimateWait(); + WebElement fileName = Get.byTestId("file-name"); + Assert.assertEquals(fileName.getText(),inputFileName); + browseASDCPage.assertButtonState(setButtonTestId, isValid); + } + } + + private void deleteSupplementaryFile() { + if (Features.FLAG_SUPPLEMENTARY_FILE.isActive()) { + Click.byTestId("remove-uploaded-file"); + GeneralUIUtils.ultimateWait(); + WebElement fileName = Get.byTestId("file-name"); + Assert.assertEquals(fileName.getText(),"Choose file"); + } + } + + private void createVfModule(ServiceData serviceData, String serviceInstanceName, boolean addedByDefault, boolean addOpensPopup) { + clickAddVfModule(serviceData, addedByDefault); + if (!addOpensPopup) { + clickEditVfModule(serviceData); + } + fillAndSetVfModulePopup(serviceData, serviceInstanceName); + } + + private void fillAndSetVfModulePopup(ServiceData serviceData, String serviceInstanceName) { + String setButtonTestId = "form-set"; BrowseASDCPage browseASDCPage = new BrowseASDCPage(); -// Click.byTestId(Constants.DrawingBoard.NODE_PREFIX + vnfName); - drawingBoardPage.clickAddButtonByNodeName(vfModuleName); - if (!isInstanceNameGenerated) { - Input.text("VF instance name", "instanceName"); - } else { - Assert.assertNull(Get.byTestId("instanceName")); - Assert.assertNull(Get.byTestId("volumeGroupName")); + Assert.assertEquals(isElementByIdRequired("instanceName-label"), !serviceData.vnfData.isGeneratedNaming,"instance name input should be optional when EcompNaming == true, and required when false."); + + if (!serviceData.vnfData.isGeneratedNaming) { + Input.text("VF instance name", "instanceName"); } - if (vgEnabled && !isInstanceNameGenerated) { - browseASDCPage.setInputText("volumeGroupName", "some group name name"); + + if (serviceData.vfData.vgEnabled) { + browseASDCPage.setInputText("volumeGroupName", "_abc"); + Assert.assertEquals(isElementByIdRequired("volumeGroupName-label"), false, "volume Group name input should be always optional"); } else { Assert.assertNull(Get.byTestId("volumeGroupName"), "volumeGroupName input should be invisible when vgEnabled == false"); } Wait.waitByTestId("model-item-value-subscriberName", 10); - Assert.assertEquals(Get.byTestId("model-item-value-subscriberName").getText(), "USP VOICE", "Subscriber name should be shown in vf module"); - Assert.assertEquals(Get.byTestId("model-item-value-min").getText(), Integer.toString(vgMin), "Min should be shown"); - Assert.assertEquals(Get.byTestId("model-item-value-max").getText(), Integer.toString(vgMax), "Max should be shown"); - if (!isInstanceNameGenerated) { + Assert.assertEquals(Get.byTestId("model-item-value-subscriberName").getText(), "SILVIA ROBBINS", "Subscriber name should be shown in vf module"); + Assert.assertEquals(Get.byTestId("model-item-value-min").getText(), Integer.toString(serviceData.vfData.vfMin), "Min should be shown"); + Assert.assertEquals(Get.byTestId("model-item-value-max").getText(), Integer.toString(serviceData.vfData.vfMax), "Max should be shown"); + if (!serviceData.vnfData.isGeneratedNaming) { Wait.byText(serviceInstanceName); Assert.assertEquals(Get.byTestId("model-item-value-serviceName").getText(), serviceInstanceName, "Service name should be shown in vf module"); } - validateDynamicFields(vfModuleDynamicFields); + validateDynamicFields(serviceData.vfData.dynamicFields); + + uploadSupplementaryFile("invalid-file.json", false, browseASDCPage, setButtonTestId); + deleteSupplementaryFile(); + uploadSupplementaryFile("sample.json", true, browseASDCPage, setButtonTestId); browseASDCPage.screenshotDeployDialog("createVfModule-" + serviceInstanceName); Click.byTestId(setButtonTestId); } + private void clickEditVfModule(ServiceData serviceData) { + if (Features.FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD.isActive()) { + hoverAndClickEditButton(serviceData.vfData.uuid + "-" + serviceData.vfData.vfName); + } + } + + private void clickAddVfModule(ServiceData serviceData, boolean addedByDefault) { + if (Features.FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD.isActive() && addedByDefault) { + return; + } + System.out.println("VFModule should be added 'manually'"); + + final WebElement vfModuleNode = Get.byTestId(Constants.DrawingBoard.NODE_PREFIX + serviceData.vfData.vfName); + + if (vfModuleNode == null || !vfModuleNode.isDisplayed()) { + // expand tree + drawingBoardPage.clickNode(serviceData.vnfData.vnfName); + } + drawingBoardPage.clickAddButtonByNodeName(serviceData.vfData.vfName); + } + + private void clickRemoveVfModule(String vfModuleId, String vfModuleName) { + if (Features.FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD.isActive()) { + System.out.println("will remove " + vfModule0Name); + hoverAndClickDeleteButton(vfModuleId + "-" + vfModuleName); + } + } + private void assertPauseOnPausePointsVisibility(boolean visibility) { - WebElement pauseElem = Get.byId("pause"); + WebElement pauseElem = Get.byId("Pause"); final String assertionMessage = "pause on pause points visibility should be " + visibility; if (visibility) { Assert.assertNotNull(pauseElem, assertionMessage); @@ -607,121 +1143,71 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest { Assert.assertNotNull(webElement, "notification area should be visible if more then 1 qty."); } - /** - * following are two popup service models that represent two opposite/extreme states of the popup. - * they should be enough to test all the possible popup states. - */ - private void loadMacroServicePopup_withDynamicFields_partialModelDetails_ecompNamingTrue() { - loadServicePopup("csar-withDynamicFields-ecompNamingTrue-partialModelDetails.zip", "2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"); - } - - private void loadMacroServicePopup_noDynamicFields_fullModelDetails_ecompNamingFalse() { - loadServicePopup("csar-noDynamicFields-ecompNamingFalse-fullModelDetails-1a80c596.zip", "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"); - } - - @DataProvider - private Object[][] createSriovService( - ) { - List<String> dynamicFields = Arrays.asList( - "2017488 adiodvpe0 VNF config template version:", - "Adiodvpe0 bandwidth units:", - "Adiodvpe0 bandwidth:", - "2017488 adiodvpe0 aic clli:", - "2017488 adiodvpe0 asn:", - "2017488 adiodvpe0 VNF instance name"); - ServiceData withEcompNaming = new ServiceData("csar-withDynamicFields-ecompNamingTrue-partialModelDetails.zip", - "2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd", - dynamicFields, - true, true, true, false, - "2017-488_ADIOD-vPE 0", - "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1", 0, 1, new ArrayList<>()); - return new Object[][]{{withEcompNaming}}; - } + private void prepareServicePreset(ModelInfo modelInfo, boolean deploy) { + String subscriberId = "e433710f-9217-458d-a79d-1c7aff376d89"; + if (deploy) { + registerExpectationForServiceDeployment( + ImmutableList.of( + modelInfo, + PASQUALEVmxVpeBvService488Annotations + ), + subscriberId, null); + } else { + registerExpectationForServiceBrowseAndDesign(ImmutableList.of(modelInfo), subscriberId); + } + } private class ServiceData { - - public ServiceData(String csarName, String modelUuid, List<String> dynamicFields, boolean isServiceGeneratedNaming, boolean isVnfGeneratedNaming, boolean isVgEnabled, boolean multiStageDesign, String vnfName, String vfName, int vfMin, int vfMax, List<String> vfModuleDynamicFields) { - this.csarName = csarName; + ServiceData(String modelUuid, List<String> dynamicFields, boolean isServiceGeneratedNaming, boolean isVnfGeneratedNaming, boolean isVgEnabled, boolean multiStageDesign, String vnfName, String vfName, int vfMin, int vfMax, List<String> vfModuleDynamicFields, String vfVersionId) { this.modelUuid = modelUuid; this.dynamicFields = dynamicFields; this.isGeneratedNaming = isServiceGeneratedNaming; this.multiStageDesign = multiStageDesign; - this.vnfData = new VnfData(vnfName, isVnfGeneratedNaming); - this.vfData = new VfData(vfName, isVgEnabled, vfMin, vfMax, vfModuleDynamicFields); + this.vnfData = new VnfData(vnfName, "69e09f68-8b63-4cc9-b9ff-860960b5db09", "VNF instance name", isVnfGeneratedNaming); + this.vfData = new VfData(vfName, isVgEnabled, vfMin, vfMax, vfModuleDynamicFields, vfVersionId); } - public String csarName; - public String modelUuid; - public List<String> dynamicFields; - public boolean isGeneratedNaming; - public boolean multiStageDesign; - public VnfData vnfData; - public VfData vfData; - + final String modelUuid; + final List<String> dynamicFields; + final boolean isGeneratedNaming; + final boolean multiStageDesign; + final VnfData vnfData; + final VfData vfData; } private class VnfData { - - public VnfData(String vnfName, boolean isGeneratedNaming) { + VnfData(String vnfName, String vnfUuid, String vnfInstanceName, boolean isGeneratedNaming) { this.vnfName = vnfName; + this.vnfUuid = vnfUuid; + this.vnfInstanceName = vnfInstanceName; this.isGeneratedNaming = isGeneratedNaming; } - public String vnfName; - public boolean isGeneratedNaming; + final String vnfName; + final String vnfUuid; + final String vnfInstanceName; + final boolean isGeneratedNaming; } private class VfData { - public VfData(String vfName, boolean vgEnabled, int vfMin, int vfMax, List<String> dynamicFields) { + VfData(String vfName, boolean vgEnabled, int vfMin, int vfMax, List<String> dynamicFields, String uuid) { this.vfName = vfName; this.vgEnabled = vgEnabled; this.vfMin = vfMin; this.vfMax = vfMax; this.dynamicFields = dynamicFields; + this.uuid = uuid; } - public int vfMin; - - public int vfMax; - - public String vfName; - - public boolean vgEnabled; - - public List<String> dynamicFields; - + final int vfMin; + final int vfMax; + final String uuid; + final String vfName; + final boolean vgEnabled; + final List<String> dynamicFields; } - private class ServiceStatusChecker implements Predicate<Boolean> { - private String actualInstanceName; - private Set<String> expectedStatuses; - private Set<String> columnClassesSet; - - public ServiceStatusChecker(String actualInstanceName, Set<String> expectedStatuses) { - this.actualInstanceName = actualInstanceName; - this.expectedStatuses = expectedStatuses; - } - - @Override - public boolean test(Boolean noMeaning) { - InstantiationStatusPage.clickRefreshButton(); - final WebElement row = InstantiationStatusPage.getInstantiationStatusRow(actualInstanceName); - if (row == null) { - System.err.println("**********************" + actualInstanceName + "************************************************"); - columnClassesSet = Collections.singleton(actualInstanceName + " NOT FOUND"); - return false; // treat missing row as if test condition not fulfilled - } else { - columnClassesSet = new HashSet<>(Arrays.asList( - row.findElements(By.xpath(".//*[@id='" + "jobStatus" + "']")).get(0).getAttribute("class").split(" "))); - return !(Sets.intersection(expectedStatuses, columnClassesSet).isEmpty()); - } - } - - public Set<String> getColumnClassesSet() { - return columnClassesSet; - } - } } diff --git a/vid-automation/src/main/java/vid/automation/test/test/PreviousVersionsPopupTest.java b/vid-automation/src/main/java/vid/automation/test/test/PreviousVersionsPopupTest.java index aefef20e2..c52dd6bac 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/PreviousVersionsPopupTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/PreviousVersionsPopupTest.java @@ -3,26 +3,27 @@ package vid.automation.test.test; import com.google.common.collect.ImmutableList; import org.junit.Assert; import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset; -import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetMultipleVersion; -import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetNetworkZones; -import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetOneVersion; -import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetServicesGet; -import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubDetailsGet; -import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; +import org.onap.simulator.presetGenerator.presets.aai.*; import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet; import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstancePost; import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet; import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceMetadataGet; import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGet; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.By; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import vid.automation.test.infra.Click; +import vid.automation.test.infra.Get; import vid.automation.test.sections.BrowseASDCPage; import vid.automation.test.sections.CreateNewInstancePage; import vid.automation.test.sections.PreviousVersionDialog; import vid.automation.test.sections.SideMenu; import vid.automation.test.services.SimulatorApi; +import static vid.automation.test.infra.ModelInfo.ModelInfoWithMultipleVersions.modelInfoWithMultipleVersions; +import static vid.automation.test.infra.ModelInfo.serviceWithOneVersion; + public class PreviousVersionsPopupTest extends CreateInstanceDialogBaseTest{ BrowseASDCPage browseASDCPage = new BrowseASDCPage(); @@ -30,11 +31,11 @@ public class PreviousVersionsPopupTest extends CreateInstanceDialogBaseTest{ private String versionNumber1 = "1.0"; private String versionNumber2 = "2.0"; private String versionNumber3 = "3.0"; - private String modelVersionId1 = "aeababbc-010b-4a60-8df7-e64c07389466"; - private String modelVersionId2 = "aa2f8e9c-9e47-4b15-a95c-4a9385599abc"; - private String modelVersionId3 = "d849c57d-b6fe-4843-8349-4ab8bbb08d71"; - private static final String modelInvariantId = "a8dcd72d-d44d-44f2-aa85-53aa9ca99cba"; - private static final String serviceName = "action-data"; + private String modelVersionId1 = modelInfoWithMultipleVersions.modelVersionId1; + private String modelVersionId2 = modelInfoWithMultipleVersions.modelVersionId2; + private String modelVersionId3 = modelInfoWithMultipleVersions.modelVersionId3; + private static final String modelInvariantId = modelInfoWithMultipleVersions.modelInvariantId; + private static final String serviceName = modelInfoWithMultipleVersions.modelName; private String createModalTitleTestId = "create-modal-title"; @@ -58,8 +59,7 @@ public class PreviousVersionsPopupTest extends CreateInstanceDialogBaseTest{ @Test private void browseSDC_afterCancelOnPopup_browseSDCpageExists(){ prepareSimulatorWithThreeVersionsBeforeBrowseASDCService(); - SideMenu.navigateToBrowseASDCPage(); - browseASDCPage.clickPreviousVersionButton(); + navigateToBrowseAsdcAndClickPreviousButton(); browseASDCPage.clickCancelButton();// to change newVersionDialog.assertVersionRow(modelInvariantId,modelVersionId3,versionNumber3,"Browse_SDC_Service_Models-uuid-"); } @@ -67,14 +67,13 @@ public class PreviousVersionsPopupTest extends CreateInstanceDialogBaseTest{ private void browseSDC_previousVersionButton_notExists(){ prepareSimulatorWithOneVersionBeforeBrowseASDCService(); SideMenu.navigateToBrowseASDCPage(); - browseASDCPage.assertPreviousVersionButtonNotExists(modelInvariantId); + browseASDCPage.assertPreviousVersionButtonNotExists(serviceWithOneVersion.modelInvariantId); } @Test private void openPreviousVersionPopup_newestVersionButton_notExists(){ prepareSimulatorWithThreeVersionsBeforeBrowseASDCService(); - SideMenu.navigateToBrowseASDCPage(); - browseASDCPage.clickPreviousVersionButton(); + navigateToBrowseAsdcAndClickPreviousButton(); newVersionDialog.assertHighestVersionNotExists(modelVersionId3); newVersionDialog.clickCancelButton(); } @@ -84,8 +83,7 @@ public class PreviousVersionsPopupTest extends CreateInstanceDialogBaseTest{ prepareSimulatorWithThreeVersionsBeforeBrowseASDCService(); CreateNewInstancePage newInstance= new CreateNewInstancePage(); newVersionDialog = new PreviousVersionDialog(); - SideMenu.navigateToBrowseASDCPage(); - browseASDCPage.clickPreviousVersionButton(); + navigateToBrowseAsdcAndClickPreviousButton(); newVersionDialog.clickDeployServiceButtonByServiceUUID(modelVersionId2); assertNewInstanceFormOpened(createModalTitleTestId,expectedPopupIsALaCarteName); newInstance.clickCancelButtonByTestID(); @@ -94,6 +92,13 @@ public class PreviousVersionsPopupTest extends CreateInstanceDialogBaseTest{ } + private void navigateToBrowseAsdcAndClickPreviousButton() { + SideMenu.navigateToBrowseASDCPage(); + Click.byTestId("view-per-page-50"); + GeneralUIUtils.ultimateWait(); + Get.byTestId("PreviousVersion-"+modelInvariantId).findElement(By.tagName("button")).click(); + } + private void assertNewInstanceFormOpened(String createModalTitleTestId,String expectedInstanceFormName) { String newInstanceFormName = GeneralUIUtils.getWebElementByTestID(createModalTitleTestId).getText(); Assert.assertEquals(expectedInstanceFormName, newInstanceFormName); @@ -106,11 +111,12 @@ public class PreviousVersionsPopupTest extends CreateInstanceDialogBaseTest{ ImmutableList<BasePreset> presets = ImmutableList.of( new PresetGetSessionSlotCheckIntervalGet(), new PresetAAIGetSubscribersGet(), - new PresetAAIGetMultipleVersion(modelVersionId1,modelVersionId2,modelVersionId3, modelInvariantId), + new PresetAAIServiceDesignAndCreationPut(), new PresetAAIGetServicesGet(), new PresetSDCGetServiceMetadataGet(modelVersionId2, modelInvariantId, zipFileName), new PresetSDCGetServiceToscaModelGet(modelVersionId2, zipFileName), new PresetAAIGetSubDetailsGet(null), + new PresetAAIGetSubDetailsWithoutInstancesGet(null), new PresetAAIGetNetworkZones(), new PresetMSOCreateServiceInstancePost(), new PresetMSOOrchestrationRequestGet()); @@ -122,7 +128,7 @@ public class PreviousVersionsPopupTest extends CreateInstanceDialogBaseTest{ ImmutableList<BasePreset> presets = ImmutableList.of( new PresetGetSessionSlotCheckIntervalGet(), new PresetAAIGetSubscribersGet(), - new PresetAAIGetOneVersion(modelVersionId1, modelInvariantId), + new PresetAAIServiceDesignAndCreationPut(), new PresetAAIGetServicesGet()); SimulatorApi.registerExpectationFromPresets(presets, SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET); diff --git a/vid-automation/src/main/java/vid/automation/test/test/ReadOnlyTest.java b/vid-automation/src/main/java/vid/automation/test/test/ReadOnlyTest.java index c3ddd406b..8beb21982 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/ReadOnlyTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/ReadOnlyTest.java @@ -2,8 +2,9 @@ package vid.automation.test.test; import org.junit.Assert; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetNetworkCollectionDetails; -import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.testng.annotations.Test; @@ -18,6 +19,7 @@ import java.sql.*; import java.util.ArrayList; import java.util.List; +import static vid.automation.test.infra.ModelInfo.aLaCarteServiceCreationTest; import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; /** @@ -64,11 +66,8 @@ public class ReadOnlyTest extends VidBaseTestCase { @Test public void testBrowsASDCReadOnly() { - String zipFileName = "serviceCreationTest.zip"; - String modelVersionId = "aa2f8e9c-9e47-4b15-a95c-4a9385599abc"; - String modelInvariantId = "a8dcd72d-d44d-44f2-aa85-53aa9ca99cba"; - - registerExpectationForLegacyServiceDeployment(modelVersionId, modelInvariantId, zipFileName, null); + resetGetServicesCache(); + registerExpectationForLegacyServiceDeployment(aLaCarteServiceCreationTest, null); SideMenu.navigateToBrowseASDCPage(); Assert.assertTrue(isDeployBtnDisabled()); @@ -91,8 +90,7 @@ public class ReadOnlyTest extends VidBaseTestCase { @Test private void testCreateNewInstanceReadOnly() { - SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.APPEND, - "search_for_service_instance/aai_get_full_subscribers.json"); + SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(),SimulatorApi.RegistrationStrategy.APPEND); SideMenu.navigateToCreateNewServicePage(); assertDropdownPermittedItemsByValue(new ArrayList<String>(), Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS); } diff --git a/vid-automation/src/main/java/vid/automation/test/test/SanityMacroDeployTest.java b/vid-automation/src/main/java/vid/automation/test/test/SanityMacroDeployTest.java index dfa79bf30..0741a4b38 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/SanityMacroDeployTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/SanityMacroDeployTest.java @@ -1,83 +1,89 @@ package vid.automation.test.test; +import static org.hamcrest.Matchers.containsString; +import static vid.automation.test.infra.ModelInfo.macroForBrowseSdc; +import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; + +import com.google.common.collect.ImmutableList; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIServiceDesignAndCreationPut; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateMacroPre1806Post; import org.openqa.selenium.WebElement; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import vid.automation.test.Constants; -import vid.automation.test.infra.FeatureTogglingTest; import vid.automation.test.infra.SelectOption; import vid.automation.test.model.User; import vid.automation.test.sections.BrowseASDCPage; import vid.automation.test.sections.SideMenu; import vid.automation.test.services.SimulatorApi; -import static org.hamcrest.Matchers.containsString; -import static vid.automation.test.infra.Features.FLAG_ASYNC_INSTANTIATION; - public class SanityMacroDeployTest extends CreateInstanceDialogBaseTest { static final String NEW_INSTANCE_NAME = "New Instance Name"; static final String SERVICE_NAME_PNF = "vidmacrofalsenaming"; - static final String SERVICE_UUID = "4d71990b-d8ad-4510-ac61-496288d9078e"; - static final String SUBSCRIBER = "FIREWALL/MISC"; + static final String SUBSCRIBER = "CRAIG/ROBERTS"; static final String PRODUCT = "Transport"; static final String SERVICE_TYPE = "AIM Transport"; - static final String LCP_REGION = "rdm3"; + static final String LCP_REGION = "olson3"; - static final String TENANT = "AIN Web Tool-15-D-testgamma"; + static final String TENANT = "AIN Web Tool-15-D-testalexandria"; static final String AIC_ZONE = "NFTJSSSS-NFT1"; static final String PROJECT = "yyy1"; static final String OWNING_ENTITY = "aaa1"; static final String RESOURCE_NAME = "MULTI_PROVIDER_PORT_GROUP 0"; static final String RESOURCE_DESCRIPTION = "Creates a neutron multi-provider VLAN network with dummy subnet"; - static final String SERVICE_INVARIANT_UUID = "d27e42cf-087e-4d31-88ac-6c4b7585f800"; static final String SERVICE_VERSION = "1.0"; static final String SERVICE_DESCRIPTION = "vidmacrofalsenaming"; static final String SERVICE_CATEGORY = "Network L1-3"; - public SanityMacroDeployTest() { - } - - @BeforeClass protected void registerToSimulator() { - SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.APPEND, - "sanity/browse_sdc_catalog_two_services.json", + resetGetServicesCache(); + invalidateSdcModelsCache(); + SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET, "sanity/aai_get_services.json", "sanity/aai_get_aic_zones.json", - "search_for_service_instance/aai_get_full_subscribers.json", - "search_for_service_instance/aai_get_subscribers_for_customer_FIREWALL-MISC.json", + "search_for_service_instance/aai_get_subscribers_for_customer_CRAIG-ROBERTS.json", "sanity/aai_get_tenants.json", "sanity/get_mso_get_orch_request.json", - "sanity/post_mso_create_service_instance.json", "sanity/get_sdc_catalog_services_4d71990b.json", "sanity/aai_named_query_for_view_edit.json" ); + SimulatorApi.registerExpectationFromPresets(ImmutableList.of( + new PresetAAIServiceDesignAndCreationPut(), + new PresetMSOCreateMacroPre1806Post(), + new PresetAAIGetSubscribersGet(), + PresetAAIGetCloudOwnersByCloudRegionId.PRESET_RDM3_TO_ATT_NC + ), + APPEND); } @Override protected UserCredentials getUserCredentials() { - String userName = Constants.Users.FIREWALL_MISC_AIM_TRANSPORT; + String userName = Constants.Users.CRAIG_ROBERTS_AIM_TRANSPORT; User user = usersService.getUser(userName); return new UserCredentials(user.credentials.userId, user.credentials.password, userName, "", ""); } - @FeatureTogglingTest(value = FLAG_ASYNC_INSTANTIATION, flagActive = false) @Test private void browseServiceModel_MacroService_CreatedSuccessfully() { + BrowseASDCPage browseASDCPage = new BrowseASDCPage(); SideMenu.navigateToBrowseASDCPage(); GeneralUIUtils.ultimateWait(); - browseASDCPage.clickDeployServiceButtonByServiceUUID(SERVICE_UUID); + browseASDCPage.clickDeployServiceButtonByServiceUUID(macroForBrowseSdc.modelVersionId); WebElement modalTitle = GeneralUIUtils.getWebElementByTestID(Constants.CREATE_MODAL_TITLE_ID, 30); Assert.assertThat(modalTitle.getText().toLowerCase(), containsString("macro")); + GeneralUIUtils.ultimateWait(); assertServiceDetails(); @@ -91,17 +97,29 @@ public class SanityMacroDeployTest extends CreateInstanceDialogBaseTest { } private void fillCreateInstanceModal() { + + + waitForInstanceField(); + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.sleep(10000); // stuff is getting weird + WebElement instance_name = GeneralUIUtils.getWebElementByTestID(Constants.INSTANCE_NAME_SELECT_TESTS_ID, 30); instance_name.sendKeys(NEW_INSTANCE_NAME); + waitForInstanceField(); + GeneralUIUtils.ultimateWait(); SelectOption.byTestIdAndVisibleText(SUBSCRIBER, Constants.SUBSCRIBER_NAME_SELECT_TESTS_ID); + waitForInstanceField(); GeneralUIUtils.ultimateWait(); SelectOption.byTestIdAndVisibleText(PRODUCT, Constants.ViewEdit.PRODUCT_FAMILY_SELECT_TESTS_ID); + + waitForInstanceField(); GeneralUIUtils.ultimateWait(); SelectOption.byTestIdAndVisibleText(SERVICE_TYPE, Constants.SERVICE_TYPE_SELECT_TESTS_ID); + GeneralUIUtils.ultimateWait(); - SelectOption.byTestIdAndVisibleText(LCP_REGION, Constants.ViewEdit.LCP_REGION_SELECT_TESTS_ID); + viewEditPage.selectLcpRegion(LCP_REGION, "AIC"); SelectOption.byTestIdAndVisibleText(TENANT, Constants.ViewEdit.TENANT_SELECT_TESTS_ID); SelectOption.byTestIdAndVisibleText(AIC_ZONE, Constants.ViewEdit.AIC_ZONE_TEST_ID); @@ -109,12 +127,22 @@ public class SanityMacroDeployTest extends CreateInstanceDialogBaseTest { SelectOption.byTestIdAndVisibleText(OWNING_ENTITY, Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID); } + private void waitForInstanceField() { + GeneralUIUtils.sleep(200); // stuff is getting weird + SelectOption.waitForOptionInSelect(SUBSCRIBER, Constants.SUBSCRIBER_NAME_SELECT_TESTS_ID); + SelectOption.waitForOptionInSelect(TENANT, Constants.ViewEdit.TENANT_SELECT_TESTS_ID); + SelectOption.waitForOptionInSelect(AIC_ZONE, Constants.ViewEdit.AIC_ZONE_TEST_ID); + SelectOption.waitForOptionInSelect(PROJECT, Constants.OwningEntity.PROJECT_SELECT_TEST_ID); + SelectOption.waitForOptionInSelect(OWNING_ENTITY, Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID); + GeneralUIUtils.sleep(200); // stuff is getting weird + } + private void assertServiceDetails() { WebElement currElem = GeneralUIUtils.getWebElementByTestID(Constants.SERVICE_NAME, 30); Assert.assertEquals(currElem.getText(), SERVICE_NAME_PNF); currElem = GeneralUIUtils.getWebElementByTestID(Constants.SERVICE_UUID, 30); - Assert.assertEquals(currElem.getText(), SERVICE_UUID); + Assert.assertEquals(currElem.getText(), macroForBrowseSdc.modelVersionId); currElem = GeneralUIUtils.getWebElementByTestID(Constants.RESOURCE_NAME, 30); Assert.assertEquals(currElem.getText(), RESOURCE_NAME); @@ -123,7 +151,7 @@ public class SanityMacroDeployTest extends CreateInstanceDialogBaseTest { Assert.assertEquals(currElem.getText(), RESOURCE_DESCRIPTION); currElem = GeneralUIUtils.getWebElementByTestID(Constants.SERVICE_INVARIANT_UUID, 30); - Assert.assertEquals(currElem.getText(), SERVICE_INVARIANT_UUID); + Assert.assertEquals(currElem.getText(), macroForBrowseSdc.modelInvariantId); currElem = GeneralUIUtils.getWebElementByTestID(Constants.SERVICE_VERSION, 30); Assert.assertEquals(currElem.getText(), SERVICE_VERSION); diff --git a/vid-automation/src/main/java/vid/automation/test/test/SanityTest.java b/vid-automation/src/main/java/vid/automation/test/test/SanityTest.java index 29d25f21f..4ec3d4958 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/SanityTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/SanityTest.java @@ -1,8 +1,10 @@ package vid.automation.test.test; +import java.io.IOException; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; import org.openqa.selenium.WebElement; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -14,12 +16,10 @@ import vid.automation.test.sections.SearchExistingPage; import vid.automation.test.sections.SideMenu; import vid.automation.test.services.SimulatorApi; -import java.io.IOException; - public class SanityTest extends VidBaseTestCase { - static final String SUBSCRIBER = "Mobility"; - static final String SERVICE_NAME = "abc_mdns_2017_1011_IST_Service_CSI"; + static final String SUBSCRIBER = "Emanuel"; + static final String SERVICE_NAME = "abc_CHARLOTTE_2017_1011_IST_Service_CSI"; static final String SERVICE_ID = "ec884145-dbe8-4228-8165-f0c4d7123f8b"; public SanityTest() throws IOException { @@ -29,19 +29,19 @@ public class SanityTest extends VidBaseTestCase { @BeforeClass protected void registerToSimulator() { SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET, - "sanity/get_aai_get_subscribers.json" - , "sanity/aai_get_services.json" + "sanity/aai_get_services.json" , "sanity/get_aai_sub_details.json" , "sanity/get_aai_search_named_query.json" , "sanity/get_aai_search_instance_by_id.json" , "sanity/get_sdc_catalog_services_a1531622.json" , "sanity/get_aai_search_instance_by_name.json" ); + SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), SimulatorApi.RegistrationStrategy.APPEND); } @Override protected UserCredentials getUserCredentials() { - String userName = Constants.Users.MOBILITY_VMMSC; + String userName = Constants.Users.EMANUEL_vWINIFRED; User user = usersService.getUser(userName); return new UserCredentials(user.credentials.userId, user.credentials.password, userName, "", ""); } @@ -90,13 +90,7 @@ public class SanityTest extends VidBaseTestCase { } private String confirmFilterById() { - WebElement filter = GeneralUIUtils.getWebElementByTestID(Constants.FILTER_SUBSCRIBER_DETAILS_ID, 30); - filter.sendKeys(SERVICE_ID); - - WebElement firstElement = GeneralUIUtils.getWebElementByTestID(Constants.INSTANCE_ID_FOR_NAME_TEST_ID_PREFIX + SERVICE_NAME, 30); - String filteredId = firstElement.getText(); - Assert.assertTrue(filteredId.equals(SERVICE_ID)); - return filteredId; + return confirmFilterById(SERVICE_NAME, SERVICE_ID); } private void confirmResultBySubscriber() { diff --git a/vid-automation/src/main/java/vid/automation/test/test/SearchExistingInstanceTest.java b/vid-automation/src/main/java/vid/automation/test/test/SearchExistingInstanceTest.java index 7f18b2f83..c8370a571 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/SearchExistingInstanceTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/SearchExistingInstanceTest.java @@ -1,20 +1,20 @@ package vid.automation.test.test; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import vid.automation.test.Constants; import vid.automation.test.infra.Click; -import vid.automation.test.infra.Wait; import vid.automation.test.model.User; import vid.automation.test.sections.SearchExistingPage; import vid.automation.test.sections.SideMenu; import vid.automation.test.services.BulkRegistration; import vid.automation.test.services.SimulatorApi; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - public class SearchExistingInstanceTest extends VidBaseTestCase { public static final String serviceIdOeWirelineProjectX1 = "7e4f8130-5dee-47c4-8770-1abc5f5ded83"; @@ -22,25 +22,15 @@ public class SearchExistingInstanceTest extends VidBaseTestCase { @BeforeClass public void registerToSimulatorAndLogin() { - SimulatorApi.clearAll(); + SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET); BulkRegistration.searchExistingServiceInstanceByOEAndProject(); } - @Test(groups = { "shouldBeMigratedToWorkWithSimulator" }) - private void testSearchExistingInstanceById() throws Exception { - User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); - relogin(user.credentials); - SideMenu.navigateToSearchExistingPage(); - goToExistingInstanceById("3f93c7cb-2fd0-4557-9514-e189b7b04f9d"); - - //a flow that updates an existing instance is tested in testCreateNewServiceInstance. - } - @Test private void testSearchExistingInstanceByOwningEntitySingleValue() { SearchExistingPage searchExistingPage = new SearchExistingPage(); SideMenu.navigateToSearchExistingPage(); - searchExistingPage.searchByOwningEntity("Wireline"); + searchExistingPage.searchByOwningEntity("Melissa"); searchExistingPage.clickSubmitButton(); GeneralUIUtils.ultimateWait(); assertTrue(searchExistingPage.checkEditOrViewExistsByInstanceId(serviceIdOeWirelineProjectX1)); @@ -49,7 +39,7 @@ public class SearchExistingInstanceTest extends VidBaseTestCase { @Test(groups = { "shouldBeMigratedToWorkWithSimulator" }) private void testSearchExistingInstanceByOwningEntityMultiValue() throws Exception { - User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + User user = usersService.getUser(Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA); relogin(user.credentials); SearchExistingPage searchExistingPage = new SearchExistingPage(); SideMenu.navigateToSearchExistingPage(); @@ -78,7 +68,7 @@ public class SearchExistingInstanceTest extends VidBaseTestCase { SearchExistingPage searchExistingPage = new SearchExistingPage(); SideMenu.navigateToSearchExistingPage(); searchExistingPage.searchByProject("yyy1"); - searchExistingPage.searchByOwningEntity("Wireline"); + searchExistingPage.searchByOwningEntity("Melissa"); searchExistingPage.clickSubmitButton(); GeneralUIUtils.ultimateWait(); assertTrue(searchExistingPage.checkEditOrViewExistsByInstanceId(serviceIdOeWirelineProjectYYY1)); @@ -88,7 +78,7 @@ public class SearchExistingInstanceTest extends VidBaseTestCase { @Test(groups = { "shouldBeMigratedToWorkWithSimulator" }) private void testSearchExistingInstanceByProjectWithSpecialCharacters() throws Exception { - User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + User user = usersService.getUser(Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA); relogin(user.credentials); SearchExistingPage searchExistingPage = new SearchExistingPage(); SideMenu.navigateToSearchExistingPage(); @@ -103,7 +93,7 @@ public class SearchExistingInstanceTest extends VidBaseTestCase { @Test(groups = { "shouldBeMigratedToWorkWithSimulator" }) private void testSearchExistingInstanceByProjectMultiValue() throws Exception { - User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + User user = usersService.getUser(Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA); relogin(user.credentials); SearchExistingPage searchExistingPage = new SearchExistingPage(); SideMenu.navigateToSearchExistingPage(); diff --git a/vid-automation/src/main/java/vid/automation/test/test/VidBaseTestCase.java b/vid-automation/src/main/java/vid/automation/test/test/VidBaseTestCase.java index e5a8b5786..c472793fc 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/VidBaseTestCase.java +++ b/vid-automation/src/main/java/vid/automation/test/test/VidBaseTestCase.java @@ -3,22 +3,35 @@ package vid.automation.test.test; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableList; import org.apache.commons.lang3.StringUtils; +import org.glassfish.jersey.uri.internal.JerseyUriBuilder; import org.junit.Assert; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubDetailsGet; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset; import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset; -import org.onap.simulator.presetGenerator.presets.aai.*; -import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAICloudRegionAndSourceFromConfigurationPut; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetNetworkZones; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetPortMirroringSourcePorts; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetServicesGet; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubDetailsWithoutInstancesGet; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetTenants; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIPostNamedQueryForViewEdit; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIServiceDesignAndCreationPut; +import org.onap.simulator.presetGenerator.presets.ecompportal_att.EcompPortalPresetsUtils; import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2; import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstancePost; import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet; import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceMetadataGet; import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGet; -import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; -import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.utilities.FileHandling; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.execute.setup.SetupCDTest; +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.springframework.http.client.ClientHttpRequestInterceptor; +import org.springframework.web.client.RestTemplate; import org.testng.ITestContext; import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeSuite; @@ -31,26 +44,71 @@ import vid.automation.test.sections.*; import vid.automation.test.services.CategoryParamsService; import vid.automation.test.services.SimulatorApi; import vid.automation.test.services.UsersService; +import vid.automation.test.utils.CookieAndJsonHttpHeadersInterceptor; import vid.automation.test.utils.DB_CONFIG; import vid.automation.test.utils.TestConfigurationHelper; +import vid.automation.test.utils.TestHelper; import java.io.File; import java.lang.reflect.Method; +import java.net.URI; +import java.net.URISyntaxException; import java.sql.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - +import java.util.*; +import java.util.concurrent.TimeUnit; + +import static java.util.Collections.emptySet; +import static java.util.Collections.singletonList; +import static java.util.stream.Collectors.*; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; import static org.testng.Assert.assertEquals; import static org.testng.AssertJUnit.fail; +import static vid.automation.test.utils.TestHelper.GET_SERVICE_MODELS_BY_DISTRIBUTION_STATUS; +import static vid.automation.test.utils.TestHelper.GET_TENANTS; public class VidBaseTestCase extends SetupCDTest{ protected final UsersService usersService = new UsersService(); protected final CategoryParamsService categoryParamsService = new CategoryParamsService(); + protected final RestTemplate restTemplate = new RestTemplate(); + protected final URI uri; + protected final URI envUrI; + + public VidBaseTestCase() { + try { + this.envUrI = new URI(System.getProperty("ENV_URL")); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + this.uri = new JerseyUriBuilder().host(envUrI.getHost()).port(envUrI.getPort()).scheme("http").path("vid").build(); + } + + public void login() { + UserCredentials userCredentials = getUserCredentials(); + final List<ClientHttpRequestInterceptor> interceptors = singletonList(new CookieAndJsonHttpHeadersInterceptor(uri, userCredentials)); + restTemplate.setInterceptors(interceptors); + } + + public void invalidateSdcModelsCache() { + if (Features.FLAG_SERVICE_MODEL_CACHE.isActive()) { + restTemplate.postForObject(uri + "/rest/models/reset", "", Object.class); + } + } + + protected void resetGetServicesCache() { + login(); + TestHelper.resetAaiCache(GET_SERVICE_MODELS_BY_DISTRIBUTION_STATUS, restTemplate, uri); + } + + protected void resetGetTenantsCache() { + login(); + TestHelper.resetAaiCache(GET_TENANTS, restTemplate, uri); + } @Override protected UserCredentials getUserCredentials() { @@ -71,7 +129,7 @@ public class VidBaseTestCase extends SetupCDTest{ } @Override - protected org.openecomp.sdc.ci.tests.datatypes.Configuration getEnvConfiguration() { + protected org.onap.sdc.ci.tests.datatypes.Configuration getEnvConfiguration() { return TestConfigurationHelper.getEnvConfiguration(); } @@ -102,63 +160,86 @@ public class VidBaseTestCase extends SetupCDTest{ } } + @BeforeSuite(alwaysRun = true) + public void setSmallDefaultTimeout() throws Exception { + getDriver().manage().timeouts().implicitlyWait(250, TimeUnit.MILLISECONDS); + } + @Override protected void loginToLocalSimulator(UserCredentials userCredentials) { LoginExternalPage.performLoginExternal(userCredentials); } - static public class ModelInfo { - public final String modelVersionId; - public final String modelInvariantId; - public final String zipFileName; + protected String getReduxState() { + final JavascriptExecutor javascriptExecutor = (JavascriptExecutor) GeneralUIUtils.getDriver(); + String reduxState = (String)javascriptExecutor.executeScript("return window.sessionStorage.getItem('reduxState');"); + System.out.println(reduxState); + return reduxState; + } - public ModelInfo(String modelVersionId, String modelInvariantId, String zipFileName) { - this.modelVersionId = modelVersionId; - this.modelInvariantId = modelInvariantId; - this.zipFileName = zipFileName; + protected void setReduxState(String state) { + final JavascriptExecutor javascriptExecutor = (JavascriptExecutor) GeneralUIUtils.getDriver(); + String script = String.format("window.sessionStorage.setItem('reduxState', '%s');", state); + System.out.println("executing script:"); + System.out.println(script); + javascriptExecutor.executeScript(script); + } + + protected void registerExpectationForLegacyServiceDeployment(ModelInfo modelInfo, String subscriberId) { + List<BasePreset> presets = new ArrayList<>(Arrays.asList( + new PresetAAIPostNamedQueryForViewEdit(BaseMSOPreset.DEFAULT_INSTANCE_ID, true, false), + new PresetAAIGetPortMirroringSourcePorts("9533-config-LB1113", "myRandomInterfaceId", "i'm a port", true) + )); + + presets.add(new PresetMSOCreateServiceInstancePost()); + presets.add(new PresetMSOOrchestrationRequestGet()); + + presets.addAll(getPresetForServiceBrowseAndDesign(ImmutableList.of(modelInfo), subscriberId)); + + SimulatorApi.registerExpectationFromPresets(presets, SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET); + } + + protected void registerExpectationForServiceDeployment(List<ModelInfo> modelInfoList, String subscriberId, PresetMSOCreateServiceInstanceGen2 createServiceInstancePreset) { + List<BasePreset> presets = new ArrayList<>(Arrays.asList( + new PresetAAIPostNamedQueryForViewEdit(BaseMSOPreset.DEFAULT_INSTANCE_ID, true, false), + new PresetAAIGetPortMirroringSourcePorts("9533-config-LB1113", "myRandomInterfaceId", "i'm a port", true) + )); + + if (createServiceInstancePreset != null) { + presets.add(createServiceInstancePreset); } + presets.add(new PresetMSOOrchestrationRequestGet("IN_PROGRESS")); + + presets.addAll(getPresetForServiceBrowseAndDesign(modelInfoList, subscriberId)); + + SimulatorApi.registerExpectationFromPresets(presets, SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET); } - protected void registerExpectationForLegacyServiceDeployment(String modelVersionId, String modelInvariantId, String zipFileName, String subscriberId) { - registerExpectationForServiceDeployment(ServiceDeployment.LEGACY, ImmutableList.of(new ModelInfo(modelVersionId,modelInvariantId,zipFileName)), subscriberId); + protected void registerExpectationForServiceBrowseAndDesign(List<ModelInfo> modelInfoList, String subscriberId) { + SimulatorApi.registerExpectationFromPresets(getPresetForServiceBrowseAndDesign(modelInfoList, subscriberId), SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET); } - private enum ServiceDeployment {ASYNC, LEGACY} + protected List<BasePreset> getPresetForServiceBrowseAndDesign(List<ModelInfo> modelInfoList, String subscriberId) { - protected void registerExpectationForServiceDeployment(ServiceDeployment serviceDeploymentOnMsoExpectations, List<ModelInfo> modelInfoList, String subscriberId) { List<BasePreset> presets = new ArrayList<>(Arrays.asList( - new PresetGetSessionSlotCheckIntervalGet(), - new PresetAAIGetSubscribersGet(), - new PresetAAIGetServicesGet(), - new PresetAAIGetSubDetailsGet(subscriberId), - new PresetAAIPostNamedQueryForViewEdit("f8791436-8d55-4fde-b4d5-72dd2cf13cfb"), - new PresetAAICloudRegionAndSourceFromConfigurationPut("9533-config-LB1113", "myRandomCloudRegionId"), - new PresetAAIGetPortMirroringSourcePorts("9533-config-LB1113", "myRandomInterfaceId", "i'm a port", true), - new PresetAAIGetNetworkZones(), - new PresetAAIGetTenants(), - new PresetAAIServiceDesignAndCreationPut(modelInfoList.stream().map( - x-> new PresetAAIServiceDesignAndCreationPut.ServiceModelIdentifiers(x.modelVersionId, x.modelInvariantId)) - .collect(Collectors.toList())) - )); + new PresetAAIGetSubDetailsGet(subscriberId), + new PresetAAIGetSubDetailsWithoutInstancesGet(subscriberId), + new PresetAAIGetSubscribersGet(), + new PresetAAIGetServicesGet(), + new PresetAAICloudRegionAndSourceFromConfigurationPut("9533-config-LB1113", "myRandomCloudRegionId"), + new PresetAAIGetNetworkZones(), + new PresetAAIGetTenants(), + new PresetAAIServiceDesignAndCreationPut() + )); + + presets.addAll(EcompPortalPresetsUtils.getEcompPortalPresets()); modelInfoList.forEach(modelInfo -> { presets.add(new PresetSDCGetServiceMetadataGet(modelInfo.modelVersionId, modelInfo.modelInvariantId, modelInfo.zipFileName)); presets.add(new PresetSDCGetServiceToscaModelGet(modelInfo.modelVersionId, modelInfo.zipFileName)); }); - switch (serviceDeploymentOnMsoExpectations) { - case ASYNC: - presets.add(new PresetAAISearchNodeQueryEmptyResult()); - presets.add(new PresetMSOCreateServiceInstanceGen2()); - presets.add(new PresetMSOOrchestrationRequestGet("IN_PROGRESS")); - break; - case LEGACY: - presets.add(new PresetMSOCreateServiceInstancePost()); - presets.add(new PresetMSOOrchestrationRequestGet()); - break; - } - - SimulatorApi.registerExpectationFromPresets(presets, SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET); + return presets; } protected void relogin(Credentials credentials) throws Exception { @@ -200,13 +281,19 @@ public class VidBaseTestCase extends SetupCDTest{ GeneralUIUtils.ultimateWait(); List<WebElement> optionsList = GeneralUIUtils.getWebElementsListBy(By.className(dropdownOptionsClassName), 30); - for (WebElement option : - optionsList) { - String optionValue = option.getAttribute(attribute); - if ((option.isEnabled() && !permittedItems.contains(optionValue)) || - !option.isEnabled() && permittedItems.contains(optionValue)) { - fail(Constants.DROPDOWN_PERMITTED_ASSERT_FAIL_MESSAGE); - } + + final Map<Boolean, Set<String>> optionsMap = optionsList.stream() + .collect(groupingBy(WebElement::isEnabled, mapping(option -> option.getAttribute(attribute), toSet()))); + + assertGroupedPermissionsAreCorrect(permittedItems, optionsMap); + } + + private void assertGroupedPermissionsAreCorrect(ArrayList<String> permittedItems, Map<Boolean, Set<String>> optionsMap) { + if (permittedItems.isEmpty()) { + assertThat(Constants.DROPDOWN_PERMITTED_ASSERT_FAIL_MESSAGE, optionsMap.getOrDefault(Boolean.TRUE, emptySet()), is(empty())); + }else { + assertThat(Constants.DROPDOWN_PERMITTED_ASSERT_FAIL_MESSAGE, optionsMap.getOrDefault(Boolean.TRUE, emptySet()), containsInAnyOrder(permittedItems.toArray())); + assertThat(Constants.DROPDOWN_PERMITTED_ASSERT_FAIL_MESSAGE, optionsMap.getOrDefault(Boolean.FALSE, emptySet()), not(contains(permittedItems.toArray()))); } } @@ -216,7 +303,7 @@ public class VidBaseTestCase extends SetupCDTest{ GeneralUIUtils.getWebElementsListBy(By.className(dropdownOptionsClassName), 30); for (WebElement option : optionsList) { - String optionValue = option.getAttribute("value"); + //String optionValue = option.getAttribute("value"); if (!option.isEnabled()) { fail(Constants.DROPDOWN_PERMITTED_ASSERT_FAIL_MESSAGE); } @@ -227,14 +314,11 @@ public class VidBaseTestCase extends SetupCDTest{ GeneralUIUtils.ultimateWait(); List<WebElement> optionsList = GeneralUIUtils.getWebElementsListBy(By.className(dropdownOptionsClassName), 30); - for (WebElement option : - optionsList) { - String optionText = option.getText(); - if ((option.isEnabled() && !permittedItems.contains(optionText)) || - !option.isEnabled() && permittedItems.contains(optionText)) { - fail(Constants.DROPDOWN_PERMITTED_ASSERT_FAIL_MESSAGE); - } - } + + final Map<Boolean, Set<String>> optionsMap = optionsList.stream() + .collect(groupingBy(WebElement::isEnabled, mapping(WebElement::getText, toSet()))); + + assertGroupedPermissionsAreCorrect(permittedItems, optionsMap); } protected void assertViewEditButtonState(String expectedButtonText, String UUID) { @@ -244,14 +328,14 @@ public class VidBaseTestCase extends SetupCDTest{ } - protected void addNetwork(Map<String, String> metadata,String instanceName, String name, String lcpRegion, String productFamily,String platform, String lineOfBusiness, String tenant, String suppressRollback, + protected void addNetwork(Map<String, String> metadata,String instanceName, String name, String lcpRegion, String cloudOwner, String productFamily,String platform, String lineOfBusiness, String tenant, String suppressRollback, String legacyRegion, ArrayList<String> permittedTenants) { ViewEditPage viewEditPage = new ViewEditPage(); viewEditPage.selectNetworkToAdd(name); assertModelInfo(metadata, false); viewEditPage.setInstanceName(instanceName); - viewEditPage.selectLCPRegion(lcpRegion); + viewEditPage.selectLcpRegion(lcpRegion, cloudOwner); viewEditPage.selectProductFamily(productFamily); viewEditPage.selectLineOfBusiness(lineOfBusiness); assertDropdownPermittedItemsByValue(permittedTenants, Constants.ViewEdit.TENANT_OPTION_CLASS); @@ -313,10 +397,10 @@ public class VidBaseTestCase extends SetupCDTest{ searchExistingPage.clickEditViewByInstanceId(instanceUUID); } - void resumeVFModule(String vfModuleName, String lcpRegion, String tenant, String legacyRegion, ArrayList<String> permittedTenants){ + void resumeVFModule(String vfModuleName, String lcpRegion, String cloudOwner, String tenant, String legacyRegion, ArrayList<String> permittedTenants){ ViewEditPage viewEditPage = new ViewEditPage(); viewEditPage.clickResumeButton(vfModuleName); - viewEditPage.selectLCPRegion(lcpRegion); + viewEditPage.selectLcpRegion(lcpRegion, cloudOwner); assertDropdownPermittedItemsByValue(permittedTenants, Constants.ViewEdit.TENANT_OPTION_CLASS); viewEditPage.selectTenant(tenant); viewEditPage.setLegacyRegion(legacyRegion); @@ -384,7 +468,7 @@ public class VidBaseTestCase extends SetupCDTest{ } } - protected <T> void setNewInstance_leftPane_assertModelDataCorrect(Map<String, String> modelKeyToDataTestsIdMap, String prefix, T model) { + protected <T> void assertModelDataCorrect(Map<String, String> modelKeyToDataTestsIdMap, String prefix, T model) { modelKeyToDataTestsIdMap.forEach((fieldName, dataTestsId) -> { WebElement webElement = Get.byTestId(prefix + dataTestsId); assertEquals(webElement.getText(), getServiceFieldByName(fieldName, model)); @@ -410,7 +494,7 @@ public class VidBaseTestCase extends SetupCDTest{ private void assertMetadataItem(String keyTestId, String value, boolean withPrefix) { String elementTestId = (withPrefix ? Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX:"") + keyTestId; String infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); - Assert.assertThat(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE, elementTestId), infoItemText, is(value)); + assertThat(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE, elementTestId), infoItemText, is(value)); } public DeployMacroDialogBase getMacroDialog(){ @@ -423,16 +507,12 @@ public class VidBaseTestCase extends SetupCDTest{ return new DeployMacroDialogOld(); } - protected void loadServicePopup(String zipFileName, String modelVersionId ) { - String modelInvariantId = "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0"; - String subscriberId = "e433710f-9217-458d-a79d-1c7aff376d89"; - registerExpectationForServiceDeployment( - ServiceDeployment.ASYNC, - ImmutableList.of( - new ModelInfo(modelVersionId, modelInvariantId, zipFileName), - new ModelInfo("f4d84bb4-a416-4b4e-997e-0059973630b9", "598e3f9e-3244-4d8f-a8e0-0e5d7a29eda9", "service-AdiodVmxVpeBvService488-csar-annotations.zip") - ), - subscriberId); + protected void loadServicePopup(ModelInfo modelInfo) { + loadServicePopup(modelInfo.modelVersionId); + } + + + protected void loadServicePopup(String modelVersionId) { SideMenu.navigateToBrowseASDCPage(); GeneralUIUtils.ultimateWait(); loadServicePopupOnBrowseASDCPage(modelVersionId); @@ -440,7 +520,7 @@ public class VidBaseTestCase extends SetupCDTest{ protected void loadServicePopupOnBrowseASDCPage(String modelVersionId ) { DeployMacroDialog deployMacroDialog = new DeployMacroDialog(); - deployMacroDialog.goOutFromIframe(); + VidBasePage.goOutFromIframe(); deployMacroDialog.clickDeployServiceButtonByServiceUUID(modelVersionId); deployMacroDialog.goToIframe(); GeneralUIUtils.ultimateWait(); @@ -464,6 +544,10 @@ public class VidBaseTestCase extends SetupCDTest{ org.testng.Assert.assertFalse(webElement.isEnabled(), "field should be disabled if the field it depends on was not selected yet."); } + public boolean isElementByIdRequired(String id) { + return Get.byId(id).getAttribute("class").contains("required"); + } + protected int getUserIdNumberFromDB(User user) { try (Connection connection = DriverManager.getConnection(DB_CONFIG.url, DB_CONFIG.username, DB_CONFIG.password)) { Statement stmt = connection.createStatement(); @@ -495,15 +579,38 @@ public class VidBaseTestCase extends SetupCDTest{ } protected void navigateToViewEditPageOfuspVoiceVidTest444(String aaiModelVersionId) { + navigateToViewEditPage("3f93c7cb-2fd0-4557-9514-e189b7b04f9d", aaiModelVersionId); + } + + protected void navigateToViewEditPageOf_test_sssdad() { + navigateToViewEditPage("c187e9fe-40c3-4862-b73e-84ff056205f6", "ee6d61be-4841-4f98-8f23-5de9da846ca7"); + } + + protected void navigateToViewEditPage(final String serviceInstanceId, String aaiModelVersionId) { VidBasePage vidBasePage = new VidBasePage(); SideMenu.navigateToWelcomePage(); vidBasePage.navigateTo("serviceModels.htm#/instantiate?" + "subscriberId=e433710f-9217-458d-a79d-1c7aff376d89&" + "subscriberName=USP%20VOICE&" + "serviceType=VIRTUAL%20USP&" + - "serviceInstanceId=3f93c7cb-2fd0-4557-9514-e189b7b04f9d&" + + "serviceInstanceId=" + serviceInstanceId + "&" + "aaiModelVersionId=" + aaiModelVersionId + "&" + "isPermitted=true"); GeneralUIUtils.ultimateWait(); } + + + public void hoverAndClickMenuByName(String nodeName, String nodeToEdit, String contextMenuItem ) { + String buttonOfEdit = Constants.DrawingBoard.NODE_PREFIX + nodeToEdit + Constants.DrawingBoard.CONTEXT_MENU_BUTTON; + + WebElement rightTreeNode = getTreeNodeByName(nodeName); + WebElement menuButton = Get.byXpath(rightTreeNode, ".//span[@data-tests-id='" + buttonOfEdit + "']"); + + GeneralUIUtils.clickElementUsingActions(menuButton); + Click.byTestId(contextMenuItem); + } + + private WebElement getTreeNodeByName(String nodeName) { + return Get.byXpath("//tree-node-content[.//*[contains(text(), '" + nodeName + "')]]"); + } } diff --git a/vid-automation/src/main/java/vid/automation/test/test/VidBaseTestWithoutLogin.java b/vid-automation/src/main/java/vid/automation/test/test/VidBaseTestWithoutLogin.java index 9dab455cc..48f776406 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/VidBaseTestWithoutLogin.java +++ b/vid-automation/src/main/java/vid/automation/test/test/VidBaseTestWithoutLogin.java @@ -1,7 +1,7 @@ package vid.automation.test.test; -import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; -import org.openecomp.sdc.ci.tests.execute.setup.DriverFactory; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.execute.setup.DriverFactory; import vid.automation.test.utils.TestConfigurationHelper; public abstract class VidBaseTestWithoutLogin extends DriverFactory { @@ -12,7 +12,7 @@ public abstract class VidBaseTestWithoutLogin extends DriverFactory { } @Override - protected org.openecomp.sdc.ci.tests.datatypes.Configuration getEnvConfiguration() { + protected org.onap.sdc.ci.tests.datatypes.Configuration getEnvConfiguration() { return TestConfigurationHelper.getEnvConfiguration(); } diff --git a/vid-automation/src/main/java/vid/automation/test/test/ViewEditServiceInstanceTest.java b/vid-automation/src/main/java/vid/automation/test/test/ViewEditServiceInstanceTest.java index 3b9546fdd..ed64bba0a 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/ViewEditServiceInstanceTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/ViewEditServiceInstanceTest.java @@ -1,54 +1,65 @@ package vid.automation.test.test; +import static org.apache.logging.log4j.core.util.Assert.isNonEmpty; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.collection.IsEmptyCollection.empty; +import static org.testng.AssertJUnit.assertEquals; +import static vid.automation.test.infra.Features.FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE; +import static vid.automation.test.infra.Features.FLAG_COLLECTION_RESOURCE_SUPPORT; +import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; + import com.google.common.collect.ImmutableMap; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.hamcrest.MatcherAssert; import org.junit.Assert; import org.junit.Before; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetNetworkCollectionDetails; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.testng.annotations.AfterMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import vid.automation.test.Constants; -import vid.automation.test.infra.*; +import vid.automation.test.infra.Click; +import vid.automation.test.infra.Exists; +import vid.automation.test.infra.FeatureTogglingTest; +import vid.automation.test.infra.Features; +import vid.automation.test.infra.Get; +import vid.automation.test.infra.Wait; import vid.automation.test.model.User; import vid.automation.test.sections.VidBasePage; import vid.automation.test.sections.ViewEditPage; import vid.automation.test.services.BulkRegistration; import vid.automation.test.services.SimulatorApi; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.time.LocalDate; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static org.hamcrest.Matchers.equalTo; -import static org.testng.AssertJUnit.assertEquals; -import static vid.automation.test.infra.Features.FLAG_COLLECTION_RESOURCE_SUPPORT; -import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; - public class ViewEditServiceInstanceTest extends VidBaseTestCase { private ViewEditPage viewEditPage = new ViewEditPage(); VidBasePage vidBasePage =new VidBasePage(); private String serviceInstanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d"; private String crServiceInstanceId = "3f93c7cb-2fd0-4557-9514-e189b7testCR"; + private String serviceFabricInstanceId = "c187e9fe-40c3-4862-b73e-84ff056205f61234"; private String serviceInstanceId2 ="c187e9fe-40c3-4862-b73e-84ff056205f6"; private final String DEACTIVATE_ACTION = "deactivate"; private final String ACTIVATE_ACTION = "activate"; private List<String> pnfs = Arrays.asList("SANITY6785cce9", "tesai371ve2"); private final String serviceInstanceIdeWithoutModelVerId ="9caf5581-40ab-47be-b1f1-909a87724add"; - private final String crNetworkText ="NETWORK INSTANCE GROUP: l3network-id-rs804s | ROLE: HngwProtectedOam.OAM | TYPE: Tenant_Layer_3 | # OF NETWORKS: 3"; + private final String crNetworkText ="NETWORK INSTANCE GROUP: l3network-id-rs804s | ROLE: RosemaProtectedOam.OAM | TYPE: Tenant_Layer_3 | # OF NETWORKS: 3"; private final String crCollectionText ="COLLECTION: collection-name | TYPE: L3-NETWORK"; private final String crInfoText = "\"requestState\": \"COMPLETE\""; SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss"); - static final String LCP_REGION = "mtn6"; + static final String LCP_REGION = "hvf6"; + static final String CLOUD_OWNER = "AIC"; static final String TENANT = "bae71557c5bb4d5aac6743a4e5f1d054"; @@ -80,13 +91,16 @@ public class ViewEditServiceInstanceTest extends VidBaseTestCase { webElement.click(); viewEditPage.clickDeleteButton(); } - private void deleteInstance(String deleteButtonId, String successMessage) { + deleteInstance(deleteButtonId, successMessage, Constants.CONFIRM_RESUME_DELETE_TESTS_ID); + } + + private void deleteInstance(String deleteButtonId, String successMessage, String confirmButtonId) { navigateToViewEditPageOfuspVoiceVidTest444("7a6ee536-f052-46fa-aa7e-2fca9d674c44"); Click.byTestId(deleteButtonId); - viewEditPage.selectLCPRegion(LCP_REGION); + viewEditPage.selectLcpRegion(LCP_REGION, CLOUD_OWNER); viewEditPage.selectTenant(TENANT); - vidBasePage.clickConfirmButtonInResumeDelete(); + vidBasePage.clickButtonByTestId(confirmButtonId); viewEditPage.assertMsoRequestModal(successMessage); viewEditPage.clickCommitCloseButton(); GeneralUIUtils.ultimateWait(); @@ -106,6 +120,28 @@ public class ViewEditServiceInstanceTest extends VidBaseTestCase { deleteInstance(Constants.ViewEdit.DELETE_VF_MODULE_BUTTON_TEST_ID + "aa", Constants.ViewEdit.VF_MODULE_DELETED_SUCCESSFULLY_TEXT); } + @FeatureTogglingTest(value = FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE) + @Test + public void softDeleteAndResumeVfModuleInstance_deleteDialogAppears_msoResponseIsOk() { + SimulatorApi.clearAll(); + String vfModuleName = "my_vfModule"; + BulkRegistration.deleteExistingVfModuleInstance("ACTIVE"); + deleteInstance(Constants.ViewEdit.DELETE_VF_MODULE_BUTTON_TEST_ID + vfModuleName, Constants.ViewEdit.VF_MODULE_DELETED_SUCCESSFULLY_TEXT, Constants.SOFT_DELETE_TESTS_ID); + BulkRegistration.resumeWithHomingDataVfModule("ACTIVE", "Assigned", vfModuleName); + navigateToViewEditPageOfuspVoiceVidTest444("7a6ee536-f052-46fa-aa7e-2fca9d674c44"); + viewEditPage.clickResumeButton(vfModuleName); + assertThat("Select lcp region shouldn't be display when homing data is presented", + GeneralUIUtils.getDriver().findElements(Get.getXpathForDataTestId(Constants.ViewEdit.LCP_REGION_SELECT_TESTS_ID)), + is(empty())); + assertThat("Select tenant shouldn't be display when homing data is presented", + GeneralUIUtils.getDriver().findElements(Get.getXpathForDataTestId(Constants.ViewEdit.TENANT_SELECT_TESTS_ID)), + is(empty())); + viewEditPage.clickConfirmButtonInResumeDelete(); + assertSuccessfulVFModuleCreation(); + viewEditPage.clickCommitCloseButton(); + GeneralUIUtils.ultimateWait(); + } + @Test public void deleteNetworkInstance_deleteDialogAppears_msoResponseIsOk() { SimulatorApi.clearAll(); @@ -147,12 +183,30 @@ public class ViewEditServiceInstanceTest extends VidBaseTestCase { viewEditPage.clickCloseButton(); } + @Test + public void testActivateServiceInstanceWithFabric() { + String orchStatus = "assiGNed"; + SimulatorApi.clearAll(); + BulkRegistration.searchExistingServiceInstanceWithFabric(orchStatus); + goToExistingInstanceById(serviceFabricInstanceId); + viewEditPage.assertButtonState(Constants.ViewEdit.DEACTIVATE_BUTTON_TEST_ID,false); + boolean flagIsActive = Features.FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS.isActive(); + if(flagIsActive) { + viewEditPage.assertButtonState(Constants.ViewEdit.ACTIVATE_FABRIC_CONFIGURATION_BUTTON_TEST_ID, true); + viewEditPage.clickActivateFabricConfigurationButton(); + viewEditPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT); + viewEditPage.clickCloseButton(); + } + } + private void assertAndCheckShowAssignmentsSdncUrl(String orchStatus, String serviceInstanceId) { boolean buttonIsEnable = Features.FLAG_SHOW_ASSIGNMENTS.isActive() && orchStatus.equals("assiGNed"); - viewEditPage.assertButtonState(Constants.ViewEdit.SHOW_ASSIGNMENTS_BUTTON_TEST_ID, buttonIsEnable); + boolean isNotDisplay = GeneralUIUtils.getDriver().findElements(Get.getXpathForDataTestId(Constants.ViewEdit.SHOW_ASSIGNMENTS_BUTTON_TEST_ID)).isEmpty(); + Assert.assertNotEquals(isNotDisplay, buttonIsEnable); + if (buttonIsEnable) { WebElement webElement = Get.byTestId(Constants.ViewEdit.SHOW_ASSIGNMENTS_BUTTON_TEST_ID); - String expectedUrl = "https://mtanjv9sdma51.aic.cip.att.com:8448/configAdapter/index#/resource_manager/"+serviceInstanceId; + String expectedUrl = "https://mtan.onap.org:8448/configAdapter/index#/resource_manager/"+serviceInstanceId; MatcherAssert.assertThat("Show assignments SDNC url is wrong", webElement.getAttribute("href"), equalTo(expectedUrl)); } @@ -358,13 +412,13 @@ public class ViewEditServiceInstanceTest extends VidBaseTestCase { "pending-delete", false); for(Map.Entry<String, Boolean> entry: vfModulesStatuses.entrySet()) { WebElement vfModule = GeneralUIUtils.getWebElementByClassName("vfModuleTreeNode-" + entry.getKey()); - Assert.assertEquals(!vfModule.findElements(By.className("resume")).isEmpty(), entry.getValue()); + Assert.assertEquals(isNonEmpty(vfModule.findElements(By.className("resume"))), entry.getValue()); } } @Before public void before() throws Exception { - User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + User user = usersService.getUser(Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA); relogin(user.credentials); } diff --git a/vid-automation/src/main/java/vid/automation/test/test/ViewEditWithDrawingBoardTest.java b/vid-automation/src/main/java/vid/automation/test/test/ViewEditWithDrawingBoardTest.java new file mode 100644 index 000000000..724e68065 --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/test/ViewEditWithDrawingBoardTest.java @@ -0,0 +1,178 @@ +package vid.automation.test.test; + +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.SERVICE_NAME; +import static org.testng.AssertJUnit.assertTrue; +import static vid.automation.test.infra.ModelInfo.aLaCarteVnfGroupingService; +import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; +import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET; +import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMultimap; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.UUID; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIFilterServiceInstanceById; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetServicesGet; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubDetailsGetSpecificService; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubDetailsWithoutInstancesGetSpecificService; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIModelsByInvariantIdGet; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet; +import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOAddOrRemoveOneInstanceGroupMember; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2WithNamesAlacarteGroupingService; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteInstanceGroup; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames; +import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceMetadataGet; +import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGet; +import org.testng.annotations.Test; +import vid.automation.test.Constants; +import vid.automation.test.infra.FeatureTogglingTest; +import vid.automation.test.infra.Features; +import vid.automation.test.infra.Wait; +import vid.automation.test.sections.DrawingBoardPage; +import vid.automation.test.sections.VidBasePage; +import vid.automation.test.services.SimulatorApi; + +public class ViewEditWithDrawingBoardTest extends VidBaseTestCase { + private final String RELATED_VNF_UUID1 = "a9f1b136-11ed-471f-8d77-f123c7501a01"; + private final String RELATED_VNF_UUID2 = "963b67e1-079a-404e-abef-b745d770bd85"; + private final String RELATED_VNF_UUID3 = "5a34a4f4-81a4-4eed-871b-f0b1187160d4"; + private static final String MSO_COMPLETE_STATUS = "COMPLETE"; + private static final String COMPLETED = "COMPLETED"; + private String vnfGroupInstanceId; + private String vnfGroupInstanceName; + private String serviceInstanceName; + private String serviceInstanceId = "b9af7c1d-a2d7-4370-b747-1b266849ad32"; + String subscriberId = "e433710f-9217-458d-a79d-1c7aff376d89"; + String serviceType = "TYLER SILVIA"; + String serviceReqId = "3cf5ea96-6b34-4945-b5b1-4a7798b1caf2"; + + @FeatureTogglingTest(Features.FLAG_1902_VNF_GROUPING) + @Test + public void testDeleteVnfGroupWithMembers() { + + String vnf1Name = registerServiceInstanceTopologyExpectationOnAAIAndGetVnf1Name(); + final ImmutableMap<PresetMSOServiceInstanceGen2WithNames.Keys, String> names = ImmutableMap.of(SERVICE_NAME, serviceInstanceName); + + + List<BasePreset> presets = ImmutableList.of( + new PresetAAIGetSubscribersGet(), + new PresetAAIGetServicesGet(), + new PresetAAIFilterServiceInstanceById(subscriberId, serviceType, serviceInstanceId), + new PresetAAIGetSubDetailsGetSpecificService(subscriberId, serviceType, "Active", aLaCarteVnfGroupingService, serviceInstanceId), + new PresetAAIGetSubDetailsWithoutInstancesGetSpecificService(subscriberId, serviceType), + new PresetSDCGetServiceMetadataGet(aLaCarteVnfGroupingService), + new PresetSDCGetServiceToscaModelGet(aLaCarteVnfGroupingService), + new PresetMSOCreateServiceInstanceGen2WithNamesAlacarteGroupingService(names, 0, serviceReqId) + ); + + SimulatorApi.registerExpectationFromPresets(presets, APPEND); + registerMsoPreset(); + GeneralUIUtils.ultimateWait(); + goToExistingInstanceById(serviceInstanceId); + GeneralUIUtils.ultimateWait(); + + DrawingBoardPage drawingBoardPage = new DrawingBoardPage(); + drawingBoardPage.goToIframe(); + GeneralUIUtils.ultimateWait(); + hoverAndClickMenuByName(vnf1Name, "daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0", Constants.InstantiationStatus.CONTEXT_MENU_DELETE); + GeneralUIUtils.ultimateWait(); + drawingBoardPage.clickDeployButton(); + + + VidBasePage.goOutFromIframe(); + GeneralUIUtils.ultimateWait(); + drawingBoardPage.goToIframe(); + GeneralUIUtils.ultimateWait(); + + DrawingBoardPage.ServiceStatusChecker serviceStatusChecker = new DrawingBoardPage.ServiceStatusChecker(serviceInstanceName, Collections.singleton(COMPLETED)); + boolean statusIsShown = Wait.waitFor(serviceStatusChecker, null, 10, 1); + assertTrue("Service "+serviceInstanceName+" wasn't completed after in time", statusIsShown); + + } + + public void registerMsoPreset(){ + String vnfGroupRequestId = UUID.randomUUID().toString(); + String firstMemberRequestId = UUID.randomUUID().toString(); + String secondMemberRequestId = UUID.randomUUID().toString(); + String thirdMemberRequestId = UUID.randomUUID().toString(); + + List <PresetMSODeleteInstanceGroup> vnfGroupPreset = ImmutableList.of( + new PresetMSODeleteInstanceGroup(vnfGroupRequestId, vnfGroupInstanceId, getUserCredentials().getUserId())); + + List<PresetMSOAddOrRemoveOneInstanceGroupMember> instanceGroupMemberPreset = ImmutableList.of( + new PresetMSOAddOrRemoveOneInstanceGroupMember(vnfGroupInstanceId, "963b67e1-079a-404e-abef-b745d770bd85", getUserCredentials().getUserId(), firstMemberRequestId, PresetMSOAddOrRemoveOneInstanceGroupMember.InstanceGroupMemberAction.Remove), + new PresetMSOAddOrRemoveOneInstanceGroupMember(vnfGroupInstanceId, "a9f1b136-11ed-471f-8d77-f123c7501a01", getUserCredentials().getUserId(), secondMemberRequestId, PresetMSOAddOrRemoveOneInstanceGroupMember.InstanceGroupMemberAction.Remove), + new PresetMSOAddOrRemoveOneInstanceGroupMember(vnfGroupInstanceId, "5a34a4f4-81a4-4eed-871b-f0b1187160d4", getUserCredentials().getUserId(), thirdMemberRequestId, PresetMSOAddOrRemoveOneInstanceGroupMember.InstanceGroupMemberAction.Remove) + ); + + List<PresetMSOOrchestrationRequestGet> inProgressPresets = new ArrayList<>(); + inProgressPresets.add(new PresetMSOOrchestrationRequestGet(MSO_COMPLETE_STATUS, vnfGroupRequestId)); + inProgressPresets.add(new PresetMSOOrchestrationRequestGet(MSO_COMPLETE_STATUS, firstMemberRequestId)); + inProgressPresets.add(new PresetMSOOrchestrationRequestGet(MSO_COMPLETE_STATUS, secondMemberRequestId)); + inProgressPresets.add(new PresetMSOOrchestrationRequestGet(MSO_COMPLETE_STATUS, thirdMemberRequestId)); + + final ImmutableList.Builder<BasePreset> basePresetBuilder = new ImmutableList.Builder<>(); + basePresetBuilder + .addAll(instanceGroupMemberPreset) + .addAll(inProgressPresets) + .addAll(vnfGroupPreset); + List<BasePreset> presets = basePresetBuilder.build(); + registerExpectationFromPresets(presets, SimulatorApi.RegistrationStrategy.APPEND); + } + + + public String registerServiceInstanceTopologyExpectationOnAAIAndGetVnf1Name() { + PresetAAIStandardQueryGet relatedVnf1 = + PresetAAIStandardQueryGet.ofVnf(RELATED_VNF_UUID1, "7a6ee536-f052-46fa-aa7e-2fca9d674c44", "7a6ee536-f052-46fa-aa7e-2fca9d674c44", + "", ImmutableMultimap.of()); + + PresetAAIStandardQueryGet relatedVnf2 = + PresetAAIStandardQueryGet.ofVnf(RELATED_VNF_UUID2, "d6557200-ecf2-4641-8094-5393ae3aae60","d6557200-ecf2-4641-8094-5393ae3aae60", + "", ImmutableMultimap.of()); + + PresetAAIStandardQueryGet relatedVnf3 = + PresetAAIStandardQueryGet.ofVnf(RELATED_VNF_UUID3, "d6557200-ecf2-4641-8094-5393ae3aae60","d6557200-ecf2-4641-8094-5393ae3aae60", + "", ImmutableMultimap.of()); + + final PresetAAIStandardQueryGet vnfGroup1 = + PresetAAIStandardQueryGet.ofInstanceGroup("vnfGroup-type", "Teresa Bradley", + ImmutableMultimap.<String, String>builder() + .putAll("generic-vnf", relatedVnf1.getReqPath(), relatedVnf2.getReqPath(), relatedVnf3.getReqPath()) + .build() + ); + + final PresetAAIStandardQueryGet vnfGroup2 = + PresetAAIStandardQueryGet.ofInstanceGroup("vnfGroup-type", "Stanley Mccarthy", ImmutableMultimap.of()); + + final PresetAAIStandardQueryGet serviceInstance = + PresetAAIStandardQueryGet.ofServiceInstance(serviceInstanceId, aLaCarteVnfGroupingService.modelVersionId, aLaCarteVnfGroupingService.modelInvariantId, "e433710f-9217-458d-a79d-1c7aff376d89", "TYLER SILVIA", + ImmutableMultimap.<String, String>builder() + .putAll("instance-group", vnfGroup1.getReqPath(), vnfGroup2.getReqPath()) + .build() + ); + SimulatorApi.registerExpectationFromPresets(ImmutableList.of( + serviceInstance, + vnfGroup1,vnfGroup2, relatedVnf1, relatedVnf2, relatedVnf3, + new PresetAAIModelsByInvariantIdGet(ImmutableList.of(aLaCarteVnfGroupingService.modelInvariantId)), + new PresetGetSessionSlotCheckIntervalGet(), + new PresetAAIGetSubscribersGet(), + new PresetSDCGetServiceMetadataGet(aLaCarteVnfGroupingService), + new PresetSDCGetServiceToscaModelGet(aLaCarteVnfGroupingService) + ), CLEAR_THEN_SET); + + serviceInstanceName = serviceInstance.getInstanceName(); + vnfGroupInstanceName = vnfGroup1.getInstanceName(); + vnfGroupInstanceId = vnfGroup1.getInstanceId(); + return vnfGroupInstanceName; + } + + +} diff --git a/vid-automation/src/main/java/vid/automation/test/test/SubInterfaceTest.java b/vid-automation/src/main/java/vid/automation/test/test/VlanTagSubInterfaceTest.java index 59baaf776..3f8db2a94 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/SubInterfaceTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/VlanTagSubInterfaceTest.java @@ -1,12 +1,27 @@ package vid.automation.test.test; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.PRESET_AAIAIC25_TO_ATT_AIC; +import static org.testng.AssertJUnit.assertEquals; +import static vid.automation.test.infra.Features.FLAG_COLLECTION_RESOURCE_SUPPORT; +import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; +import static vid.automation.test.test.ALaCarteflowTest.AIC; + import com.google.common.collect.ImmutableList; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetRelatedInstanceGroupsByVnfId; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetServicesGet; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetTenants; -import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVNFInstancePost; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVnfVlanTagging; import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.Select; import org.testng.Assert; @@ -19,49 +34,36 @@ import vid.automation.test.infra.FeatureTogglingTest; import vid.automation.test.infra.Get; import vid.automation.test.infra.SelectOption; import vid.automation.test.sections.SearchExistingPage; -import vid.automation.test.sections.ViewEditPage; +import vid.automation.test.sections.VidBasePage; import vid.automation.test.services.BulkRegistration; import vid.automation.test.services.SimulatorApi; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNull; -import static vid.automation.test.infra.Features.FLAG_COLLECTION_RESOURCE_SUPPORT; -import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; - @FeatureTogglingTest(FLAG_COLLECTION_RESOURCE_SUPPORT) -public class SubInterfaceTest extends CreateInstanceDialogBaseTest { +public class VlanTagSubInterfaceTest extends CreateInstanceDialogBaseTest { - private final ViewEditPage viewEditPage = new ViewEditPage(); private final String ecompNamingFalseInstanceId = "dc3a893e-0104-4ef6-abfe-6c2932294a3e"; private final String ecompNamingTrueInstanceId = "dc3a893e-0104-4ef6-abfe-6c2932294a3f"; @BeforeClass protected void registerToSimulator() { SimulatorApi.clearAll(); - BulkRegistration.createNewServiceInstance("USP VOICE"); + BulkRegistration.createNewServiceInstance("SILVIA ROBBINS"); BulkRegistration.searchExistingVFServiceWithVFCInstanceGroupInstance("Created"); SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.APPEND , "add_subinterface/get_sdc_catalog_services_vid-test-333.json" - , "add_subinterface/aai_get_services.json" - , "add_subinterface/aai_get_subscribers.json" , "add_subinterface/aai_get_aic_zones.json" ); - final PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest presetAAIGetInstanceGroupsByCloudRegion1 = new PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest("e433710f-9217-458d-a79d-1c7aff376d89", "mtn6", "untraaa"); - final PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest presetAAIGetInstanceGroupsByCloudRegion2 = new PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest("e433710f-9217-458d-a79d-1c7aff376d89", "AAIAIC25", "untraaa"); + final PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest presetAAIGetInstanceGroupsByCloudRegion1 = new PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest("irma-aic", "hvf6", "untraaa"); + final PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest presetAAIGetInstanceGroupsByCloudRegion2 = new PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest("irma-aic", "JANET25", "untraaa"); SimulatorApi.registerExpectationFromPresets(ImmutableList.of( - new PresetMSOCreateVNFInstancePost(ecompNamingTrueInstanceId, "6bce7302-70bd-4057-b48e-8d5b99e686ca"), - new PresetMSOCreateVNFInstancePost(ecompNamingFalseInstanceId, "6bce7302-70bd-4057-b48e-8d5b99e686cb"), + new PresetAAIGetServicesGet(), + new PresetAAIGetSubscribersGet(), + new PresetMSOCreateVnfVlanTagging(ecompNamingTrueInstanceId, "6bce7302-70bd-4057-b48e-8d5b99e686ca", true), + new PresetMSOCreateVnfVlanTagging(ecompNamingFalseInstanceId, "6bce7302-70bd-4057-b48e-8d5b99e686cb", false), + PRESET_AAIAIC25_TO_ATT_AIC, new PresetAAIGetTenants(), presetAAIGetInstanceGroupsByCloudRegion1, presetAAIGetInstanceGroupsByCloudRegion2, @@ -77,17 +79,20 @@ public class SubInterfaceTest extends CreateInstanceDialogBaseTest { @DataProvider private Object[][] getServices() { - return new Object[][]{{ecompNamingTrueInstanceId, true}, {ecompNamingFalseInstanceId, false}}; + return new Object[][]{ + {ecompNamingTrueInstanceId}, + {ecompNamingFalseInstanceId} + }; } @Test(dataProvider = "getServices") - public void createSubInterface_validPopupDataAndUIEcompNamingTrue(String serviceUuid, boolean ecompNamingEnabled) { + public void createSubInterface_validPopupDataAndUI(String serviceUuid) { SearchExistingPage searchExistingPage = new SearchExistingPage(); - searchExistingPage.goOutFromIframe(); + VidBasePage.goOutFromIframe(); goToExistingInstanceById(serviceUuid); - String vnfName = "vDBE 0"; + String vnfName = "vDOROTHEA 0"; Assert.assertNotNull(Get.byClassAndText("instanceGroupTreeNode","instance group name")); GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.ADD_VNF_BUTTON_TEST_ID, 60); GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.VNF_OPTION_TEST_ID_PREFIX + vnfName, 60); @@ -97,17 +102,13 @@ public class SubInterfaceTest extends CreateInstanceDialogBaseTest { searchExistingPage.goToIframe(); WebElement instanceNameInput = GeneralUIUtils.getInputElement(Constants.INSTANCE_NAME_SELECT_TESTS_ID); - if (ecompNamingEnabled) { - assertNull(instanceNameInput); - } else { - instanceNameInput.sendKeys("New Name"); - } - SelectOption.byTestIdAndVisibleText("VIRTUAL USP", Constants.ViewEdit.PRODUCT_FAMILY_SELECT_TESTS_ID); - SelectOption.byTestIdAndVisibleText("AAIAIC25", Constants.ViewEdit.LCP_REGION_SELECT_TESTS_ID); + instanceNameInput.sendKeys("NewName"); + SelectOption.byTestIdAndVisibleText("TYLER SILVIA", Constants.ViewEdit.PRODUCT_FAMILY_SELECT_TESTS_ID); + viewEditPage.selectLcpRegion("JANET25", AIC); SelectOption.byTestIdAndVisibleText("USP-SIP-IC-24335-T-01", Constants.ViewEdit.TENANT_SELECT_TESTS_ID); SelectOption.byTestIdAndVisibleText("UUUAIAAI-YYY1", Constants.ViewEdit.AIC_ZONE_TEST_ID); - SelectOption.byTestIdAndVisibleText("plat1", Constants.OwningEntity.PLATFORM_SELECT_TEST_ID); - SelectOption.byTestIdAndVisibleText("ecomp", Constants.OwningEntity.LOB_SELECT_TEST_ID); + SelectOption.byTestIdAndVisibleText("xxx1", Constants.OwningEntity.PLATFORM_SELECT_TEST_ID); + SelectOption.byTestIdAndVisibleText("ONAP", Constants.OwningEntity.LOB_SELECT_TEST_ID); SelectOption.byTestIdAndVisibleText("Rollback", Constants.SUPPRESS_ROLLBACK_SELECT_TESTS_ID); @@ -177,7 +178,7 @@ public class SubInterfaceTest extends CreateInstanceDialogBaseTest { } Click.byTestId(Constants.ConfigurationCreation.NEXT_BUTTON_TEST_ID); - searchExistingPage.goOutFromIframe(); + VidBasePage.goOutFromIframe(); assertSuccessfulServiceInstanceCreation(); viewEditPage.clickCommitCloseButton(); } diff --git a/vid-automation/src/main/java/vid/automation/test/utils/CookieAndJsonHttpHeadersInterceptor.java b/vid-automation/src/main/java/vid/automation/test/utils/CookieAndJsonHttpHeadersInterceptor.java index 07fd3754e..c98b2428a 100644 --- a/vid-automation/src/main/java/vid/automation/test/utils/CookieAndJsonHttpHeadersInterceptor.java +++ b/vid-automation/src/main/java/vid/automation/test/utils/CookieAndJsonHttpHeadersInterceptor.java @@ -1,7 +1,7 @@ package vid.automation.test.utils; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; import org.springframework.http.*; import org.springframework.http.client.ClientHttpRequestExecution; import org.springframework.http.client.ClientHttpRequestInterceptor; diff --git a/vid-automation/src/main/java/vid/automation/test/utils/DB_CONFIG.java b/vid-automation/src/main/java/vid/automation/test/utils/DB_CONFIG.java index ef5625232..717e2a746 100644 --- a/vid-automation/src/main/java/vid/automation/test/utils/DB_CONFIG.java +++ b/vid-automation/src/main/java/vid/automation/test/utils/DB_CONFIG.java @@ -1,8 +1,8 @@ package vid.automation.test.utils; public class DB_CONFIG { - public static String url = String.format("jdbc:mariadb://%s:%d/vid_openecomp_epsdk", - System.getProperty("DB_HOST", System.getProperty("VID_HOST", "127.0.0.1" )), + public static String url = String.format("jdbc:mariadb://%s:%d/vid_portal", + System.getProperty("DB_HOST", System.getProperty("VID_HOST", "10.0.0.10" )), Integer.valueOf(System.getProperty("DB_PORT", "3306")) ); public static String username = "euser"; diff --git a/vid-automation/src/main/java/vid/automation/test/utils/ExtendedHamcrestMatcher.java b/vid-automation/src/main/java/vid/automation/test/utils/ExtendedHamcrestMatcher.java new file mode 100644 index 000000000..b1c713f1e --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/utils/ExtendedHamcrestMatcher.java @@ -0,0 +1,24 @@ +package vid.automation.test.utils; + +import org.hamcrest.Matcher; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import static org.hamcrest.core.AllOf.allOf; +import static org.hamcrest.core.IsCollectionContaining.hasItem; + +public class ExtendedHamcrestMatcher { + + + //this method return matcher for has items that support collection as input (Instead of ...) + public static <T> Matcher<Iterable<T>> hasItemsFromCollection(Collection<T> items) { + List<Matcher<? super Iterable<T>>> all = new ArrayList<>(items.size()); + for (T element : items) { + all.add(hasItem(element)); + } + + return allOf(all); + } +} diff --git a/vid-automation/src/main/java/vid/automation/test/utils/ReadFile.java b/vid-automation/src/main/java/vid/automation/test/utils/ReadFile.java index 655cc20a6..1f6cd032b 100644 --- a/vid-automation/src/main/java/vid/automation/test/utils/ReadFile.java +++ b/vid-automation/src/main/java/vid/automation/test/utils/ReadFile.java @@ -3,7 +3,7 @@ package vid.automation.test.utils; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; -import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.onap.sdc.ci.tests.utilities.FileHandling; import vid.automation.test.infra.Input; import java.io.IOException; diff --git a/vid-automation/src/main/java/vid/automation/test/utils/RegExMatcher.java b/vid-automation/src/main/java/vid/automation/test/utils/RegExMatcher.java new file mode 100644 index 000000000..c540cf5ea --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/utils/RegExMatcher.java @@ -0,0 +1,29 @@ +package vid.automation.test.utils; + +import org.hamcrest.Description; +import org.hamcrest.TypeSafeMatcher; + +public class RegExMatcher extends TypeSafeMatcher<String> { + + private final String regEx; + + public RegExMatcher(String regEx) { + this.regEx = regEx; + } + + + @Override + public void describeTo(Description description) { + description.appendText("matches regEx="+regEx); + } + + + @Override + protected boolean matchesSafely(String item) { + return item.matches(regEx); + } + + public static RegExMatcher matchesRegEx(final String regEx) { + return new RegExMatcher(regEx); + } +} diff --git a/vid-automation/src/main/java/vid/automation/test/utils/TestConfigurationHelper.java b/vid-automation/src/main/java/vid/automation/test/utils/TestConfigurationHelper.java index ae731dbc0..0b2978dda 100644 --- a/vid-automation/src/main/java/vid/automation/test/utils/TestConfigurationHelper.java +++ b/vid-automation/src/main/java/vid/automation/test/utils/TestConfigurationHelper.java @@ -6,13 +6,13 @@ public class TestConfigurationHelper { private TestConfigurationHelper(){} - public static org.openecomp.sdc.ci.tests.datatypes.Configuration getEnvConfiguration() { + public static org.onap.sdc.ci.tests.datatypes.Configuration getEnvConfiguration() { try { String envUrl = System.getProperty("ENV_URL"); boolean isCustomLogin = Boolean.parseBoolean(System.getProperty("CUSTOM_LOGIN")); - org.openecomp.sdc.ci.tests.datatypes.Configuration configuration = new org.openecomp.sdc.ci.tests.datatypes.Configuration(envUrl, isCustomLogin); + org.onap.sdc.ci.tests.datatypes.Configuration configuration = new org.onap.sdc.ci.tests.datatypes.Configuration(envUrl, isCustomLogin); String geckoDriverPath = System.getProperty("GECKO_PATH"); if(geckoDriverPath == null){ diff --git a/vid-automation/src/main/java/vid/automation/test/utils/TestHelper.java b/vid-automation/src/main/java/vid/automation/test/utils/TestHelper.java new file mode 100644 index 000000000..83876fa27 --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/utils/TestHelper.java @@ -0,0 +1,15 @@ +package vid.automation.test.utils; + +import org.springframework.web.client.RestTemplate; + +import java.net.URI; + +public class TestHelper { + + public static String GET_SERVICE_MODELS_BY_DISTRIBUTION_STATUS = "getServiceModelsByDistributionStatus"; + public static String GET_TENANTS = "getTenants"; + + public static void resetAaiCache(String cacheName, RestTemplate restTemplate, URI vidUri) { + restTemplate.delete(vidUri + "/aai_reset_cache/"+cacheName); + } +} |