diff options
120 files changed, 2726 insertions, 3343 deletions
@@ -13,20 +13,16 @@ <maven.compiler.target>1.8</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <nexus.proxy>https://nexus.onap.org</nexus.proxy> + <nexus.proxy>https://nexus.onap.org</nexus.proxy> <staging.profile.id>176c31dfe190a</staging.profile.id> + <httpclient.version>4.5.5</httpclient.version> + <snakeyaml.version>1.21</snakeyaml.version> + <slf4j.version>1.7.25</slf4j.version> </properties> <dependencies> <dependency> - <groupId>org.openecomp.d2</groupId> - <artifactId>ui-api-ci</artifactId> - <version>1.0.1-SNAPSHOT</version> - </dependency> - - - <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> <version>3.8.0</version> @@ -38,7 +34,82 @@ <artifactId>DCAE-DT-PROPERTY</artifactId> <version>${project.version}</version> </dependency> - </dependencies> + + <!-- Snake Yaml --> + <dependency> + <groupId>org.yaml</groupId> + <artifactId>snakeyaml</artifactId> + <version>${snakeyaml.version}</version> + <scope>compile</scope> + </dependency> + + <!-- http client --> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>${httpclient.version}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpmime</artifactId> + <version>${httpclient.version}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.5</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-collections4</artifactId> + <version>4.1</version> + </dependency> + + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>2.8.4</version> + </dependency> + + <dependency> + <groupId>com.googlecode.json-simple</groupId> + <artifactId>json-simple</artifactId> + <version>1.1.1</version> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>${slf4j.version}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + <version>${slf4j.version}</version> + </dependency> + <dependency> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <version>6.14.3</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>com.aventstack</groupId> + <artifactId>extentreports</artifactId> + <version>3.1.5</version> + <scope>compile</scope> + </dependency> + + </dependencies> <build> <plugins> @@ -56,7 +127,7 @@ <configuration> <archive> <manifest> - <mainClass>com.att.ecomp.dcae.ci.run.RunTestSuite</mainClass> + <mainClass>org.onap.dcae.ci.run.RunTestSuite</mainClass> </manifest> </archive> <descriptorRefs> @@ -66,34 +137,10 @@ </execution> </executions> </plugin> - <!-- Site Plugin --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-site-plugin</artifactId> - <version>3.4</version> - <dependencies> - <dependency> - <groupId>org.apache.maven.wagon</groupId> - <artifactId>wagon-webdav-jackrabbit</artifactId> - <version>2.10</version> - </dependency> - </dependencies> - </plugin> - <!-- Staging Plugin --> - <plugin> - <groupId>org.sonatype.plugins</groupId> - <artifactId>nexus-staging-maven-plugin</artifactId> - <version>1.6.7</version> - <extensions>true</extensions> - <configuration> - <nexusUrl>${nexus.proxy}</nexusUrl> - <stagingProfileId>${staging.profile.id}</stagingProfileId> - <serverId>ecomp-staging</serverId> - </configuration> - </plugin> </plugins> </build> - <repositories> + + <repositories> <!-- LF repositories --> <repository> <id>ecomp-releases</id> @@ -129,4 +176,5 @@ <url>dav:${nexus.proxy}${sitePath}</url> </site> </distributionManagement> + </project> diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionMicroServicesApiTests.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionMicroServicesApiTests.java deleted file mode 100644 index 52fae05..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionMicroServicesApiTests.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.composition; - -import static org.assertj.core.api.Assertions.*; - -import org.onap.sdc.dcae.composition.model.ModelDcae; -import org.testng.annotations.*; - -import java.io.IOException; - -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; -import org.openecomp.d2.ci.datatypes.http.RestResponse; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.DcaeTestConstants; -import com.att.ecomp.dcae.ci.utilities.DcaeUtil; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - - -public class CompositionMicroServicesApiTests extends DcaeRestBaseTest { - - @Test - public void getAllElementsTest() throws IOException, ParseException{ - Report.log(Status.INFO, "getAllElementsTest start"); - RestResponse services = DcaeRestClient.getElements(); - Report.log(Status.INFO, "getAllElementsTest response=%s", services); - assertThat(services.getStatusCode().intValue()).isEqualTo(200); -// System.out.println(services); - String response = services.getResponse(); - JSONParser parser = new JSONParser(); - JSONObject o = (JSONObject) parser.parse(response); - JSONObject ele = (JSONObject) o.get("data"); - String arrString = ele.get(("elements")).toString(); -// System.out.println(arrString); - assertThat(arrString) - .as("Check that elements not empty") - .isNotEmpty(); - } - - @Test - public void getMsElementsTest() throws IOException, ParseException{ - Report.log(Status.INFO, "getMsElementsTest start"); - RestResponse services = DcaeUtil.SdcElementsModelType.getMsElements(); - Report.log(Status.INFO, "getMsElementsTest response=%s", services); - assertThat(services.getStatusCode().intValue()).isEqualTo(200); -// System.out.println(services); - String response = services.getResponse(); - JSONParser parser = new JSONParser(); - JSONObject o = (JSONObject) parser.parse(response); - JSONObject ele = (JSONObject) o.get("data"); - String arrString = ele.get(("element")).toString(); -// System.out.println(arrString); - assertThat(arrString) - .as("Check that elements not empty") - .isNotEmpty(); - } - - @Test - public void getItemModelTest() throws IOException{ - Report.log(Status.INFO, "getItemModelTest start"); - RestResponse itemModelRes = DcaeUtil.SdcElementsModelType.getItemModelFromSdc(2); - Report.log(Status.INFO, "getItemModelTest response=%s", itemModelRes); - assertThat(itemModelRes.getStatusCode().intValue()).isEqualTo(200); - - String response = itemModelRes.getResponse(); - JSONObject object = (JSONObject) JSONValue.parse(response); - String errorMsg = object.get("error").toString(); - assertThat(errorMsg).isEqualTo(DcaeTestConstants.Composition.EMPTY_OBJECT); - } - - @Test - public void getItemTypeTest() throws IOException{ - Report.log(Status.INFO, "getItemModelTest start"); - RestResponse itemModelRes = DcaeUtil.SdcElementsModelType.getItemModelFromSdc(2); - Report.log(Status.INFO, "itemModelRes response=%s", itemModelRes); - String response = itemModelRes.getResponse(); - - String uuid = DcaeUtil.SdcElementsModelType.getItemUuid(2); - - ModelDcae model = gson.fromJson(response, ModelDcae.class); - Report.log(Status.INFO, "model "+model); - String type = model.getData().getModel().getNodes().get(0).getType(); - Report.log(Status.INFO, "type "+type); - - RestResponse services = DcaeRestClient.getItemType(uuid, type); - assertThat(services.getStatusCode().intValue()).isEqualTo(200); - } - -// @Test -// public void saveCompositionCheckoutConflictTest() throws IOException{ -// // pull checkout VFCMT -// Vfcmt checkoutVFCMT = DcaeUtil.CatalogReources.checkoutVFCMT(); -// // call API -// RestResponse saveComposition = DcaeRestClient.saveComposition(checkoutVFCMT.getUuid(), checkoutVFCMT.getLastUpdaterUserId()); -// System.out.println(saveComposition); -// assertThat(saveComposition.getStatusCode()) -// .as("status 500") -// .isEqualTo(500); -// } -// -// @Test -// public void saveCompositionTest() throws IOException{ -// // Create new VFCMT -// Resource createNewVfcmtObject = DcaeUtil.CatalogReources.createNewVfcmtObject(); -// // Call SDC API to create the new VFCMT -// RestResponse resNewVfcmt = DcaeRestClient.createVfcmt(createNewVfcmtObject.getResourceInstanceName(),createNewVfcmtObject.getDescription()); -// -// Vfcmt newVfcmt = gson.fromJson(resNewVfcmt.getResponse(), Vfcmt.class); -// -// // call api -// RestResponse saveComposition = DcaeRestClient.saveComposition(newVfcmt.getUuid(), newVfcmt.getLastUpdaterUserId()); -// System.out.println(saveComposition); -// String response = saveComposition.getResponse(); -// -// String msg = "Artifact created"; -// int errorIndex = response.indexOf(msg); -// assertThat(errorIndex) -// .as("Conflict of checkout") -// .isGreaterThan(-1); -// } - -// @Test -// public void submitCompositionTest() throws IOException{ -// // pull checkout VFCMT -// Vfcmt checkoutVFCMT = DcaeUtil.CatalogReources.checkoutVFCMT(); -// String componentId = checkoutVFCMT.getUuid(); -// /* TODO: create new service (requires SDC api support) instead of using a random one that already exists */ -// ThinService oneService = DcaeUtil.Services.getOneService(componentId,0); -// Resource oneVfInstance = DcaeUtil.Services.getOneVfInstance(oneService, 0); -// RestResponse submitCompositionRes = DcaeRestClient -// .submitComposition(componentId, oneService.getUuid(), oneVfInstance.getResourceInstanceName()); -// String response = submitCompositionRes.getResponse(); -// int errorIndex = response.indexOf(DcaeTestConstants.Sdc.State.CONFLICT); -// assertThat("Conflict of checkout",errorIndex, greaterThan(-1)); -// } - -//TODO Block need to get shai service -// @Test -// public void submitCompositionTest() throws IOException{ -// String componentId = DcaeUtil.CatalogReources.getComponentID(202); -// ThinService oneService = DcaeUtil.Services.getOneService(0); -// Resource oneVfInstance = DcaeUtil.Services.getOneVfInstance(oneService, 0); -// RestResponse submitCompositionRes = DcaeRestClient -// .submitComposition(componentId, oneService.getUuid(), oneVfInstance.getResourceInstanceName()); -// String response = submitCompositionRes.getResponse(); -// JSONObject object = (JSONObject) JSONValue.parse(response); -// assertThat("Success response is not null", object.get("successResponse"), is(notNullValue())); -// } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCertify.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCertify.java deleted file mode 100644 index 4081b20..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCertify.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.lifeCycle; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.aventstack.extentreports.Status; -import org.assertj.core.api.SoftAssertions; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.testng.annotations.Test; - -public class PutCertify extends DcaeRestBaseTest { - - private ArrangeHelper arrange = new ArrangeHelper(client); - - /* Positive */ - - @Test - public void certifyVfcmt_success() throws Exception { - // arrange - Vfcmt vfcmt = arrange.getCheckedinVfcmt(); - // act - ExtentTestActions.log(Status.INFO, "Calling certify vfcmt with lastUpdater as user (designer role)"); - RestResponse response = DcaeRestClient.certifyVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); - // assert - Vfcmt vfcmtAfterCheckin = gson.fromJson(response.getResponse(), Vfcmt.class); - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).isEqualTo(200); - softly.assertThat(vfcmtAfterCheckin.getLifecycleState()).isEqualTo("CERTIFIED"); - }); - } - - - /* Negative */ - - @Test - public void notReadyForCertification_statusCode500() throws Exception { - // arrange - Vfcmt vfcmt = arrange.getCheckedoutVfcmt(); - // act - ExtentTestActions.log(Status.INFO, "Calling certify on a checked out vfcmt"); - RestResponse response = DcaeRestClient.certifyVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); - // assert - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).isEqualTo(500); - }); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Error.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Error.java deleted file mode 100644 index b1a1f49..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Error.java +++ /dev/null @@ -1,8 +0,0 @@ - -package com.att.ecomp.dcae.ci.entities.composition.items; - - -public class Error { - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/services/CiService.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/services/CiService.java deleted file mode 100644 index 7921965..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/services/CiService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.att.ecomp.dcae.ci.entities.composition.services; - -import org.onap.sdc.dcae.composition.services.Service; -import org.openecomp.d2.ci.datatypes.ServiceReqDetails; - -public class CiService extends Service { - // converts from ui-api-ci object to dcae-ci object (partial construction) - public CiService(ServiceReqDetails service) { - super(service.getName(), service.getUUID(), service.getVersion()); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/services/Vfi.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/services/Vfi.java deleted file mode 100644 index dcf74cb..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/services/Vfi.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.att.ecomp.dcae.ci.entities.composition.services; - -import org.openecomp.d2.ci.datatypes.ServiceReqDetails; - -public class Vfi { - private String name; - private ServiceReqDetails container; - - public Vfi(String name, ServiceReqDetails container) { - this.name = name; - this.container = container; - } - - public String getName() { - return name; - } - - public ServiceReqDetails getContainer() { - return container; - } -}
\ No newline at end of file diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcCategory.java b/src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcCategory.java deleted file mode 100644 index dd82f7d..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcCategory.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.att.ecomp.dcae.ci.entities.sdc; - -import java.util.List; - -public class SdcCategory { - - private String name; - private List<SdcCategory> subcategories; - - - public String getName() { - return name; - } - - public List<SdcCategory> getSubcategories() { - return subcategories; - } - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcComponent.java b/src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcComponent.java deleted file mode 100644 index 386d3de..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcComponent.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.att.ecomp.dcae.ci.entities.sdc; - -import java.util.List; -import java.util.Map; - -public class SdcComponent { - - private String lastUpdaterUserId; - private String uniqueId; - private String version; - private String resourceType; - private List<SdcCategory> categories; - private Map<String, String> allVersions; - - public String getLastUpdaterUserId() { - return lastUpdaterUserId; - } - - public String getUniqueId() { - return uniqueId; - } - - public String getVersion() { - return version; - } - - public String getResourceType() { - return resourceType; - } - - public List<SdcCategory> getCategories() { - return categories; - } - - public Map<String, String> getAllVersions() { - return allVersions; - } - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/run/RunTestSuite.java b/src/main/java/com/att/ecomp/dcae/ci/run/RunTestSuite.java deleted file mode 100644 index 67639a2..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/run/RunTestSuite.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.att.ecomp.dcae.ci.run; - -import org.openecomp.d2.ci.run.RunTest; - -public class RunTestSuite { - - public static void main(String[] args) { - RunTest.runTestSuite(); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAECompositionPage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAECompositionPage.java deleted file mode 100644 index 9098d23..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAECompositionPage.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.pages; - -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.tests.verificator.CompositionVerificator; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class DCAECompositionPage { - - public static WebElement expandList(String listname) - { - ExtentTestActions.log(Status.INFO,String.format("Expand %s list", listname)); - GeneralUIUtils.clickOnElementByTestId(listname); - GeneralUIUtils.ultimateWait(); - WebDriver driver = GeneralUIUtils.getDriver(); - WebDriverWait wait = new WebDriverWait(driver, 10); - WebElement categoryElement = driver.findElement(ByTest.id(listname)).findElement(By.xpath("./..")); - return wait.until(Locator.from(categoryElement).findVisible(By.cssSelector(".draggable"), 0)); - } - - public static void addItemFromList(WebElement item) - { - ExtentTestActions.log(Status.INFO,String.format("Click on %s item", item.getText())); - item.click(); - GeneralUIUtils.ultimateWait(); - - } - - public static void clickSave() - { - ExtentTestActions.log(Status.INFO,"Click save button"); - GeneralUIUtils.clickOnElementByTestId("SaveButton"); - GeneralUIUtils.ultimateWait(); - GeneralUIUtils.waitForElementInVisibilityByTestId("saveMsg"); - String actualSaveRes = GeneralUIUtils.getWebElementByTestID("saveMsg").getText(); - CompositionVerificator.verifySaveSuccessfully(actualSaveRes); - GeneralUIUtils.ultimateWait(); - } - - public static void clickSubmit() - { - ExtentTestActions.log(Status.INFO,"Click submit button"); - GeneralUIUtils.clickOnElementByTestId("SubmitButton"); - GeneralUIUtils.ultimateWait(); - GeneralUIUtils.waitForElementInVisibilityByTestId("submitMsg"); - String actualSubmitRes = GeneralUIUtils.getWebElementByTestID("submitMsg").getText(); - CompositionVerificator.verifySubmitSuccessfully(actualSubmitRes); - GeneralUIUtils.ultimateWait(); - } - - public static void SelectFlowType(String flowType) { - Report.log(Status.INFO, "Selecting flow type '%s'", flowType); - WebDriver driver = GeneralUIUtils.getDriver(); - Select flowTypeSelect = new Select(driver.findElement(ByTest.id("flowTypeSelect"))); - flowTypeSelect.selectByVisibleText(flowType); - } -} - - - - diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEGeneralPage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEGeneralPage.java deleted file mode 100644 index f1f947a..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEGeneralPage.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.pages; - -import java.util.UUID; - -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; -import org.openqa.selenium.WebElement; -import com.aventstack.extentreports.Status; - -public class DCAEGeneralPage { - - public static String addAssetName(String name) - { - WebElement nameTextbox = GeneralUIUtils.getWebElementByTestID("name"); - String assetName = name + UUID.randomUUID(); - nameTextbox.clear(); - nameTextbox.sendKeys(assetName); - GeneralUIUtils.ultimateWait(); - ExtentTestActions.log(Status.INFO,String.format("Add asset name: %s.", assetName)); - return assetName; - } - - public static void addAssetDescription(String description) - { - ExtentTestActions.log(Status.INFO,"Add asset description"); - WebElement descriptionTextbox = GeneralUIUtils.getWebElementByTestID("description"); - descriptionTextbox.clear(); - descriptionTextbox.sendKeys(description); - GeneralUIUtils.ultimateWait(); - } - - - public static void clickSaveAsset() throws Exception - { - ExtentTestActions.log(Status.INFO,"Click Save asset"); - GeneralUIUtils.waitForElementInVisibilityByTestId("Save-General"); - GeneralUIUtils.clickOnElementByTestId("Save-General"); - GeneralUIUtils.ultimateWait(); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEHomePage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEHomePage.java deleted file mode 100644 index 17ee026..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEHomePage.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.pages; - - -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; - -import com.aventstack.extentreports.Status; - - -public class DCAEHomePage { - - - - public static void clickOnDcaeTab() - { - ExtentTestActions.log(Status.INFO,"Clicking on DCAE Tab"); - GeneralUIUtils.clickOnElementByTestId("main-menu-button-dcae"); - GeneralUIUtils.ultimateWait(); - } - - public static void clickOnCreateNewAsset() - { - ExtentTestActions.log(Status.INFO,"Clicking on Create new asset button"); - GeneralUIUtils.clickOnElementByTestId("AddButtonsArea"); - GeneralUIUtils.ultimateWait(); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAELeftPanel.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAELeftPanel.java deleted file mode 100644 index 563c42b..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAELeftPanel.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.pages; - - - -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; - -import com.aventstack.extentreports.Status; - -public class DCAELeftPanel { - - public static void navigateToServices() - { - ExtentTestActions.log(Status.INFO,"Navigate to Services internal tab"); - GeneralUIUtils.clickOnElementByTestId("dcae-menu-item-Services"); - GeneralUIUtils.ultimateWait(); - } - - public static void navigateToComposition() - { - ExtentTestActions.log(Status.INFO,"Navigate to Composition internal tab"); - GeneralUIUtils.clickOnElementByTestId("dcae-menu-item-Composition"); - GeneralUIUtils.ultimateWait(); - } - - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEServicesPage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEServicesPage.java deleted file mode 100644 index f935715..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEServicesPage.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.pages; - - -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; - -import com.aventstack.extentreports.Status; - -public class DCAEServicesPage { - - public static void selectService(String serviceName) - { - GeneralUIUtils.ultimateWait(); - ExtentTestActions.log(Status.INFO,String.format("Select Service: %s from services dropdown", serviceName)); - GeneralUIUtils.getSelectList(serviceName, "Service Name SelectList"); - GeneralUIUtils.ultimateWait(); - } - - public static void selectVNFI(String VNFIName) - { - GeneralUIUtils.ultimateWait(); - VNFIName = VNFIName + " 0"; - ExtentTestActions.log(Status.INFO,String.format("Select VNFI: %s from VNFIs dropdown", VNFIName)); - GeneralUIUtils.getSelectList(VNFIName, "VNFI Name SelectList"); - GeneralUIUtils.ultimateWait(); - } - - - public static void clickAttach(String VNFIName) - { - ExtentTestActions.log(Status.INFO,"Click attach button"); - GeneralUIUtils.clickOnElementByTestId("Attach Button"); - GeneralUIUtils.ultimateWait(); - VNFIName = VNFIName + " 0"; - GeneralUIUtils.waitForElementInVisibilityByTestId(VNFIName); // Element to wait for after object is attached. - GeneralUIUtils.ultimateWait(); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateServicePage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateServicePage.java deleted file mode 100644 index 4bf9fc4..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateServicePage.java +++ /dev/null @@ -1,175 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.pages;
-
-import java.util.UUID;
-
-import org.openecomp.d2.ci.report.ExtentTestActions;
-import org.openecomp.d2.ci.utilities.GeneralUIUtils;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.Action;
-import org.openqa.selenium.interactions.Actions;
-
-import com.aventstack.extentreports.Status;
-
-public class SDCCreateServicePage
-{
- public static String addServiceName()
- {
- GeneralUIUtils.waitForElementInVisibilityByTestId("name");
- WebElement serviceNameTextbox = GeneralUIUtils.getWebElementByTestID("name");
- serviceNameTextbox.clear();
- String serviceName = "Service" + UUID.randomUUID();
- ExtentTestActions.log(Status.INFO, String.format("Add Service Name: %s", serviceName));
- serviceNameTextbox.sendKeys(serviceName);
- GeneralUIUtils.ultimateWait();
- return serviceName;
- }
-
- public static void addServiceCategory(String category)
- {
- ExtentTestActions.log(Status.INFO, String.format("Add %s Category", category));
- GeneralUIUtils.waitForElementInVisibilityByTestId("selectGeneralCategory");
- GeneralUIUtils.getSelectList(category, "selectGeneralCategory");
- GeneralUIUtils.ultimateWait();
- }
-
- public static void addServiceDescription()
- {
- ExtentTestActions.log(Status.INFO,"Add Service Desc");
- GeneralUIUtils.waitForElementInVisibilityByTestId("description");
- WebElement serviceDescTextbox = GeneralUIUtils.getWebElementByTestID("description");
- serviceDescTextbox.clear();
- String serviceDesc = "Desc";
- serviceDescTextbox.sendKeys(serviceDesc);
- GeneralUIUtils.ultimateWait();
- }
-
- public static void addServiceDescriptionProjectCode()
- {
- ExtentTestActions.log(Status.INFO,"Add Service Project Code");
- GeneralUIUtils.waitForElementInVisibilityByTestId("projectCode");
- WebElement projectCodeTextbox = GeneralUIUtils.getWebElementByTestID("projectCode");
- projectCodeTextbox.clear();
- String projectCode = "12345";
- projectCodeTextbox.sendKeys(projectCode);
- GeneralUIUtils.ultimateWait();
- }
-
- public static String addAllServiceMandtoryFields(String category)
- {
- String serviceName = addServiceName();
- addServiceCategory(category);
- addServiceDescription();
- addServiceDescriptionProjectCode();
-
- return serviceName;
- }
-
- public static void clickOnCreateServiceButton()
- {
- ExtentTestActions.log(Status.INFO,"Click on Create Service Button");
- GeneralUIUtils.waitForElementInVisibilityByTestId("create/save");
- GeneralUIUtils.clickOnElementByTestId("create/save");
- GeneralUIUtils.ultimateWait();
- }
-
- public static void clickOnCheckInServiceButton()
- {
- ExtentTestActions.log(Status.INFO,"Click on Check In Service Button");
- GeneralUIUtils.waitForElementInVisibilityByTestId("check_in");
- GeneralUIUtils.clickOnElementByTestId("check_in");
- GeneralUIUtils.ultimateWait();
- }
-
- public static void addCheckInMessage()
- {
- ExtentTestActions.log(Status.INFO,"Add check in message in pop window");
- GeneralUIUtils.waitForElementInVisibilityByTestId("checkindialog");
- WebElement checkInDialogTextbox = GeneralUIUtils.getWebElementByTestID("checkindialog");
- checkInDialogTextbox.clear();
- String vfCheckInDialog = "Text";
- checkInDialogTextbox.sendKeys(vfCheckInDialog);
- GeneralUIUtils.ultimateWait();
- }
-
- public static void clickOnCheckInOKFButton()
- {
- ExtentTestActions.log(Status.INFO,"Click OK in check in pop up window");
- GeneralUIUtils.waitForElementInVisibilityByTestId("OK");
- GeneralUIUtils.clickOnElementByTestId("OK");
- GeneralUIUtils.ultimateWait();
- }
-
- public static void checkInService()
- {
- clickOnCheckInServiceButton();
- addCheckInMessage();
- clickOnCheckInOKFButton();
- }
-
- public static void clickOnServiceCompsitionTab()
- {
- ExtentTestActions.log(Status.INFO,"Click on Service composition tab");
- GeneralUIUtils.waitForElementInVisibilityByTestId("CompositionLeftSideMenu");
- GeneralUIUtils.clickOnElementByTestId("CompositionLeftSideMenu");
- GeneralUIUtils.ultimateWait();
- }
-
-
- public static void searchAssetOnCompsitionTab(String assetName)
- {
- ExtentTestActions.log(Status.INFO,String.format("Search for %s in Service composition", assetName));
- GeneralUIUtils.waitForElementInVisibilityByTestId("searchAsset");
- WebElement compositionSearchTextbox = GeneralUIUtils.getWebElementByTestID("searchAsset");
- compositionSearchTextbox.clear();
- compositionSearchTextbox.sendKeys(assetName);
- GeneralUIUtils.ultimateWait();
- }
-
- public static void dragAndDropAssetToCanvas(String assetName)
- {
- ExtentTestActions.log(Status.INFO,String.format("Drag and drop %s to Canvas", assetName));
- GeneralUIUtils.waitForElementInVisibilityByTestId("searchAsset");
- WebElement vfElementFrom = GeneralUIUtils.getWebElementByTestID("leftbar-section-content-item-" + assetName);
- WebElement canvasElementTo = GeneralUIUtils.getWebElementByTestID("canvas");
- GeneralUIUtils.ultimateWait();
- WebDriver driver = GeneralUIUtils.getDriver();
- Actions builder = new Actions(driver);
- Action dragAndDrop = builder.clickAndHold(vfElementFrom).moveToElement(canvasElementTo).release(canvasElementTo).build();
- dragAndDrop.perform();
- GeneralUIUtils.ultimateWait();
- }
-
- public static void addAssetToCanvas(String assetName)
- {
- searchAssetOnCompsitionTab(assetName);
- dragAndDropAssetToCanvas(assetName);
- }
-
- public static void clickOnElementInCanavs()
- {
- ExtentTestActions.log(Status.INFO,"Click on VF in Canavs");
- GeneralUIUtils.waitForElementInVisibilityByTestId("canvas");
- WebElement canvasElement = GeneralUIUtils.getWebElementByTestID("canvas");
- GeneralUIUtils.ultimateWait();
- WebDriver driver = GeneralUIUtils.getDriver();
- Actions actions = new Actions(driver);
- actions.moveToElement(canvasElement, 1316, 661);
- actions.clickAndHold();
- actions.moveToElement(canvasElement, 1316, 661);
- actions.release();
- actions.perform();
- GeneralUIUtils.ultimateWait();
- }
-
- public static void clickOnArtifactTab()
- {
- ExtentTestActions.log(Status.INFO,"Click on Artifcat");
- GeneralUIUtils.getWebElementByTestID("deployment-artifact-tab");
- GeneralUIUtils.clickOnElementByTestId("deployment-artifact-tab");
- }
-
-
-
-
-}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateVFPage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateVFPage.java deleted file mode 100644 index d7a30ba..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateVFPage.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.pages;
-
-import java.util.UUID;
-
-import org.openecomp.d2.ci.report.ExtentTestActions;
-import org.openecomp.d2.ci.utilities.GeneralUIUtils;
-import org.openqa.selenium.WebElement;
-
-import com.aventstack.extentreports.Status;
-
-public class SDCCreateVFPage
-{
- public static String addVFName()
- {
- GeneralUIUtils.waitForElementInVisibilityByTestId("name");
- WebElement vfNameTextbox = GeneralUIUtils.getWebElementByTestID("name");
- vfNameTextbox.clear();
- String vfName = "VF" + UUID.randomUUID();
- vfNameTextbox.sendKeys(vfName);
- ExtentTestActions.log(Status.INFO, String.format("Add VF Name: %s",vfName));
- GeneralUIUtils.ultimateWait();
- return vfName;
- }
-
- public static void addVFCategory(String category)
- {
- ExtentTestActions.log(Status.INFO, String.format("Add %s Category", category));
- GeneralUIUtils.waitForElementInVisibilityByTestId("selectGeneralCategory");
- GeneralUIUtils.getSelectList(category, "selectGeneralCategory");
- GeneralUIUtils.ultimateWait();
- }
-
- public static void addVFDescription()
- {
- ExtentTestActions.log(Status.INFO,"Add VF Desc");
- GeneralUIUtils.waitForElementInVisibilityByTestId("description");
- WebElement vfdescTextbox = GeneralUIUtils.getWebElementByTestID("description");
- vfdescTextbox.clear();
- String vfDesc = "Desc";
- vfdescTextbox.sendKeys(vfDesc);
- GeneralUIUtils.ultimateWait();
- }
-
- public static void addVFVendorName()
- {
- ExtentTestActions.log(Status.INFO,"Add VF Vendor Name");
- GeneralUIUtils.waitForElementInVisibilityByTestId("vendorName");
- WebElement vendorTextbox = GeneralUIUtils.getWebElementByTestID("vendorName");
- vendorTextbox.clear();
- String vfVendorName = "Vendor";
- vendorTextbox.sendKeys(vfVendorName);
- GeneralUIUtils.ultimateWait();
- }
-
- public static void addVFVendorRelease()
- {
- ExtentTestActions.log(Status.INFO,"Add VF Vendor Release");
- GeneralUIUtils.waitForElementInVisibilityByTestId("vendorRelease");
- WebElement vendorReleaseTextbox = GeneralUIUtils.getWebElementByTestID("vendorRelease");
- vendorReleaseTextbox.clear();
- String vfVendorRelease = "1";
- vendorReleaseTextbox.sendKeys(vfVendorRelease);
- GeneralUIUtils.ultimateWait();
- }
-
- public static String addAllVFMandtoryFields(String category)
- {
- String vfName = addVFName();
- addVFCategory(category);
- addVFDescription();
- addVFVendorName();
- addVFVendorRelease();
-
- return vfName;
- }
-
- public static void clickOnCreateVFButton()
- {
- ExtentTestActions.log(Status.INFO,"Click on Create VF Button");
- GeneralUIUtils.waitForElementInVisibilityByTestId("create/save");
- GeneralUIUtils.clickOnElementByTestId("create/save");
- GeneralUIUtils.ultimateWait();
- }
-
- public static void clickOnCheckInVFButton()
- {
- ExtentTestActions.log(Status.INFO,"Click on Check In VF Button");
- GeneralUIUtils.waitForElementInVisibilityByTestId("check_in");
- GeneralUIUtils.clickOnElementByTestId("check_in");
- GeneralUIUtils.ultimateWait();
- }
-
- public static void addCheckInMessage()
- {
- ExtentTestActions.log(Status.INFO,"Add check in message in pop window");
- GeneralUIUtils.waitForElementInVisibilityByTestId("checkindialog");
- WebElement checkInDialogTextbox = GeneralUIUtils.getWebElementByTestID("checkindialog");
- checkInDialogTextbox.clear();
- String vfCheckInDialog = "Text";
- checkInDialogTextbox.sendKeys(vfCheckInDialog);
- GeneralUIUtils.ultimateWait();
- }
-
- public static void clickOnCheckInOKFButton()
- {
- ExtentTestActions.log(Status.INFO,"Click OK in check in pop up window");
- GeneralUIUtils.waitForElementInVisibilityByTestId("OK");
- GeneralUIUtils.clickOnElementByTestId("OK");
- GeneralUIUtils.ultimateWait();
- }
-
- public static void checkInVF()
- {
- clickOnCheckInVFButton();
- addCheckInMessage();
- clickOnCheckInOKFButton();
- }
-
-
-
-
-
-}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCHomePage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCHomePage.java deleted file mode 100644 index 00a4e4e..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCHomePage.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.pages;
-
-import org.openecomp.d2.ci.report.ExtentTestActions;
-import org.openecomp.d2.ci.setup.SetupCDTest;
-import org.openecomp.d2.ci.utilities.GeneralUIUtils;
-import org.openqa.selenium.WebElement;
-
-import com.att.ecomp.dcae.ci.utilities.ConfigurationReader;
-import com.aventstack.extentreports.Status;
-
-public class SDCHomePage
-{
-
- public static void clickOnAddVf()
- {
- ExtentTestActions.log(Status.INFO,"Clicking on Add VF button");
- GeneralUIUtils.waitForElementInVisibilityByTestId("AddButtonsArea");
- GeneralUIUtils.hoverOnAreaByTestId("AddButtonsArea");
- GeneralUIUtils.waitForElementInVisibilityByTestId("createResourceButton");
- GeneralUIUtils.clickOnElementByTestId("createResourceButton");
- GeneralUIUtils.ultimateWait();
- }
-
- public static void clickOnAddsService()
- {
- ExtentTestActions.log(Status.INFO,"Clicking on Add Service button");
- GeneralUIUtils.waitForElementInVisibilityByTestId("AddButtonsArea");
- GeneralUIUtils.hoverOnAreaByTestId("AddButtonsArea");
- GeneralUIUtils.waitForElementInVisibilityByTestId("createServiceButton");
- GeneralUIUtils.clickOnElementByTestId("createServiceButton");
- GeneralUIUtils.ultimateWait();
- }
-
- public static void searchForElement(String name)
- {
- ExtentTestActions.log(Status.INFO,"Search for element in Homepage");
- GeneralUIUtils.waitForElementInVisibilityByTestId("main-menu-input-search");
- WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID("main-menu-input-search");
- searchTextbox.clear();
- searchTextbox.sendKeys(name);
- GeneralUIUtils.ultimateWait();
- }
-
- public static void clickOnElement(String name)
- {
- ExtentTestActions.log(Status.INFO,"Clicking on Add VF button");
- GeneralUIUtils.waitForElementInVisibilityByTestId(name);
- GeneralUIUtils.clickOnElementByTestId(name);
- GeneralUIUtils.ultimateWait();
- }
-
- public static void clickOnHomeTab() throws Exception {
- ExtentTestActions.log(Status.INFO,"Navigate to SDC Homepage");
- GeneralUIUtils.clickOnElementByCSS("div[class=triangle] span"); // Temp workaround... need to click by data-tests-id
- GeneralUIUtils.ultimateWait();
- GeneralUIUtils.clickOnElementByTestId("sub-menu-button-home");
- GeneralUIUtils.ultimateWait();
- }
-
-}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/BaseTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/BaseTest.java deleted file mode 100644 index a197dd3..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/BaseTest.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor; - -import java.io.File; -import java.util.Map; - -import org.openecomp.d2.ci.datatypes.Configuration; -import org.openecomp.d2.ci.datatypes.UserCredentials; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.setup.DriverFactory; -import org.openecomp.d2.ci.utilities.FileHandling; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.web.util.UriComponentsBuilder; -import org.testng.annotations.BeforeMethod; - -import com.att.ecomp.dcae.ci.ui.rule_editor.components.LoginPage; -import com.att.ecomp.dcae.ci.utilities.ConfigurationReader; -import com.att.ecomp.dcae.ci.utilities.DcaeEntityClient; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class BaseTest extends DriverFactory { - - private String baseUrl = ConfigurationReader.getConfiguration().getRuleEditorUrl(); - private final long defaultTimeout = 90; - protected WebDriverWait defaultTimeoutWait; - - @BeforeMethod - protected void setupTest(){ - try { - /** - * this is surrounded by a try block because of a bug in TestNg that causes 'afterMethod' to not be called - * when an exception is thrown in the 'beforeMethod' - this prevents the ExtentReport from producing a report - */ - - Report.log(Status.INFO, "Setting up..."); - LinkedMultiValueMap<String, String> params = arrangeRequiredParams(); - String url = UriComponentsBuilder.fromHttpUrl(baseUrl).queryParams(params).build().toUriString(); - Report.log(Status.INFO, "Deleting cookies..."); - WebDriver driver = getDriver(); - driver.manage().deleteAllCookies(); - Report.log(Status.INFO, "Navigating to URL: %s", url); - driver.navigate().to(url); - Report.log(Status.INFO, "Checking if diverted to login page..."); - defaultTimeoutWait = new WebDriverWait(driver, defaultTimeout); - if (LoginPage.isCurrentPage(driver)) { - Report.log(Status.INFO, "Preforming login..."); - WebElement root = driver.findElement(By.cssSelector("body")); - LoginPage loginPage = new LoginPage(defaultTimeoutWait, root); - loginPage.login(getUserCredentials()); - Report.log(Status.INFO, "Refreshing..."); - driver.navigate().refresh(); // refresh fixes missing cookies after login - Report.log(Status.INFO, "Logged-in successfully."); - } else { - Report.log(Status.INFO, "Not in login page."); - } - Report.log(Status.INFO, "Setup done."); - } catch (Exception err) { - Report.fatal("Error during setup", err); - } - } - - protected LinkedMultiValueMap<String, String> arrangeRequiredParams() throws Exception { - String userId = getUserCredentials().getUserId(); - DcaeEntityClient dcaeEntityClient = new DcaeEntityClient(); - Report.log(Status.INFO, "Creating vfcmt..."); - Vfcmt vfcmt = dcaeEntityClient.createVfcmt(userId); -// Report.log(Status.INFO, "Generating cdump of snmp (simulated drag of snmp component)..."); - String cdump = getFakeCdump(); - Report.log(Status.INFO, "Saving composition..."); - RestResponse saveResponse = DcaeRestClient.saveComposition(vfcmt.getUuid(), userId, cdump); - if (saveResponse.getStatusCode() != 200) { - throw new Exception("Save composition failed.\nDetails: " + saveResponse.toString()); - } - LinkedMultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(); - params.add("vfcmtUuid", vfcmt.getUuid()); - params.add("nodeName", "map"); - params.add("nodeId", "map"); - params.add("fieldName", "fake"); - params.add("userId", userId); - params.add("flowType", "FOI"); - return params; - } - - protected LinkedMultiValueMap<String, String> arrangeFakeParams() { - LinkedMultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(); - params.add("vfcmtUuid", "aece8152-a97f-4ec4-9a42-941d8e586f97"); - params.add("nodeName", "map"); - params.add("nodeId", "map"); - params.add("fieldName", "fake"); - params.add("userId", "fakeo"); - params.add("flowType", "FOI"); - return params; - } - - private static String getFakeCdump() { - return "{\"nid\":\"map\"}"; - } - - protected UserRoleEnum getUserRole() - { - return UserRoleEnum.DESIGNER; - } - - @Override - protected Configuration getEnvConfiguration() { - return ConfigurationReader.getConfiguration(); - } - - @Override - protected UserCredentials getUserCredentials() { - try { - String userRole = getUserRole().name().toLowerCase(); - String credentialsFile = System.getProperty("credentials.file"); - if (credentialsFile == null) - credentialsFile = ConfigurationReader.confPath() + "credentials.yaml"; - File file = new File(credentialsFile); - if (!file.exists()){ - throw new Exception("Please provide a credentails file"); - } - Map<?, ?> credentialsParsedFile = FileHandling.parseYamlFile(credentialsFile); - Map<String, String> credentialsMap = (Map<String, String>) credentialsParsedFile.get(userRole); - String userId = (String) credentialsMap.get("username"); - String password = (String) credentialsMap.get("password"); - String firstname = (String) credentialsMap.get("firstname"); - String lastname = (String) credentialsMap.get("lastname"); - - return new UserCredentials(userId, password, firstname, lastname, null); - - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/TranslateResult.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/TranslateResult.java deleted file mode 100644 index 22545b9..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/TranslateResult.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor; - -import com.fasterxml.jackson.annotation.*; - -public class TranslateResult { - - public enum Status { - ok, - error - } - - private Status status; - private String data; - - @JsonCreator - public TranslateResult( - @JsonProperty("status") Status status, - @JsonProperty("data") String data) { - - this.status = status; - this.data = data; - } - - public Status getStatus() { - return status; - } - - public String getData() { - return data; - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/BaseComponenet.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/BaseComponenet.java deleted file mode 100644 index c159af9..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/BaseComponenet.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components; - -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; - -public class BaseComponenet { - - protected WebDriverWait wait; - protected WebElement root; - - public BaseComponenet(WebDriverWait timeout, WebElement element) { - this.wait = timeout; - this.root = element; - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/HomePage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/HomePage.java deleted file mode 100644 index 47ab468..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/HomePage.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components; - -import static org.testng.Assert.fail; - -import java.util.Arrays; - -import org.openqa.selenium.JavascriptExecutor; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.rule_editor.TranslateResult; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class HomePage extends BaseComponenet { - - public HomePage(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public void waitForLoaderFinish() { - Report.log(Status.INFO, "Wait for loader finish..."); - ByTest loaderTestId = ByTest.id("loader"); - WebElement loader = wait.until(Locator.from(root).find(loaderTestId, 0)); // wait until loader appears - wait.until(ExpectedConditions.invisibilityOfAllElements(Arrays.asList(loader))); // wait until loader disappears - } - - public void load(String version, String eventType) { - Report.log(Status.INFO, "Selecting version..."); - select(ByTest.id("selectVersion"), version); - Report.log(Status.INFO, "Selecting event-type..."); - select(ByTest.id("selectEventType"), eventType); - } - - public RuleComponent getRule(int index) { - WebElement ruleElement = wait.until(Locator.from(root).findVisible(ByTest.id("ruleElement"), index)); - return new RuleComponent(wait, ruleElement); - } - - private WebElement getRulePopupElem() { - return wait.until(Locator.from(root).findVisible(ByTest.id("popupRuleEditor"), 0)); - } - - public WebElement getRoot() { - return root; - } - - public RulePopup clickAddFirstRule() { - Report.log(Status.INFO, "Clicking add-rule..."); - wait.until(Locator.from(root).findVisible(ByTest.id("btnAddFirstRule"), 0)).click(); - WebElement popupAddRule = getRulePopupElem(); - Report.log(Status.INFO, "Rule popup visible"); - return new RulePopup(wait, popupAddRule); - } - - public RulePopup clickAddMoreRule() { - Report.log(Status.INFO, "Clicking add-rule..."); - wait.until(Locator.from(root).findVisible(ByTest.id("addMoreRule"), 0)).click(); - WebElement popupAddRule = getRulePopupElem(); - Report.log(Status.INFO, "Rule popup visible"); - return new RulePopup(wait, popupAddRule); - } - - public void clickOnRuleDeleteConfirmPopup (){ - Report.log(Status.INFO, "Click on delete on popup confirmation"); - WebElement deletePopup = wait.until(Locator.from(root).findVisible(ByTest.id("delete-popup"), 0)); - wait.until(Locator.from(root).findVisible(ByTest.id("btnDelete"), 0)).click(); - waitForLoaderFinish(); - } - - public void clickTranslate() { - Report.log(Status.INFO, "Clicking Translate..."); - wait.until(Locator.from(root).findVisible(ByTest.id("btnTranslate"), 0)).click(); - waitForLoaderFinish(); - } - - public void clickCancel() { - Report.log(Status.INFO, "Clicking Cancel..."); - wait.until(Locator.from(root).findVisible(ByTest.id("btnCancel"), 0)).click(); - } - - public String getTranslation(WebDriver driver) throws Exception { - Report.log(Status.INFO, "Retriving translation result..."); - Object result = (Object) ((JavascriptExecutor) driver).executeScript("return window.translateResult;"); - ObjectMapper mapper = new ObjectMapper(); - TranslateResult parsedResult = mapper.convertValue(result, TranslateResult.class); - switch(parsedResult.getStatus()) { - case error: - fail(String.format("translate error: %s", parsedResult.getData())); - break; - case ok: - Report.logDebug("translation:", parsedResult.getData()); - return parsedResult.getData(); - } - throw new Exception(String.format("invalid status argument. expected (ok/error) but got %s", parsedResult.getData())); - } - - /* Private Methods */ - - private void select(ByTest by, String option) { - WebElement selectElement = wait.until(Locator.from(root).findVisible(by, 0)); - wait.until(Locator.from(selectElement).find(ByTest.id("option"), 0)); // wait for dynamic options - Select versionSelect = new Select(selectElement); - versionSelect.selectByVisibleText(option); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/LoginPage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/LoginPage.java deleted file mode 100644 index cc17481..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/LoginPage.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components; - -import org.openecomp.d2.ci.datatypes.UserCredentials; -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 com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class LoginPage extends BaseComponenet { - - public LoginPage(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public void login(String userId, String password) { - Report.log(Status.INFO, "Filling input userid..."); - root.findElement(By.name("userid")).sendKeys(userId); - Report.log(Status.INFO, "Filling input password..."); - root.findElement(By.name("password")).sendKeys(password); - Report.log(Status.INFO, "Clicking submit..."); - root.findElement(By.name("btnSubmit")).click(); - Report.log(Status.INFO, "Waiting for login success page..."); - wait.until(ExpectedConditions.titleIs("AT&T - Log On Successful")); - Report.log(Status.INFO, "Clicking OK..."); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("successOK"))).click(); - } - - public void login(UserCredentials credentials) { - login(credentials.getUserId(), credentials.getPassword()); - } - - public static boolean isCurrentPage(WebDriver driver) { - return driver.getTitle().equals("AT&T Security Server: Login"); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RuleComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RuleComponent.java deleted file mode 100644 index 94bf547..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RuleComponent.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components; - -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class RuleComponent extends BaseComponenet { - - public RuleComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public String getDescription(){ - Report.log(Status.INFO, "Get rule description"); - return root.getText(); - } - - public RulePopup clickEdit(WebDriver driver, WebElement homePageRoot){ - Report.log(Status.INFO, "Click on edit..."); - Actions action = new Actions(driver); - action.moveToElement(root).perform(); - wait.until(Locator.from(root).findVisible(ByTest.id("editRule"), 0)).click(); - WebElement rulePopupElem = wait.until(Locator.from(homePageRoot).findVisible(ByTest.id("popupRuleEditor"), 0)); - return new RulePopup(wait, rulePopupElem); - } - - public void clickDelete(WebDriver driver){ - Report.log(Status.INFO, "Click on delete..."); - Actions action = new Actions(driver); - action.moveToElement(root).perform(); - wait.until(Locator.from(root).findVisible(ByTest.id("deleteRule"), 0)).click(); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RulePopup.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RulePopup.java deleted file mode 100644 index 1cde952..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RulePopup.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components; - -import java.util.Arrays; - -import org.apache.commons.lang3.NotImplementedException; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.ActionComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.ActionType; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.ConcatActionComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.CopyActionComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.MapActionComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.condition.ConditionComponent; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class RulePopup extends BaseComponenet { - - public RulePopup(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public String getDescription() { - Report.log(Status.INFO, "get input description..."); - return wait.until(Locator.from(root).findVisible(ByTest.id("inputDescription"), 0)).getAttribute("value"); - } - - public void setDescription(String text) { - Report.log(Status.INFO, "Filling input description..."); - wait.until(Locator.from(root).findVisible(ByTest.id("inputDescription"), 0)).sendKeys(text); - } - - public ActionComponent getAction(ActionType actionType, int index) { - WebElement actionElement = wait.until(Locator.from(root).findVisible(ByTest.id("action"), index)); - ActionComponent newActionComponent = createAction(actionType, wait, actionElement); - return newActionComponent; - } - - public CopyActionComponent addCopyAction(int index) { - return (CopyActionComponent) addAction(ActionType.Copy, index); - } - - public ConcatActionComponent addConcatAction(int index) { - return (ConcatActionComponent) addAction(ActionType.Concat, index); - } - - public MapActionComponent addMapAction(int index) { - return (MapActionComponent) addAction(ActionType.Map, index); - } - - public WebElement getErrorList(){ - return wait.until(Locator.from(root).findVisible(ByTest.id("errorList"), 0)); - } - - public void clickOnAddCondition(){ - wait.until(Locator.from(root).find(ByTest.id("isCondition"), 0)).click(); - } - - public void addSimpleCondition(){ - clickOnAddCondition(); - Report.log(Status.INFO, "Create and fill simple condition"); - ConditionComponent condition = new ConditionComponent(wait,root); - condition.setLeftField(0, "A"); - condition.setRightField(0, "B"); - condition.selectOperator(0, "Contains"); - } - - public void addComplexCondition(){ - Report.log(Status.INFO, "Click on add condition checkbox"); - clickOnAddCondition(); - Report.log(Status.INFO, "Create and fill top condition"); - ConditionComponent condition1 = new ConditionComponent(wait,root); - condition1.setLeftField(0, "A"); - condition1.setRightField(0, "B"); - condition1.selectOperator(0, "Contains"); - Report.log(Status.INFO, "Click on add group condition"); - wait.until(Locator.from(root).findVisible(ByTest.id("addConditionGroup"), 0)).click(); - Report.log(Status.INFO, "Create and fill first nested condition"); - ConditionComponent innerCondition1 = new ConditionComponent(wait,root); - condition1.setLeftField(1, "C"); - condition1.setRightField(1, "D"); - condition1.selectOperator(1, "Contains"); - Report.log(Status.INFO, "Create and fill second nested condition"); - ConditionComponent innerCondition2 = new ConditionComponent(wait,root); - condition1.setLeftField(2, "E"); - condition1.setRightField(2, "F"); - condition1.selectOperator(2, "Contains"); - } - - public void clickSave() { - Report.log(Status.INFO, "Clicking Save (changes on rule-editor)..."); - wait.until(Locator.from(root).findVisible(ByTest.id("btnSave"), 0)).click(); - waitForLoaderFinish(); - } - - public void clickCancel() { - Report.log(Status.INFO, "Clicking Cancel (changes on rule-editor)..."); - wait.until(Locator.from(root).findVisible(ByTest.id("btnCancel"), 0)).click(); - } - - - /* Private Methods */ - - private void waitForLoaderFinish() { - Report.log(Status.INFO, "Wait for loader finish..."); - ByTest loaderTestId = ByTest.id("loader"); - WebElement loader = root.findElement(loaderTestId); - wait.until(ExpectedConditions.invisibilityOfAllElements(Arrays.asList(loader))); // wait until loader disappears - } - - private ActionComponent addAction(ActionType actionType, int index) { - Report.log(Status.INFO, "Selecting action..."); - WebElement actionElement = wait.until(Locator.from(root).findVisible(ByTest.id("selectAction"), 0)); - Select actionSelect = new Select(actionElement); - actionSelect.selectByVisibleText(actionType.toString()); - Report.log(Status.INFO, "Clicking Add Action..."); - wait.until(Locator.from(root).findVisible(ByTest.id("btnAddAction"), 0)).click(); - return getAction(actionType, index); - } - - private static ActionComponent createAction(ActionType actionType, WebDriverWait wait, WebElement newActionElement) { - switch (actionType) { - case Concat: - return new ConcatActionComponent(wait, newActionElement); - case Copy: - return new CopyActionComponent(wait, newActionElement); - case Map: - return new MapActionComponent(wait, newActionElement); - default: - throw new IllegalArgumentException(String.format("action type '%s' not supported", actionType)); - } - } - - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionComponent.java deleted file mode 100644 index c12931a..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionComponent.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions; - -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.rule_editor.components.BaseComponenet; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class ActionComponent extends BaseComponenet { - - public ActionComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public void delete() { - Report.log(Status.INFO, "click on delete action"); - wait.until(Locator.from(root).findVisible(ByTest.id("deleteAction"), 0)).click(); - } - - public void setTarget(String target) { - Report.log(Status.INFO, "Filling input target..."); - getTargetElement().clear(); - getTargetElement().sendKeys(target); - } - - public void setTargetFromTree(){ - Report.log(Status.INFO, "Pick target from tree"); - wait.until(Locator.from(root).findVisible(ByTest.id("openTargetTree"), 0)).click(); - Report.log(Status.INFO, "Click on tree toggle"); - wait.until(Locator.from(root).findVisible(ByTest.cssSelector(".toggle-children-wrapper"),0)).click(); - Report.log(Status.INFO, "Click on first target node"); - wait.until(Locator.from(root).findVisible(ByTest.id("targetNode"), 1)).click(); - } - - public String getTarget() { - Report.log(Status.INFO, "get input target..."); - return getTargetElement().getAttribute("value"); - } - - /* Private Methods */ - - private WebElement getTargetElement() { - return wait.until(Locator.from(root).findVisible(ByTest.id("inputTarget"), 0)); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionType.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionType.java deleted file mode 100644 index 4cb4a28..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionType.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions; - -public enum ActionType { - Copy, - Concat, - Map -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ConcatActionComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ConcatActionComponent.java deleted file mode 100644 index 435441e..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ConcatActionComponent.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions; - -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from.DeleteableFromComponent; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - - -public class ConcatActionComponent extends ActionComponent { - - public ConcatActionComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public DeleteableFromComponent clickAddInput(int index) { - Report.log(Status.INFO, "Clicking on add input (another from)..."); - wait.until(Locator.from(root).findVisible(ByTest.id("btnAddInput"), 0)).click(); - return getFromComponent(index); - } - - public DeleteableFromComponent getFromComponent(int index) { - Report.log(Status.INFO, "Getting from component at index %d...", index); - WebElement fromElement = wait.until(Locator.from(root).findVisible(ByTest.id("fromComponent"), index)); - return new DeleteableFromComponent(wait, fromElement); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/CopyActionComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/CopyActionComponent.java deleted file mode 100644 index 3241ce6..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/CopyActionComponent.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions; - -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from.RegexFromComponent; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class CopyActionComponent extends ActionComponent { - - public CopyActionComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public RegexFromComponent getFromComponent() { - Report.log(Status.INFO, "Getting fromComponent..."); - WebElement fromElement = wait.until(Locator.from(root).findVisible(ByTest.id("fromComponent"), 0)); - return new RegexFromComponent(wait, fromElement); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/MapActionComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/MapActionComponent.java deleted file mode 100644 index 37efe17..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/MapActionComponent.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions; - -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from.RegexFromComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from.SimpleFromComponent; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class MapActionComponent extends ActionComponent { - - public MapActionComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public SimpleFromComponent getFromComponent() { - Report.log(Status.INFO, "getting simple from component"); - WebElement fromElement = wait.until(Locator.from(root).findVisible(ByTest.id("fromComponent"), 0)); - return new SimpleFromComponent(wait, fromElement); - } - - public void openDefaultOption(){ - Report.log(Status.INFO, "open default opention by click on checkbox"); - wait.until(Locator.from(root).find(ByTest.id("defaultCheckbox"), 0)).click(); - } - - public void setDefaultData(String value){ - Report.log(Status.INFO, "set default field with a value"); - wait.until(Locator.from(root).findVisible(ByTest.id("defaultInput"), 0)).sendKeys(value); - } - - public void setKeyData(String value){ - Report.log(Status.INFO, "set map key with a value"); - wait.until(Locator.from(root).findVisible(ByTest.id("key"), 0)).sendKeys(value); - } - - public void setValueData(String value){ - Report.log(Status.INFO, "set map value with a value"); - wait.until(Locator.from(root).findVisible(ByTest.id("value"), 0)).sendKeys(value); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/DeleteableFromComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/DeleteableFromComponent.java deleted file mode 100644 index 4037419..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/DeleteableFromComponent.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from; - -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class DeleteableFromComponent extends SimpleFromComponent { - - public DeleteableFromComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public void clickDelete(WebDriver driver) { - Report.log(Status.INFO, "Click on delete from..."); - Actions action = new Actions(driver); - action.moveToElement(root).perform(); - wait.until(Locator.from(root).findVisible(ByTest.id("btnDelete"), 0)).click(); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/RegexFromComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/RegexFromComponent.java deleted file mode 100644 index 159d0c9..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/RegexFromComponent.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from; - -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class RegexFromComponent extends SimpleFromComponent { - - public RegexFromComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public void clickRegex() { - Report.log(Status.INFO, "Clicking regex button..."); - wait.until(Locator.from(root).findVisible(ByTest.id("btnFromRegex"), 0)).click(); - } - - public String getRegex() { - Report.log(Status.INFO, "Getting regex from..."); - return getRegexElement().getAttribute("value"); - } - - public void setRegex(String value) { - Report.log(Status.INFO, "Setting regex from..."); - getRegexElement().clear(); - getRegexElement().sendKeys(value); - } - - /* Private Methods */ - - private WebElement getRegexElement() { - return wait.until(Locator.from(root).findVisible(ByTest.id("inputFromRegex"), 0)); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/SimpleFromComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/SimpleFromComponent.java deleted file mode 100644 index a7cba3d..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/SimpleFromComponent.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from; - -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.rule_editor.components.BaseComponenet; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class SimpleFromComponent extends BaseComponenet { - - public SimpleFromComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public String getValue() { - Report.log(Status.INFO, "Getting input from..."); - return getFromValueElement().getAttribute("value"); - } - - public void setValue(String value) { - Report.log(Status.INFO, "Setting input from..."); - getFromValueElement().clear(); - getFromValueElement().sendKeys(value); - } - - /* Private Methods */ - - private WebElement getFromValueElement() { - return wait.until(Locator.from(root).findVisible(ByTest.id("valueInput"), 0)); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/condition/ConditionComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/condition/ConditionComponent.java deleted file mode 100644 index 12ab277..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/condition/ConditionComponent.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.condition; - -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.rule_editor.components.BaseComponenet; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; - -public class ConditionComponent extends BaseComponenet{ - - public ConditionComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public void setLeftField(int index, String value){ - WebElement left = wait.until(Locator.from(root).findVisible(ByTest.id("left"), index)); - left.clear(); - left.sendKeys(value); - } - - public void setRightField(int index, String value){ - WebElement right = wait.until(Locator.from(root).findVisible(ByTest.id("right"), index)); - right.clear(); - right.sendKeys(value); - } - - public void selectOperator(int index, String value){ - WebElement operatorElement = wait.until(Locator.from(root).findVisible(ByTest.id("selectOperator"), index)); - Select operatorSelect = new Select(operatorElement); - operatorSelect.selectByVisibleText(value); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/tests/SanityTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/tests/SanityTest.java deleted file mode 100644 index 9f31ddd..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/tests/SanityTest.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.tests; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; - -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.testng.annotations.Test; - -import com.att.ecomp.dcae.ci.ui.rule_editor.BaseTest; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.HomePage; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.RuleComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.RulePopup; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.ActionType; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.ConcatActionComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.CopyActionComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.MapActionComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from.RegexFromComponent; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class SanityTest extends BaseTest { - - @Test - public void testTranslateOfSingleCopyAction() throws Exception { - WebDriver driver = getDriver(); - ExtentTestActions.log(Status.INFO, "test start"); - List<WebElement> findElements = driver.findElements(By.cssSelector("[data-tests-id*=\"map\" i]")); - - - WebElement appElement; - HomePage homePage = initHomePage(driver); - homePage.load("5.3", "syslog"); - setRule1(homePage.clickAddFirstRule()); - setRule2(homePage.clickAddMoreRule(), driver); - RulePopup editRule1 = homePage.getRule(0).clickEdit(driver, homePage.getRoot()); - validateRule1(editRule1); - editRule1 = homePage.getRule(0).clickEdit(driver, homePage.getRoot()); - editRule1(editRule1); - RuleComponent firstRuleinList = verifyRuleListDescription(homePage); - deleteRuleFromRuleList(driver, homePage, firstRuleinList); - translateRuleList(driver, homePage); - refreshAndVerifyGetRules(driver); - } - - private void refreshAndVerifyGetRules(WebDriver driver) { - Report.log(Status.INFO, "Refresh and verify getting rule list"); - HomePage homePage; - RuleComponent firstRuleinList; - driver.navigate().refresh(); - homePage = initHomePage(driver); - firstRuleinList = homePage.getRule(0); - assertThat(firstRuleinList.getDescription()).contains("Yanir Manor"); - } - - private void translateRuleList(WebDriver driver, HomePage homePage) throws Exception { - Report.log(Status.INFO, "Translate rule list"); - homePage.clickTranslate(); - String translation = homePage.getTranslation(driver); - assertThat(translation).isNotEmpty(); - } - - private void deleteRuleFromRuleList(WebDriver driver, HomePage homePage, RuleComponent firstRuleinList) { - Report.log(Status.INFO, "Delete the first rule from list"); - firstRuleinList.clickDelete(driver); - homePage.clickOnRuleDeleteConfirmPopup(); - } - - private RuleComponent verifyRuleListDescription(HomePage homePage) { - Report.log(Status.INFO, "Verify Rule List Description"); - RuleComponent firstRuleinList = homePage.getRule(0); - assertThat(firstRuleinList.getDescription()).contains("Oren Levi"); - return firstRuleinList; - } - - private HomePage initHomePage(WebDriver driver) { - WebElement appElement = driver.findElement(By.cssSelector("body")); - HomePage homePage = new HomePage(defaultTimeoutWait, appElement); - homePage.waitForLoaderFinish(); - return homePage; - } - - private void setRule1(RulePopup rulePopup) { - Report.log(Status.INFO, "Set first rule"); - rulePopup.setDescription("Oren Levi"); - CopyActionComponent copyAction = rulePopup.addCopyAction(0); - rulePopup.clickSave(); - WebElement errorList = rulePopup.getErrorList(); - assertThat(errorList.getText()).isNotEmpty(); - rulePopup.addSimpleCondition(); - RegexFromComponent fromComponent = copyAction.getFromComponent(); - fromComponent.setValue("Argentina"); - fromComponent.clickRegex(); - fromComponent.setRegex("*"); - copyAction.setTarget("Mexico"); - rulePopup.clickSave(); - } - - private void validateRule1(RulePopup rulePopup) { - Report.log(Status.INFO, "Validate first rule"); - assertThat(rulePopup.getDescription()).isEqualTo("Oren Levi"); - CopyActionComponent copyAction = (CopyActionComponent) rulePopup.getAction(ActionType.Copy, 0); - RegexFromComponent fromComponent = copyAction.getFromComponent(); - assertThat(fromComponent.getValue()).isEqualTo("Argentina"); - assertThat(fromComponent.getRegex()).isEqualTo("*"); - assertThat(copyAction.getTarget()).isEqualTo("Mexico"); - rulePopup.clickCancel(); - } - - private void editRule1(RulePopup rulePopup) { - Report.log(Status.INFO, "Edit first rule"); - CopyActionComponent copyAction = (CopyActionComponent) rulePopup.getAction(ActionType.Copy, 0); - RegexFromComponent fromComponent = copyAction.getFromComponent(); - fromComponent.setValue("Brazil"); - fromComponent.setRegex("**"); - copyAction.setTarget("Canada"); - rulePopup.clickSave(); - } - - private void setRule2(RulePopup rulePopup, WebDriver driver) { - Report.log(Status.INFO, "Set second rule"); - rulePopup.setDescription("Yanir Manor"); - - Report.log(Status.INFO, "Add complex condition"); - rulePopup.addComplexCondition(); - - Report.log(Status.INFO, "Add concat action"); - ConcatActionComponent concatAction = rulePopup.addConcatAction(0); - concatAction.getFromComponent(0).setValue("Oren"); - concatAction.getFromComponent(1).setValue("Levi"); - concatAction.clickAddInput(2).setValue("yanir"); - concatAction.getFromComponent(1).clickDelete(driver); - concatAction.setTargetFromTree(); - - Report.log(Status.INFO, "Add map action"); - MapActionComponent mapAction = rulePopup.addMapAction(1); - mapAction.getFromComponent().setValue("Mapfrom"); - mapAction.setTarget("MapTarget"); - mapAction.openDefaultOption(); - mapAction.setDefaultData("default data"); - mapAction.setKeyData("A"); - mapAction.setValueData("B"); - - rulePopup.clickSave(); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/setup/ConfigTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/setup/ConfigTest.java deleted file mode 100644 index 1f6f59a..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/setup/ConfigTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.setup; - -import java.io.File; -import java.util.Map; - -import org.openecomp.d2.ci.datatypes.Configuration; -import org.openecomp.d2.ci.datatypes.UserCredentials; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.setup.SetupCDTest; -import org.openecomp.d2.ci.utilities.FileHandling; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; -import org.openecomp.d2.ci.utilities.LoginUtils; -import org.openqa.selenium.WebElement; -import org.testng.annotations.BeforeMethod; - -import com.att.ecomp.dcae.ci.utilities.ConfigurationReader; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public abstract class ConfigTest extends SetupCDTest { - - protected abstract UserRoleEnum getUserRole(); - - @Override - protected Configuration getEnvConfiguration() { - return ConfigurationReader.getConfiguration(); - } - - @Override - protected UserCredentials getUserCredentials() { - try { - String userRole = getUserRole().name().toLowerCase(); - String credentialsFile = System.getProperty("credentials.file"); - if (credentialsFile == null) - credentialsFile = ConfigurationReader.confPath() + "credentials.yaml"; - File file = new File(credentialsFile); - if (!file.exists()){ - throw new Exception("Please provide a credentails file"); - } - Map<?, ?> credentialsParsedFile = FileHandling.parseYamlFile(credentialsFile); - Map<String, String> credentialsMap = (Map<String, String>) credentialsParsedFile.get(userRole); - String userId = (String) credentialsMap.get("username"); - String password = (String) credentialsMap.get("password"); - String firstname = (String) credentialsMap.get("firstname"); - String lastname = (String) credentialsMap.get("lastname"); - - UserCredentials userCredentials = new UserCredentials(userId, password, firstname, lastname, null); - Report.log(Status.INFO, "Using user Credentials="+userCredentials); - return userCredentials; - - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - @Override - protected void loginToLocalSimulator(UserCredentials user) { - LoginUtils.loginToLocalWebsealSimulator(user); - } - - @BeforeMethod - public void beforeTest(){ - try{ - if(getEnvConfiguration().getUrl().contains("localhost")) - { - GeneralUIUtils.ultimateWait(); - } - else - { - WebElement close = GeneralUIUtils.getWebElementByClassName("sdc-welcome-close"); - close.click(); - GeneralUIUtils.ultimateWait(); - } - } - catch(Exception e){ - Report.logDebug("Exception has occured in beforeTest - unable to proceed to test ", e); - e.printStackTrace(); - } - } - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/setup/DcaeConfiguration.java b/src/main/java/com/att/ecomp/dcae/ci/ui/setup/DcaeConfiguration.java deleted file mode 100644 index 2eee2b4..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/setup/DcaeConfiguration.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.setup; - -import org.openecomp.d2.ci.datatypes.Configuration; - -public class DcaeConfiguration extends Configuration { - - private String apiPath; - private String dcaeBeHost; - private String dcaeBePort; - private String ruleEditorUrl; - - - - public String getApiPath() { - return apiPath; - } - - public void setApiPath(String apiPath) { - this.apiPath = apiPath; - } - - public String getDcaeBeHost() { - return dcaeBeHost; - } - - public void setDcaeBeHost(String dcaeBeHost) { - this.dcaeBeHost = dcaeBeHost; - } - - public String getDcaeBePort() { - return dcaeBePort; - } - - public void setDcaeBePort(String dcaeBePort) { - this.dcaeBePort = dcaeBePort; - } - - public String getRuleEditorUrl() { - return ruleEditorUrl; - } - - public void setRuleEditorUrl(String ruleEditorUrl) { - this.ruleEditorUrl = ruleEditorUrl; - } - - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/DCAESanity.java b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/DCAESanity.java deleted file mode 100644 index b7f2441..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/DCAESanity.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.tests;
-
-import org.openecomp.d2.ci.datatypes.UserRoleEnum;
-import org.openecomp.d2.ci.report.ExtentTestActions;
-import org.openecomp.d2.ci.utilities.GeneralUIUtils;
-import org.openqa.selenium.WebElement;
-import org.testng.annotations.Test;
-import com.att.ecomp.dcae.ci.ui.pages.DCAECompositionPage;
-import com.att.ecomp.dcae.ci.ui.pages.DCAEGeneralPage;
-import com.att.ecomp.dcae.ci.ui.pages.DCAEHomePage;
-import com.att.ecomp.dcae.ci.ui.pages.DCAELeftPanel;
-import com.att.ecomp.dcae.ci.ui.pages.DCAEServicesPage;
-import com.att.ecomp.dcae.ci.ui.pages.SDCCreateServicePage;
-import com.att.ecomp.dcae.ci.ui.pages.SDCCreateVFPage;
-import com.att.ecomp.dcae.ci.ui.pages.SDCHomePage;
-import com.att.ecomp.dcae.ci.ui.setup.ConfigTest;
-import com.att.ecomp.dcae.ci.ui.tests.verificator.ServiceVerificator;
-import com.aventstack.extentreports.Status;
-
-public class DCAESanity extends ConfigTest{
-
- @Override
- protected UserRoleEnum getUserRole() {
- // TODO Auto-generated method stub
- return UserRoleEnum.DESIGNER;
- }
-
- @Test (description = "DCAE Main scenario", groups={"Sanity"})
- public void sanityTestSDCSection() throws Exception
- {
- String vfName;
- String serviceName;
-
- // ------------------ SDC-Side: Create VF --------------------------
-
- System.out.println("Start Test");
-
- SDCHomePage.clickOnAddVf();
- vfName = SDCCreateVFPage.addAllVFMandtoryFields("Utility"); //Creates VF, need to send only the desired category name
- SDCCreateVFPage.clickOnCreateVFButton();
- SDCCreateVFPage.checkInVF();
-
- // ------------------ SDC-Side: Create Service ---------------------
- SDCHomePage.clickOnAddsService();
- serviceName = SDCCreateServicePage.addAllServiceMandtoryFields("Network L1-3");
- SDCCreateServicePage.clickOnCreateServiceButton();
- SDCCreateServicePage.clickOnServiceCompsitionTab();
- SDCCreateServicePage.addAssetToCanvas(vfName);
- SDCCreateServicePage.checkInService();
-
- // ------------------ DCAE-Side: Create Asset -------------------
-
- DCAEHomePage.clickOnDcaeTab();
- DCAEHomePage.clickOnCreateNewAsset();
-
- String assetName = DCAEGeneralPage.addAssetName("Asset Name");
- DCAEGeneralPage.addAssetDescription("Asset Description");
- DCAEGeneralPage.clickSaveAsset();
-
- DCAELeftPanel.navigateToServices();
-
- DCAEServicesPage.selectService(serviceName);
- DCAEServicesPage.selectVNFI(vfName);
- DCAEServicesPage.clickAttach(vfName);
-
- DCAELeftPanel.navigateToComposition();
-
- WebElement item = DCAECompositionPage.expandList("Microservice");
- DCAECompositionPage.addItemFromList(item);
- DCAECompositionPage.SelectFlowType("Syslog");
- DCAECompositionPage.clickSave();
- DCAECompositionPage.clickSubmit();
-
- //------------------ Verify Blue Print
-
- SDCHomePage.clickOnHomeTab();
- SDCHomePage.searchForElement(serviceName);
- SDCHomePage.clickOnElement(serviceName);
- try
- {
- SDCCreateServicePage.clickOnServiceCompsitionTab();
- }
- catch(Exception e)
- {
- GeneralUIUtils.getDriver().navigate().refresh();
- SDCCreateServicePage.clickOnServiceCompsitionTab();
- ExtentTestActions.log(Status.WARNING,"SDC UI known Bug - Blank page with text: {{getStatus()}}, the browser was refreshed to bypass this bug.");
- }
-
- SDCCreateServicePage.clickOnElementInCanavs();
- SDCCreateServicePage.clickOnArtifactTab();
- ServiceVerificator.verifyBluePrintArtifactExist(assetName);
-
- ExtentTestActions.log(Status.INFO, "Test Ended.");
-
- System.out.println("End Test");
- }
-
-}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/SanityTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/SanityTest.java deleted file mode 100644 index a13a12e..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/SanityTest.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.tests; - -import org.openecomp.d2.ci.datatypes.Configuration; -import org.openecomp.d2.ci.datatypes.UserCredentials; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openqa.selenium.WebElement; -import org.testng.annotations.Test; -import com.att.ecomp.dcae.ci.ui.pages.DCAECompositionPage; -import com.att.ecomp.dcae.ci.ui.pages.DCAEGeneralPage; -import com.att.ecomp.dcae.ci.ui.pages.DCAEHomePage; -import com.att.ecomp.dcae.ci.ui.pages.DCAELeftPanel; -import com.att.ecomp.dcae.ci.ui.pages.DCAEServicesPage; -import com.att.ecomp.dcae.ci.ui.pages.SDCCreateServicePage; -import com.att.ecomp.dcae.ci.ui.pages.SDCCreateVFPage; -import com.att.ecomp.dcae.ci.ui.pages.SDCHomePage; -import com.att.ecomp.dcae.ci.ui.setup.ConfigTest; - -public class SanityTest extends ConfigTest{ - - - public Configuration configuration = ConfigTest.getConfiguration(); - - - @Override - protected UserRoleEnum getUserRole() { - return UserRoleEnum.DESIGNER; - } - - - // Only when running locally - @Override - public void navigateAndLogin(UserCredentials userCredentials) throws Exception { - - navigateToUrl(configuration.getUrl()); - } - - - @Test (description = "DCAE Main scenario", groups={"Sanity"}) - public void sanityTestDCAESection() throws InterruptedException{ - - //HomePage.clickOnDcaeTab(); // not needed on local - - - - - - - - ////------TO DELETE - String vfName; - String serviceName; - - // ------------------ SDC-Side: Create VF -------------------------- - - System.out.println("Start Test"); - - SDCCreateServicePage.clickOnElementInCanavs(); - - SDCHomePage.clickOnAddVf(); - vfName = SDCCreateVFPage.addAllVFMandtoryFields("Microservice"); //Creates VF, need to send only the desired category name - SDCCreateVFPage.clickOnCreateVFButton(); - SDCCreateVFPage.checkInVF(); - - // ------------------ SDC-Side: Create Service --------------------- - SDCHomePage.clickOnAddsService(); - serviceName = SDCCreateServicePage.addAllServiceMandtoryFields("Network L1-3"); - SDCCreateServicePage.clickOnCreateServiceButton(); - SDCCreateServicePage.clickOnServiceCompsitionTab(); - SDCCreateServicePage.addAssetToCanvas(vfName); - SDCCreateServicePage.checkInService(); - - - ////------TO DELETE - - - - - - - - - - - System.out.println("Start Test"); - - DCAEHomePage.clickOnCreateNewAsset(); - - DCAEGeneralPage.addAssetName("Asset Name"); - DCAEGeneralPage.addAssetDescription("Asset Description"); -// DCAEGeneralPage.clickSaveAsset(); - - DCAELeftPanel.navigateToServices(); - - DCAEServicesPage.selectService("Servicedbb463a1-50bb-4aef-b84c-8c2bb9a8f866"); - DCAEServicesPage.selectVNFI("VF30ca7676-35c5-4c3c-9cc8-a06c23b17872"); - DCAEServicesPage.clickAttach("VF30ca7676-35c5-4c3c-9cc8-a06c23b17872"); - - DCAELeftPanel.navigateToComposition(); - - WebElement item = DCAECompositionPage.expandList("Microservice"); - DCAECompositionPage.addItemFromList(item); - DCAECompositionPage.clickSave(); - DCAECompositionPage.clickSubmit(); - - System.out.println("End Test"); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/ServiceTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/ServiceTest.java deleted file mode 100644 index bc99033..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/ServiceTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.tests; - -import java.util.UUID; - -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; -import org.openqa.selenium.WebElement; -import org.testng.annotations.Test; - -import com.att.ecomp.dcae.ci.ui.pages.DCAEHomePage; -import com.att.ecomp.dcae.ci.ui.setup.ConfigTest; - -public class ServiceTest extends ConfigTest { - - @Override - protected UserRoleEnum getUserRole() { - return UserRoleEnum.DESIGNER; - } - - @Test - public void createServiceTest(){ - DCAEHomePage.clickOnDcaeTab(); - - GeneralUIUtils.hoverOnAreaByTestId("AddButtonsArea"); - GeneralUIUtils.findByText("Add Service Assurance Template").click(); - GeneralUIUtils.ultimateWait(); - - WebElement nameTextbox = GeneralUIUtils.getWebElementByTestID("name"); - nameTextbox.clear(); - nameTextbox.sendKeys("autoServicer" + UUID.randomUUID()); - - WebElement descriptionTextbox = GeneralUIUtils.getWebElementByTestID("description"); - descriptionTextbox.clear(); - descriptionTextbox.sendKeys("new service"); - - GeneralUIUtils.findByText("Create").click(); - GeneralUIUtils.ultimateWait(); - } - - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/CompositionVerificator.java b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/CompositionVerificator.java deleted file mode 100644 index 59faa2a..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/CompositionVerificator.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.tests.verificator; - -import static org.testng.Assert.assertTrue; - -public class CompositionVerificator { - - public static void verifySaveSuccessfully(String actualSaveRes) - { - assertTrue(actualSaveRes.startsWith("Composition Created")); - } - - public static void verifySubmitSuccessfully(String actualSubmitRes) { - assertTrue(actualSubmitRes.equalsIgnoreCase("Blueprint Created")); - - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/ServiceVerificator.java b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/ServiceVerificator.java deleted file mode 100644 index 99957cf..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/ServiceVerificator.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.tests.verificator;
-
-import org.openecomp.d2.ci.report.ExtentTestActions;
-import org.openecomp.d2.ci.utilities.GeneralUIUtils;
-
-import com.aventstack.extentreports.Status;
-
-import static org.testng.Assert.assertTrue;
-
-public class ServiceVerificator
-{
- public static void verifyBluePrintArtifactExist(String name)
- {
- ExtentTestActions.log(Status.INFO,"Verifying Blue Print artifact exist");
- String artifactName = "Foi" + "." + name.replaceAll("\\s+","").replaceAll("-", "") + ".event_proc_bp.yaml";
- GeneralUIUtils.waitForElementInVisibilityByTestId("artifactName-blueprint-foi");
- String actualBluePrintFileName = GeneralUIUtils.getWebElementByTestID("artifactName-blueprint-foi").getText();
- assertTrue(artifactName.equalsIgnoreCase(actualBluePrintFileName));
- ExtentTestActions.log(Status.INFO, String.format("Actual Blue print file name is: %s.", actualBluePrintFileName));
- GeneralUIUtils.ultimateWait();
- }
-}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/ByTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/utils/ByTest.java deleted file mode 100644 index ab59b28..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/ByTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.utils; - -import org.openqa.selenium.By.ByCssSelector; - -public class ByTest extends ByCssSelector { - - private static final long serialVersionUID = 7435597710732625685L; // auto generated - does nothing - - protected ByTest(String cssSelector) { - super(cssSelector); - } - - public static ByTest id(String id) { - return new ByTest(String.format("[data-tests-id=\"%s\"]", id)); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/Locator.java b/src/main/java/com/att/ecomp/dcae/ci/ui/utils/Locator.java deleted file mode 100644 index 7e625d5..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/Locator.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.utils; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; - -public class Locator { - - private WebElement element; - - private Locator(WebElement element) { - this.element = element; - } - - public static Locator from(WebElement element) { - return new Locator(element); - } - - public ExpectedCondition<WebElement> find(By by, int index) { - return new NestedFinder(this.element, by) { - @Override - protected WebElement predicate(List<WebElement> elements) { - return (elements.size() > index) ? elements.get(index) : null; - } - - @Override - public String toString() { - return "element located by " + by; - } - }; - } - - public ExpectedCondition<WebElement> findVisible(By by, int index) { - return new NestedFinder(this.element, by) { - @Override - protected WebElement predicate(List<WebElement> elements) { - return visibleElementsOrNull(elements, index); - } - - @Override - public String toString() { - return "visibility of element located by " + by; - } - }; - } - - public ExpectedCondition<List<WebElement>> findNoVisible(By by) { - return new NestedFilter(this.element, by) { - @Override - protected List<WebElement> predicate(List<WebElement> elements) { - WebElement visible = visibleElementsOrNull(elements, 0); - return (visible != null) ? null : new ArrayList<WebElement>(); - } - - @Override - public String toString() { - return "no visible elements located by " + by; - } - }; - } - - private static WebElement visibleElementsOrNull(List<WebElement> elements, int index) { - List<WebElement> visibles = elements.stream() - .filter(elem -> elem.isDisplayed()) - .collect(Collectors.toList()); - return (visibles.size() > index) ? visibles.get(index) : null; - } - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFilter.java b/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFilter.java deleted file mode 100644 index 925fea5..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFilter.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.utils; - -import java.util.List; - -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; - -public abstract class NestedFilter implements ExpectedCondition<List<WebElement>> { - - private WebElement parent; - private By by; - - public NestedFilter(WebElement parent, By by) { - this.parent = parent; - this.by = by; - } - - abstract protected List<WebElement> predicate(List<WebElement> elements); - - @Override - public List<WebElement> apply(WebDriver input) { - List<WebElement> elements = parent.findElements(by); - return predicate(elements); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFinder.java b/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFinder.java deleted file mode 100644 index ead2bef..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFinder.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.utils; - -import java.util.List; - -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; - -public abstract class NestedFinder implements ExpectedCondition<WebElement> { - - private WebElement parent; - private By by; - - public NestedFinder(WebElement parent, By by) { - this.parent = parent; - this.by = by; - } - - abstract protected WebElement predicate(List<WebElement> elements); - - @Override - public WebElement apply(WebDriver input) { - List<WebElement> elements = parent.findElements(by); - return predicate(elements); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeUtil.java b/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeUtil.java deleted file mode 100644 index 9999b3d..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeUtil.java +++ /dev/null @@ -1,200 +0,0 @@ -package com.att.ecomp.dcae.ci.utilities; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import com.google.gson.*; -import org.apache.commons.lang3.RandomStringUtils; - -import org.json.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.ParseException; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.testng.Assert; - -import com.att.ecomp.dcae.ci.entities.composition.items.DcaeComponents; -import org.onap.sdc.dcae.composition.services.Resource; -import org.onap.sdc.dcae.composition.services.Service; -import org.onap.sdc.dcae.composition.services.ThinService; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.aventstack.extentreports.Status; - - -public class DcaeUtil { - public static Gson gson = new Gson(); - - public static class CatalogReources { - public static Vfcmt[] getAllReourcesFromAsdc() throws IOException{ - RestResponse allResources = DcaeRestClient.getAllVfcmts(); - return gson.fromJson(allResources.getResponse(), Vfcmt[].class); - } - - public static Vfcmt getResourceByName(String resName) throws IOException{ - Vfcmt[] vfcmts = getAllReourcesFromAsdc(); - List<Vfcmt> vfcmtsStr = Arrays.stream(vfcmts). - filter(item -> item.getName().equals(resName)). - collect(Collectors.toList()); - - return vfcmtsStr.get(0); - } - - public static Vfcmt getOneResourceFromList(int index) throws IOException{ - Vfcmt[] vfcmtList = getAllReourcesFromAsdc(); - return vfcmtList[index]; - } - - public static String getComponentID(int index) throws IOException{ - Vfcmt vfcmt = getOneResourceFromList(0); - return vfcmt.getUuid(); - } - - public static Resource createNewVfcmtObject() throws IOException{ - Resource res = new Resource(); - res.setResourceInstanceName("LiavNewVFCMT" + RandomStringUtils.randomAlphanumeric(20)); - res.setDescription("This is a test VFCMT"); - return res; - } - - public static Vfcmt notCheckoutVFCMT() throws IOException{ /* TODO: remove this function and use instead in DcaeEntityClient.getCheckedoutVfcmt() */ - Vfcmt[] vfcmtList = getAllReourcesFromAsdc(); - List<Vfcmt> vfcmtsStr = Arrays.stream(vfcmtList). - filter(item -> (item.getLifecycleState().equals(DcaeTestConstants.Sdc.State.NOT_CERTIFIED_CHECKOUT) == false)). - collect(Collectors.toList()); - - return vfcmtsStr.get(0); - } - - public static Vfcmt vfcmtNotUserOwner(String user) throws IOException{ - Vfcmt[] vfcmtList = getAllReourcesFromAsdc(); - List<Vfcmt> vfcmtsStr = Arrays.stream(vfcmtList) - .filter(item -> (item.getLastUpdaterUserId().equals(user) == false)) - .collect(Collectors.toList()); - - return vfcmtsStr.get(0); - } - - } - - public static class Services{ - public static ThinService[] getServices(String VFCMTId, String userId) throws IOException{ - RestResponse services = null; - try{ - services = DcaeRestClient.getServices(VFCMTId, userId); - }catch(Exception e){ - System.err.println("Exception occurred while trying to fetch all resources from SDC: "+e); - return null; - } - Assert.assertTrue(services.getStatusCode().intValue() == 200); - String response = services.getResponse(); - ThinService[] serviceList = gson.fromJson(response, ThinService[].class); - return serviceList.length > 0 ? serviceList : null; - } - - public static ThinService getOneService(String VFCMTId,int index, String userId) throws IOException { - ThinService[] services = getServices(VFCMTId, userId); - return services[index]; - } - - - public static List<Resource> getVfListInstance(ThinService thinService) throws IOException { - RestResponse serviceInstancRes = null; - try{ - serviceInstancRes = DcaeRestClient.getServicesInstance(thinService.getUuid()); - }catch(Exception e){ - System.err.println("Exception occurred while trying to fetch List of VF instances from SDC service ("+thinService+"). Exception: "+e); - return null; - } - Assert.assertTrue(serviceInstancRes.getStatusCode().intValue() == 200); - String serviceInstancList = serviceInstancRes.getResponse(); - Service service = gson.fromJson(serviceInstancList, Service.class); - return service.getResources(); - } - - public static Resource getOneVfInstance(ThinService thinService,int index) throws IOException { - List<Resource> resources = getVfListInstance(thinService); - return resources.get(index); - } - - } - - - public static class SdcElementsModelType{ - public static RestResponse getMsElements() throws IOException{ - return DcaeRestClient.getItem(DcaeTestConstants.Composition.Microservice); - } - - - - public static JsonArray getSNMPModelItemFromSdc() throws Exception{ - RestResponse resMsElements = getMsElements(); - JsonParser jsonParser = new JsonParser(); - JsonObject responseJson = (JsonObject)jsonParser.parse(resMsElements.getResponse()); - JsonArray itemJsonArray = responseJson.get("data").getAsJsonObject().get("element").getAsJsonObject().get("items").getAsJsonArray(); - Report.logDebug("DCAE Components items", itemJsonArray); - Service[] services = gson.fromJson(itemJsonArray, Service[].class); - Report.log(Status.DEBUG, "Trying to find a certified VF which its name starts with supplement/map/enrich"); - List<String> collectIds = Arrays.stream(services) - .filter(x -> x.getLifecycleState().equals("CERTIFIED") && x.getModels().size() > 0 && (x.getName().startsWith("supplement") || x.getName().startsWith("map") || x.getName().startsWith("enrich"))) - .map(Service::getUuid) - .collect(Collectors.toList()); - if(collectIds==null || collectIds.size()==0){ - Report.log(Status.ERROR, "Could find any SNMP DCAE Component"); - } - JsonArray models = new JsonArray(); - for (String id : collectIds) { - RestResponse res = DcaeRestClient.getItemModel(id); - models.addAll(parseNodesFromDcaeModelAndAssignUiNid(res.getResponse())); - } - - return models; - } - - public static RestResponse getItemModelFromSdc(int itemNumber) throws IOException{ - String uuid = getItemUuid(itemNumber); - return DcaeRestClient.getItemModel(uuid); - } - - public static String getItemUuid(int itemNumber) throws IOException{ - DcaeComponents dcaeComponents = getDcaeComponents(); - return dcaeComponents.getData().getElement().getItems().get(itemNumber).getUuid(); - } - - public static DcaeComponents getDcaeComponents() throws IOException{ - RestResponse services = getMsElements(); - String response = services.getResponse(); - return gson.fromJson(response, DcaeComponents.class); - } - } - - public static JsonArray parseNodesFromDcaeModelAndAssignUiNid(String response) throws ParseException { - JsonParser parser = new JsonParser(); - JsonObject data = parser.parse(response).getAsJsonObject().get("data").getAsJsonObject(); - JsonObject model = data.get("model").getAsJsonObject(); - JsonArray nodes = model.get("nodes").getAsJsonArray(); - nodes.forEach((n) -> - n.getAsJsonObject().add("nid", n.getAsJsonObject().get("name")) - ); - Report.logDebug("nodes after adding ui nid", nodes); - return nodes; - } - - public static String generateCdumpFromSnmpModels(String vfcmtId) throws Exception { - JsonArray snmpModelItemFromSdc = SdcElementsModelType.getSNMPModelItemFromSdc(); - JsonObject cdump = DcaeRestClient.generateCdumpInput(vfcmtId); - cdump.add("nodes", snmpModelItemFromSdc); - Report.logDebug("cdump", cdump); - return cdump.toString(); - } - - - - /* private JSONObject getServiceInstance(JSONObject service) throws IOException { - RestResponse serviceInstancRes = DcaeRestClient.getServicesInstance(service.get("uuid").toString()); - Assert.assertTrue(serviceInstancRes.getStatusCode().intValue() == 200); - String serviceInstancList = serviceInstancRes.getResponse(); - return (JSONObject) JSONValue.parse(serviceInstancList); -}*/ - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/utilities/Report.java b/src/main/java/com/att/ecomp/dcae/ci/utilities/Report.java deleted file mode 100644 index f2fe6fb..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/utilities/Report.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.att.ecomp.dcae.ci.utilities; - -import org.openecomp.d2.ci.report.ExtentTestActions; - -import com.aventstack.extentreports.Status; - -public class Report { - - public static void log(Status status, String format, Object... args) { - ExtentTestActions.log(status, String.format(format, args)); - } - - public static void logDebug(String message, Object obj) { - log(Status.DEBUG, "%s %s", message, wrapWithTextareaRO(obj.toString())); - } - - public static void fatal(String message, Exception err) { - log(Status.FATAL, "%s %s", message, wrapWithTextareaRO(err.toString())); - } - - /* Private members */ - - private static String wrapWithTextareaRO(String str) { - return String.format("<textarea readonly style=\"height:100px\">%s</textarea>", str); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/utilities/SdcInternalApiClient.java b/src/main/java/com/att/ecomp/dcae/ci/utilities/SdcInternalApiClient.java deleted file mode 100644 index 4adade1..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/utilities/SdcInternalApiClient.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.att.ecomp.dcae.ci.utilities; - -import com.att.ecomp.dcae.ci.entities.composition.services.Vfi; -import com.att.ecomp.dcae.ci.entities.sdc.SdcComponent; -import com.att.ecomp.dcae.ci.entities.sdc.SdcComponentMetadata; -import com.att.ecomp.dcae.ci.ui.setup.DcaeConfiguration; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.reflect.TypeToken; -import org.openecomp.d2.ci.api.BaseRestUtils; -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.api.ServiceRestUtils; -import org.openecomp.d2.ci.api.VfRestUtils; -import org.openecomp.d2.ci.datatypes.*; -import org.openecomp.d2.ci.datatypes.http.RestResponse; - -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class SdcInternalApiClient extends BaseRestUtils { - - private static Gson gson = (new GsonBuilder()).create(); - private static User defaultUser = DcaeRestClient.getDefaultUser(); - - /** - * - * @return - * @throws Exception - */ - public static ServiceReqDetails createService() throws Exception { - ServiceReqDetails defaultService = ElementFactory.getDefaultService(); - RestResponse response = ServiceRestUtils.createService(defaultService, defaultUser); - Report.logDebug("Response:", response); - if (response.getStatusCode() != 201) { - throw new Exception("Unable to create service.\nResponse: " + response.toString()); - } - return gson.fromJson(response.getResponse(), ServiceReqDetails.class); - } - - /** - * - * @return - * @throws Exception - */ - public static ResourceReqDetails createVf() throws Exception { - ResourceReqDetails defaultVf = ElementFactory.getDefaultResource(ResourceTypeEnum.VF); - RestResponse response = VfRestUtils.createResource(defaultVf, defaultUser); - Report.logDebug("Response:", response); - if (response.getStatusCode() != 201) { - throw new Exception("Unable to create vf.\nResponse: " + response.toString()); - } - return gson.fromJson(response.getResponse(), ResourceReqDetails.class); - } - - /** - * - * @param vf - * @return - * @throws Exception - */ - public static ResourceReqDetails checkinVf(ResourceReqDetails vf) throws Exception { - RestResponse response = VfRestUtils.changeResourceState(vf, defaultUser, LifeCycleStatesEnum.CHECKIN); - Report.logDebug("Response:", response); - if (response.getStatusCode() != 200) { - throw new Exception("Unable to checkin vf.\nResponse: " + response.toString()); - } - return gson.fromJson(response.getResponse(), ResourceReqDetails.class); - } - - /** - * - * @param service - * @param vf - * @return - * @throws Exception - */ - public static Vfi createVfi(ServiceReqDetails service, ResourceReqDetails vf) throws Exception { - RestResponse response = ServiceRestUtils.createComponentInstance(service, vf, defaultUser, ComponentTypeEnum.RESOURCE, true); - Report.logDebug("Response:", response); - if (response.getStatusCode() != 201) { - throw new Exception("Unable to create vfi.\nResponse: " + response.toString()); - } - try { - JsonObject resBody = new JsonParser().parse(response.getResponse()).getAsJsonObject(); - String vfiName = resBody.get("name").getAsString(); - return new Vfi(vfiName, service); - } catch (Exception err) { - throw new Exception(String.format("Unable to parse vfi name\nResponse: %s\n", response), err); - } - } - - // DELETE - Clean up // - - public static RestResponse deleteAssetFromSdc(String context, String uniqueId) throws IOException { - DcaeConfiguration configuration = ConfigurationReader.getConfiguration(); - String url = String.format("%s:%s/sdc2/rest/v1/catalog/%s/%s", configuration.getBeHost(), configuration.getBePort(), context, uniqueId); - return sendDelete(url, ElementFactory.getDefaultUser(UserRoleEnum.ADMIN).getUserId()); - } - - public static RestResponse deleteMarkedResources() throws IOException { - DcaeConfiguration configuration = ConfigurationReader.getConfiguration(); - String url = String.format("%s:%s/sdc2/rest/v1/inactiveComponents/resource", configuration.getBeHost(), configuration.getBePort()); - return sendDelete(url, ElementFactory.getDefaultUser(UserRoleEnum.ADMIN).getUserId()); - } - - public static RestResponse deleteMarkedServices() throws IOException { - DcaeConfiguration configuration = ConfigurationReader.getConfiguration(); - String url = String.format("%s:%s/sdc2/rest/v1/inactiveComponents/service", configuration.getBeHost(), configuration.getBePort()); - return sendDelete(url, ElementFactory.getDefaultUser(UserRoleEnum.ADMIN).getUserId()); - } - - public static Map<String, List<SdcComponent>> getAssetsByUser(String userId) throws IOException { - DcaeConfiguration configuration = ConfigurationReader.getConfiguration(); - String url = String.format("%s:%s/sdc2/rest/v1/followed", configuration.getBeHost(), configuration.getBePort()); - RestResponse restResponse = sendGet(url, userId); - return 200 == restResponse.getStatusCode() ? gson.fromJson(restResponse.getResponse(), new TypeToken<Map<String, List<SdcComponent>>>(){}.getType()) : new HashMap<>(); - } - - - public static SdcComponentMetadata getAssetMetadata(String context, String uniqueId, String userId) throws IOException { - DcaeConfiguration configuration = ConfigurationReader.getConfiguration(); - String url = String.format("%s:%s/sdc2/rest/v1/catalog/%s/%s/filteredDataByParams?include=metadata", configuration.getBeHost(), configuration.getBePort(), context, uniqueId); - RestResponse restResponse = sendGet(url, userId); - return gson.fromJson(restResponse.getResponse(), SdcComponentMetadata.class); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/healthcheck/HealthcheckTest.java b/src/main/java/org/onap/dcae/ci/api/healthcheck/HealthcheckTest.java index 6a3755a..cce54bf 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/healthcheck/HealthcheckTest.java +++ b/src/main/java/org/onap/dcae/ci/api/healthcheck/HealthcheckTest.java @@ -1,23 +1,20 @@ -package com.att.ecomp.dcae.ci.api.healthcheck; - -import static org.assertj.core.api.Assertions.*; -import org.testng.annotations.*; - -import java.io.IOException; -import java.util.List; +package org.onap.dcae.ci.api.healthcheck; +import com.aventstack.extentreports.Status; import org.assertj.core.api.SoftAssertions; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; -import org.openecomp.d2.ci.datatypes.http.RestResponse; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; import org.onap.sdc.dcae.composition.restmodels.health.ComponentsInfo; import org.onap.sdc.dcae.composition.restmodels.health.HealthResponse; + import org.testng.annotations.Test; -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; +import java.io.IOException; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; public class HealthcheckTest extends DcaeRestBaseTest { diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/DcaeRestBaseTest.java b/src/main/java/org/onap/dcae/ci/api/tests/DcaeRestBaseTest.java index 2dd0646..6bd8b51 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/DcaeRestBaseTest.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/DcaeRestBaseTest.java @@ -1,14 +1,18 @@ -package com.att.ecomp.dcae.ci.api.tests; - -import com.att.ecomp.dcae.ci.entities.composition.services.CiService; -import com.att.ecomp.dcae.ci.entities.sdc.SdcComponent; -import com.att.ecomp.dcae.ci.utilities.*; -import org.openecomp.d2.ci.datatypes.Configuration; -import org.openecomp.d2.ci.setup.SetupReport; +package org.onap.dcae.ci.api.tests; import com.aventstack.extentreports.Status; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import org.apache.commons.lang3.RandomStringUtils; +import org.onap.dcae.ci.config.Configuration; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.entities.composition.services.CiService; +import org.onap.dcae.ci.entities.composition.services.Vfi; +import org.onap.dcae.ci.entities.sdc.SdcComponent; +import org.onap.dcae.ci.entities.sdc.SdcResource; +import org.onap.dcae.ci.entities.sdc.SdcService; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.*; import org.onap.sdc.dcae.composition.model.Requirement; import org.onap.sdc.dcae.composition.model.Value; import org.onap.sdc.dcae.composition.model.deserializer.RequirementDeserializer; @@ -21,14 +25,6 @@ import org.onap.sdc.dcae.composition.services.Artifact; import org.onap.sdc.dcae.composition.services.Resource; import org.onap.sdc.dcae.composition.services.Service; import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.api.ResponseParser; -import org.openecomp.d2.ci.api.ServiceRestUtils; -import org.openecomp.d2.ci.api.VfRestUtils; -import org.openecomp.d2.ci.datatypes.*; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openecomp.d2.ci.utilities.GeneralUtility; import org.testng.annotations.AfterSuite; import java.io.IOException; @@ -38,8 +34,6 @@ import java.util.stream.Collectors; import static org.assertj.core.api.Assertions.assertThat; -import java.util.Collections; - public class DcaeRestBaseTest extends SetupReport { @@ -61,44 +55,20 @@ public class DcaeRestBaseTest extends SetupReport { return ConfigurationReader.getConfiguration(); } - protected Service createServiceWithVFiAsSdcDesigner() throws Exception{ - ExtentTestActions.log(Status.INFO, "Create Service with VFi as SDC Designer method started"); - ServiceReqDetails defaultService = ElementFactory.getDefaultService(); - - ExtentTestActions.log(Status.INFO, "Going to create service with name " + defaultService.getName()); - ResourceReqDetails vf = ElementFactory.getDefaultResource(ResourceTypeEnum.VF); - - User defaultUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - - RestResponse createServiceRes = ServiceRestUtils.createService(defaultService, defaultUser); - Status logSts = checkForErrors(createServiceRes); - ExtentTestActions.log(logSts, "Service with uuid " + defaultService.getUUID() +" created"); - - RestResponse createResourceRes = VfRestUtils.createResource(vf, defaultUser); - logSts = checkForErrors(createResourceRes); - ExtentTestActions.log(logSts, "VF with uuid " + vf.getUUID() +" created"); - - RestResponse changeResourceStateRes = VfRestUtils.changeResourceState(vf, defaultUser, LifeCycleStatesEnum.CHECKIN); - logSts = checkForErrors(changeResourceStateRes); - ExtentTestActions.log(logSts, "VF with uuid " + vf.getUUID() + " was checked in"); - - RestResponse createVfiRes = ServiceRestUtils.createComponentInstance(defaultService, vf, defaultUser, ComponentTypeEnum.RESOURCE, true); - logSts = checkForErrors(createVfiRes); - ExtentTestActions.log(logSts, "VF instance added to service"); - - String vfiName = ResponseParser.getValueFromJsonResponse(createVfiRes.getResponse(), "name"); - return convertToDcaeServiceWithVfi(defaultService, vfiName); + protected Service createServiceWithVFiAsSdcDesigner() throws IOException { + Report.log(Status.INFO, "Create Service with VFi as SDC Designer method started"); - } + SdcResource vf = SdcInternalApiClient.createVf(); + vf = SdcInternalApiClient.checkinVf(vf); + SdcService service = SdcInternalApiClient.createService(); + Vfi vfi = SdcInternalApiClient.createVfi(service, vf); + return convertToDcaeServiceWithVfi(service, vfi.getName()); - private Status checkForErrors(RestResponse httpResponse) { - Status logSts = httpResponse.getStatusCode()==200 || httpResponse.getStatusCode()==201 ? Status.INFO : Status.ERROR; - assertThat(httpResponse.getStatusCode()).isIn(200, 201); - return logSts; } + // converts from ui-api-ci object to dcae-ci object (partial construction) - private Service convertToDcaeServiceWithVfi(ServiceReqDetails service, String vfiName){ + private Service convertToDcaeServiceWithVfi(SdcService service, String vfiName){ Service newService = new CiService(service); Resource newVfi = new Resource(); newVfi.setResourceInstanceName(vfiName); @@ -107,7 +77,7 @@ public class DcaeRestBaseTest extends SetupReport { } protected Vfcmt createVfcmt() throws IOException { - String newName = "CI" + GeneralUtility.generateUUIDforSufix(); + String newName = "CI" + RandomStringUtils.randomAlphanumeric(4); Report.log(Status.INFO, "createVfcmt start"); RestResponse res = DcaeRestClient.createVfcmt(newName, "description"); Report.log(Status.INFO, "createVfcmt response=%s", res); @@ -132,7 +102,7 @@ public class DcaeRestBaseTest extends SetupReport { final String resources = "resources"; final String services = "services"; - List<String> testUsers = Collections.synchronizedList(Arrays.asList(UserRoleEnum.DESIGNER.getUserId(), UserRoleEnum.DESIGNER2.getUserId())); + List<String> testUsers = Collections.synchronizedList(Arrays.asList(DcaeRestClient.getDefaultUserId(), DcaeRestClient.getDesigner2UserId())); Map<String, List<SdcComponent>> testComponents = testUsers.parallelStream() .map(DcaeRestBaseTest::getSafeComponentByUser) .flatMap(m -> m.entrySet().stream()) diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/blueprint/SaveCompositionPositve.java b/src/main/java/org/onap/dcae/ci/api/tests/blueprint/SaveCompositionPositve.java index 17dcce8..b5f37f8 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/blueprint/SaveCompositionPositve.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/blueprint/SaveCompositionPositve.java @@ -1,21 +1,20 @@ -package com.att.ecomp.dcae.ci.api.tests.blueprint; +package org.onap.dcae.ci.api.tests.blueprint; -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.DcaeUtil; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.att.ecomp.dcae.ci.utilities.StringUtils; import com.aventstack.extentreports.Status; import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.text.WordUtils; import org.assertj.core.api.SoftAssertions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.utilities.DcaeUtil; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; import org.onap.sdc.dcae.composition.restmodels.sdc.Resource; import org.onap.sdc.dcae.composition.services.Service; import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.testng.annotations.Test; +import org.testng.annotations.Test; import static org.assertj.core.api.Assertions.assertThat; public class SaveCompositionPositve extends DcaeRestBaseTest { @@ -66,13 +65,13 @@ public class SaveCompositionPositve extends DcaeRestBaseTest { @Test public void test_responseStatusOkAndCreateMode() throws Exception{ // assert - ExtentTestActions.log(Status.INFO, "Save Composition init"); + Report.log(Status.INFO, "Save Composition init"); Vfcmt vfcmtWithoutArtifactUuid = createNewVfcmtWithoutArtifact(); String uuid = vfcmtWithoutArtifactUuid.getUuid(); String lastUpdaterUserId = vfcmtWithoutArtifactUuid.getLastUpdaterUserId(); response = DcaeRestClient.saveComposition(uuid, lastUpdaterUserId); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - ExtentTestActions.log(Status.INFO, "Verifing response status is 200"); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.INFO, "Verifing response status is 200"); SoftAssertions.assertSoftly(softly -> { softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); softly.assertThat((gson.fromJson(response.getResponse(), Resource.class)).getVersion()) @@ -84,20 +83,20 @@ public class SaveCompositionPositve extends DcaeRestBaseTest { @Test public void test_updateMode() throws Exception { // assert - ExtentTestActions.log(Status.INFO, "Save Composition init"); + Report.log(Status.INFO, "Save Composition init"); Vfcmt vfcmtWithArtifactUuid = createVFCMTAndServiceWithVFIAndAttach(); String uuid = vfcmtWithArtifactUuid.getUuid(); String lastUpdaterUserId = vfcmtWithArtifactUuid.getLastUpdaterUserId(); - ExtentTestActions.log(Status.INFO, "New VFCMT uuid="+uuid+", lastUpdaterUserId="+lastUpdaterUserId); + Report.log(Status.INFO, "New VFCMT uuid="+uuid+", lastUpdaterUserId="+lastUpdaterUserId); //generate cdump String cdump = DcaeUtil.generateCdumpFromSnmpModels(uuid); // save composition.yml - ExtentTestActions.log(Status.INFO, "Going to Save the composition now"); + Report.log(Status.INFO, "Going to Save the composition now"); DcaeRestClient.saveComposition(uuid, lastUpdaterUserId, cdump); // update response = DcaeRestClient.saveComposition(uuid, lastUpdaterUserId, cdump); - ExtentTestActions.log(Status.DEBUG, "Save composition Response: " + StringUtils.truncate(response)); - ExtentTestActions.log(Status.INFO, "Verifying response status is 200"); + Report.log(Status.DEBUG, "Save composition Response: " + StringUtils.truncate(response)); + Report.log(Status.INFO, "Verifying response status is 200"); SoftAssertions.assertSoftly(softly -> { softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); softly.assertThat((gson.fromJson(response.getResponse(), Resource.class)).getVersion()) diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionControllerApiTests.java b/src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionControllerApiTests.java index 9f8833b..a6e1525 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionControllerApiTests.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionControllerApiTests.java @@ -1,32 +1,31 @@ -package com.att.ecomp.dcae.ci.api.tests.composition; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.function.Predicate; -import java.util.stream.Collectors; +package org.onap.dcae.ci.api.tests.composition; +import com.aventstack.extentreports.Status; +import com.google.gson.JsonObject; import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.text.WordUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.json.simple.parser.ParseException; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.utilities.DcaeUtil; +import org.onap.dcae.ci.report.Report; import org.onap.sdc.dcae.composition.services.Artifact; -import org.onap.sdc.dcae.composition.util.DcaeBeConstants; -import org.openecomp.d2.ci.api.ResponseParser; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.testng.annotations.Test; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; import org.onap.sdc.dcae.composition.services.Resource; import org.onap.sdc.dcae.composition.services.Service; +import org.onap.sdc.dcae.composition.util.DcaeBeConstants; import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.DcaeUtil; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; -import com.google.gson.JsonObject; + +import org.testng.annotations.Test; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; public class CompositionControllerApiTests extends DcaeRestBaseTest { @@ -134,7 +133,7 @@ public class CompositionControllerApiTests extends DcaeRestBaseTest { private void assertBlueprintSuccessResponse(RestResponse response){ assertThat(response.getStatusCode()).isEqualTo(200); - assertThat(ResponseParser.getValueFromJsonResponse(response.getResponse(), "successResponse")).isNotNull(); + assertThat(DcaeUtil.getValueFromJsonResponse(response.getResponse(), "successResponse")).isNotNull(); } private void assertBlueprintsExistOnVfiAfterUpload(List<ImmutablePair<String, String>> expectedBpDetails, String serviceId, String vfiName) throws IOException{ @@ -172,7 +171,7 @@ public class CompositionControllerApiTests extends DcaeRestBaseTest { } private ImmutablePair<String, String> buildBlueprintDetails(String bpType, String normalizedVfcmtName) { - return new ImmutablePair<>("blueprint"+bpType.toLowerCase().replaceAll(" ", ""),bpType.replaceAll(" ", "-")+"."+normalizedVfcmtName+"."+EVENT_PROC_BP_YAML); + return new ImmutablePair<>("blueprint"+(bpType.replaceAll(" ", "")+normalizedVfcmtName).toLowerCase(),bpType.replaceAll(" ", "-")+"."+normalizedVfcmtName+"."+EVENT_PROC_BP_YAML); } @@ -193,11 +192,10 @@ public class CompositionControllerApiTests extends DcaeRestBaseTest { Report.log(Status.DEBUG, "Generated cdump="+cdump); cdump.add("nodes", DcaeUtil.parseNodesFromDcaeModelAndAssignUiNid(res.getResponse())); Report.log(Status.DEBUG, "save composition - generate and save composition.yml artifact"); - res = DcaeRestClient.saveComposition(vfcmtId, DcaeRestClient.getDefaultUser().getUserId(), cdump.toString()); + res = DcaeRestClient.saveComposition(vfcmtId, DcaeRestClient.getDefaultUserId(), cdump.toString()); Report.log(Status.DEBUG, "Save composition result="+res); assertThat(res.getStatusCode()).isEqualTo(200); } - } diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionElementsControllerTests.java b/src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionElementsControllerTests.java index 46a62c0..0193df1 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionElementsControllerTests.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionElementsControllerTests.java @@ -1,4 +1,4 @@ -package com.att.ecomp.dcae.ci.api.tests.composition; +package org.onap.dcae.ci.api.tests.composition; import java.io.IOException; import java.lang.reflect.Type; @@ -6,22 +6,24 @@ import java.util.List; import java.util.stream.Collectors; import org.assertj.core.api.SoftAssertions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; + +import org.onap.dcae.ci.entities.composition.rightMenu.element.Item; +import org.onap.dcae.ci.entities.composition.rightMenu.elements.Element; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; import org.onap.sdc.dcae.composition.model.Model; -import org.openecomp.d2.ci.datatypes.http.RestResponse; + import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.entities.composition.rightMenu.element.Item; -import com.att.ecomp.dcae.ci.entities.composition.rightMenu.elements.Element; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.Report; import com.aventstack.extentreports.Status; import com.google.gson.JsonElement; import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; -public class CompositionElementsControllerTests extends DcaeRestBaseTest { +public class CompositionElementsControllerTests extends DcaeRestBaseTest { JsonParser parser = new JsonParser(); @@ -175,7 +177,7 @@ public class CompositionElementsControllerTests extends DcaeRestBaseTest { private String getElementItemName(JsonElement obj) { Type listType = new TypeToken<List<Element>>(){}.getType(); List<Element> fromJson = gson.fromJson(obj, listType); - List<Element> collect = fromJson.stream().filter(x->x.getName().equals("Collector")).collect(Collectors.toList()); + List<Element> collect = fromJson.stream().filter(x->x.getName().equals("Microservice")).collect(Collectors.toList()); Element element = collect.get(0); String elementItemName = element.getName(); return elementItemName; @@ -184,14 +186,14 @@ public class CompositionElementsControllerTests extends DcaeRestBaseTest { private String getElementItemID(JsonElement data) { Type listType = new TypeToken<List<Item>>(){}.getType(); List<Item> elementsItemFoi = gson.fromJson(data, listType); - Report.log(Status.INFO, "getElementItemID for FOI collector"); - List<Item> foiItemData = elementsItemFoi.stream().filter(x->x.getName().equals("FOI")).collect(Collectors.toList()); + Report.log(Status.INFO, "getElementItemID for map"); + List<Item> foiItemData = elementsItemFoi.stream().filter(x->x.getName().equalsIgnoreCase("map")).collect(Collectors.toList()); if(foiItemData!=null && foiItemData.size()>0){ Item item = foiItemData.get(0); String elemId = item.getItemId(); return elemId; }else{ - Report.log(Status.ERROR, "getElementItemID for FOI collector failed. Does the CI environment has FOI Collector component in it??"); + Report.log(Status.ERROR, "getElementItemID for map failed. Does the CI environment has map component in it??"); return null; } } diff --git a/src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionMicroServicesApiTests.java b/src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionMicroServicesApiTests.java new file mode 100644 index 0000000..9808400 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionMicroServicesApiTests.java @@ -0,0 +1,90 @@ +package org.onap.dcae.ci.api.tests.composition; + +import static org.assertj.core.api.Assertions.*; + +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.utilities.DcaeTestConstants; +import org.onap.dcae.ci.utilities.DcaeUtil; +import org.onap.dcae.ci.report.Report; +import org.onap.sdc.dcae.composition.model.ModelDcae; +import org.testng.annotations.*; + +import java.io.IOException; + +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; + + +import com.aventstack.extentreports.Status; + + +public class CompositionMicroServicesApiTests extends DcaeRestBaseTest { + + @Test + public void getAllElementsTest() throws IOException, ParseException{ + Report.log(Status.INFO, "getAllElementsTest start"); + RestResponse services = DcaeRestClient.getElements(); + Report.log(Status.INFO, "getAllElementsTest response=%s", services); + assertThat(services.getStatusCode().intValue()).isEqualTo(200); + String response = services.getResponse(); + JSONParser parser = new JSONParser(); + JSONObject o = (JSONObject) parser.parse(response); + JSONObject ele = (JSONObject) o.get("data"); + String arrString = ele.get("elements").toString(); + assertThat(arrString) + .as("Check that elements not empty") + .isNotEmpty(); + } + + @Test + public void getMsElementsTest() throws IOException, ParseException{ + Report.log(Status.INFO, "getMsElementsTest start"); + RestResponse services = DcaeUtil.SdcElementsModelType.getMsElements(); + Report.log(Status.INFO, "getMsElementsTest response=%s", services); + assertThat(services.getStatusCode().intValue()).isEqualTo(200); + String response = services.getResponse(); + JSONParser parser = new JSONParser(); + JSONObject o = (JSONObject) parser.parse(response); + JSONObject ele = (JSONObject) o.get("data"); + String arrString = ele.get("element").toString(); + assertThat(arrString) + .as("Check that elements not empty") + .isNotEmpty(); + } + + @Test + public void getItemModelTest() throws IOException{ + Report.log(Status.INFO, "getItemModelTest start"); + RestResponse itemModelRes = DcaeUtil.SdcElementsModelType.getItemModelFromSdc(0); + Report.log(Status.INFO, "getItemModelTest response=%s", itemModelRes); + assertThat(itemModelRes.getStatusCode().intValue()).isEqualTo(200); + + String response = itemModelRes.getResponse(); + JSONObject object = (JSONObject) JSONValue.parse(response); + String errorMsg = object.get("error").toString(); + assertThat(errorMsg).isEqualTo(DcaeTestConstants.Composition.EMPTY_OBJECT); + } + + @Test + public void getItemTypeTest() throws IOException{ + Report.log(Status.INFO, "getItemModelTest start"); + RestResponse itemModelRes = DcaeUtil.SdcElementsModelType.getItemModelFromSdc(0); + Report.log(Status.INFO, "itemModelRes response=%s", itemModelRes); + String response = itemModelRes.getResponse(); + + String uuid = DcaeUtil.SdcElementsModelType.getItemUuid(0); + + ModelDcae model = gson.fromJson(response, ModelDcae.class); + Report.log(Status.INFO, "model "+model); + String type = model.getData().getModel().getNodes().get(0).getType(); + Report.log(Status.INFO, "type "+type); + + RestResponse services = DcaeRestClient.getItemType(uuid, type); + assertThat(services.getStatusCode().intValue()).isEqualTo(200); + } + +} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/GetCompositionControllerTests.java b/src/main/java/org/onap/dcae/ci/api/tests/composition/GetCompositionControllerTests.java index 3493536..169c5a8 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/GetCompositionControllerTests.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/composition/GetCompositionControllerTests.java @@ -1,4 +1,4 @@ -package com.att.ecomp.dcae.ci.api.tests.composition; +package org.onap.dcae.ci.api.tests.composition; import static org.assertj.core.api.Assertions.assertThat; @@ -6,25 +6,24 @@ import java.io.IOException; import com.google.gson.JsonArray; import com.google.gson.JsonObject; + import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.text.WordUtils; import org.assertj.core.api.SoftAssertions; import org.json.simple.JSONObject; import org.json.simple.JSONValue; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.springframework.http.HttpStatus; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.utilities.DcaeUtil; +import org.onap.dcae.ci.report.Report; import org.testng.annotations.Test; -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; import org.onap.sdc.dcae.composition.services.Service; import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.DcaeUtil; -import com.att.ecomp.dcae.ci.utilities.Report; import com.aventstack.extentreports.Status; -public class GetCompositionControllerTests extends DcaeRestBaseTest { +public class GetCompositionControllerTests extends DcaeRestBaseTest { private static final String VFCMT_NAME = "teSt.__.monitoring---TempLATE."; @@ -38,7 +37,7 @@ public class GetCompositionControllerTests extends DcaeRestBaseTest { saveComposition(uuid, lastUpdaterUserId); Report.log(Status.INFO, "Composition saved"); - ExtentTestActions.log(Status.INFO, "Get Composition - execute"); + Report.log(Status.INFO, "Get Composition - execute"); RestResponse response = DcaeRestClient.getComposition(uuid); JSONObject resData = (JSONObject) JSONValue.parse(response.getResponse()); SoftAssertions.assertSoftly(softly -> { @@ -49,12 +48,12 @@ public class GetCompositionControllerTests extends DcaeRestBaseTest { @Test public void test_getCompositionNoArtifact() throws Exception{ - ExtentTestActions.log(Status.INFO, "test_getCompositionNoArtifact Get Composition - create vfcmt"); + Report.log(Status.INFO, "test_getCompositionNoArtifact Get Composition - create vfcmt"); Vfcmt newVfcmt = createNewVfcmt(); String uuid = newVfcmt.getUuid(); - - ExtentTestActions.log(Status.INFO, "Get Composition - execute"); + + Report.log(Status.INFO, "Get Composition - execute"); RestResponse response = DcaeRestClient.getComposition(uuid); SoftAssertions.assertSoftly(softly -> { diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/SaveAndSubmitCompositionFullFlowTest.java b/src/main/java/org/onap/dcae/ci/api/tests/composition/SaveAndSubmitCompositionFullFlowTest.java index aaeebdc..566a028 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/SaveAndSubmitCompositionFullFlowTest.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/composition/SaveAndSubmitCompositionFullFlowTest.java @@ -1,22 +1,23 @@ -package com.att.ecomp.dcae.ci.api.tests.composition; +package org.onap.dcae.ci.api.tests.composition; + -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; import com.aventstack.extentreports.Status; import com.google.gson.reflect.TypeToken; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; import org.onap.sdc.dcae.composition.restmodels.CreateMcResponse; import org.onap.sdc.dcae.composition.restmodels.CreateVFCMTRequest; import org.onap.sdc.dcae.composition.restmodels.MonitoringComponent; -import org.onap.sdc.dcae.composition.restmodels.sdc.ExternalReferencesMap; import org.onap.sdc.dcae.composition.restmodels.sdc.Resource; import org.onap.sdc.dcae.composition.restmodels.sdc.ResourceDetailed; import org.onap.sdc.dcae.composition.services.Service; import org.onap.sdc.dcae.composition.util.DcaeBeConstants; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.io.IOException; import java.lang.reflect.Type; import java.util.List; import java.util.Map; @@ -31,19 +32,19 @@ public class SaveAndSubmitCompositionFullFlowTest extends DcaeRestBaseTest { @BeforeClass public void setup() { try { - ExtentTestActions.log(Status.INFO, "running before class - find a base template"); + Report.log(Status.INFO, "running before class - find a base template"); Resource[] resources = gson.fromJson(DcaeRestClient.getAllMonitoringTemplatesVfcmts().getResponse(), Resource[].class); if (resources.length > 0){ baseTemplate = resources[0]; } } catch (Exception e) { - ExtentTestActions.log(Status.ERROR, e); + Report.log(Status.ERROR, e); } } @Test - public void saveAndSubmitCompositionSuccessTest() throws Exception { + public void saveAndSubmitCompositionSuccessTest() throws IOException { CreateVFCMTRequest request = new CreateVFCMTRequest(); // If you crashed here (below) it is because your environment has no Base Monitoring Templates @@ -59,7 +60,7 @@ public class SaveAndSubmitCompositionFullFlowTest extends DcaeRestBaseTest { .isEqualTo(200); CreateMcResponse mcResponse = gson.fromJson(response.getResponse(), CreateMcResponse.class); - ExtentTestActions.log(Status.INFO, "Vfcmt created successfully. About to update composition"); + Report.log(Status.INFO, "Vfcmt created successfully. About to update composition"); String initialUuid = mcResponse.getVfcmt().getUuid(); response = DcaeRestClient.saveComposition(request.getServiceUuid(), request.getVfiName(), initialUuid, gson.toJson(mcResponse.getCdump())); assertThat(response.getStatusCode()) @@ -71,13 +72,13 @@ public class SaveAndSubmitCompositionFullFlowTest extends DcaeRestBaseTest { assertThat(mc.getLifecycleState()).isEqualTo(DcaeBeConstants.LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name()); assertThat(mc.getVersion()).isEqualTo("0.2"); - ExtentTestActions.log(Status.INFO, "About to submit the composition"); + Report.log(Status.INFO, "About to submit the composition"); response = DcaeRestClient.submitComposition(request.getServiceUuid(), request.getVfiName(), mc.getUuid()); assertThat(response.getStatusCode()) .as("status code") .isEqualTo(200); // the submit action should certify the mc. - ExtentTestActions.log(Status.INFO, "Save new composition version after submit"); + Report.log(Status.INFO, "Save new composition version after submit"); response = DcaeRestClient.saveComposition(request.getServiceUuid(), request.getVfiName(), initialUuid, gson.toJson(mcResponse.getCdump())); assertThat(response.getStatusCode()) .as("status code") @@ -91,11 +92,11 @@ public class SaveAndSubmitCompositionFullFlowTest extends DcaeRestBaseTest { assertThat(response.getStatusCode()) .as("status code") .isEqualTo(200); - ExtentTestActions.log(Status.INFO, "Verify service vfi has references to both mc versions"); + Report.log(Status.INFO, "Verify service vfi has references to both mc versions"); Type typeToken = new TypeToken<Map<String, List<MonitoringComponent>>>(){}.getType(); Map<String, List<MonitoringComponent>> monitoringComponents = gson.fromJson(response.getResponse(), typeToken); assertThat(monitoringComponents.get("monitoringComponents").size()).isEqualTo(2); - ExtentTestActions.log(Status.INFO, "About to re-submit the composition"); + Report.log(Status.INFO, "About to re-submit the composition"); response = DcaeRestClient.submitComposition(request.getServiceUuid(), request.getVfiName(), mc.getUuid()); assertThat(response.getStatusCode()) .as("status code") diff --git a/src/main/java/org/onap/dcae/ci/api/tests/deploy_tool/DeployToolTest.java b/src/main/java/org/onap/dcae/ci/api/tests/deploy_tool/DeployToolTest.java new file mode 100644 index 0000000..46836f2 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/deploy_tool/DeployToolTest.java @@ -0,0 +1,19 @@ +package org.onap.dcae.ci.api.tests.deploy_tool; + + +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; +import org.testng.annotations.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class DeployToolTest extends DcaeRestBaseTest { + + @Test + public void verifyDeployToolVfcmtExist() throws Exception { + Vfcmt[] vfcmts = client.getAllBaseVfcmts(); + assertThat(vfcmts).isNotNull(); + assertThat(vfcmts.length).isGreaterThan(0); + } + +} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/ArrangeHelper.java b/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/ArrangeHelper.java index 933fc38..a3631f8 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/ArrangeHelper.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/ArrangeHelper.java @@ -1,9 +1,9 @@ -package com.att.ecomp.dcae.ci.api.tests.lifeCycle; +package org.onap.dcae.ci.api.tests.lifeCycle; import static org.assertj.core.api.Assertions.fail; -import com.att.ecomp.dcae.ci.utilities.DcaeEntityClient; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.utilities.DcaeEntityClient; +import org.onap.dcae.ci.utilities.DcaeRestClient; import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; public class ArrangeHelper { @@ -36,7 +36,7 @@ public class ArrangeHelper { * @return checkedin vfcmt */ public Vfcmt getCheckedinVfcmt() { - String userId = DcaeRestClient.getDefaultUser().getUserId(); + String userId = DcaeRestClient.getDefaultUserId(); return getCheckedinVfcmt(userId); } @@ -62,7 +62,7 @@ public class ArrangeHelper { * @return checkedout vfcmt */ public Vfcmt getCheckedoutVfcmt() { - String userId = DcaeRestClient.getDefaultUser().getUserId(); + String userId = DcaeRestClient.getDefaultUserId(); return getCheckedoutVfcmt(userId); } } diff --git a/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCertify.java b/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCertify.java new file mode 100644 index 0000000..6fc6bbe --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCertify.java @@ -0,0 +1,34 @@ +package org.onap.dcae.ci.api.tests.lifeCycle; + + +import com.aventstack.extentreports.Status; +import org.assertj.core.api.SoftAssertions; + +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; +import org.testng.annotations.Test; + +public class PutCertify extends DcaeRestBaseTest { + + private ArrangeHelper arrange = new ArrangeHelper(client); + + /* Positive */ + + @Test + public void certifyVfcmt_success() throws Exception { + // arrange + Vfcmt vfcmt = arrange.getCheckedinVfcmt(); + // act + Report.log(Status.INFO, "Calling certify vfcmt with lastUpdater as user (designer role)"); + RestResponse response = DcaeRestClient.certifyVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); + // assert + Vfcmt vfcmtAfterCheckin = gson.fromJson(response.getResponse(), Vfcmt.class); + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).isEqualTo(200); + softly.assertThat(vfcmtAfterCheckin.getLifecycleState()).isEqualTo("CERTIFIED"); + }); + } +} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCheckin.java b/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCheckin.java index 45f71e0..6866a0a 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCheckin.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCheckin.java @@ -1,23 +1,24 @@ -package com.att.ecomp.dcae.ci.api.tests.lifeCycle; +package org.onap.dcae.ci.api.tests.lifeCycle; import java.io.IOException; import java.util.UUID; import org.assertj.core.api.SoftAssertions; -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; + +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; import org.testng.annotations.*; import static org.assertj.core.api.Assertions.*; -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; + import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; + import com.aventstack.extentreports.Status; -public class PutCheckin extends DcaeRestBaseTest{ +public class PutCheckin extends DcaeRestBaseTest { private ArrangeHelper arrange = new ArrangeHelper(client); @@ -28,7 +29,7 @@ public class PutCheckin extends DcaeRestBaseTest{ // arrange Vfcmt vfcmt = arrange.getCheckedoutVfcmt(); // act - ExtentTestActions.log(Status.INFO, "Checkin the vfcmt with it's lastUpdater user"); + Report.log(Status.INFO, "Checkin the vfcmt with it's lastUpdater user"); RestResponse response = checkinVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); // assert Vfcmt vfcmtAfterCheckin = gson.fromJson(response.getResponse(), Vfcmt.class); @@ -45,7 +46,7 @@ public class PutCheckin extends DcaeRestBaseTest{ // arrange Vfcmt vfcmt = arrange.getCheckedinVfcmt(); // act - ExtentTestActions.log(Status.INFO, "Checkin the vfcmt <b>AGAIN</b> with it's lastUpdater user"); + Report.log(Status.INFO, "Checkin the vfcmt <b>AGAIN</b> with it's lastUpdater user"); RestResponse response = checkinVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); // assert assertThat(response.getStatusCode()).isEqualTo(409); @@ -54,9 +55,9 @@ public class PutCheckin extends DcaeRestBaseTest{ @Test public void invalidVfcmtUuid_statusCode400() throws Exception { // arrange - String userId = DcaeRestClient.getDefaultUser().getUserId(); + String userId = DcaeRestClient.getDefaultUserId(); // act - ExtentTestActions.log(Status.INFO, "Checkin with an invalid-uuid as vfcmt-uuid"); + Report.log(Status.INFO, "Checkin with an invalid-uuid as vfcmt-uuid"); RestResponse response = checkinVfcmt("invalid-vfcmt-uuid", userId); // assert assertThat(response.getStatusCode()).isEqualTo(400); @@ -66,9 +67,9 @@ public class PutCheckin extends DcaeRestBaseTest{ public void nonExistingUuid_statusCode409() throws Exception { // arrange String uuid = UUID.randomUUID().toString(); - String userId = DcaeRestClient.getDefaultUser().getUserId(); + String userId = DcaeRestClient.getDefaultUserId(); // act - ExtentTestActions.log(Status.INFO, "Checkin with a non-existing vfcmt-uuid"); + Report.log(Status.INFO, "Checkin with a non-existing vfcmt-uuid"); RestResponse response = checkinVfcmt(uuid, userId); // assert assertThat(response.getStatusCode()).isEqualTo(409); @@ -79,7 +80,7 @@ public class PutCheckin extends DcaeRestBaseTest{ // arrange Vfcmt vfcmt = arrange.getCheckedoutVfcmt(); // act - ExtentTestActions.log(Status.INFO, "Checkin with a non-existing user"); + Report.log(Status.INFO, "Checkin with a non-existing user"); RestResponse response = checkinVfcmt(vfcmt.getUuid(), "anonymus"); // assert assertThat(response.getStatusCode()).isEqualTo(403); @@ -88,11 +89,11 @@ public class PutCheckin extends DcaeRestBaseTest{ @Test public void notLastUser_statusCode403() throws Exception { // arrange - String user1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER).getUserId(); - String user2 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2).getUserId(); + String user1 = DcaeRestClient.getDefaultUserId(); + String user2 = DcaeRestClient.getDesigner2UserId(); Vfcmt vfcmt = arrange.getCheckedoutVfcmt(user1); // act - ExtentTestActions.log(Status.INFO, "Checkin the vfcmt with different user: " + user2); + Report.log(Status.INFO, "Checkin the vfcmt with different user: " + user2); RestResponse response = checkinVfcmt(vfcmt.getUuid(), user2); // assert assertThat(response.getStatusCode()).isEqualTo(403); @@ -102,10 +103,10 @@ public class PutCheckin extends DcaeRestBaseTest{ public void invalidAssetType_statusCode400() throws Exception { // arrange String assetType = "kengero"; - String userId = DcaeRestClient.getDefaultUser().getUserId(); + String userId = DcaeRestClient.getDefaultUserId(); Vfcmt vfcmt = arrange.getCheckedoutVfcmt(); // act - ExtentTestActions.log(Status.INFO, "Checkin the vfcmt with invalid asset-type"); + Report.log(Status.INFO, "Checkin the vfcmt with invalid asset-type"); RestResponse response = checkinGeneral(assetType, userId, vfcmt); // assert assertThat(response.getStatusCode()).isEqualTo(400); @@ -115,7 +116,7 @@ public class PutCheckin extends DcaeRestBaseTest{ /* Private Methods */ /** - * Performs checkin on a general vfcmt/service, use this in test action + * Performs checkin on a general vfcmt, use this in test action * @param assetType * @param userId * @param vfcmt @@ -124,7 +125,7 @@ public class PutCheckin extends DcaeRestBaseTest{ */ private RestResponse checkinGeneral(String assetType, String userId, Vfcmt vfcmt) throws IOException { RestResponse response = DcaeRestClient.checkinGeneral(assetType, vfcmt.getUuid(), userId); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); return response; } @@ -137,7 +138,7 @@ public class PutCheckin extends DcaeRestBaseTest{ */ private RestResponse checkinVfcmt(String vfcmtUuid, String userId) throws IOException { RestResponse response = DcaeRestClient.checkinVfcmt(vfcmtUuid, userId); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); return response; } diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCheckout.java b/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCheckout.java index 5696ee3..b8b7afc 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCheckout.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCheckout.java @@ -1,23 +1,23 @@ -package com.att.ecomp.dcae.ci.api.tests.lifeCycle; +package org.onap.dcae.ci.api.tests.lifeCycle; import java.io.IOException; import java.util.UUID; + import org.assertj.core.api.SoftAssertions; -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; + +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; import org.testng.annotations.*; import static org.assertj.core.api.Assertions.*; -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; import com.aventstack.extentreports.Status; -public class PutCheckout extends DcaeRestBaseTest{ +public class PutCheckout extends DcaeRestBaseTest { private ArrangeHelper arrange = new ArrangeHelper(client); @@ -28,7 +28,7 @@ public class PutCheckout extends DcaeRestBaseTest{ // arrange Vfcmt vfcmt = arrange.getCheckedinVfcmt(); // act - ExtentTestActions.log(Status.INFO, "Checkout the vfcmt with it's lastUpdater user"); + Report.log(Status.INFO, "Checkout the vfcmt with it's lastUpdater user"); RestResponse response = checkoutVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); // assert Vfcmt vfcmtAfterCheckout = gson.fromJson(response.getResponse(), Vfcmt.class); @@ -41,11 +41,11 @@ public class PutCheckout extends DcaeRestBaseTest{ @Test public void notLastUser_success() throws Exception { // arrange - String user1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER).getUserId(); - String user2 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2).getUserId(); + String user1 = DcaeRestClient.getDefaultUserId(); + String user2 = DcaeRestClient.getDesigner2UserId(); Vfcmt vfcmt = arrange.getCheckedinVfcmt(user1); // act - ExtentTestActions.log(Status.INFO, "Checkout the vfcmt with different user: " + user2); + Report.log(Status.INFO, "Checkout the vfcmt with different user: " + user2); RestResponse response = checkoutVfcmt(vfcmt.getUuid(), user2); // assert Vfcmt vfcmtAfterCheckout = gson.fromJson(response.getResponse(), Vfcmt.class); @@ -63,7 +63,7 @@ public class PutCheckout extends DcaeRestBaseTest{ // arrange Vfcmt vfcmt = arrange.getCheckedoutVfcmt(); // act - ExtentTestActions.log(Status.INFO, "Checkout the vfcmt with it's lastUpdater user"); + Report.log(Status.INFO, "Checkout the vfcmt with it's lastUpdater user"); RestResponse response = checkoutVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); // assert assertThat(response.getStatusCode()).isEqualTo(403); @@ -72,9 +72,9 @@ public class PutCheckout extends DcaeRestBaseTest{ @Test public void invalidVfcmtUuid_statusCode400() throws Exception { // arrange - String userId = DcaeRestClient.getDefaultUser().getUserId(); + String userId = DcaeRestClient.getDefaultUserId(); // act - ExtentTestActions.log(Status.INFO, "Checkout with an invalid-uuid as vfcmt-uuid"); + Report.log(Status.INFO, "Checkout with an invalid-uuid as vfcmt-uuid"); RestResponse response = checkoutVfcmt("invalid-vfcmt-uuid", userId); // assert assertThat(response.getStatusCode()).isEqualTo(400); @@ -84,9 +84,9 @@ public class PutCheckout extends DcaeRestBaseTest{ public void nonExistingUuid_statusCode409() throws Exception { // arrange String uuid = UUID.randomUUID().toString(); - String userId = DcaeRestClient.getDefaultUser().getUserId(); + String userId = DcaeRestClient.getDefaultUserId(); // act - ExtentTestActions.log(Status.INFO, "Checkin with a non-existing vfcmt-uuid"); + Report.log(Status.INFO, "Checkin with a non-existing vfcmt-uuid"); RestResponse response = checkoutVfcmt(uuid, userId); // assert assertThat(response.getStatusCode()).isEqualTo(409); @@ -97,7 +97,7 @@ public class PutCheckout extends DcaeRestBaseTest{ // arrange Vfcmt vfcmt = arrange.getCheckedinVfcmt(); // act - ExtentTestActions.log(Status.INFO, "Checkin with a non-existing user"); + Report.log(Status.INFO, "Checkin with a non-existing user"); RestResponse response = checkoutVfcmt(vfcmt.getUuid(), "anonymus"); // assert assertThat(response.getStatusCode()).isEqualTo(403); @@ -107,10 +107,10 @@ public class PutCheckout extends DcaeRestBaseTest{ public void invalidAssetType_statusCode400() throws Exception { // arrange String assetType = "kengero"; - String userId = DcaeRestClient.getDefaultUser().getUserId(); + String userId = DcaeRestClient.getDefaultUserId(); Vfcmt vfcmt = arrange.getCheckedoutVfcmt(); // act - ExtentTestActions.log(Status.INFO, "Checkout the vfcmt with invalid asset-type"); + Report.log(Status.INFO, "Checkout the vfcmt with invalid asset-type"); RestResponse response = checkoutGeneral(assetType, userId, vfcmt); // assert assertThat(response.getStatusCode()).isEqualTo(400); @@ -129,7 +129,7 @@ public class PutCheckout extends DcaeRestBaseTest{ */ private RestResponse checkoutGeneral(String assetType, String userId, Vfcmt vfcmt) throws IOException { RestResponse response = DcaeRestClient.checkinGeneral(assetType, vfcmt.getUuid(), userId); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); return response; } @@ -142,7 +142,7 @@ public class PutCheckout extends DcaeRestBaseTest{ */ private RestResponse checkoutVfcmt(String vfcmtUuid, String userId) throws IOException { RestResponse response = DcaeRestClient.checkoutVfcmt(vfcmtUuid, userId); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); return response; } } diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/GetDefinitionTest.java b/src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/GetDefinitionTest.java index 358f45a..154d952 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/GetDefinitionTest.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/GetDefinitionTest.java @@ -1,4 +1,4 @@ -package com.att.ecomp.dcae.ci.api.tests.ruleEditor; +package org.onap.dcae.ci.api.tests.ruleEditor; import java.lang.reflect.Field; import java.lang.reflect.Type; @@ -8,15 +8,16 @@ import java.util.List; import org.apache.commons.lang3.StringUtils; import org.assertj.core.api.SoftAssertions; -import org.openecomp.d2.ci.datatypes.http.RestResponse; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; + import org.onap.sdc.dcae.composition.restmodels.ruleeditor.EventTypeDefinitionUI; import org.onap.sdc.dcae.composition.restmodels.ruleeditor.EventTypesByVersionUI; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.Report; import com.aventstack.extentreports.Status; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/GetListEventsAndVersionsTest.java b/src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/GetListEventsAndVersionsTest.java index 66ca1cb..0764e34 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/GetListEventsAndVersionsTest.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/GetListEventsAndVersionsTest.java @@ -1,15 +1,17 @@ -package com.att.ecomp.dcae.ci.api.tests.ruleEditor; +package org.onap.dcae.ci.api.tests.ruleEditor; -import org.apache.commons.collections.SetUtils; + +import org.apache.commons.collections4.SetUtils; import org.apache.commons.lang3.StringUtils; import org.assertj.core.api.SoftAssertions; -import org.openecomp.d2.ci.datatypes.http.RestResponse; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; + +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; import org.onap.sdc.dcae.composition.restmodels.ruleeditor.EventTypesByVersionUI; import org.testng.annotations.Test; -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.Report; import com.aventstack.extentreports.Status; public class GetListEventsAndVersionsTest extends DcaeRestBaseTest { @@ -35,7 +37,7 @@ public class GetListEventsAndVersionsTest extends DcaeRestBaseTest { .doesNotContainNull(); softly.assertThat(resBody).extracting("eventTypes").as("eventTypes list") - .doesNotContain(SetUtils.EMPTY_SET) + .doesNotContain(SetUtils.emptySet()) .doesNotContainNull(); softly.assertThat(resBody).flatExtracting("eventTypes").as("eventTypes list (flatten)") .doesNotContainAnyElementsOf(EventTypesByVersionUI.DEFAULT_EVENTS) diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/RuleEditorControllerTest.java b/src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/RuleEditorControllerTest.java index 73b51be..45de16a 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/RuleEditorControllerTest.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/RuleEditorControllerTest.java @@ -1,21 +1,22 @@ -package com.att.ecomp.dcae.ci.api.tests.ruleEditor; +package org.onap.dcae.ci.api.tests.ruleEditor; -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.entities.rule_editor.SaveRuleError; + +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.entities.rule_editor.SaveRuleError; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; import org.onap.sdc.dcae.composition.services.Artifact; import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.Report; import com.aventstack.extentreports.Status; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.JsonObject; import org.onap.sdc.dcae.composition.restmodels.ruleeditor.MappingRules; import org.onap.sdc.dcae.composition.restmodels.ruleeditor.Rule; -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; + import org.testng.annotations.Test; import org.assertj.core.api.SoftAssertions; -import org.openecomp.d2.ci.datatypes.http.RestResponse; + import static org.assertj.core.api.Assertions.assertThat; import static org.testng.Assert.fail; @@ -27,8 +28,10 @@ public class RuleEditorControllerTest extends DcaeRestBaseTest { private String ruleRequestBody = "{version:4.1,eventType:syslogFields,description:newRule,actions:[{from:{value:fromField,regex:\"\"},target:event.commonEventHeader.target,id:id,actionType:copy}," + "{actionType:concat,from:{values:[{value:concat1},{value:_concat2}]},target:concatTargetField},{actionType:copy,from:{value:extractFromHere,regex:\"([^:]*):.*\"},target:regexTargetField}," + + "{actionType:\"Log Text\",logText:{text:\"some text\",level:WARN}},{actionType:CLear,from:{values:[{value:first_input},{value:second_input}]}}," + "{actionType:map,from:{value:fromField},target:mapTargetField,map:{values:[{key:sourceVal1,value:targetVal1},{key:sourceVal2,value:targetVal2}],haveDefault:true,default:'\"\"'}}," - + "{actionType:\"Date Formatter\",id:98908,from:{value:\"${dateFormatterFrom}\"},target:dateFormatterTarget,dateFormatter:{toTimezone:UVW,fromTimezone:XYZ,fromFormat:inputFormat,toFormat:outputFormat}}]," + + "{actionType:\"Date Formatter\",id:98908,from:{value:\"${dateFormatterFrom}\"},target:dateFormatterTarget,dateFormatter:{toTimezone:UVW,fromTimezone:XYZ,fromFormat:inputFormat,toFormat:outputFormat}}," + + "{actionType:\"Log Event\",id:465456,logEvent:{title:\"some log title\"}},{actionType:\"Replace Text\",from:{value:fromField},replaceText:{find:findText,replace:replacement}}]," + "condition:{left:\"${leftOperand}\",operator:contains,right:[rightOperand1,rightOperand2]}}"; @Test @@ -52,20 +55,22 @@ public class RuleEditorControllerTest extends DcaeRestBaseTest { + "{\"string\":\"${leftOperand}\",\"value\":\"rightOperand2\",\"class\":\"Contains\"}],\"class\":\"Or\"}," + "\"processors\":[{\"updates\":{\"event.commonEventHeader.target\":\"fromField\",\"concatTargetField\":\"concat1_concat2\"},\"class\":\"Set\"}," + "{\"regex\":\"([^:]*):.*\",\"field\":\"regexTargetField\",\"value\":\"extractFromHere\",\"class\":\"ExtractText\"}," + + "{\"logLevel\":\"WARN\",\"logText\":\"some text\",\"class\":\"LogText\"},{\"fields\":[\"first_input\",\"second_input\"],\"class\":\"Clear\"}," + "{\"map\":{\"sourceVal1\":\"targetVal1\",\"sourceVal2\":\"targetVal2\"},\"field\":\"fromField\",\"toField\":\"mapTargetField\",\"default\":\"\",\"class\":\"MapAlarmValues\"}," - + "{\"fromFormat\":\"inputFormat\",\"fromTz\":\"XYZ\",\"toField\":\"dateFormatterTarget\",\"toFormat\":\"outputFormat\",\"toTz\":\"UVW\",\"value\":\"${dateFormatterFrom}\",\"class\":\"DateFormatter\"}]}," - + "{\"phase\":\"%s\",\"processors\":[{\"phase\":\"map_publish\",\"class\":\"RunPhase\"}]}]}"; + + "{\"fromFormat\":\"inputFormat\",\"fromTz\":\"XYZ\",\"toField\":\"dateFormatterTarget\",\"toFormat\":\"outputFormat\",\"toTz\":\"UVW\",\"value\":\"${dateFormatterFrom}\",\"class\":\"DateFormatter\"}," + + "{\"title\":\"some log title\",\"class\":\"LogEvent\"},{\"field\":\"fromField\",\"find\":\"findText\",\"replace\":\"replacement\",\"class\":\"ReplaceText\"}]}," + + "{\"phase\":\"%s\",\"processors\":[{\"phase\":\"snmp_publish\",\"class\":\"RunPhase\"}]}]}"; Vfcmt vfcmt = createVfcmt(); String name = vfcmt.getName(); saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody); - RestResponse res = DcaeRestClient.translateRules(vfcmt.getUuid(),"map", "map", "param1", "SNMP"); + RestResponse res = DcaeRestClient.translateRules(vfcmt.getUuid(),"map", "map", "param1", "SNMP MSE"); Report.log(Status.INFO, "translateRules response= "+res); assertThat(res.getStatusCode()).isEqualTo(200); assertThat(res.getResponse()).isEqualTo(String.format(expectedTranslation, name, name, name)); } @Test - public void addNewRuleToExistingArtifact() throws Exception{ + public void addNewRuleToExistingArtifact() throws Exception { Vfcmt vfcmt = createVfcmt(); String nid = "n.565663636.0"; RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", nid, "param1", ruleRequestBody); @@ -210,7 +215,7 @@ public class RuleEditorControllerTest extends DcaeRestBaseTest { RestResponse res = DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), "{\"nid\":\"map\"}"); assertThat(res.getStatusCode()).isEqualTo(200); //check out by other user then try to save rule by current user - res = DcaeRestClient.checkoutVfcmt(vfcmt.getUuid(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2).getUserId()); + res = DcaeRestClient.checkoutVfcmt(vfcmt.getUuid(), DcaeRestClient.getDesigner2UserId()); assertThat(res.getStatusCode()).isEqualTo(200); res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "someParam", ruleRequestBody); assertThat(res.getStatusCode()).isEqualTo(403); @@ -316,4 +321,33 @@ public class RuleEditorControllerTest extends DcaeRestBaseTest { assertThat(res.getStatusCode()).isEqualTo(400); assertThat(res.getResponse()).isEqualTo(String.format(expectedError, "%1", "Flow type null not found", "Flow type null not found")); } + + @Test + public void getExistingRuleTargetsTest() throws Exception { + String dcaeCompName = "theComponent"; + String nid = "theNid"; + String configParam1 = "ConfigParam1"; + String configParam2 = "ConfigParam2"; + final String UID = "uid"; + + Vfcmt vfcmt = createVfcmt(); + RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, dcaeCompName, nid, configParam1, ruleRequestBody); + gson.fromJson(res.getResponse(), JsonObject.class).get(UID).getAsString(); + res = DcaeRestClient.saveRule(vfcmt.getUuid(), dcaeCompName, nid, configParam2, ruleRequestBody); + Report.log(Status.INFO, "saveRule1 response= "+res); + gson.fromJson(res.getResponse(), JsonObject.class).get(UID).getAsString(); + res = DcaeRestClient.saveRule(vfcmt.getUuid(), dcaeCompName, nid, configParam1, ruleRequestBody); + Report.log(Status.INFO, "saveRule2 response= "+res); + gson.fromJson(res.getResponse(), JsonObject.class).get(UID).getAsString(); + res = DcaeRestClient.saveRule(vfcmt.getUuid(), dcaeCompName, nid, configParam1, ruleRequestBody); + Report.log(Status.INFO, "saveRule3 response= "+res); + + res = DcaeRestClient.getExistingRuleTargets(vfcmt.getUuid(),dcaeCompName,nid); + if (res.getStatusCode() != 200) { + fail("Unable to arrange test, get existing rule targets test failed\n" + res.toString()); + } + String response = res.getResponse(); + assertThat(response.contains(configParam1)); + assertThat(response.contains(configParam2)); + } } diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/attachment/GetAttachment.java b/src/main/java/org/onap/dcae/ci/api/tests/services/attachment/GetAttachment.java index a1c9193..e9e4d27 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/attachment/GetAttachment.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/services/attachment/GetAttachment.java @@ -1,6 +1,4 @@ -package com.att.ecomp.dcae.ci.api.tests.services.attachment; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; +package org.onap.dcae.ci.api.tests.services.attachment; import static org.assertj.core.api.Assertions.*; @@ -9,12 +7,14 @@ import java.util.UUID; import org.assertj.core.api.SoftAssertions; import org.json.simple.JSONObject; import org.json.simple.JSONValue; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.openecomp.d2.ci.datatypes.http.RestResponse; + import org.testng.annotations.*; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.Report; import com.aventstack.extentreports.Status; public class GetAttachment extends DcaeRestBaseTest { diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/attachment/PostAttachment.java b/src/main/java/org/onap/dcae/ci/api/tests/services/attachment/PostAttachment.java index afd018f..e435ee2 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/attachment/PostAttachment.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/services/attachment/PostAttachment.java @@ -1,22 +1,23 @@ -package com.att.ecomp.dcae.ci.api.tests.services.attachment; +package org.onap.dcae.ci.api.tests.services.attachment; import static org.assertj.core.api.Assertions.*; -import com.att.ecomp.dcae.ci.entities.composition.services.Vfi; import org.assertj.core.api.SoftAssertions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.entities.composition.services.Vfi; +import org.onap.dcae.ci.entities.sdc.SdcResource; +import org.onap.dcae.ci.entities.sdc.SdcService; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.SdcInternalApiClient; import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; import org.testng.annotations.*; import java.util.UUID; import org.json.simple.JSONObject; import org.json.simple.JSONValue; -import org.openecomp.d2.ci.datatypes.ResourceReqDetails; -import org.openecomp.d2.ci.datatypes.ServiceReqDetails; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.SdcInternalApiClient; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.Report; + import com.aventstack.extentreports.Status; public class PostAttachment extends DcaeRestBaseTest { @@ -36,7 +37,7 @@ public class PostAttachment extends DcaeRestBaseTest { } // act Report.log(Status.INFO, "Attaching vfcmt [%s] to vfi [%s]", vfcmt.getUuid(), vfi.getName()); - RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), vfi.getContainer().getUUID(), vfi.getName()); + RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), vfi.getContainer().getUuid(), vfi.getName()); Report.logDebug("Response:", response); // assert JSONObject resData = (JSONObject) JSONValue.parse(response.getResponse()); @@ -64,7 +65,7 @@ public class PostAttachment extends DcaeRestBaseTest { } // act Report.log(Status.INFO, "Updating attachment of vfcmt [%s] to a new vfi [%s]", vfcmt.getUuid(), vfi.getName()); - RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), vfi.getContainer().getUUID(), vfi.getName()); + RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), vfi.getContainer().getUuid(), vfi.getName()); Report.logDebug("Response:", response); // assert JSONObject resData = (JSONObject) JSONValue.parse(response.getResponse()); @@ -83,7 +84,7 @@ public class PostAttachment extends DcaeRestBaseTest { @Test public void vfWithVfi_statusCode400() throws Exception { // arrange - ResourceReqDetails vf; + SdcResource vf; Vfi vfi; try { Report.log(Status.INFO, "Create vf"); @@ -93,8 +94,8 @@ public class PostAttachment extends DcaeRestBaseTest { throw new Exception("Could not arrange test", err); } // act - Report.log(Status.INFO, "Attaching vf [%s] to vfi [%s]", vf.getUUID(), vfi.getName()); - RestResponse response = DcaeRestClient.attachVfiRef(vf.getUUID(), vfi.getContainer().getUUID(), vfi.getName()); + Report.log(Status.INFO, "Attaching vf [%s] to vfi [%s]", vf.getUuid(), vfi.getName()); + RestResponse response = DcaeRestClient.attachVfiRef(vf.getUuid(), vfi.getContainer().getUuid(), vfi.getName()); Report.logDebug("Response:", response); // assert assertThat(response.getStatusCode()).as("status code").isEqualTo(400); @@ -131,14 +132,14 @@ public class PostAttachment extends DcaeRestBaseTest { try { vfcmt = client.createCheckedinVfcmt(); Report.log(Status.INFO, "Create service"); - ServiceReqDetails service = SdcInternalApiClient.createService(); + SdcService service = SdcInternalApiClient.createService(); vfi = new Vfi("fakeVfi", service); } catch (Exception err) { throw new Exception("Could not arrange test", err); } // act - Report.log(Status.INFO, "Attaching vfcmt [%s] to real service [%s] and fake vfi [%s]", vfcmt.getUuid(), vfi.getContainer().getUUID(), vfi.getName()); - RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), vfi.getContainer().getUUID(), vfi.getName()); + Report.log(Status.INFO, "Attaching vfcmt [%s] to real service [%s] and fake vfi [%s]", vfcmt.getUuid(), vfi.getContainer().getUuid(), vfi.getName()); + RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), vfi.getContainer().getUuid(), vfi.getName()); Report.logDebug("Response:", response); // assert assertThat(response.getStatusCode()).as("status code").isEqualTo(404); @@ -149,12 +150,12 @@ public class PostAttachment extends DcaeRestBaseTest { private Vfi arrangeVfi() throws Exception { Report.log(Status.INFO, "Create service"); - ServiceReqDetails service = SdcInternalApiClient.createService(); + SdcService service = SdcInternalApiClient.createService(); Report.log(Status.INFO, "Create vf"); - ResourceReqDetails vf = SdcInternalApiClient.createVf(); + SdcResource vf = SdcInternalApiClient.createVf(); Report.log(Status.INFO, "Checkin vf"); - ResourceReqDetails vfCheckedin = SdcInternalApiClient.checkinVf(vf); - Report.log(Status.INFO, "Create vfi from (service [%s] + vf [%s])", service.getUUID(), vf.getUUID()); + vf = SdcInternalApiClient.checkinVf(vf); + Report.log(Status.INFO, "Create vfi from (service [%s] + vf [%s])", service.getUuid(), vf.getUuid()); return SdcInternalApiClient.createVfi(service, vf); } @@ -162,7 +163,7 @@ public class PostAttachment extends DcaeRestBaseTest { private void arrangeAttachmentToNewVfi(Vfcmt vfcmt) throws Exception { Vfi vfi = arrangeVfi(); Report.log(Status.INFO, "Attaching vfcmt [%s] to vfi [%s]", vfcmt.getUuid(), vfi.getName()); - RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), vfi.getContainer().getUUID(), vfi.getName()); + RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), vfi.getContainer().getUuid(), vfi.getName()); Report.logDebug("Response:", response); if (response.getStatusCode() != 200) { throw new Exception("Failed to attach vfcmt to vfi\nResponse: " + response.toString()); diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/instance/GetServiceInstanceNagative.java b/src/main/java/org/onap/dcae/ci/api/tests/services/instance/GetServiceInstanceNagative.java index 582bc9b..8e72204 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/instance/GetServiceInstanceNagative.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/services/instance/GetServiceInstanceNagative.java @@ -1,10 +1,12 @@ -package com.att.ecomp.dcae.ci.api.tests.services.instance; +package org.onap.dcae.ci.api.tests.services.instance; + -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; import com.aventstack.extentreports.Status; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; + +import org.onap.dcae.ci.report.Report; import org.testng.annotations.Test; import java.io.IOException; @@ -15,10 +17,9 @@ public class GetServiceInstanceNagative extends DcaeRestBaseTest { @Test public void test_invalidServiceID() throws IOException{ - ExtentTestActions.log(Status.INFO, "Send invalid service Instance"); + Report.log(Status.INFO, "Send invalid service Instance"); RestResponse response = DcaeRestClient.getServicesInstance("123456789"); - ExtentTestActions.log(Status.INFO, "Verifying response status is 404"); + Report.log(Status.INFO, "Verifying response status is 404"); assertThat(response.getStatusCode()).as("response status").isEqualTo(404); } - } diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/instance/GetServiceInstancePositive.java b/src/main/java/org/onap/dcae/ci/api/tests/services/instance/GetServiceInstancePositive.java index a724b39..b22e2f7 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/instance/GetServiceInstancePositive.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/services/instance/GetServiceInstancePositive.java @@ -1,4 +1,4 @@ -package com.att.ecomp.dcae.ci.api.tests.services.instance; +package org.onap.dcae.ci.api.tests.services.instance; import static org.assertj.core.api.Assertions.assertThat; @@ -9,20 +9,19 @@ import java.util.List; import java.util.function.Predicate; import org.assertj.core.api.SoftAssertions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; import org.onap.sdc.dcae.composition.restmodels.sdc.ServiceDetailed; import org.onap.sdc.dcae.composition.services.Resource; import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; import org.onap.sdc.dcae.composition.restmodels.DcaeMinimizedService; import org.springframework.util.CollectionUtils; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; - -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; import com.aventstack.extentreports.Status; import com.google.gson.JsonArray; import com.google.gson.JsonObject; @@ -39,11 +38,11 @@ public class GetServiceInstancePositive extends DcaeRestBaseTest { DcaeMinimizedService service = arrangeService(); try { // act - ExtentTestActions.log(Status.INFO, "Get all VFIs for service [" + service.getUuid() + "]"); + Report.log(Status.INFO, "Get all VFIs for service [" + service.getUuid() + "]"); response = DcaeRestClient.getServicesInstance(service.getUuid()); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); } catch (Exception err) { - ExtentTestActions.log(Status.FAIL, "Unable to execute api call: " + err.toString()); + Report.log(Status.FAIL, "Unable to execute api call: " + err.toString()); err.printStackTrace(); } } @@ -53,16 +52,16 @@ public class GetServiceInstancePositive extends DcaeRestBaseTest { try { Predicate<DcaeMinimizedService> hasVfi = p -> !CollectionUtils.isEmpty(getService(p.getUuid()).getResources()); Vfcmt vfcmt = client.createCheckedoutVfcmt(); - ExtentTestActions.log(Status.INFO, "Created vfcmt [" + vfcmt.getUuid() + "]"); - ExtentTestActions.log(Status.INFO, "Get all services for vfcmt [" + vfcmt.getUuid() + "]"); + Report.log(Status.INFO, "Created vfcmt [" + vfcmt.getUuid() + "]"); + Report.log(Status.INFO, "Get all services for vfcmt [" + vfcmt.getUuid() + "]"); RestResponse responseServices = DcaeRestClient.getServices(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(responseServices)); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(responseServices)); DcaeMinimizedService[] servicesList = gson.fromJson(responseServices.getResponse(), DcaeMinimizedService[].class); // TODO: create a service instead of picking a random one // find a service with a vfi service = Arrays.stream(servicesList).filter(hasVfi).findAny().orElse(null); } catch (Exception err) { - ExtentTestActions.log(Status.ERROR, "Could not arrange test: " + err.toString()); + Report.log(Status.ERROR, "Could not arrange test: " + err.toString()); } return service; } @@ -72,7 +71,7 @@ public class GetServiceInstancePositive extends DcaeRestBaseTest { try { service = gson.fromJson(DcaeRestClient.getServicesInstance(serviceId).getResponse(), ServiceDetailed.class); } catch (Exception e) { - ExtentTestActions.log(Status.ERROR, "Could not arrange test: " + e.toString()); + Report.log(Status.ERROR, "Could not arrange test: " + e.toString()); } return service; } @@ -80,27 +79,27 @@ public class GetServiceInstancePositive extends DcaeRestBaseTest { @Test public void test_responseStatusOk() throws IOException{ // assert - ExtentTestActions.log(Status.INFO, "Verifing response status is 200"); + Report.log(Status.INFO, "Verifing response status is 200"); assertThat(response.getStatusCode()).as("response status").isEqualTo(200); } @Test public void test_atLeastOneOrMoreResources() throws IOException{ // assert - ExtentTestActions.log(Status.INFO, "Parsing response to a one service instance"); + Report.log(Status.INFO, "Parsing response to a one service instance"); List<Resource> resourceList = getResourceListFromJsonResponse(); - ExtentTestActions.log(Status.INFO, "validating parsed response structure"); + Report.log(Status.INFO, "validating parsed response structure"); assertThat(resourceList).size().isGreaterThanOrEqualTo(1); // TODO: create a VFI for the service instead of picking a random one } @Test public void test_responseIsValidStructure() throws IOException{ // assert - ExtentTestActions.log(Status.INFO, "Parsing response to a one service instance"); + Report.log(Status.INFO, "Parsing response to a one service instance"); List<Resource> resourceList = getResourceListFromJsonResponse(); - - ExtentTestActions.log(Status.INFO, "validating parsed response structure"); + + Report.log(Status.INFO, "validating parsed response structure"); SoftAssertions.assertSoftly(softly -> { softly.assertThat(resourceList.get(0).getResourceInstanceName()).isNotEmpty(); diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/list/GetAllServicesNagative.java b/src/main/java/org/onap/dcae/ci/api/tests/services/list/GetAllServicesNagative.java index a1935ae..be7d651 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/list/GetAllServicesNagative.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/services/list/GetAllServicesNagative.java @@ -1,20 +1,19 @@ -package com.att.ecomp.dcae.ci.api.tests.services.list; +package org.onap.dcae.ci.api.tests.services.list; import static org.assertj.core.api.Assertions.assertThat; import static org.testng.Assert.fail; import java.io.IOException; -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; import org.testng.annotations.Test; -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; + import com.aventstack.extentreports.Status; public class GetAllServicesNagative extends DcaeRestBaseTest { @@ -22,8 +21,8 @@ public class GetAllServicesNagative extends DcaeRestBaseTest { @Test public void userNotLastUpdater_statusCode403() throws Exception{ // arrange - String user1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER).getUserId(); - String user2 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2).getUserId(); + String user1 = DcaeRestClient.getDefaultUserId(); + String user2 = DcaeRestClient.getDesigner2UserId(); Vfcmt vfcmt = null; try { vfcmt = client.createCheckedoutVfcmt(user1); @@ -31,7 +30,7 @@ public class GetAllServicesNagative extends DcaeRestBaseTest { fail("Unable to arrange test", err); } // act - ExtentTestActions.log(Status.INFO, "GetServices for user that is not the vfcmt last-updater"); + Report.log(Status.INFO, "GetServices for user that is not the vfcmt last-updater"); RestResponse response = getServices(vfcmt.getUuid(), user2); // assert assertThat(response.getStatusCode()).as("response status").isEqualTo(403); @@ -42,7 +41,7 @@ public class GetAllServicesNagative extends DcaeRestBaseTest { private RestResponse getServices(String uuid, String user2) throws IOException { RestResponse response = DcaeRestClient.getServices(uuid, user2); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); return response; } } diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/list/GetAllServicesPositive.java b/src/main/java/org/onap/dcae/ci/api/tests/services/list/GetAllServicesPositive.java index 88a7b71..b8b947f 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/list/GetAllServicesPositive.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/services/list/GetAllServicesPositive.java @@ -1,4 +1,4 @@ -package com.att.ecomp.dcae.ci.api.tests.services.list; +package org.onap.dcae.ci.api.tests.services.list; import static org.assertj.core.api.Assertions.assertThat; @@ -7,16 +7,16 @@ import java.lang.reflect.Type; import java.util.List; import org.assertj.core.api.SoftAssertions; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; + import org.onap.sdc.dcae.composition.restmodels.sdc.Service; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; import com.aventstack.extentreports.Status; import com.google.gson.reflect.TypeToken; @@ -26,17 +26,17 @@ public class GetAllServicesPositive extends DcaeRestBaseTest { @BeforeClass public void executeApiCall() throws Exception { - ExtentTestActions.log(Status.INFO, "@BeforeClass --> executeApiCall"); + Report.log(Status.INFO, "@BeforeClass --> executeApiCall"); Vfcmt component = client.createCheckedoutVfcmt(); String uuid = component.getUuid(); String userIdLastUpdaterUserId = component.getLastUpdaterUserId(); try { // act - ExtentTestActions.log(Status.INFO, "Get all services"); + Report.log(Status.INFO, "Get all services"); response = DcaeRestClient.getServices(uuid, userIdLastUpdaterUserId); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); } catch (Exception err) { - ExtentTestActions.log(Status.ERROR, err); + Report.log(Status.ERROR, err); err.printStackTrace(); } } @@ -44,19 +44,19 @@ public class GetAllServicesPositive extends DcaeRestBaseTest { @Test public void test_responseStatusOk() throws IOException{ // assert - ExtentTestActions.log(Status.INFO, "Verifing response status is 200"); + Report.log(Status.INFO, "Verifing response status is 200"); assertThat(response.getStatusCode()).as("response status").isEqualTo(200); } @Test public void test_responseIsValidStructure() throws IOException{ // assert - ExtentTestActions.log(Status.INFO, "Parsing response to a List of Services"); + Report.log(Status.INFO, "Parsing response to a List of Services"); Type listType = new TypeToken<List<Service>>(){}.getType(); List<Service> servicesList = gson.fromJson(response.getResponse(), listType); Service service = servicesList.get(0); - - ExtentTestActions.log(Status.INFO, "validating parsed response structure"); + + Report.log(Status.INFO, "validating parsed response structure"); SoftAssertions.assertSoftly(softly -> { softly.assertThat(service.getInvariantUUID()).isNotEmpty(); diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/CreateMonitoringComponent.java b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/CreateMonitoringComponent.java index 33dd50f..1dc27d6 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/CreateMonitoringComponent.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/CreateMonitoringComponent.java @@ -1,9 +1,12 @@ -package com.att.ecomp.dcae.ci.api.tests.vfcmt; +package org.onap.dcae.ci.api.tests.vfcmt; + -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; import com.aventstack.extentreports.Status; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; import org.onap.sdc.dcae.composition.restmodels.CreateMcResponse; import org.onap.sdc.dcae.composition.restmodels.CreateVFCMTRequest; import org.onap.sdc.dcae.composition.restmodels.ImportVFCMTRequest; @@ -13,10 +16,7 @@ import org.onap.sdc.dcae.composition.restmodels.sdc.ResourceDetailed; import org.onap.sdc.dcae.composition.services.Service; import org.onap.sdc.dcae.composition.util.DcaeBeConstants; import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; + import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -37,14 +37,14 @@ public class CreateMonitoringComponent extends DcaeRestBaseTest { // arrange try { // act - ExtentTestActions.log(Status.INFO, "Creating vfcmt"); + Report.log(Status.INFO, "Creating vfcmt"); RestResponse clientResponse = DcaeRestClient.getAllMonitoringTemplatesVfcmts(); Resource[] resources = gson.fromJson(clientResponse.getResponse(),Resource[].class); if (resources.length > 0){ res = resources[0]; } } catch (Exception err) { - ExtentTestActions.log(Status.ERROR, err); + Report.log(Status.ERROR, err); } } @@ -56,7 +56,7 @@ public class CreateMonitoringComponent extends DcaeRestBaseTest { try { service = createServiceWithVFiAsSdcDesigner(); } catch (Exception e) { - ExtentTestActions.log(Status.ERROR, e); + Report.log(Status.ERROR, e); return; } @@ -82,7 +82,7 @@ public class CreateMonitoringComponent extends DcaeRestBaseTest { RestResponse r = DcaeRestClient.getAttachedService(vfUuid); assertThat(r.getResponse().contains(service.getUuid())).isTrue(); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); } @Test @@ -96,7 +96,7 @@ public class CreateMonitoringComponent extends DcaeRestBaseTest { response = DcaeRestClient.createMc(gson.toJson(request),fakeUserId); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); // assert assertThat(response.getStatusCode()) .as("status code") @@ -111,7 +111,7 @@ public class CreateMonitoringComponent extends DcaeRestBaseTest { try { service = createServiceWithVFiAsSdcDesigner(); } catch (Exception e) { - ExtentTestActions.log(Status.ERROR, e); + Report.log(Status.ERROR, e); return; } @@ -136,7 +136,7 @@ public class CreateMonitoringComponent extends DcaeRestBaseTest { .isEqualTo(200); Map<String, List<Map>> refs = gson.fromJson(response.getResponse(), Map.class); assertThat(vfcmt.getUuid().equals(refs.get("monitoringComponents").get(0).get("uuid"))).isTrue(); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); } @Test @@ -147,7 +147,7 @@ public class CreateMonitoringComponent extends DcaeRestBaseTest { try { service = createServiceWithVFiAsSdcDesigner(); } catch (Exception e) { - ExtentTestActions.log(Status.ERROR, e); + Report.log(Status.ERROR, e); return; } @@ -171,14 +171,14 @@ public class CreateMonitoringComponent extends DcaeRestBaseTest { response = DcaeRestClient.getResourceDetails(vfcmt.getUuid()); ResourceDetailed updatedMC = gson.fromJson(response.getResponse(), ResourceDetailed.class); assertThat(updatedMC.getVersion()).isEqualTo("0.2"); - assertThat(updatedMC.getLastUpdaterUserId()).isEqualTo(DcaeRestClient.getDefaultUser().getUserId()); + assertThat(updatedMC.getLastUpdaterUserId()).isEqualTo(DcaeRestClient.getDefaultUserId()); assertThat(updatedMC.getLifecycleState()).isEqualTo(DcaeBeConstants.LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name()); // assert that the updated cdump includes 'flowType' response = DcaeRestClient.getComposition(vfcmt.getUuid()); String cdump = gson.fromJson(response.getResponse(), MessageResponse.class).getSuccessResponse(); assertThat(cdump).isEqualTo("{\"flowType\":\"flowType_xxx\",\"cid\":\"1234567\"}"); - ExtentTestActions.log(Status.DEBUG, "Response updated mock cdump: " + cdump); + Report.log(Status.DEBUG, "Response updated mock cdump: " + cdump); } @Test @@ -189,7 +189,7 @@ public class CreateMonitoringComponent extends DcaeRestBaseTest { try { service = createServiceWithVFiAsSdcDesigner(); } catch (Exception e) { - ExtentTestActions.log(Status.ERROR, e); + Report.log(Status.ERROR, e); return; } @@ -218,7 +218,7 @@ public class CreateMonitoringComponent extends DcaeRestBaseTest { String ref = gson.fromJson(response.getResponse(), MessageResponse.class).getSuccessResponse(); assertThat(ref).isEqualTo(service.getUuid()+"/resources/"+vfiName); - ExtentTestActions.log(Status.DEBUG, "Response cloned Monitoring component: " + mcResponse); + Report.log(Status.DEBUG, "Response cloned Monitoring component: " + mcResponse); } @Test @@ -234,7 +234,7 @@ public class CreateMonitoringComponent extends DcaeRestBaseTest { .as("status code") .isEqualTo(404); - ExtentTestActions.log(Status.DEBUG, "Error response: " + response.getResponse()); + Report.log(Status.DEBUG, "Error response: " + response.getResponse()); // assert vfcmt version was not increased response = DcaeRestClient.getResourceDetails(vfcmt.getUuid()); vfcmt = gson.fromJson(response.getResponse(), Vfcmt.class); @@ -243,7 +243,7 @@ public class CreateMonitoringComponent extends DcaeRestBaseTest { private Vfcmt prepareMockVfcmtForImport() throws IOException { - RestResponse createResponse = DcaeRestClient.createVfcmt(StringUtils.randomString("CI-", 20), "description", ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2).getUserId()); + RestResponse createResponse = DcaeRestClient.createVfcmt(StringUtils.randomString("CI-", 20), "description", DcaeRestClient.getDesigner2UserId()); Vfcmt vfcmt = gson.fromJson(createResponse.getResponse(), Vfcmt.class); // create a composition artifact DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), "{\"cid\":\"1234567\"}"); diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/CreateVfcmt.java b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/CreateVfcmt.java index deb1020..6ca6053 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/CreateVfcmt.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/CreateVfcmt.java @@ -1,23 +1,20 @@ -package com.att.ecomp.dcae.ci.api.tests.vfcmt; +package org.onap.dcae.ci.api.tests.vfcmt; import static org.assertj.core.api.Assertions.*; import java.io.IOException; import org.assertj.core.api.SoftAssertions; -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.datatypes.User; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.utilities.DcaeTestConstants; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; import org.testng.annotations.*; -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.DcaeTestConstants; import com.aventstack.extentreports.Status; -import com.att.ecomp.dcae.ci.utilities.StringUtils; public class CreateVfcmt extends DcaeRestBaseTest { @@ -32,12 +29,11 @@ public class CreateVfcmt extends DcaeRestBaseTest { input.setDescription(StringUtils.randomString("", 10)); try { // act - ExtentTestActions.log(Status.INFO, "Creating vfcmt"); + Report.log(Status.INFO, "Creating vfcmt"); response = DcaeRestClient.createVfcmt(input.getName(), input.getDescription()); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); } catch (Exception err) { - ExtentTestActions.log(Status.ERROR, err); - err.printStackTrace(); + Report.log(Status.ERROR, err); } } @@ -46,21 +42,21 @@ public class CreateVfcmt extends DcaeRestBaseTest { @Test public void test_responseStatusOk() throws IOException { // assert - ExtentTestActions.log(Status.INFO, "Verifing response status is 200"); + Report.log(Status.INFO, "Verifing response status is 200"); assertThat(response.getStatusCode()).as("response status").isEqualTo(200); } @Test public void test_responseIsValidStructure() throws IOException { // assert - ExtentTestActions.log(Status.INFO, "Parsing response to a VFCMT"); + Report.log(Status.INFO, "Parsing response to a VFCMT"); Vfcmt createdVfcmt = gson.fromJson(response.getResponse(), Vfcmt.class); - ExtentTestActions.log(Status.INFO, "validating parsed response structure"); + Report.log(Status.INFO, "validating parsed response structure"); SoftAssertions.assertSoftly(softly -> { softly.assertThat(createdVfcmt.getCategory()).isEqualTo("Template"); softly.assertThat(createdVfcmt.getInvariantUUID()).isNotEmpty(); softly.assertThat(createdVfcmt.getUuid()).isNotEmpty(); - softly.assertThat(createdVfcmt.getLastUpdaterUserId()).isEqualTo(DcaeRestClient.getDefaultUser().getUserId()); + softly.assertThat(createdVfcmt.getLastUpdaterUserId()).isEqualTo(DcaeRestClient.getDefaultUserId()); softly.assertThat(createdVfcmt.getLifecycleState()).isEqualTo(DcaeTestConstants.Sdc.State.NOT_CERTIFIED_CHECKOUT); softly.assertThat(createdVfcmt.getName()).isEqualTo(input.getName()); softly.assertThat(createdVfcmt.getDescription()).isEqualTo(input.getDescription()); @@ -72,17 +68,7 @@ public class CreateVfcmt extends DcaeRestBaseTest { /* Negative tests */ -// @Test -// public void testNameLengthGraterThen50_TBD() throws IOException { -// // arrange -// int length = 51; -// String name = StringUtils.randomString("CI-", length); -// String description = StringUtils.randomString("", 10); -// // act -// RestResponse response = DcaeRestClient.createVfcmt(name, description); -// // assert -// -// } + @Test public void testWithNonExistingUser_status403() throws IOException { @@ -91,11 +77,11 @@ public class CreateVfcmt extends DcaeRestBaseTest { String name = StringUtils.randomString("CI-", 20); String description = StringUtils.randomString("", 10); // act - ExtentTestActions.log(Status.INFO, "Creating vfcmt with fake user"); - RestResponse response = DcaeRestClient.createVfcmt(name, description, fakeUserId); - ExtentTestActions.log(Status.DEBUG, "response: " + StringUtils.truncate(response)); + Report.log(Status.INFO, "Creating vfcmt with fake user"); + RestResponse res = DcaeRestClient.createVfcmt(name, description, fakeUserId); + Report.log(Status.DEBUG, "response: " + StringUtils.truncate(res)); // assert - assertThat(response.getStatusCode()) + assertThat(res.getStatusCode()) .as("status code") .isEqualTo(403); } @@ -104,16 +90,16 @@ public class CreateVfcmt extends DcaeRestBaseTest { public void testCreateTwoVfcmtsWithSameName_status409() throws IOException { // arrange String name = StringUtils.randomString("CI-", 20); - ExtentTestActions.log(Status.INFO, "Creating first vfcmt with name '" + name + "'"); + Report.log(Status.INFO, "Creating first vfcmt with name '" + name + "'"); RestResponse response1 = DcaeRestClient.createVfcmt(name, StringUtils.randomString("", 10)); - ExtentTestActions.log(Status.DEBUG, "First Response: " + StringUtils.truncate(response1)); + Report.log(Status.DEBUG, "First Response: " + StringUtils.truncate(response1)); if (response1.getStatusCode() != 200) { fail("unable to arrange test - could not create the first vfcmt"); } // act - ExtentTestActions.log(Status.INFO, "Creating second vfcmt with same name '" + name + "'"); + Report.log(Status.INFO, "Creating second vfcmt with same name '" + name + "'"); RestResponse response2 = DcaeRestClient.createVfcmt(name, StringUtils.randomString("", 10)); - ExtentTestActions.log(Status.DEBUG, "Second response: " + StringUtils.truncate(response2)); + Report.log(Status.DEBUG, "Second response: " + StringUtils.truncate(response2)); // assert assertThat(response2.getStatusCode()) .as("second status code") @@ -123,13 +109,13 @@ public class CreateVfcmt extends DcaeRestBaseTest { @Test public void testWithNonDesignerRole_status403() throws IOException { // arrange - User tester = ElementFactory.getDefaultUser(UserRoleEnum.TESTER); + String testerId = DcaeRestClient.getDefaultTesterId(); String name = StringUtils.randomString("CI-", 20); String description = StringUtils.randomString("", 10); // act - ExtentTestActions.log(Status.INFO, "Creating vfcmt with role tester"); - RestResponse response = DcaeRestClient.createVfcmt(name, description, tester.getUserId()); - ExtentTestActions.log(Status.DEBUG, "response: " + StringUtils.truncate(response)); + Report.log(Status.INFO, "Creating vfcmt with role tester"); + RestResponse response = DcaeRestClient.createVfcmt(name, description, testerId); + Report.log(Status.DEBUG, "response: " + StringUtils.truncate(response)); // assert assertThat(response.getStatusCode()) .as("status code") diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetAllMonitoringTemplateVfcmts.java b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetAllMonitoringTemplateVfcmts.java index 874c00d..4a9a952 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetAllMonitoringTemplateVfcmts.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetAllMonitoringTemplateVfcmts.java @@ -1,12 +1,13 @@ -package com.att.ecomp.dcae.ci.api.tests.vfcmt; +package org.onap.dcae.ci.api.tests.vfcmt; -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; import com.aventstack.extentreports.Status; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; + import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -21,37 +22,37 @@ public class GetAllMonitoringTemplateVfcmts extends DcaeRestBaseTest { public void executeApiCall() { try { // act - ExtentTestActions.log(Status.INFO, "Fetching all monitoring templates vfcmt resources"); + Report.log(Status.INFO, "Fetching all monitoring templates vfcmt resources"); response = DcaeRestClient.getAllMonitoringTemplatesVfcmts(); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); } catch (Exception err) { - ExtentTestActions.log(Status.ERROR, err); + Report.log(Status.ERROR, err); } } @Test public void testResponseStatusOk() { // assert - ExtentTestActions.log(Status.INFO, "Verifying response status is 200"); + Report.log(Status.INFO, "Verifying response status is 200"); assertThat(response.getStatusCode()).as("response status").isEqualTo(200); } @Test public void testResponseBodyIsListOfVfcmtsOnly() { // assert - ExtentTestActions.log(Status.INFO, "Parsing response to a list of monitoring template VFCMTs"); + Report.log(Status.INFO, "Parsing response to a list of monitoring template VFCMTs"); Vfcmt[] vfcmtList = gson.fromJson(response.getResponse(), Vfcmt[].class); - ExtentTestActions.log(Status.INFO, "Verifying we got items"); + Report.log(Status.INFO, "Verifying we got items"); assertThat(vfcmtList).isNotEmpty(); - ExtentTestActions.log(Status.INFO, "Verifying all items of the parsed response are VFCMTs"); + Report.log(Status.INFO, "Verifying all items of the parsed response are VFCMTs"); assertThat(vfcmtList) .as("response data") .extracting("resourceType") .containsOnly("VFCMT"); - ExtentTestActions.log(Status.INFO, "Verifying that all items of the parsed response are monitoring template VFCMTs"); + Report.log(Status.INFO, "Verifying that all items of the parsed response are monitoring template VFCMTs"); assertThat(vfcmtList) .as("response data") .extracting("subCategory") diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetAllVfcmts.java b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetAllVfcmts.java index 3483de7..65e3f91 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetAllVfcmts.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetAllVfcmts.java @@ -1,15 +1,17 @@ -package com.att.ecomp.dcae.ci.api.tests.vfcmt; +package org.onap.dcae.ci.api.tests.vfcmt; import static org.assertj.core.api.Assertions.*; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; import org.testng.annotations.*; -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; + import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; + import com.aventstack.extentreports.Status; public class GetAllVfcmts extends DcaeRestBaseTest { @@ -20,12 +22,11 @@ public class GetAllVfcmts extends DcaeRestBaseTest { public void executeApiCall() { try { // act - ExtentTestActions.log(Status.INFO, "Fetching all vfcmt resources"); + Report.log(Status.INFO, "Fetching all vfcmt resources"); response = DcaeRestClient.getAllVfcmts(); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); } catch (Exception err) { - ExtentTestActions.log(Status.ERROR, err); - err.printStackTrace(); + Report.log(Status.ERROR, err); } } @@ -34,16 +35,16 @@ public class GetAllVfcmts extends DcaeRestBaseTest { @Test public void testResponseStatusOk() { // assert - ExtentTestActions.log(Status.INFO, "Verifing response status is 200"); + Report.log(Status.INFO, "Verifying response status is 200"); assertThat(response.getStatusCode()).as("response status").isEqualTo(200); } @Test public void testResponseBodyIsListOfVfcmtsOnly() { // assert - ExtentTestActions.log(Status.INFO, "Parsing response to a list of VFCMTs"); + Report.log(Status.INFO, "Parsing response to a list of VFCMTs"); Vfcmt[] vfcmtList = gson.fromJson(response.getResponse(), Vfcmt[].class); - ExtentTestActions.log(Status.INFO, "Verifing all items of the parsed response are VFCMTs"); + Report.log(Status.INFO, "Verifying all items of the parsed response are VFCMTs"); assertThat(vfcmtList) .as("response data") .extracting("resourceType") diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetVfcmtsForMigration.java b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetVfcmtsForMigration.java index f63ab7f..c12a14c 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetVfcmtsForMigration.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetVfcmtsForMigration.java @@ -1,15 +1,16 @@ -package com.att.ecomp.dcae.ci.api.tests.vfcmt; +package org.onap.dcae.ci.api.tests.vfcmt; + -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; import com.aventstack.extentreports.Status; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; import org.onap.sdc.dcae.composition.restmodels.CreateMcResponse; import org.onap.sdc.dcae.composition.restmodels.CreateVFCMTRequest; import org.onap.sdc.dcae.composition.restmodels.sdc.Resource; import org.onap.sdc.dcae.composition.services.Service; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -29,30 +30,21 @@ public class GetVfcmtsForMigration extends DcaeRestBaseTest { public void executeApiCall() { try { // act - ExtentTestActions.log(Status.INFO, "Selecting vfcmt resources for migration"); + Report.log(Status.INFO, "Selecting vfcmt resources for migration"); response = DcaeRestClient.getVfcmtsForMigration("services","1111111","1.3"); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - ExtentTestActions.log(Status.INFO, "getAllMonitoringTemplatesVfcmts"); + Report.log(Status.INFO, "getAllMonitoringTemplatesVfcmts"); RestResponse clientResponse = DcaeRestClient.getAllMonitoringTemplatesVfcmts(); Resource[] resources = gson.fromJson(clientResponse.getResponse(),Resource[].class); if (resources.length > 0){ res = resources[0]; } } catch (Exception err) { - ExtentTestActions.log(Status.ERROR, err); - err.printStackTrace(); + Report.log(Status.ERROR, err); } } - @Test - public void testResponseStatus500ServiceNotFound() { - // assert - ExtentTestActions.log(Status.INFO, "Verifing response status is 500"); - assertThat(response.getStatusCode()).as("response status").isEqualTo(500); - assertThat(response.getResponse().contains("resource was not found")); - } - // If tests are taking too long: consider removing this very tedious and long test @Test public void testCreateMonitoringComponentSuccess() throws IOException { @@ -65,7 +57,7 @@ public class GetVfcmtsForMigration extends DcaeRestBaseTest { try { service = createServiceWithVFiAsSdcDesigner(); } catch (Exception e) { - e.printStackTrace(); + Report.log(Status.ERROR, e); return; } @@ -79,18 +71,18 @@ public class GetVfcmtsForMigration extends DcaeRestBaseTest { List<String> listOfVfcmtsConnectedToService = new ArrayList<>(); for (int i = 0 ; i < 4 ; i++){ request.setName(StringUtils.randomString("CI-", 20)); - addMandatoryInputFieldsToRequestObject(request); + DcaeRestClient.fillCreateMcRequestMandatoryFields(request); response = DcaeRestClient.createMc(gson.toJson(request)); assertThat(response.getStatusCode()).as(STATUS_CODE).isEqualTo(200); CreateMcResponse mcResponse = gson.fromJson(response.getResponse(),CreateMcResponse.class); String key = mcResponse.getVfcmt().getUuid(); String value = gson.toJson(mcResponse.getCdump()); assertThat(value.contains(key)).isTrue(); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); listOfVfcmtsConnectedToService.add(key); } - response = DcaeRestClient.getVfcmtsForMigration("services",service.getUuid(),service.getVersion()); + response = DcaeRestClient.getVfcmtsForMigration("service",service.getUuid(),service.getVersion()); assertThat(response.getStatusCode()).as(STATUS_CODE).isEqualTo(200); listOfVfcmtsConnectedToService.forEach( s -> assertThat(response.getResponse().contains(s)).isFalse()); diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/VfcmtCreationFlow.java b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/VfcmtCreationFlow.java index 34f4686..f5ed264 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/VfcmtCreationFlow.java +++ b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/VfcmtCreationFlow.java @@ -1,10 +1,10 @@ -package com.att.ecomp.dcae.ci.api.tests.vfcmt; +package org.onap.dcae.ci.api.tests.vfcmt; -import org.openecomp.d2.ci.report.ExtentTestActions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.report.Report; import org.testng.annotations.*; import static org.assertj.core.api.Assertions.*; -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; import com.aventstack.extentreports.Status; import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; @@ -16,21 +16,21 @@ public class VfcmtCreationFlow extends DcaeRestBaseTest { @BeforeClass public void executeFlow() throws Exception { - ExtentTestActions.log(Status.INFO, "@BeforeClass --> executeFlow (getAllVfcmts)"); + Report.log(Status.INFO, "@BeforeClass --> executeFlow (getAllVfcmts)"); try { // act vfcmtsBeforeAdd = client.getAllVfcmts(); newVfcmt = client.createVfcmt(); vfcmtsAfterAdd = client.getAllVfcmts(); } catch (Exception err) { - ExtentTestActions.log(Status.ERROR, err); + Report.log(Status.ERROR, err); err.printStackTrace(); } } @Test public void test_numberOfVfcmtsIncresed() { - ExtentTestActions.log(Status.INFO, String.format("asserting (after[%d] > before[%d])", vfcmtsAfterAdd.length, vfcmtsBeforeAdd.length)); + Report.log(Status.INFO, String.format("asserting (after[%d] > before[%d])", vfcmtsAfterAdd.length, vfcmtsBeforeAdd.length)); // assert assertThat(vfcmtsAfterAdd.length).isGreaterThan(vfcmtsBeforeAdd.length); } diff --git a/src/main/java/org/onap/dcae/ci/config/Configuration.java b/src/main/java/org/onap/dcae/ci/config/Configuration.java new file mode 100644 index 0000000..0631800 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/config/Configuration.java @@ -0,0 +1,299 @@ +package org.onap.dcae.ci.config; + +import org.yaml.snakeyaml.Yaml; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.OpenOption; +import java.nio.file.Paths; + +public class Configuration { + private String apiPath; + private String dcaeBeHost; + private String beHost; + private String feHost; + private int bePort; + private int fePort; + private String dcaeBePort; + 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 String ruleEditorUrl; + + public Configuration() { + this.basicInit((String) null); + } + + public Configuration(String url) { + this.basicInit(url); + } + + public static synchronized Configuration loadConfigFile(File configFile) { + return loadConfigFile(configFile, Configuration.class); + } + + private void basicInit(String url) { + this.remoteTesting = false; + this.captureTraffic = false; + this.useBrowserMobProxy = false; + this.reportFolder = "." + File.separator + "ExtentReport" + File.separator; + this.reportFileName = "UI_Extent_Report.html"; + this.screenshotFolder = this.reportFolder + "screenshots" + File.separator; + this.harFilesFolder = this.reportFolder + "har_files" + File.separator; + this.browser = "firefox"; + this.url = url; + this.numOfAttemptsToRefresh = 2; + } + + public String getBeHost() { + return this.beHost; + } + + public void setBeHost(String beHost) { + this.beHost = beHost; + } + + public String getFeHost() { + return this.feHost; + } + + public void setFeHost(String feHost) { + this.feHost = feHost; + } + + public int getBePort() { + return this.bePort; + } + + public void setBePort(int bePort) { + this.bePort = bePort; + } + + public int getFePort() { + return this.fePort; + } + + public void setFePort(int fePort) { + this.fePort = fePort; + } + + public String getUrl() { + return this.url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getRemoteTestingMachineIP() { + return this.remoteTestingMachineIP; + } + + public void setRemoteTestingMachineIP(String remoteTestingMachineIP) { + this.remoteTestingMachineIP = remoteTestingMachineIP; + } + + public int getRemoteTestingMachinePort() { + return this.remoteTestingMachinePort; + } + + public void setRemoteTestingMachinePort(int remoteTestingMachinePort) { + this.remoteTestingMachinePort = remoteTestingMachinePort; + } + + public boolean isRemoteTesting() { + return this.remoteTesting; + } + + public void setRemoteTesting(boolean remoteTesting) { + this.remoteTesting = remoteTesting; + } + + public String getBrowser() { + return this.browser; + } + + public void setBrowser(String browser) { + this.browser = browser; + } + + public String getSystemUnderDebug() { + return this.systemUnderDebug; + } + + public void setSystemUnderDebug(String systemUnderDebug) { + this.systemUnderDebug = systemUnderDebug; + } + + public String getReportDBhost() { + return this.reportDBhost; + } + + public void setReportDBhost(String reportDBhost) { + this.reportDBhost = reportDBhost; + } + + public int getReportDBport() { + return this.reportDBport; + } + + public void setReportDBport(int reportDBport) { + this.reportDBport = reportDBport; + } + + public boolean isCaptureTraffic() { + return this.captureTraffic; + } + + public void setCaptureTraffic(boolean captureTraffic) { + this.captureTraffic = captureTraffic; + } + + public boolean isUseBrowserMobProxy() { + return this.useBrowserMobProxy; + } + + public void setUseBrowserMobProxy(boolean useBrowserMobProxy) { + this.useBrowserMobProxy = useBrowserMobProxy; + } + + public String getStopOnClassFailure() { + return this.stopOnClassFailure; + } + + public void setStopOnClassFailure(String stopOnClassFailure) { + this.stopOnClassFailure = stopOnClassFailure; + } + + public String getReportFileName() { + return this.reportFileName; + } + + public void setReportFileName(String reportFileName) { + this.reportFileName = reportFileName; + } + + public String getReportFolder() { + return this.reportFolder; + } + + public void setReportFolder(String reportFolder) { + this.reportFolder = reportFolder; + } + + public int getNumOfAttemptsToRefresh() { + return this.numOfAttemptsToRefresh; + } + + public void setNumOfAttemptsToRefresh(int numOfAttemptsToRefresh) { + this.numOfAttemptsToRefresh = numOfAttemptsToRefresh; + } + + public boolean isRerun() { + return this.rerun; + } + + public void setRerun(boolean rerun) { + this.rerun = rerun; + } + + public String getWindowsDownloadDirectory() { + return this.windowsDownloadDirectory; + } + + public void setWindowsDownloadDirectory(String windowsDownloadDirectory) { + this.windowsDownloadDirectory = windowsDownloadDirectory; + } + + public String getScreenshotFolder() { + return this.screenshotFolder; + } + + public void setScreenshotFolder(String screenshotFolder) { + this.screenshotFolder = screenshotFolder; + } + + public String getHarFilesFolder() { + return this.harFilesFolder; + } + + public void setHarFilesFolder(String harFilesFolder) { + this.harFilesFolder = harFilesFolder; + } + + public String getDcaeBeHost() { + return dcaeBeHost; + } + + public void setDcaeBeHost(String dcaeBeHost) { + this.dcaeBeHost = dcaeBeHost; + } + + public String getDcaeBePort() { + return dcaeBePort; + } + + public void setDcaeBePort(String dcaeBePort) { + this.dcaeBePort = dcaeBePort; + } + + public String getApiPath() { + return apiPath; + } + + public void setApiPath(String apiPath) { + this.apiPath = apiPath; + } + + public String getRuleEditorUrl() { + return ruleEditorUrl; + } + + public void setRuleEditorUrl(String ruleEditorUrl) { + this.ruleEditorUrl = ruleEditorUrl; + } + + + public static synchronized <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, new String[0]), new OpenOption[0]); + Yaml yaml = new Yaml(); + config = yaml.loadAs(in, clazz); + } catch (IOException var14) { + var14.printStackTrace(); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException var13) { + var13.printStackTrace(); + } + } + + } + + return config; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/RestResponse.java b/src/main/java/org/onap/dcae/ci/entities/RestResponse.java new file mode 100644 index 0000000..4e5b60f --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/RestResponse.java @@ -0,0 +1,57 @@ +package org.onap.dcae.ci.entities; + +import java.util.List; +import java.util.Map; + +public class RestResponse { + Integer statusCode; + String response; + Map<String, List<String>> headerFields; + String responseMessage; + + public RestResponse() { + } + + public RestResponse(Integer errorCode, String response, Map<String, List<String>> headerFields, String responseMessage) { + this.statusCode = errorCode; + this.response = response; + this.headerFields = headerFields; + this.responseMessage = responseMessage; + } + + public Integer getStatusCode() { + return this.statusCode; + } + + public void setStatusCode(Integer errorCode) { + this.statusCode = errorCode; + } + + public String getResponse() { + return this.response; + } + + public void setResponse(String response) { + this.response = response; + } + + public Map<String, List<String>> getHeaderFields() { + return this.headerFields; + } + + public void setHeaderFields(Map<String, List<String>> headerFields) { + this.headerFields = headerFields; + } + + public String getResponseMessage() { + return this.responseMessage; + } + + public void setResponseMessage(String responseMessage) { + this.responseMessage = responseMessage; + } + + public String toString() { + return "RestResponse [errorCode=" + this.statusCode + ", response=" + this.response + ", headerFields=" + this.headerFields + ", responseMessage=" + this.responseMessage + "]"; + } +} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Artifact.java b/src/main/java/org/onap/dcae/ci/entities/composition/items/Artifact.java index c7687d2..eae61ea 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Artifact.java +++ b/src/main/java/org/onap/dcae/ci/entities/composition/items/Artifact.java @@ -1,5 +1,5 @@ -package com.att.ecomp.dcae.ci.entities.composition.items; +package org.onap.dcae.ci.entities.composition.items; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Data.java b/src/main/java/org/onap/dcae/ci/entities/composition/items/Data.java index 267c296..f7f44d3 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Data.java +++ b/src/main/java/org/onap/dcae/ci/entities/composition/items/Data.java @@ -1,5 +1,5 @@ -package com.att.ecomp.dcae.ci.entities.composition.items; +package org.onap.dcae.ci.entities.composition.items; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/DcaeComponents.java b/src/main/java/org/onap/dcae/ci/entities/composition/items/DcaeComponents.java index 26a7000..c434a0d 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/DcaeComponents.java +++ b/src/main/java/org/onap/dcae/ci/entities/composition/items/DcaeComponents.java @@ -1,9 +1,11 @@ -package com.att.ecomp.dcae.ci.entities.composition.items; +package org.onap.dcae.ci.entities.composition.items; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; +import java.lang.*; + public class DcaeComponents { @SerializedName("id") @@ -17,7 +19,7 @@ public class DcaeComponents { private Data data; @SerializedName("error") @Expose - private Error error; + private java.lang.Error error; public Object getId() { return id; @@ -43,11 +45,11 @@ public class DcaeComponents { this.data = data; } - public Error getError() { + public java.lang.Error getError() { return error; } - public void setError(Error error) { + public void setError(java.lang.Error error) { this.error = error; } diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Element.java b/src/main/java/org/onap/dcae/ci/entities/composition/items/Element.java index f681587..64c6601 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Element.java +++ b/src/main/java/org/onap/dcae/ci/entities/composition/items/Element.java @@ -1,5 +1,5 @@ -package com.att.ecomp.dcae.ci.entities.composition.items; +package org.onap.dcae.ci.entities.composition.items; import java.util.List; import com.google.gson.annotations.Expose; diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/items/Error.java b/src/main/java/org/onap/dcae/ci/entities/composition/items/Error.java new file mode 100644 index 0000000..bad41a1 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/items/Error.java @@ -0,0 +1,8 @@ + +package org.onap.dcae.ci.entities.composition.items; + + +public class Error { + + +} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Item.java b/src/main/java/org/onap/dcae/ci/entities/composition/items/Item.java index 777e4aa..a184886 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Item.java +++ b/src/main/java/org/onap/dcae/ci/entities/composition/items/Item.java @@ -1,5 +1,5 @@ -package com.att.ecomp.dcae.ci.entities.composition.items; +package org.onap.dcae.ci.entities.composition.items; import java.util.List; import com.google.gson.annotations.Expose; diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Model.java b/src/main/java/org/onap/dcae/ci/entities/composition/items/Model.java index a1b732f..2b3a85b 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Model.java +++ b/src/main/java/org/onap/dcae/ci/entities/composition/items/Model.java @@ -1,5 +1,5 @@ -package com.att.ecomp.dcae.ci.entities.composition.items; +package org.onap.dcae.ci.entities.composition.items; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Artifact.java b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Artifact.java index 413fda7..4d095ab 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Artifact.java +++ b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Artifact.java @@ -1,5 +1,5 @@ -package com.att.ecomp.dcae.ci.entities.composition.rightMenu.element; +package org.onap.dcae.ci.entities.composition.rightMenu.element; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Item.java b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Item.java index f0b5cfa..aa96b43 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Item.java +++ b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Item.java @@ -1,5 +1,5 @@ -package com.att.ecomp.dcae.ci.entities.composition.rightMenu.element; +package org.onap.dcae.ci.entities.composition.rightMenu.element; import java.util.List; import com.google.gson.annotations.Expose; diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/ItemsElement.java b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/ItemsElement.java index f1fce3e..d7ed2cb 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/ItemsElement.java +++ b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/ItemsElement.java @@ -1,5 +1,5 @@ -package com.att.ecomp.dcae.ci.entities.composition.rightMenu.element; +package org.onap.dcae.ci.entities.composition.rightMenu.element; import java.util.List; import com.google.gson.annotations.Expose; diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Model.java b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Model.java index b5e7fad..4541aaf 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Model.java +++ b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Model.java @@ -1,5 +1,5 @@ -package com.att.ecomp.dcae.ci.entities.composition.rightMenu.element; +package org.onap.dcae.ci.entities.composition.rightMenu.element; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Service.java b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Service.java index 7001293..3c33535 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Service.java +++ b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Service.java @@ -1,5 +1,5 @@ -package com.att.ecomp.dcae.ci.entities.composition.rightMenu.element; +package org.onap.dcae.ci.entities.composition.rightMenu.element; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/elements/Element.java b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/elements/Element.java index eb8e592..350a350 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/elements/Element.java +++ b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/elements/Element.java @@ -1,4 +1,4 @@ -package com.att.ecomp.dcae.ci.entities.composition.rightMenu.elements; +package org.onap.dcae.ci.entities.composition.rightMenu.elements; import java.util.List; import com.google.gson.annotations.Expose; diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/elements/Elements.java b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/elements/Elements.java index aea6e20..b5dad46 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/elements/Elements.java +++ b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/elements/Elements.java @@ -1,4 +1,4 @@ -package com.att.ecomp.dcae.ci.entities.composition.rightMenu.elements; +package org.onap.dcae.ci.entities.composition.rightMenu.elements; import java.util.List; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/services/CiService.java b/src/main/java/org/onap/dcae/ci/entities/composition/services/CiService.java new file mode 100644 index 0000000..5a272b6 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/services/CiService.java @@ -0,0 +1,11 @@ +package org.onap.dcae.ci.entities.composition.services; + +import org.onap.dcae.ci.entities.sdc.SdcService; +import org.onap.sdc.dcae.composition.services.Service; + +public class CiService extends Service { + // partial construction - converts from internal SDC object to dcae-ci object (external SDC) + public CiService(SdcService service) { + super(service.getName(), service.getUuid(), service.getVersion()); + } +} diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/services/Vfi.java b/src/main/java/org/onap/dcae/ci/entities/composition/services/Vfi.java new file mode 100644 index 0000000..4b084d6 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/services/Vfi.java @@ -0,0 +1,21 @@ +package org.onap.dcae.ci.entities.composition.services; + +import org.onap.dcae.ci.entities.sdc.SdcService; + +public class Vfi { + private String name; + private SdcService container; + + public Vfi(String name, SdcService container) { + this.name = name; + this.container = container; + } + + public String getName() { + return name; + } + + public SdcService getContainer() { + return container; + } +}
\ No newline at end of file diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/rule_editor/SaveRuleError.java b/src/main/java/org/onap/dcae/ci/entities/rule_editor/SaveRuleError.java index 7af5e51..407cc37 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/rule_editor/SaveRuleError.java +++ b/src/main/java/org/onap/dcae/ci/entities/rule_editor/SaveRuleError.java @@ -1,4 +1,4 @@ -package com.att.ecomp.dcae.ci.entities.rule_editor; +package org.onap.dcae.ci.entities.rule_editor; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/org/onap/dcae/ci/entities/sdc/SdcCategory.java b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcCategory.java new file mode 100644 index 0000000..8d14aa2 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcCategory.java @@ -0,0 +1,28 @@ +package org.onap.dcae.ci.entities.sdc; + +import java.util.Arrays; +import java.util.List; + +public class SdcCategory { + + private String name; + private List<SdcCategory> subcategories; + + + public String getName() { + return name; + } + + public List<SdcCategory> getSubcategories() { + return subcategories; + } + + public SdcCategory(String categoryName) { + this.name = categoryName; + } + + public SdcCategory(String categoryName, String subCategoryName){ + this(categoryName); + this.subcategories = Arrays.asList(new SdcCategory(subCategoryName)); + } +} diff --git a/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponent.java b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponent.java new file mode 100644 index 0000000..1dc7206 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponent.java @@ -0,0 +1,113 @@ +package org.onap.dcae.ci.entities.sdc; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class SdcComponent { + + private String name; + private String description; + private List<String> tags; + private String contactId; + private String icon; + private String uuid; + + private String lastUpdaterUserId; + private String uniqueId; + private String version; + private String resourceType; + private List<SdcCategory> categories; + private Map<String, String> allVersions; + + 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 List<String> getTags() { + return tags; + } + + public void setTags(List<String> tags) { + this.tags = tags; + } + + 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 getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + public String getUniqueId() { + return uniqueId; + } + + public void setUniqueId(String uniqueId) { + this.uniqueId = uniqueId; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public List<SdcCategory> getCategories() { + return categories; + } + + public void setCategories(List<SdcCategory> categories) { + this.categories = categories; + } + + public Map<String, String> getAllVersions() { + return allVersions; + } + + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentFactory.java b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentFactory.java new file mode 100644 index 0000000..1cb9cbc --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentFactory.java @@ -0,0 +1,41 @@ +package org.onap.dcae.ci.entities.sdc; + +import org.apache.commons.lang3.RandomStringUtils; + +import org.onap.dcae.ci.utilities.DcaeRestClient; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class SdcComponentFactory { + + private SdcComponentFactory(){} + + public static SdcService getDefaultService() { + SdcService service = new SdcService(); + service.setCategories(Arrays.asList(new SdcCategory("Mobility"))); + setDefaultComponentFields(service, "CiService"); + return service; + } + + public static SdcResource getDefaultResource() { + SdcResource resource = new SdcResource(); + resource.setVendorName("vendorName"); + resource.setVendorRelease("1.1"); + resource.setResourceType("VF"); + resource.setCategories(Arrays.asList(new SdcCategory("Generic", "Infrastructure"))); + setDefaultComponentFields(resource, "CiResource"); + return resource; + } + + private static void setDefaultComponentFields(SdcComponent component, String name) { + component.setName(name.concat(RandomStringUtils.randomAlphanumeric(4))); + List<String> tags = new ArrayList<>(); + tags.add(component.getName()); + component.setTags(tags); + component.setDescription("Ci component description"); + component.setIcon("defaultIcon"); + component.setContactId(DcaeRestClient.getDefaultUserId()); + } +} diff --git a/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentInstance.java b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentInstance.java new file mode 100644 index 0000000..d300908 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentInstance.java @@ -0,0 +1,20 @@ +package org.onap.dcae.ci.entities.sdc; + + +public class SdcComponentInstance { + + String componentUid; + String description; + String posX; + String posY; + String name; + String uniqueId; + + public SdcComponentInstance(SdcResource vf) { + this.componentUid = vf.getUniqueId(); + this.posX = "20"; + this.posY = "20"; + this.name = vf.getName(); + this.description = vf.getDescription(); + } +} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcComponentMetadata.java b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentMetadata.java index 0ebf94c..c284e5d 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcComponentMetadata.java +++ b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentMetadata.java @@ -1,4 +1,4 @@ -package com.att.ecomp.dcae.ci.entities.sdc; +package org.onap.dcae.ci.entities.sdc; public class SdcComponentMetadata { diff --git a/src/main/java/org/onap/dcae/ci/entities/sdc/SdcResource.java b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcResource.java new file mode 100644 index 0000000..8cd5605 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcResource.java @@ -0,0 +1,26 @@ +package org.onap.dcae.ci.entities.sdc; + + +public class SdcResource extends SdcComponent { + + private String vendorName; + private String vendorRelease; + + + 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; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/sdc/SdcService.java b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcService.java new file mode 100644 index 0000000..4ee3ac0 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcService.java @@ -0,0 +1,37 @@ +package org.onap.dcae.ci.entities.sdc; + +import org.onap.dcae.ci.entities.sdc.SdcComponent; + + +public class SdcService extends SdcComponent { + + private String projectCode = "12345"; + private String serviceRole = "";// empty string is valid + private String serviceType = "";// empty string is valid + private String instantiationType = "Macro"; + + + public void setServiceRole(String serviceRole){ + this.serviceRole = serviceRole; + } + + public String getServiceRole(){ + return serviceRole; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getServiceType(){ + return serviceType; + } + + public void setInstantiationType(String instantiationType) { + this.instantiationType = instantiationType; + } + + public String getInstantiationType(){ + return instantiationType; + } +} diff --git a/src/main/java/org/onap/dcae/ci/enums/HttpHeaderEnum.java b/src/main/java/org/onap/dcae/ci/enums/HttpHeaderEnum.java new file mode 100644 index 0000000..aed1c53 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/enums/HttpHeaderEnum.java @@ -0,0 +1,25 @@ +package org.onap.dcae.ci.enums; + +public enum HttpHeaderEnum { + Content_MD5("Content-MD5"), + USER_ID("USER_ID"), + 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"), + X_ECOMP_SERVICE_ID_HEADER("X-ECOMP-ServiceID"); + + + String value; + + private HttpHeaderEnum(String value) { + this.value = value; + } + + public String getValue() { + return this.value; + } +} diff --git a/src/main/java/org/onap/dcae/ci/report/ExtentManager.java b/src/main/java/org/onap/dcae/ci/report/ExtentManager.java new file mode 100644 index 0000000..cbf28cb --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/report/ExtentManager.java @@ -0,0 +1,192 @@ +package org.onap.dcae.ci.report; + +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; +import org.apache.commons.io.FileUtils; +import org.onap.dcae.ci.config.Configuration; +import org.onap.dcae.ci.utilities.SetupReport; +import org.testng.ITestContext; + +import java.io.*; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.Properties; + +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/Bip8cTLQ6rOlw2dnkcSIvDy5wwdr2EwZJZSaoL6rym2uTt9UHO" + + "\n" + "})"; + private static String suiteName; + + public synchronized static ExtentReports setReporter(String filepath, String htmlFile, String dbIp, int dbPort, Boolean isAppend) { + 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) { + setHtmlReportConfiguration(filePath, htmlFile); + htmlReporter.setAppendExisting(isAppend); + extent.attachReporter(htmlReporter); + } + + public synchronized static ExtentReports getReporter() { + return extent; + } + + public static void initReporter(Configuration config, ITestContext context) { + setSuiteName(context); + String envData = config.getUrl(); + String dbIp = config.getReportDBhost(); + int dbPort = config.getReportDBport(); + String filepath = config.getReportFolder(); + String htmlFile = config.getReportFileName(); + + + if (suiteName.equals(SetupReport.TESTNG_FAILED_XML_NAME)) { + if (config.isUseBrowserMobProxy()) { + setTrafficCaptue(config); + } + + setReporter(filepath, htmlFile, dbIp, dbPort, true); + suiteName = getKeyByValueFromPropertyFormatFile(filepath + VERSIONS_INFO_FILE_NAME, "suiteName"); + } else { + deleteDirectory(config.getReportFolder()); + createDirectory(filepath); + setReporter(filepath, htmlFile, dbIp, dbPort, false); + createVersionsInfoFile(filepath, VERSIONS_INFO_FILE_NAME, envData, suiteName); + } + reporterDataDefinition(envData, suiteName); + } + + private static void createVersionsInfoFile(String path, String file, String envData, String suiteName) { + File myFoo = new File(path + file); + FileOutputStream fooStream; + try { + fooStream = new FileOutputStream(myFoo, false); + String versions = ("env=\"" + envData + "\"\n" + "suiteName=\"" + suiteName + "\"\n"); + byte[] myBytes = versions.getBytes(); + fooStream.write(myBytes); + fooStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static void reporterDataDefinition(String envData, String suiteNameFromVersionInfoFile) { + extent.setSystemInfo("Host Name Address", getExecutionHostAddress()); + extent.setSystemInfo("ExecutedOn", envData); + extent.setSystemInfo("SuiteName", suiteNameFromVersionInfoFile); + } + + private static void setSuiteName(ITestContext context) { + String suitePath = context.getSuite().getXmlSuite().getFileName(); + if (suitePath != null) { + File file = new File(suitePath); + suiteName = file.getName(); + } + } + + public static String getSuiteName() { + return suiteName; + } + + public synchronized static void setHtmlReportConfiguration(String filePath, String htmlFile) { + htmlReporter = new ExtentHtmlReporter(filePath + htmlFile); + 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); + } + + public static void closeReporter() { + extent.flush(); + } + + public static void setTrafficCaptue(Configuration config) { + config.setCaptureTraffic(true); + } + + + private 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("\"",""); + } + + private static void deleteDirectory(String directoryPath) { + File dir = new File(directoryPath); + try { + FileUtils.deleteDirectory(dir); + } catch (IOException e) { + System.out.println("Failed to delete " + dir); + } + } + + private static void createDirectory(String directoryPath) { + File directory = new File(String.valueOf(directoryPath)); + if (! directory.exists()){ + directory.mkdir(); + } + } + + private 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"; + } +} diff --git a/src/main/java/org/onap/dcae/ci/report/ExtentTestManager.java b/src/main/java/org/onap/dcae/ci/report/ExtentTestManager.java new file mode 100644 index 0000000..1b98001 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/report/ExtentTestManager.java @@ -0,0 +1,42 @@ +package org.onap.dcae.ci.report; + +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<>(); + private static ExtentReports extent = ExtentManager.getReporter(); + + public static synchronized ExtentTest getTest() { + ExtentTest extentTest = extentTestMap.get(Thread.currentThread().getId()); + if (extentTest == null){ + extentTest = startTest("Automated setup/cleanup"); + } + return extentTest; + } + + public static synchronized void endTest() { + 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/src/main/java/org/onap/dcae/ci/report/Report.java b/src/main/java/org/onap/dcae/ci/report/Report.java new file mode 100644 index 0000000..bd74d49 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/report/Report.java @@ -0,0 +1,155 @@ +package org.onap.dcae.ci.report; + +import com.aventstack.extentreports.ExtentTest; +import com.aventstack.extentreports.Status; +import com.aventstack.extentreports.markuputils.ExtentColor; +import com.aventstack.extentreports.markuputils.Markup; +import com.aventstack.extentreports.markuputils.MarkupHelper; +import org.onap.dcae.ci.report.ExtentManager; +import org.onap.dcae.ci.report.ExtentTestManager; +import org.onap.dcae.ci.utilities.SetupReport; +import org.testng.ITestResult; + +public class Report { + + private static String testName; + private static Throwable throwable; + private static int status; + + public static void log(Status status, String format, Object... args) { + log(status, String.format(format, args)); + } + + public static void logDebug(String message, Object obj) { + log(Status.DEBUG, "%s %s", message, wrapWithTextareaRO(obj.toString())); + } + + public static void fatal(String message, Exception err) { + log(Status.FATAL, "%s %s", message, wrapWithTextareaRO(err.toString())); + } + + + 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); + System.out.println(message); + } + + public static void log(Status logStatus, String message, String duration){ + log(logStatus, message + addDurationTag(duration)); + } + + public static void log(Status logStatus, Throwable throwable){ + ExtentTest test = ExtentTestManager.getTest(); + test.log(logStatus, throwable); + } + + 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); + } + } + + + private static String addDurationTag(String duration){ + return "<td width=\"80px\">" + duration + "</td>"; + } + + public static void report(ITestResult result) { + + testName = result.getName(); + throwable = result.getThrowable(); + status = result.getStatus(); + String suiteName = ExtentManager.getSuiteName(); + + switch (status) { + case ITestResult.SUCCESS: + logSuccessAfterTest(); + break; + + case ITestResult.FAILURE: + if (suiteName.equals(SetupReport.TESTNG_FAILED_XML_NAME)) { + logFatalAfterTest(); + } else { + logFailAfterTest(); + } + break; + + case ITestResult.SKIP: + logSkipAfterTest(); + break; + + default: + break; + } + + } + + /* Private members */ + + private static String wrapWithTextareaRO(String str) { + return String.format("<textarea readonly style=\"height:100px\">%s</textarea>", str); + } + + private static void logSuccessAfterTest() { + final Status logStatus = Status.PASS; + addTag(logStatus, "Success"); + } + + private static void logFailAfterTest() { + addTag(Status.FAIL, "Failure"); + try { + log(Status.ERROR, "ERROR - The following exepction occured : "); + log(Status.ERROR, throwable); + } 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); + } 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); + } catch (Exception e) { + log(logStatus, "FATAL - The following exepction occured : " + e.getMessage()); + } + } + + +} diff --git a/src/main/java/org/onap/dcae/ci/run/RunTestSuite.java b/src/main/java/org/onap/dcae/ci/run/RunTestSuite.java new file mode 100644 index 0000000..01c921c --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/run/RunTestSuite.java @@ -0,0 +1,28 @@ +package org.onap.dcae.ci.run; + +import org.testng.TestNG; + +import java.util.ArrayList; +import java.util.List; + +public class RunTestSuite { + + private RunTestSuite(){} + + public static void main(String[] args) { + TestNG testng = new TestNG(); + List<String> suites = new ArrayList<>(); + + 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/src/main/java/org/onap/dcae/ci/utilities/BaseRestUtils.java b/src/main/java/org/onap/dcae/ci/utilities/BaseRestUtils.java new file mode 100644 index 0000000..def25fd --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/utilities/BaseRestUtils.java @@ -0,0 +1,96 @@ +package org.onap.dcae.ci.utilities; + +import org.onap.dcae.ci.config.Configuration; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.enums.HttpHeaderEnum; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public class BaseRestUtils { + + protected static final String acceptHeaderData = "application/json"; + protected static final String contentTypeHeaderData = "application/json"; + + public BaseRestUtils() { + } + + protected static String getApiUrl(String path) { + Configuration configuration = SetupReport.getConfiguration(); + return String.format("%s:%s/sdc2/rest/v1/catalog/%s", configuration.getBeHost(), configuration.getBePort(), path); + } + + 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<>(); + + 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; + } + + protected static RestResponse sendGet(String url, String userId) throws IOException { + return sendGet(url, userId, (Map) 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; + } + + 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; + } + + public static RestResponse sendPost(String url, String userBodyJson, String userId, String accept) throws IOException { + return sendPost(url, userBodyJson, userId, accept, (Map) 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; + } + + protected static RestResponse sendDelete(String url, String userId) throws IOException { + return sendDelete(url, userId, (Map) 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; + } + +} diff --git a/src/main/java/com/att/ecomp/dcae/ci/utilities/ConfigurationReader.java b/src/main/java/org/onap/dcae/ci/utilities/ConfigurationReader.java index 1736d9a..c557194 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/utilities/ConfigurationReader.java +++ b/src/main/java/org/onap/dcae/ci/utilities/ConfigurationReader.java @@ -1,19 +1,17 @@ -package com.att.ecomp.dcae.ci.utilities; +package org.onap.dcae.ci.utilities; -import java.io.File; - -import org.openecomp.d2.ci.datatypes.Configuration; +import org.onap.dcae.ci.config.Configuration; -import com.att.ecomp.dcae.ci.ui.setup.DcaeConfiguration; +import java.io.File; public class ConfigurationReader { - private static DcaeConfiguration config; + private static Configuration config; - public static DcaeConfiguration getConfiguration() { + public static Configuration getConfiguration() { if (config == null){ File file = getConfigFile(); - config = Configuration.loadConfigFile(file, DcaeConfiguration.class); + config = Configuration.loadConfigFile(file, Configuration.class); } return config; } diff --git a/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeEntityClient.java b/src/main/java/org/onap/dcae/ci/utilities/DcaeEntityClient.java index c2a401d..d6b267f 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeEntityClient.java +++ b/src/main/java/org/onap/dcae/ci/utilities/DcaeEntityClient.java @@ -1,16 +1,15 @@ -package com.att.ecomp.dcae.ci.utilities; - -import org.openecomp.d2.ci.datatypes.devObjects.LifecycleStateEnum; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; +package org.onap.dcae.ci.utilities; import com.aventstack.extentreports.Status; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.report.Report; import org.onap.sdc.dcae.composition.model.Requirement; import org.onap.sdc.dcae.composition.model.Value; import org.onap.sdc.dcae.composition.model.deserializer.RequirementDeserializer; import org.onap.sdc.dcae.composition.model.deserializer.ValueDeserializer; +import org.onap.sdc.dcae.composition.util.DcaeBeConstants; import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; public class DcaeEntityClient { @@ -37,7 +36,7 @@ public class DcaeEntityClient { */ public Vfcmt createVfcmt(String name, String description, String userId) throws Exception { RestResponse response = DcaeRestClient.createVfcmt(name, description, userId); - ExtentTestActions.log(Status.DEBUG, "Create VFCMT Response: " + StringUtils.truncate(response)); + Report.log(Status.DEBUG, "Create VFCMT Response: " + StringUtils.truncate(response)); if (response.getStatusCode() != 200) { throw new Exception("Response: " + StringUtils.truncate(response)); } @@ -64,7 +63,7 @@ public class DcaeEntityClient { * @throws Exception */ public Vfcmt createVfcmt() throws Exception { - return createVfcmt(DcaeRestClient.getDefaultUser().getUserId()); + return createVfcmt(DcaeRestClient.getDefaultUserId()); } /** @@ -73,15 +72,25 @@ public class DcaeEntityClient { * @throws Exception */ public Vfcmt[] getAllVfcmts() throws Exception { - ExtentTestActions.log(Status.INFO, "Fetching all vfcmt resources"); + Report.log(Status.INFO, "Fetching all vfcmt resources"); RestResponse response = DcaeRestClient.getAllVfcmts(); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + return convertResponseToVfcmt(response); + } + + public Vfcmt[] getAllBaseVfcmts() throws Exception { + Report.log(Status.INFO, "Fetching all vfcmt resources"); + RestResponse response = DcaeRestClient.getAllMonitoringTemplatesVfcmts(); + return convertResponseToVfcmt(response); + } + + private Vfcmt[] convertResponseToVfcmt(RestResponse response) throws Exception { + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); if (response.getStatusCode() != 200) { throw new Exception("Response: " + StringUtils.truncate(response)); } return gson.fromJson(response.getResponse(), Vfcmt[].class); } - + /** * * @param userId @@ -89,9 +98,9 @@ public class DcaeEntityClient { * @throws Exception */ public Vfcmt createCheckedoutVfcmt(String userId) throws Exception { - ExtentTestActions.log(Status.INFO, "Creating vfcmt..."); + Report.log(Status.INFO, "Creating vfcmt..."); Vfcmt vfcmt = createVfcmt(userId); - if (vfcmt.getLifecycleState().equals(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name()) == false) { + if (vfcmt.getLifecycleState().equals(DcaeBeConstants.LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name()) == false) { throw new Exception("created vfcmt is not in checkout state!"); } return vfcmt; @@ -103,7 +112,7 @@ public class DcaeEntityClient { * @throws Exception */ public Vfcmt createCheckedoutVfcmt() throws Exception { - String userId = DcaeRestClient.getDefaultUser().getUserId(); + String userId = DcaeRestClient.getDefaultUserId(); Report.log(Status.INFO, "Going to create checked out VFCMT with user="+userId); return createCheckedoutVfcmt(userId); } @@ -115,11 +124,11 @@ public class DcaeEntityClient { * @throws Exception */ public Vfcmt createCheckedinVfcmt(String userId) throws Exception { - ExtentTestActions.log(Status.INFO, "Creating vfcmt"); + Report.log(Status.INFO, "Creating vfcmt"); Vfcmt vfcmt = createVfcmt(userId); - ExtentTestActions.log(Status.INFO, "Checkin the vfcmt"); + Report.log(Status.INFO, "Checkin the vfcmt"); RestResponse response = DcaeRestClient.checkinVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); Vfcmt vfcmtAfterCheckin = gson.fromJson(response.getResponse(), Vfcmt.class); if (response.getStatusCode() != 200) { throw new Exception("Unable to checkin newly created vfcmt"); @@ -133,7 +142,7 @@ public class DcaeEntityClient { * @throws Exception */ public Vfcmt createCheckedinVfcmt() throws Exception { - String userId = DcaeRestClient.getDefaultUser().getUserId(); + String userId = DcaeRestClient.getDefaultUserId(); return createCheckedinVfcmt(userId); } } diff --git a/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeRestClient.java b/src/main/java/org/onap/dcae/ci/utilities/DcaeRestClient.java index a776d20..1e45829 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeRestClient.java +++ b/src/main/java/org/onap/dcae/ci/utilities/DcaeRestClient.java @@ -1,31 +1,44 @@ -package com.att.ecomp.dcae.ci.utilities; +package org.onap.dcae.ci.utilities; + -import com.att.ecomp.dcae.ci.ui.setup.DcaeConfiguration; import com.aventstack.extentreports.Status; import com.google.common.net.UrlEscapers; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import org.json.simple.JSONObject; +import org.onap.dcae.ci.config.Configuration; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.report.Report; import org.onap.sdc.dcae.composition.restmodels.CreateVFCMTRequest; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.openecomp.d2.ci.api.BaseRestUtils; -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.datatypes.User; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.datatypes.http.RestResponse; + import java.io.IOException; public class DcaeRestClient extends BaseRestUtils { - private static User defaultUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + private static String designerDefaultId = "cs0008"; + private static String designer2UserId = "me0009"; + private static String adminDefaultId = "jh0003"; + private static String testerDefaultId = "jm0007"; - public static User getDefaultUser() { - return defaultUser; + public static String getDefaultUserId() { + return designerDefaultId; } + public static String getDesigner2UserId() { + return designer2UserId; + } + + public static String getDefaultAdminId() { + return adminDefaultId; + } + + public static String getDefaultTesterId() { + return testerDefaultId; + } + protected static String getApiUrl(String path) { - DcaeConfiguration configuration = ConfigurationReader.getConfiguration(); + Configuration configuration = ConfigurationReader.getConfiguration(); String dcaeBePort = configuration.getDcaeBePort(); String dcaeBeHost = configuration.getDcaeBeHost(); @@ -55,16 +68,16 @@ public class DcaeRestClient extends BaseRestUtils { /* VFCMT */ public static RestResponse getAllVfcmts() throws IOException { - return sendGet(getApiUrl("/getResourcesByCategory"), defaultUser.getUserId()); + return sendGet(getApiUrl("/getResourcesByCategory"), designerDefaultId); } public static RestResponse getAllMonitoringTemplatesVfcmts() throws IOException { - return sendGet(getApiUrl("/getResourcesByMonitoringTemplateCategory"), defaultUser.getUserId()); + return sendGet(getApiUrl("/getResourcesByMonitoringTemplateCategory"), designerDefaultId); } public static RestResponse getVfcmtsForMigration(String contextType,String serviceUuid, String serviceVersion) throws IOException{ - return sendGet(getApiUrl("/" + contextType + "/" + serviceUuid + "/" + serviceVersion + "/getVfcmtsForMigration"), defaultUser.getUserId()); + return sendGet(getApiUrl("/" + contextType + "/" + serviceUuid + "/" + serviceVersion + "/getVfcmtsForMigration"), designerDefaultId); } public static RestResponse createVfcmt(String name, String description, String userId) throws IOException { @@ -73,7 +86,7 @@ public class DcaeRestClient extends BaseRestUtils { } public static RestResponse createMc(String request) throws IOException { - return sendPost(getApiUrl("/createMC"), request, defaultUser.getUserId(), "application/json"); + return sendPost(getApiUrl("/createMC"), request, designerDefaultId, "application/json"); } public static RestResponse createMc(String request,String userId) throws IOException { @@ -81,27 +94,26 @@ public class DcaeRestClient extends BaseRestUtils { } public static RestResponse createVfcmt(String name, String description) throws IOException{ - return createVfcmt(name, description, defaultUser.getUserId()); + return createVfcmt(name, description, designerDefaultId); } public static RestResponse importMc(String request) throws IOException { - return sendPost(getApiUrl("/importMC"), request, defaultUser.getUserId(), "application/json"); + return sendPost(getApiUrl("/importMC"), request, designerDefaultId, "application/json"); } public static RestResponse getAttachedService(String vfcmtUuid) throws IOException { Report.log(Status.INFO, "getAttachedService for VFCMT uuid="+vfcmtUuid); - RestResponse res = sendGet(getApiUrl("/" + vfcmtUuid + "/attachment"), defaultUser.getUserId()); + RestResponse res = sendGet(getApiUrl("/" + vfcmtUuid + "/attachment"), designerDefaultId); Report.log(Status.INFO, "getAttachedService result=%s", res); return res; } public static RestResponse getServiceExternalReferences(String serviceUuid, String version) throws IOException { Report.log(Status.INFO, "getServiceExternalReferences for service uuid="+serviceUuid); - RestResponse res = sendGet(getApiUrl("/services/" + serviceUuid + "/" + version + "/monitoringComponents"), defaultUser.getUserId()); + RestResponse res = sendGet(getApiUrl("/SERVICE/" + serviceUuid + "/" + version + "/monitoringComponents"), designerDefaultId); Report.log(Status.INFO, "getServiceExternalReferences result=%s", res); return res; } - /* VF */ public static RestResponse getServices(String VFCMTId, String userId) throws IOException{ @@ -109,7 +121,7 @@ public class DcaeRestClient extends BaseRestUtils { } public static RestResponse getServicesInstance(String uuid) throws IOException{ - return sendGet(getApiUrl("/service/"+uuid), defaultUser.getUserId()); + return sendGet(getApiUrl("/service/"+uuid), designerDefaultId); } public static RestResponse attachVfiRef(String vfcmtUuid, String serviceId, String vfiName) throws IOException{ @@ -118,25 +130,24 @@ public class DcaeRestClient extends BaseRestUtils { jsonAttachObj.put("serviceUuid", serviceId); jsonAttachObj.put("instanceName", vfiName); - return sendPost(getApiUrl("/" + vfcmtUuid + "/attachment"), jsonAttachObj.toString(), defaultUser.getUserId(), "application/json"); + return sendPost(getApiUrl("/" + vfcmtUuid + "/attachment"), jsonAttachObj.toString(), designerDefaultId, "application/json"); } public static RestResponse getResourceDetails(String componentId) throws IOException{ - return sendGet(getApiUrl("/resource/"+ componentId), defaultUser.getUserId()); + return sendGet(getApiUrl("/resource/"+ componentId), designerDefaultId); } - public static RestResponse getElements() throws IOException{ - return sendGet(getApiUrl("/elements"), defaultUser.getUserId()); + return sendGet(getApiUrl("/elements"), designerDefaultId); } public static RestResponse getItem(String element) throws IOException{ - return sendGet(getApiUrl("/"+ element +"/elements"), defaultUser.getUserId()); + return sendGet(getApiUrl("/"+ element +"/elements"), designerDefaultId); } public static RestResponse getItemModel(String elementId) throws IOException{ - return sendGet(getApiUrl("/"+ elementId +"/model"), defaultUser.getUserId()); + return sendGet(getApiUrl("/"+ elementId +"/model"), designerDefaultId); } public static RestResponse getItemType(String elementId, String type) throws IOException{ - return sendGet(getApiUrl("/"+ elementId +"/type/"+ type +"/"), defaultUser.getUserId()); + return sendGet(getApiUrl("/"+ elementId +"/type/"+ type +"/"), designerDefaultId); } public static RestResponse saveComposition(String componentId, String userId) throws IOException{ JsonObject json = generateCdumpInput(componentId); @@ -145,12 +156,12 @@ public class DcaeRestClient extends BaseRestUtils { // edit composition new flow - service context public static RestResponse saveComposition(String serviceUuid, String vfiName, String vfcmtUuid, String body) throws IOException{ - return sendPost(getApiUrl(String.format("/services/%s/%s/saveComposition/%s", serviceUuid, UrlEscapers.urlFragmentEscaper().escape(vfiName), vfcmtUuid)), body, defaultUser.getUserId(), "application/json"); + return sendPost(getApiUrl(String.format("/service/%s/%s/saveComposition/%s", serviceUuid, UrlEscapers.urlFragmentEscaper().escape(vfiName), vfcmtUuid)), body, designerDefaultId, "application/json"); } // submit composition new flow - service context public static RestResponse submitComposition(String serviceUuid, String vfiName, String vfcmtUuid) throws IOException { - return sendPost(getApiUrl(String.format("/services/createBluePrint/%s/%s/%s", vfcmtUuid, serviceUuid, UrlEscapers.urlFragmentEscaper().escape(vfiName))), "", defaultUser.getUserId(), "application/json"); + return sendPost(getApiUrl(String.format("/service/createBluePrint/%s/%s/%s", vfcmtUuid, serviceUuid, UrlEscapers.urlFragmentEscaper().escape(vfiName))), "", designerDefaultId, "application/json"); } public static RestResponse saveComposition(String componentId, String userId, String body) throws IOException{ @@ -158,10 +169,10 @@ public class DcaeRestClient extends BaseRestUtils { } public static RestResponse getComposition(String componentId) throws IOException{ - return sendGet(getApiUrl("/getComposition/"+ componentId), defaultUser.getUserId()); + return sendGet(getApiUrl("/getComposition/"+ componentId), designerDefaultId); } public static RestResponse submitComposition(String componentId, String serviceUuid, String vnfiName, String monitoringType) throws IOException{ - return sendPost(getApiUrl("/createBluePrint/"+ componentId +"/"+ serviceUuid +"/"+ UrlEscapers.urlFragmentEscaper().escape(vnfiName) + "/"+ UrlEscapers.urlFragmentEscaper().escape(monitoringType)), "" ,defaultUser.getUserId(), "application/json"); + return sendPost(getApiUrl("/createBluePrint/"+ componentId +"/"+ serviceUuid +"/"+ UrlEscapers.urlFragmentEscaper().escape(vnfiName) + "/"+ UrlEscapers.urlFragmentEscaper().escape(monitoringType)), "" ,designerDefaultId, "application/json"); } /* Life Cycle */ @@ -189,27 +200,32 @@ public class DcaeRestClient extends BaseRestUtils { /* Rule Editor */ public static RestResponse getVesEventTypes() throws IOException { - return sendGet(getApiUrl("/rule-editor/list-events-by-versions"), defaultUser.getUserId()); + return sendGet(getApiUrl("/rule-editor/list-events-by-versions"), designerDefaultId); } public static RestResponse getVesDataTypes(String vesVersion, String eventType) throws IOException { - return sendGet(getApiUrl(String.format("/rule-editor/definition/%s/%s", vesVersion, eventType)), defaultUser.getUserId()); + return sendGet(getApiUrl(String.format("/rule-editor/definition/%s/%s", vesVersion, eventType)), designerDefaultId); } public static RestResponse saveRule(String vfcmtUid, String dcaeCompName, String nid, String configParam, String body) throws IOException { - return sendPost(getApiUrl(String.format("/rule-editor/rule/%s/%s/%s/%s", vfcmtUid, dcaeCompName, nid, configParam)), body, defaultUser.getUserId(), "application/json" ); + return sendPost(getApiUrl(String.format("/rule-editor/rule/%s/%s/%s/%s", vfcmtUid, dcaeCompName, nid, configParam)), body, designerDefaultId, "application/json" ); } public static RestResponse getRules(String vfcmtUid, String dcaeCompName, String nid, String configParam) throws IOException { - return sendGet(getApiUrl(String.format("/rule-editor/rule/%s/%s/%s/%s", vfcmtUid, dcaeCompName, nid, configParam)), defaultUser.getUserId()); + return sendGet(getApiUrl(String.format("/rule-editor/rule/%s/%s/%s/%s", vfcmtUid, dcaeCompName, nid, configParam)), designerDefaultId); } public static RestResponse deleteRule(String vfcmtUid, String dcaeCompName, String nid, String configParam, String ruleUid) throws IOException { - return sendDelete(getApiUrl(String.format("/rule-editor/rule/%s/%s/%s/%s/%s", vfcmtUid, dcaeCompName, nid, configParam, ruleUid)), defaultUser.getUserId()); + return sendDelete(getApiUrl(String.format("/rule-editor/rule/%s/%s/%s/%s/%s", vfcmtUid, dcaeCompName, nid, configParam, ruleUid)), designerDefaultId); } public static RestResponse translateRules(String vfcmtUid, String dcaeCompName, String nid, String configParam, String flowType) throws IOException { - return sendGet(getApiUrl(String.format("/rule-editor/rule/translate/%s/%s/%s/%s?flowType=%s", vfcmtUid, dcaeCompName, nid, configParam, flowType)), defaultUser.getUserId()); + return sendGet(getApiUrl(String.format("/rule-editor/rule/translate/%s/%s/%s/%s?flowType=%s", vfcmtUid, dcaeCompName, nid, configParam, flowType)), designerDefaultId); + } + + public static RestResponse getExistingRuleTargets(String vfcmtUuid, String dcaeCompName, String nid) throws IOException { + String url = getApiUrl(String.format("/rule-editor/getExistingRuleTargets/%s/%s/%s", vfcmtUuid, dcaeCompName, nid)); + return sendGet(url, designerDefaultId); } @@ -222,7 +238,7 @@ public class DcaeRestClient extends BaseRestUtils { public static <T extends CreateVFCMTRequest> void fillCreateMcRequestMandatoryFields(T request) { request.setFlowType("flowType_xxx"); - request.setContextType("services"); + request.setContextType("SERVICE"); request.setName(StringUtils.randomString("CI-", 20)); request.setDescription("create test vfcmt"); if(null == request.getVfiName()) { diff --git a/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeTestConstants.java b/src/main/java/org/onap/dcae/ci/utilities/DcaeTestConstants.java index 355a687..6bca647 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeTestConstants.java +++ b/src/main/java/org/onap/dcae/ci/utilities/DcaeTestConstants.java @@ -1,4 +1,4 @@ -package com.att.ecomp.dcae.ci.utilities; +package org.onap.dcae.ci.utilities; public class DcaeTestConstants { diff --git a/src/main/java/org/onap/dcae/ci/utilities/DcaeUtil.java b/src/main/java/org/onap/dcae/ci/utilities/DcaeUtil.java new file mode 100644 index 0000000..5d6eff4 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/utilities/DcaeUtil.java @@ -0,0 +1,205 @@ +package org.onap.dcae.ci.utilities; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import com.google.gson.*; +import org.apache.commons.lang3.RandomStringUtils; + +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; +import org.json.simple.parser.ParseException; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.entities.composition.items.DcaeComponents; +import org.onap.dcae.ci.report.Report; +import org.onap.sdc.dcae.composition.util.DcaeBeConstants; +import org.testng.Assert; + +import org.onap.sdc.dcae.composition.services.Resource; +import org.onap.sdc.dcae.composition.services.Service; +import org.onap.sdc.dcae.composition.services.ThinService; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; +import com.aventstack.extentreports.Status; + + +public class DcaeUtil { + public static Gson gson = new Gson(); + + public static class CatalogReources { + public static Vfcmt[] getAllReourcesFromAsdc() throws IOException{ + RestResponse allResources = DcaeRestClient.getAllVfcmts(); + return gson.fromJson(allResources.getResponse(), Vfcmt[].class); + } + + public static Vfcmt getResourceByName(String resName) throws IOException{ + Vfcmt[] vfcmts = getAllReourcesFromAsdc(); + List<Vfcmt> vfcmtsStr = Arrays.stream(vfcmts). + filter(item -> item.getName().equals(resName)). + collect(Collectors.toList()); + + return vfcmtsStr.get(0); + } + + public static Vfcmt getOneResourceFromList(int index) throws IOException{ + Vfcmt[] vfcmtList = getAllReourcesFromAsdc(); + return vfcmtList[index]; + } + + public static String getComponentID(int index) throws IOException{ + Vfcmt vfcmt = getOneResourceFromList(0); + return vfcmt.getUuid(); + } + + public static Resource createNewVfcmtObject() throws IOException{ + Resource res = new Resource(); + res.setResourceInstanceName("LiavNewVFCMT" + RandomStringUtils.randomAlphanumeric(20)); + res.setDescription("This is a test VFCMT"); + return res; + } + + public static Vfcmt notCheckoutVFCMT() throws IOException{ /* TODO: remove this function and use instead in DcaeEntityClient.getCheckedoutVfcmt() */ + Vfcmt[] vfcmtList = getAllReourcesFromAsdc(); + List<Vfcmt> vfcmtsStr = Arrays.stream(vfcmtList). + filter(item -> (item.getLifecycleState().equals(DcaeTestConstants.Sdc.State.NOT_CERTIFIED_CHECKOUT) == false)). + collect(Collectors.toList()); + + return vfcmtsStr.get(0); + } + + public static Vfcmt vfcmtNotUserOwner(String user) throws IOException{ + Vfcmt[] vfcmtList = getAllReourcesFromAsdc(); + List<Vfcmt> vfcmtsStr = Arrays.stream(vfcmtList) + .filter(item -> (item.getLastUpdaterUserId().equals(user) == false)) + .collect(Collectors.toList()); + + return vfcmtsStr.get(0); + } + + } + + public static class Services{ + public static ThinService[] getServices(String VFCMTId, String userId) throws IOException{ + RestResponse services = null; + try{ + services = DcaeRestClient.getServices(VFCMTId, userId); + }catch(Exception e){ + System.err.println("Exception occurred while trying to fetch all resources from SDC: "+e); + return null; + } + Assert.assertTrue(services.getStatusCode().intValue() == 200); + String response = services.getResponse(); + ThinService[] serviceList = gson.fromJson(response, ThinService[].class); + return serviceList.length > 0 ? serviceList : null; + } + + public static ThinService getOneService(String VFCMTId,int index, String userId) throws IOException { + ThinService[] services = getServices(VFCMTId, userId); + return services[index]; + } + + + public static List<Resource> getVfListInstance(ThinService thinService) throws IOException { + RestResponse serviceInstancRes = null; + try{ + serviceInstancRes = DcaeRestClient.getServicesInstance(thinService.getUuid()); + }catch(Exception e){ + System.err.println("Exception occurred while trying to fetch List of VF instances from SDC service ("+thinService+"). Exception: "+e); + return null; + } + Assert.assertTrue(serviceInstancRes.getStatusCode().intValue() == 200); + String serviceInstancList = serviceInstancRes.getResponse(); + Service service = gson.fromJson(serviceInstancList, Service.class); + return service.getResources(); + } + + public static Resource getOneVfInstance(ThinService thinService,int index) throws IOException { + List<Resource> resources = getVfListInstance(thinService); + return resources.get(index); + } + + } + + + public static class SdcElementsModelType{ + public static RestResponse getMsElements() throws IOException{ + return DcaeRestClient.getItem(DcaeTestConstants.Composition.Microservice); + } + + + + public static JsonArray getSNMPModelItemFromSdc() throws Exception { + RestResponse resMsElements = getMsElements(); + JsonParser jsonParser = new JsonParser(); + JsonObject responseJson = (JsonObject)jsonParser.parse(resMsElements.getResponse()); + JsonArray itemJsonArray = responseJson.get("data").getAsJsonObject().get("element").getAsJsonObject().get("items").getAsJsonArray(); + Report.logDebug("DCAE Components items", itemJsonArray); + Service[] services = gson.fromJson(itemJsonArray, Service[].class); + Report.log(Status.DEBUG, "Trying to find a certified VF which its name starts with supplement/map/enrich"); + List<String> collectIds = Arrays.stream(services) + .filter(x -> DcaeBeConstants.LifecycleStateEnum.CERTIFIED == DcaeBeConstants.LifecycleStateEnum.valueOf(x.getLifecycleState())&& !x.getModels().isEmpty()) + .filter(x -> x.getName().toLowerCase().startsWith("supplement") || x.getName().toLowerCase().startsWith("map") || x.getName().toLowerCase().startsWith("enrich")) + .map(Service::getUuid) + .collect(Collectors.toList()); + if(collectIds.isEmpty()) { + Report.log(Status.WARNING, "Could not find any SNMP DCAE Component"); + } + JsonArray models = new JsonArray(); + for (String id : collectIds) { + RestResponse res = DcaeRestClient.getItemModel(id); + models.addAll(parseNodesFromDcaeModelAndAssignUiNid(res.getResponse())); + } + + return models; + } + + public static RestResponse getItemModelFromSdc(int itemNumber) throws IOException{ + String uuid = getItemUuid(itemNumber); + return DcaeRestClient.getItemModel(uuid); + } + + public static String getItemUuid(int itemNumber) throws IOException{ + DcaeComponents dcaeComponents = getDcaeComponents(); + return dcaeComponents.getData().getElement().getItems().get(itemNumber).getUuid(); + } + + public static DcaeComponents getDcaeComponents() throws IOException{ + RestResponse services = getMsElements(); + String response = services.getResponse(); + return gson.fromJson(response, DcaeComponents.class); + } + } + + public static JsonArray parseNodesFromDcaeModelAndAssignUiNid(String response) throws ParseException { + JsonParser parser = new JsonParser(); + JsonObject data = parser.parse(response).getAsJsonObject().get("data").getAsJsonObject(); + JsonObject model = data.get("model").getAsJsonObject(); + JsonArray nodes = model.get("nodes").getAsJsonArray(); + nodes.forEach((n) -> + n.getAsJsonObject().add("nid", n.getAsJsonObject().get("name")) + ); + Report.logDebug("nodes after adding ui nid", nodes); + return nodes; + } + + public static String generateCdumpFromSnmpModels(String vfcmtId) throws Exception { + JsonArray snmpModelItemFromSdc = SdcElementsModelType.getSNMPModelItemFromSdc(); + JsonObject cdump = DcaeRestClient.generateCdumpInput(vfcmtId); + cdump.add("nodes", snmpModelItemFromSdc); + Report.logDebug("cdump", cdump); + return cdump.toString(); + } + + public static String getValueFromJsonResponse(String response, String fieldName) { + try { + JSONObject jsonResp = (JSONObject) JSONValue.parse(response); + Object fieldValue = jsonResp.get(fieldName); + return fieldValue.toString(); + + } catch (Exception e) { + return null; + } + + } +} diff --git a/src/main/java/org/onap/dcae/ci/utilities/HttpRequest.java b/src/main/java/org/onap/dcae/ci/utilities/HttpRequest.java new file mode 100644 index 0000000..3b58109 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/utilities/HttpRequest.java @@ -0,0 +1,305 @@ +package org.onap.dcae.ci.utilities; + +import org.apache.commons.io.IOUtils; +import org.onap.dcae.ci.entities.RestResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +public class HttpRequest { + private static final 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 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(); + } + + + 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) { + 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 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(); + } + + 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 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; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/utilities/SdcInternalApiClient.java b/src/main/java/org/onap/dcae/ci/utilities/SdcInternalApiClient.java new file mode 100644 index 0000000..3010de0 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/utilities/SdcInternalApiClient.java @@ -0,0 +1,107 @@ +package org.onap.dcae.ci.utilities; + +import com.aventstack.extentreports.Status; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; +import org.onap.dcae.ci.config.Configuration; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.entities.composition.services.Vfi; +import org.onap.dcae.ci.entities.sdc.*; +import org.onap.dcae.ci.report.Report; + +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; + +public class SdcInternalApiClient extends BaseRestUtils { + + private static Gson gson = (new GsonBuilder()).create(); + private static String defaultUserId = DcaeRestClient.getDefaultUserId(); + private static String adminUserId = DcaeRestClient.getDefaultAdminId(); + private static Configuration configuration = ConfigurationReader.getConfiguration(); + + + public static SdcService createService() throws IOException { + String url = getApiUrl("services"); + SdcService service = SdcComponentFactory.getDefaultService(); + Report.log(Status.INFO, "Going to create service with name " + service.getName()); + String serviceBodyJson = gson.toJson(service); + RestResponse res = sendPost(url, serviceBodyJson, defaultUserId, acceptHeaderData); + Report.logDebug("Response:", res); + assertThat(res.getStatusCode()).isEqualTo(201); + return gson.fromJson(res.getResponse(), SdcService.class); + } + + + public static SdcResource createVf() throws IOException { + String url = getApiUrl("resources"); + SdcResource defaultVf = SdcComponentFactory.getDefaultResource(); + String resourceBodyJson = gson.toJson(defaultVf); + RestResponse res = sendPost(url, resourceBodyJson, defaultUserId, acceptHeaderData); + Report.logDebug("Response:", res); + assertThat(res.getStatusCode()).isEqualTo(201); + return gson.fromJson(res.getResponse(), SdcResource.class); + } + + + public static SdcResource checkinVf(SdcResource vf) throws IOException { + RestResponse response = changeResourceLifeCycleState(vf.getUniqueId(), "checkin"); + Report.logDebug("Response:", response); + assertThat(response.getStatusCode()).isEqualTo(200); + return gson.fromJson(response.getResponse(), SdcResource.class); + } + + + public static Vfi createVfi(SdcService service, SdcResource vf) throws IOException { + String url = getApiUrl(String.format("services/%s/resourceInstance", service.getUniqueId())); + SdcComponentInstance vfi = new SdcComponentInstance(vf); + String requestBodyJson = gson.toJson(vfi); + RestResponse createResourceInstance = sendPost(url, requestBodyJson, defaultUserId, acceptHeaderData); + Report.logDebug("Response:", createResourceInstance); + assertThat(createResourceInstance.getStatusCode()).isEqualTo(201); + return new Vfi(DcaeUtil.getValueFromJsonResponse(createResourceInstance.getResponse(), "name"), service); + } + + + public static RestResponse changeResourceLifeCycleState(String assetUniqueId, String lifeCycleOperation) throws IOException { + String url = getApiUrl(String.format("resources/%s/lifecycleState/%s", assetUniqueId, lifeCycleOperation)); + return sendPost(url, "{\"userRemarks\":\"Ci lifecycle operation\"}", defaultUserId, acceptHeaderData); + } + + + // DELETE - Clean up // + + public static RestResponse deleteAssetFromSdc(String context, String uniqueId) throws IOException { + String url = getApiUrl(String.format("%s/%s", context, uniqueId)); + return sendDelete(url, adminUserId); + } + + public static RestResponse deleteMarkedResources() throws IOException { + + String url = String.format("%s:%s/sdc2/rest/v1/inactiveComponents/resource", configuration.getBeHost(), configuration.getBePort()); + return sendDelete(url, adminUserId); + } + + public static RestResponse deleteMarkedServices() throws IOException { + String url = String.format("%s:%s/sdc2/rest/v1/inactiveComponents/service", configuration.getBeHost(), configuration.getBePort()); + return sendDelete(url, adminUserId); + } + + public static Map<String, List<SdcComponent>> getAssetsByUser(String userId) throws IOException { + String url = String.format("%s:%s/sdc2/rest/v1/followed", configuration.getBeHost(), configuration.getBePort()); + RestResponse restResponse = sendGet(url, userId); + return 200 == restResponse.getStatusCode() ? gson.fromJson(restResponse.getResponse(), new TypeToken<Map<String, List<SdcComponent>>>(){}.getType()) : new HashMap<>(); + } + + + public static SdcComponentMetadata getAssetMetadata(String context, String uniqueId, String userId) throws IOException { + String url = getApiUrl(String.format("%s/%s/filteredDataByParams?include=metadata", context, uniqueId)); + RestResponse restResponse = sendGet(url, userId); + return gson.fromJson(restResponse.getResponse(), SdcComponentMetadata.class); + } + +} diff --git a/src/main/java/org/onap/dcae/ci/utilities/SetupReport.java b/src/main/java/org/onap/dcae/ci/utilities/SetupReport.java new file mode 100644 index 0000000..dd797f2 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/utilities/SetupReport.java @@ -0,0 +1,131 @@ +package org.onap.dcae.ci.utilities; + + +import org.onap.dcae.ci.config.Configuration; +import org.onap.dcae.ci.report.ExtentManager; +import org.onap.dcae.ci.report.ExtentTestManager; +import org.onap.dcae.ci.report.Report; +import org.testng.ITestContext; +import org.testng.ITestResult; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; + +import java.lang.reflect.Method; + +public abstract class SetupReport { + public static final String TESTNG_FAILED_XML_NAME = "testng-failed.xml"; + private static Method myMethod; + private static Configuration configuration; + + public SetupReport() { + try { + configuration = this.getEnvConfiguration(); + } catch (Exception var2) { + var2.printStackTrace(); + } + + } + + protected abstract Configuration getEnvConfiguration(); + + @BeforeSuite( + alwaysRun = true + ) + public void beforeSuiteStarts(ITestContext context) { + this.initReport(context); + } + + @BeforeMethod( + alwaysRun = true + ) + public void beforeTestStarts(Method method, Object[] testArgs) { + myMethod = method; + this.initTestReporting(testArgs); + } + + @AfterMethod( + alwaysRun = true + ) + public void afterTestEnds(ITestResult result) { + this.reportTestResult(result); + this.closeTestReporting(); + this.closeReport(); + } + + public static Configuration getConfiguration() { + return configuration; + } + + private void initReport(ITestContext context) { + try { + ExtentManager.initReporter(this.getEnvConfiguration(), context); + } catch (Exception var3) { + var3.printStackTrace(); + } + + } + + private void initTestReporting(Object[] testArgs) { + if(this.isDataProviderEmpty(testArgs)) { + this.startTest(); + } else { + this.startTest(this.getDataProviderValues(testArgs)); + } + + } + + private boolean isDataProviderEmpty(Object[] testArgs) { + return testArgs.length == 0; + } + + private String getDataProviderValues(Object[] testArgs) { + StringBuilder sb = new StringBuilder(); + Object[] var3 = testArgs; + int var4 = testArgs.length; + + for(int var5 = 0; var5 < var4; ++var5) { + Object arg = var3[var5]; + sb.append(arg); + sb.append(" "); + } + + return sb.toString().trim(); + } + + private void reportTestResult(ITestResult result) { + Report.report(result); + } + + private void closeTestReporting() { + ExtentTestManager.endTest(); + } + + private void closeReport() { + ExtentManager.closeReporter(); + } + + private void startTest(String fromDataProvider) { + String suiteName = ExtentManager.getSuiteName(); + String methodName = this.getFullMethodName(fromDataProvider); + if(suiteName != null) { + if(suiteName.equals("testng-failed.xml")) { + ExtentTestManager.startTest("<html><font color=\"red\">ReRun - </font></html>" + methodName); + } else { + ExtentTestManager.startTest(methodName); + } + + ExtentTestManager.assignCategory(this.getClass()); + } + + } + + private void startTest() { + this.startTest(""); + } + + private String getFullMethodName(String fromDataProvider) { + return fromDataProvider.equals("")?myMethod.getName():myMethod.getName() + " " + fromDataProvider; + } +} + diff --git a/src/main/java/com/att/ecomp/dcae/ci/utilities/StringUtils.java b/src/main/java/org/onap/dcae/ci/utilities/StringUtils.java index 90c5602..b57dcab 100644 --- a/src/main/java/com/att/ecomp/dcae/ci/utilities/StringUtils.java +++ b/src/main/java/org/onap/dcae/ci/utilities/StringUtils.java @@ -1,4 +1,4 @@ -package com.att.ecomp.dcae.ci.utilities; +package org.onap.dcae.ci.utilities; import org.apache.commons.lang3.RandomStringUtils; diff --git a/src/main/resources/scripts/run.sh b/src/main/resources/scripts/run.sh index b262832..158f497 100644 --- a/src/main/resources/scripts/run.sh +++ b/src/main/resources/scripts/run.sh @@ -35,7 +35,7 @@ fi LOGS_PROP_FILE=file:${FULL_PATH}/conf/log4j.properties CONF_FILE=${FULL_PATH}/conf/conf.yaml CREDENTIALS_FILE=${FULL_PATH}/conf/credentials.yaml -MainClass=com.att.ecomp.dcae.ci.run.RunTestSuite +MainClass=org.onap.dcae.ci.run.RunTestSuite cmd="java -Dconfig.resource=${CONF_FILE} -Dcredentials.file=${CREDENTIALS_FILE} -Dlog4j.configuration=${LOGS_PROP_FILE} -DtestSuite=${SUITE_FILE} -cp $JAR_FILE ${MainClass} &" diff --git a/src/main/resources/testSuite/testSuite.xml b/src/main/resources/testSuite/testSuite.xml index a3fee3b..da131eb 100644 --- a/src/main/resources/testSuite/testSuite.xml +++ b/src/main/resources/testSuite/testSuite.xml @@ -1,31 +1,34 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite name="Suite"> - <test name="Test"> - <classes> - <class name="com.att.ecomp.dcae.ci.api.healthcheck.HealthcheckTest"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.blueprint.SaveCompositionPositve"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.composition.CompositionControllerApiTests"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.composition.CompositionElementsControllerTests"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.composition.CompositionMicroServicesApiTests"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.composition.GetCompositionControllerTests"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.composition.SaveAndSubmitCompositionFullFlowTest"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.lifeCycle.PutCheckin"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.lifeCycle.PutCheckout"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.ruleEditor.GetDefinitionTest"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.ruleEditor.GetListEventsAndVersionsTest"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.ruleEditor.RuleEditorControllerTest"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.services.attachment.GetAttachment"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.services.attachment.PostAttachment"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.services.instance.GetServiceInstanceNagative"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.services.instance.GetServiceInstancePositive"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.services.list.GetAllServicesNagative"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.services.list.GetAllServicesPositive"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.vfcmt.CreateVfcmt"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.vfcmt.GetAllVfcmts"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.vfcmt.VfcmtCreationFlow"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.vfcmt.CreateMonitoringComponent"></class> - <class name="com.att.ecomp.dcae.ci.api.tests.vfcmt.GetVfcmtsForMigration"></class> - </classes> - </test> <!-- Test --> + <test name="Test"> + <classes> + <class name="org.onap.dcae.ci.api.healthcheck.HealthcheckTest"></class> + <class name="org.onap.dcae.ci.api.tests.blueprint.SaveCompositionPositve"></class> + <class name="org.onap.dcae.ci.api.tests.composition.CompositionControllerApiTests"></class> + <class name="org.onap.dcae.ci.api.tests.composition.CompositionElementsControllerTests"></class> + <class name="org.onap.dcae.ci.api.tests.composition.CompositionMicroServicesApiTests"></class> + <class name="org.onap.dcae.ci.api.tests.composition.GetCompositionControllerTests"></class> + <class name="org.onap.dcae.ci.api.tests.composition.SaveAndSubmitCompositionFullFlowTest"></class> + <class name="org.onap.dcae.ci.api.tests.lifeCycle.PutCheckin"></class> + <class name="org.onap.dcae.ci.api.tests.lifeCycle.PutCheckout"></class> + <class name="org.onap.dcae.ci.api.tests.lifeCycle.PutCertify"></class> + <class name="org.onap.dcae.ci.api.tests.ruleEditor.GetDefinitionTest"></class> + <class name="org.onap.dcae.ci.api.tests.ruleEditor.GetListEventsAndVersionsTest"></class> + <class name="org.onap.dcae.ci.api.tests.ruleEditor.RuleEditorControllerTest"></class> + <class name="org.onap.dcae.ci.api.tests.services.attachment.GetAttachment"></class> + <class name="org.onap.dcae.ci.api.tests.services.attachment.PostAttachment"></class> + <class name="org.onap.dcae.ci.api.tests.services.instance.GetServiceInstanceNagative"></class> + <class name="org.onap.dcae.ci.api.tests.services.instance.GetServiceInstancePositive"></class> + <class name="org.onap.dcae.ci.api.tests.services.list.GetAllServicesNagative"></class> + <class name="org.onap.dcae.ci.api.tests.services.list.GetAllServicesPositive"></class> + <class name="org.onap.dcae.ci.api.tests.vfcmt.CreateVfcmt"></class> + <class name="org.onap.dcae.ci.api.tests.vfcmt.GetAllVfcmts"></class> + <class name="org.onap.dcae.ci.api.tests.vfcmt.VfcmtCreationFlow"></class> + <class name="org.onap.dcae.ci.api.tests.vfcmt.CreateMonitoringComponent"></class> + <class name="org.onap.dcae.ci.api.tests.vfcmt.GetVfcmtsForMigration"></class> + <class name="org.onap.dcae.ci.api.tests.vfcmt.GetAllMonitoringTemplateVfcmts"></class> + <class name="org.onap.dcae.ci.api.tests.deploy_tool.DeployToolTest"></class> + </classes> + </test> <!-- Test --> </suite> <!-- Suite --> diff --git a/src/main/resources/testSuite/testSuiteSelenium.xml b/src/main/resources/testSuite/testSuiteSelenium.xml deleted file mode 100644 index a79677a..0000000 --- a/src/main/resources/testSuite/testSuiteSelenium.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> -<suite name="Suite"> - <test name="Test"> - <classes> - <!--<class name="com.att.ecomp.dcae.ci.ui.tests.DCAESanity"/>--> - <class name="com.att.ecomp.dcae.ci.ui.rule_editor.tests.SanityTest"/> - </classes> - </test> <!-- Test --> -</suite> <!-- Suite --> |